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,242 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { dirname, join, relative } from "node:path";
|
|
3
|
-
|
|
4
|
-
function extractPackageNameFromImportPath(importPath: string): string {
|
|
5
|
-
if (importPath.startsWith("@")) {
|
|
6
|
-
const parts = importPath.split("/");
|
|
7
|
-
return parts.slice(0, 2).join("/");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const firstSlash = importPath.indexOf("/");
|
|
11
|
-
return firstSlash === -1 ? importPath : importPath.slice(0, firstSlash);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function extractModuleSpecifiers(content: string): string[] {
|
|
15
|
-
const specifiers = new Set<string>();
|
|
16
|
-
const importOrExportRegex =
|
|
17
|
-
/(?:import|export)\s+(?:(?:type\s+)?(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
18
|
-
const dynamicImportRegex = /import\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
19
|
-
|
|
20
|
-
let match: RegExpExecArray | null;
|
|
21
|
-
while ((match = importOrExportRegex.exec(content)) !== null) {
|
|
22
|
-
specifiers.add(match[1]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
while ((match = dynamicImportRegex.exec(content)) !== null) {
|
|
26
|
-
specifiers.add(match[1]);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return Array.from(specifiers);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function extractExternalImports(content: string): string[] {
|
|
33
|
-
const imports = new Set<string>();
|
|
34
|
-
for (const importPath of extractModuleSpecifiers(content)) {
|
|
35
|
-
if (
|
|
36
|
-
importPath.startsWith(".") ||
|
|
37
|
-
importPath.startsWith("node:") ||
|
|
38
|
-
importPath.startsWith("/")
|
|
39
|
-
) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
imports.add(extractPackageNameFromImportPath(importPath));
|
|
43
|
-
}
|
|
44
|
-
return Array.from(imports);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function extractLocalRelativeImports(content: string): string[] {
|
|
48
|
-
return extractModuleSpecifiers(content).filter(
|
|
49
|
-
(importPath) => importPath.startsWith(".") && !importPath.startsWith("/")
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function extractWorkspaceDependencies(
|
|
54
|
-
manifest: Record<string, any>
|
|
55
|
-
): string[] {
|
|
56
|
-
const deps: string[] = [];
|
|
57
|
-
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
58
|
-
if (!manifest[field]) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
for (const [name, version] of Object.entries(manifest[field])) {
|
|
62
|
-
if (typeof version === "string" && version.startsWith("workspace:")) {
|
|
63
|
-
deps.push(name);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return deps;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function findSiblingWorkspacePackageNames(sourceDir: string): string[] {
|
|
71
|
-
const packagesDir = join(sourceDir, "..");
|
|
72
|
-
const names: string[] = [];
|
|
73
|
-
|
|
74
|
-
for (const entry of readdirSync(packagesDir)) {
|
|
75
|
-
const pkgPath = join(packagesDir, entry, "package.json");
|
|
76
|
-
if (!existsSync(pkgPath)) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
const manifest = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
81
|
-
if (typeof manifest.name === "string" && manifest.name.length > 0) {
|
|
82
|
-
names.push(manifest.name);
|
|
83
|
-
}
|
|
84
|
-
} catch {
|
|
85
|
-
// Ignore malformed sibling manifests while scanning workspace package names.
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return names;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function extractWorkspaceImports(
|
|
93
|
-
content: string,
|
|
94
|
-
workspacePackageNames: Set<string>
|
|
95
|
-
): string[] {
|
|
96
|
-
const imports = new Set<string>();
|
|
97
|
-
|
|
98
|
-
for (const packageName of extractExternalImports(content)) {
|
|
99
|
-
if (workspacePackageNames.has(packageName)) {
|
|
100
|
-
imports.add(packageName);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const relativeWorkspaceImportRegex =
|
|
105
|
-
/(?:from\s+['"]\.\.\/([^./'"][^/'"]*)(?:\/[^'"]*)?['"]|import\(\s*['"]\.\.\/([^./'"][^/'"]*)(?:\/[^'"]*)?['"]\s*\))/g;
|
|
106
|
-
|
|
107
|
-
let match: RegExpExecArray | null;
|
|
108
|
-
while ((match = relativeWorkspaceImportRegex.exec(content)) !== null) {
|
|
109
|
-
const packageName = match[1] || match[2];
|
|
110
|
-
if (packageName && workspacePackageNames.has(packageName)) {
|
|
111
|
-
imports.add(packageName);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return Array.from(imports);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function collectWorkspaceDependencies(
|
|
119
|
-
sourceDir: string,
|
|
120
|
-
manifest: Record<string, any>,
|
|
121
|
-
filesToCopy: string[]
|
|
122
|
-
): string[] {
|
|
123
|
-
const workspaceDeps = new Set(extractWorkspaceDependencies(manifest));
|
|
124
|
-
const workspacePackageNames = new Set(findSiblingWorkspacePackageNames(sourceDir));
|
|
125
|
-
|
|
126
|
-
for (const filePath of collectTypeScriptSourceFiles(sourceDir, filesToCopy)) {
|
|
127
|
-
const content = readFileSync(filePath, "utf8");
|
|
128
|
-
for (const dep of extractWorkspaceImports(content, workspacePackageNames)) {
|
|
129
|
-
workspaceDeps.add(dep);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return Array.from(workspaceDeps);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function findTypeScriptFiles(dir: string): string[] {
|
|
137
|
-
const files: string[] = [];
|
|
138
|
-
|
|
139
|
-
for (const entry of readdirSync(dir)) {
|
|
140
|
-
const fullPath = join(dir, entry);
|
|
141
|
-
const stat = statSync(fullPath);
|
|
142
|
-
if (stat.isDirectory()) {
|
|
143
|
-
files.push(...findTypeScriptFiles(fullPath));
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (stat.isFile() && fullPath.endsWith(".ts")) {
|
|
147
|
-
files.push(fullPath);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return files;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function collectTypeScriptSourceFiles(
|
|
155
|
-
sourceDir: string,
|
|
156
|
-
filesToCopy: string[]
|
|
157
|
-
): string[] {
|
|
158
|
-
const files: string[] = [];
|
|
159
|
-
|
|
160
|
-
for (const entry of filesToCopy) {
|
|
161
|
-
const sourcePath = join(sourceDir, entry);
|
|
162
|
-
if (!existsSync(sourcePath)) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
const stat = statSync(sourcePath);
|
|
166
|
-
if (stat.isDirectory()) {
|
|
167
|
-
files.push(...findTypeScriptFiles(sourcePath));
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (stat.isFile() && sourcePath.endsWith(".ts")) {
|
|
171
|
-
files.push(sourcePath);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return files;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function escapeRegex(text: string): string {
|
|
179
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function createWorkspaceSpecifier(relativeFilePath: string, packageName: string, path = ""): string {
|
|
183
|
-
const fileDir = dirname(relativeFilePath);
|
|
184
|
-
const relativePackagePath = relative(fileDir === "." ? "" : fileDir, packageName).replace(
|
|
185
|
-
/\\/g,
|
|
186
|
-
"/"
|
|
187
|
-
);
|
|
188
|
-
const prefix = relativePackagePath.startsWith(".")
|
|
189
|
-
? relativePackagePath
|
|
190
|
-
: `./${relativePackagePath}`;
|
|
191
|
-
return `${prefix}${path}`;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function rewriteCrossPackageImports(
|
|
195
|
-
content: string,
|
|
196
|
-
workspaceDeps: string[],
|
|
197
|
-
relativeFilePath = ""
|
|
198
|
-
): string {
|
|
199
|
-
if (workspaceDeps.length === 0) {
|
|
200
|
-
return content;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const patterns = workspaceDeps.map(escapeRegex);
|
|
204
|
-
const relativeDepth =
|
|
205
|
-
dirname(relativeFilePath) === "."
|
|
206
|
-
? 1
|
|
207
|
-
: dirname(relativeFilePath).split(/[\\/]/).filter(Boolean).length + 1;
|
|
208
|
-
const crossPackagePrefixPattern = `(?:\\.\\./){${relativeDepth}}`;
|
|
209
|
-
|
|
210
|
-
const relativeImportRegex = new RegExp(
|
|
211
|
-
`(from\\s+['"])${crossPackagePrefixPattern}((?!\\.)${patterns.join("|")})(/[^'"]*)?(['"])`,
|
|
212
|
-
"g"
|
|
213
|
-
);
|
|
214
|
-
const bareImportRegex = new RegExp(
|
|
215
|
-
`(from\\s+['"])(${patterns.join("|")})(/[^'"]*)?(['"])`,
|
|
216
|
-
"g"
|
|
217
|
-
);
|
|
218
|
-
const dynamicRelativeImportRegex = new RegExp(
|
|
219
|
-
`(import\\(\\s*['"])${crossPackagePrefixPattern}((?!\\.)${patterns.join("|")})(/[^'"]*)?(['"]\\s*\\))`,
|
|
220
|
-
"g"
|
|
221
|
-
);
|
|
222
|
-
const dynamicBareImportRegex = new RegExp(
|
|
223
|
-
`(import\\(\\s*['"])(${patterns.join("|")})(/[^'"]*)?(['"]\\s*\\))`,
|
|
224
|
-
"g"
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
let result = content;
|
|
228
|
-
result = result.replace(relativeImportRegex, (_, prefix, packageName, path, suffix) => {
|
|
229
|
-
return `${prefix}${createWorkspaceSpecifier(relativeFilePath, packageName, path)}${suffix}`;
|
|
230
|
-
});
|
|
231
|
-
result = result.replace(bareImportRegex, (_, prefix, packageName, path, suffix) => {
|
|
232
|
-
return `${prefix}${createWorkspaceSpecifier(relativeFilePath, packageName, path)}${suffix}`;
|
|
233
|
-
});
|
|
234
|
-
result = result.replace(dynamicRelativeImportRegex, (_, prefix, packageName, path, suffix) => {
|
|
235
|
-
return `${prefix}${createWorkspaceSpecifier(relativeFilePath, packageName, path)}${suffix}`;
|
|
236
|
-
});
|
|
237
|
-
result = result.replace(dynamicBareImportRegex, (_, prefix, packageName, path, suffix) => {
|
|
238
|
-
return `${prefix}${createWorkspaceSpecifier(relativeFilePath, packageName, path)}${suffix}`;
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
return result;
|
|
242
|
-
}
|
package/cli/cliIoTypes.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { resolveAgentRuntimeDecision } from "../agent-runtime/runtimeDecision";
|
|
2
|
-
import type { AgentRuntimeDecision } from "../agent-runtime/types";
|
|
3
|
-
import type { LocalRuntimeProbeResult } from "./agentCommandSupport";
|
|
4
|
-
import type { EnvLike } from "./cliEnvHelpers";
|
|
5
|
-
|
|
6
|
-
export type CliRuntimeDoctorProbe = {
|
|
7
|
-
levelDb: {
|
|
8
|
-
ok: boolean;
|
|
9
|
-
path: string;
|
|
10
|
-
error?: string;
|
|
11
|
-
};
|
|
12
|
-
agentConfig: {
|
|
13
|
-
key: string;
|
|
14
|
-
cacheReady: boolean;
|
|
15
|
-
found: boolean;
|
|
16
|
-
};
|
|
17
|
-
provider: {
|
|
18
|
-
available: boolean;
|
|
19
|
-
label: string;
|
|
20
|
-
};
|
|
21
|
-
sync: {
|
|
22
|
-
available: boolean;
|
|
23
|
-
};
|
|
24
|
-
serverFallback: {
|
|
25
|
-
available: boolean;
|
|
26
|
-
url: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type CliRuntimeDoctorReport = {
|
|
31
|
-
decision: AgentRuntimeDecision;
|
|
32
|
-
levelDb: {
|
|
33
|
-
status: "ok" | "failed";
|
|
34
|
-
path: string;
|
|
35
|
-
error?: string;
|
|
36
|
-
};
|
|
37
|
-
agentConfig: {
|
|
38
|
-
status: "found" | "missing";
|
|
39
|
-
value: string;
|
|
40
|
-
};
|
|
41
|
-
provider: {
|
|
42
|
-
status: "available" | "missing";
|
|
43
|
-
label: string;
|
|
44
|
-
};
|
|
45
|
-
sync: {
|
|
46
|
-
status: "available" | "unavailable";
|
|
47
|
-
};
|
|
48
|
-
serverFallback: {
|
|
49
|
-
status: "available" | "unavailable";
|
|
50
|
-
value: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function readLocalAgentKey(env: EnvLike) {
|
|
55
|
-
return env.NOLO_LOCAL_AGENT_KEY || env.NOLO_AGENT || "";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function detectLocalProvider(env: EnvLike) {
|
|
59
|
-
return Boolean(
|
|
60
|
-
env.OPENAI_API_KEY ||
|
|
61
|
-
env.ANTHROPIC_API_KEY ||
|
|
62
|
-
env.GOOGLE_API_KEY ||
|
|
63
|
-
env.NOLO_LOCAL_OPENAI_BASE_URL ||
|
|
64
|
-
env.OLLAMA_BASE_URL
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function detectProviderLabel(env: EnvLike) {
|
|
69
|
-
if (env.NOLO_LOCAL_OPENAI_BASE_URL) {
|
|
70
|
-
return `openai-compatible endpoint ${env.NOLO_LOCAL_OPENAI_BASE_URL}`;
|
|
71
|
-
}
|
|
72
|
-
if (env.OLLAMA_BASE_URL) {
|
|
73
|
-
return `ollama-compatible endpoint ${env.OLLAMA_BASE_URL}`;
|
|
74
|
-
}
|
|
75
|
-
if (env.OPENAI_API_KEY) return "openai via env OPENAI_API_KEY";
|
|
76
|
-
if (env.ANTHROPIC_API_KEY) return "anthropic via env ANTHROPIC_API_KEY";
|
|
77
|
-
if (env.GOOGLE_API_KEY) return "google via env GOOGLE_API_KEY";
|
|
78
|
-
return "missing";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function buildCliRuntimeDoctorProbe(input: {
|
|
82
|
-
env: EnvLike;
|
|
83
|
-
localProbe: LocalRuntimeProbeResult;
|
|
84
|
-
authToken: string;
|
|
85
|
-
serverUrl: string;
|
|
86
|
-
}): CliRuntimeDoctorProbe {
|
|
87
|
-
const agentKey = input.localProbe.agentKey || readLocalAgentKey(input.env);
|
|
88
|
-
const cacheReady = Boolean(input.env.NOLO_AGENT_CACHE_READY);
|
|
89
|
-
return {
|
|
90
|
-
levelDb: {
|
|
91
|
-
ok: input.localProbe.ok,
|
|
92
|
-
path: input.localProbe.dbPath,
|
|
93
|
-
...(input.localProbe.error ? { error: input.localProbe.error } : {}),
|
|
94
|
-
},
|
|
95
|
-
agentConfig: {
|
|
96
|
-
key: agentKey,
|
|
97
|
-
cacheReady,
|
|
98
|
-
found: input.localProbe.ok && input.localProbe.agentFound && (Boolean(agentKey) || cacheReady),
|
|
99
|
-
},
|
|
100
|
-
provider: {
|
|
101
|
-
available: detectLocalProvider(input.env),
|
|
102
|
-
label: detectProviderLabel(input.env),
|
|
103
|
-
},
|
|
104
|
-
sync: {
|
|
105
|
-
available: Boolean(input.authToken),
|
|
106
|
-
},
|
|
107
|
-
serverFallback: {
|
|
108
|
-
available: Boolean(input.authToken || input.env.NOLO_SERVER || input.env.BASE_URL),
|
|
109
|
-
url: input.serverUrl,
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function buildCliRuntimeDoctorReport(
|
|
115
|
-
probe: CliRuntimeDoctorProbe
|
|
116
|
-
): CliRuntimeDoctorReport {
|
|
117
|
-
const missingLocalCapabilities = [
|
|
118
|
-
...(probe.levelDb.ok ? [] : ["leveldb"]),
|
|
119
|
-
...(probe.agentConfig.found ? [] : ["agent-config"]),
|
|
120
|
-
...(probe.provider.available ? [] : ["provider"]),
|
|
121
|
-
];
|
|
122
|
-
const decision = resolveAgentRuntimeDecision({
|
|
123
|
-
requestedMode: "auto",
|
|
124
|
-
syncRequested: false,
|
|
125
|
-
host: "cli",
|
|
126
|
-
hasLocalAgentConfig: probe.agentConfig.found,
|
|
127
|
-
hasLocalProvider: probe.provider.available,
|
|
128
|
-
hasLocalPersistence: true,
|
|
129
|
-
missingLocalCapabilities,
|
|
130
|
-
requiresServer: false,
|
|
131
|
-
serverFallbackAvailable: probe.serverFallback.available,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
decision,
|
|
136
|
-
levelDb: {
|
|
137
|
-
status: probe.levelDb.ok ? "ok" : "failed",
|
|
138
|
-
path: probe.levelDb.path,
|
|
139
|
-
...(probe.levelDb.error ? { error: probe.levelDb.error } : {}),
|
|
140
|
-
},
|
|
141
|
-
agentConfig: {
|
|
142
|
-
status: probe.agentConfig.found ? "found" : "missing",
|
|
143
|
-
value: probe.agentConfig.key || (probe.agentConfig.cacheReady ? "cache ready" : "no local agent key"),
|
|
144
|
-
},
|
|
145
|
-
provider: {
|
|
146
|
-
status: probe.provider.available ? "available" : "missing",
|
|
147
|
-
label: probe.provider.label,
|
|
148
|
-
},
|
|
149
|
-
sync: {
|
|
150
|
-
status: probe.sync.available ? "available" : "unavailable",
|
|
151
|
-
},
|
|
152
|
-
serverFallback: {
|
|
153
|
-
status: probe.serverFallback.available ? "available" : "unavailable",
|
|
154
|
-
value: probe.serverFallback.available ? probe.serverFallback.url : "unavailable",
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function formatCliRuntimeDoctorReport(
|
|
160
|
-
report: CliRuntimeDoctorReport
|
|
161
|
-
): string {
|
|
162
|
-
const lines = [
|
|
163
|
-
`Runtime: ${report.decision.mode}`,
|
|
164
|
-
`Reason: ${report.decision.reason}`,
|
|
165
|
-
`LevelDB: ${report.levelDb.status}`,
|
|
166
|
-
`DB path: ${report.levelDb.path}`,
|
|
167
|
-
];
|
|
168
|
-
if (report.levelDb.error) {
|
|
169
|
-
lines.push(`DB error: ${report.levelDb.error}`);
|
|
170
|
-
}
|
|
171
|
-
if (report.agentConfig.status === "found") {
|
|
172
|
-
lines.push(`Agent config: found (${report.agentConfig.value})`);
|
|
173
|
-
} else if (report.agentConfig.value === "no local agent key") {
|
|
174
|
-
lines.push("Agent config: missing (no local agent key)");
|
|
175
|
-
} else {
|
|
176
|
-
lines.push(`Agent config: missing (${report.agentConfig.value})`);
|
|
177
|
-
}
|
|
178
|
-
lines.push(`Provider: ${report.provider.status} (${report.provider.label})`);
|
|
179
|
-
lines.push("Persistence: LevelDB local store");
|
|
180
|
-
lines.push(
|
|
181
|
-
`Sync: ${report.sync.status}${
|
|
182
|
-
report.sync.status === "available" ? "" : " (not authenticated)"
|
|
183
|
-
}`
|
|
184
|
-
);
|
|
185
|
-
lines.push(`Server fallback: ${report.serverFallback.value}`);
|
|
186
|
-
if (report.decision.missingLocalCapabilities.length > 0) {
|
|
187
|
-
lines.push("Missing local capabilities:");
|
|
188
|
-
for (const capability of report.decision.missingLocalCapabilities) {
|
|
189
|
-
lines.push(`- ${capability}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return `${lines.join("\n")}\n`;
|
|
193
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function buildUserInputContent(message: string, imageUrls: string[] = []) {
|
|
2
|
-
if (imageUrls.length === 0) return message;
|
|
3
|
-
return [
|
|
4
|
-
...(message.trim() ? [{ type: "text" as const, text: message }] : []),
|
|
5
|
-
...imageUrls.map((url) => ({
|
|
6
|
-
type: "image_url" as const,
|
|
7
|
-
image_url: { url },
|
|
8
|
-
})),
|
|
9
|
-
];
|
|
10
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { LocalAgentToolEvent } from "../../agent-runtime/localLoop";
|
|
2
|
-
import type { EnvLike } from "../cliEnvHelpers";
|
|
3
|
-
|
|
4
|
-
type TaskRunReviewStatus = "passed" | "needs_changes" | "blocked";
|
|
5
|
-
|
|
6
|
-
export type TaskRunToolEvidence = {
|
|
7
|
-
toolsUsed: string[];
|
|
8
|
-
summary: {
|
|
9
|
-
callCount: number;
|
|
10
|
-
resultCount: number;
|
|
11
|
-
errorCount: number;
|
|
12
|
-
rounds: number;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type TraceLocalToolOptions = {
|
|
17
|
-
traceTools?: boolean;
|
|
18
|
-
env: EnvLike;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type CollectLocalToolEvidenceOptions = {
|
|
22
|
-
taskRunContext?: {
|
|
23
|
-
rowDbKey?: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type ResolveLocalToolRoundRetryLimitOptions = {
|
|
28
|
-
env: EnvLike;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const DEFAULT_LOCAL_AGENT_TOOL_ROUND_RETRY_LIMIT = 512;
|
|
32
|
-
|
|
33
|
-
function parsePositiveInteger(value: string | undefined) {
|
|
34
|
-
if (!value) return null;
|
|
35
|
-
const parsed = Number(value);
|
|
36
|
-
if (!Number.isInteger(parsed) || parsed <= 0) return null;
|
|
37
|
-
return parsed;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function shouldTraceLocalTools(options: TraceLocalToolOptions) {
|
|
41
|
-
return Boolean(options.traceTools || options.env.NOLO_TRACE_TOOLS === "1");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function shouldCollectLocalToolEvidence(options: CollectLocalToolEvidenceOptions) {
|
|
45
|
-
return Boolean(options.taskRunContext?.rowDbKey);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function summarizeLocalToolEvidence(
|
|
49
|
-
events: LocalAgentToolEvent[]
|
|
50
|
-
): TaskRunToolEvidence | undefined {
|
|
51
|
-
if (events.length === 0) return undefined;
|
|
52
|
-
const toolsUsed = [
|
|
53
|
-
...new Set(
|
|
54
|
-
events
|
|
55
|
-
.filter((event) => event.type === "tool-call")
|
|
56
|
-
.map((event) => event.toolName)
|
|
57
|
-
.filter(Boolean)
|
|
58
|
-
),
|
|
59
|
-
];
|
|
60
|
-
const rounds = new Set(events.map((event) => event.round)).size;
|
|
61
|
-
return {
|
|
62
|
-
toolsUsed,
|
|
63
|
-
summary: {
|
|
64
|
-
callCount: events.filter((event) => event.type === "tool-call").length,
|
|
65
|
-
resultCount: events.filter((event) => event.type === "tool-result").length,
|
|
66
|
-
errorCount: events.filter((event) => event.type === "tool-error").length,
|
|
67
|
-
rounds,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function parseLocalToolRoundLimitError(error: unknown) {
|
|
73
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
74
|
-
const match = message.match(/Local agent exceeded max tool rounds:\s*(\d+)/);
|
|
75
|
-
if (!match) return null;
|
|
76
|
-
return Number(match[1]);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function resolveLocalToolRoundRetryLimit(
|
|
80
|
-
options: ResolveLocalToolRoundRetryLimitOptions
|
|
81
|
-
) {
|
|
82
|
-
return (
|
|
83
|
-
parsePositiveInteger(options.env.NOLO_LOCAL_MAX_TOOL_ROUNDS_LIMIT) ??
|
|
84
|
-
DEFAULT_LOCAL_AGENT_TOOL_ROUND_RETRY_LIMIT
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function nextLocalToolRoundLimit(current: number) {
|
|
89
|
-
return current <= 0 ? 1 : current * 2;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function formatToolTraceEvent(event: LocalAgentToolEvent) {
|
|
93
|
-
const round = event.round + 1;
|
|
94
|
-
if (event.type === "tool-call") {
|
|
95
|
-
return `[nolo:tool] round ${round} -> ${event.toolName} (${event.toolCallId})\n`;
|
|
96
|
-
}
|
|
97
|
-
if (event.type === "tool-error") {
|
|
98
|
-
return `[nolo:tool] round ${round} !! ${event.toolName}: ${event.message ?? "failed"}\n`;
|
|
99
|
-
}
|
|
100
|
-
return `[nolo:tool] round ${round} <- ${event.toolName} (${event.toolCallId})\n`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function classifyTaskRunReviewStatus(summary?: string): TaskRunReviewStatus | undefined {
|
|
104
|
-
const normalized = summary?.toLowerCase().trim();
|
|
105
|
-
if (!normalized) return undefined;
|
|
106
|
-
|
|
107
|
-
const explicit = normalized.match(/review\s+decision\s*:\s*(passed|needs_changes|blocked)/);
|
|
108
|
-
if (explicit?.[1]) return explicit[1] as TaskRunReviewStatus;
|
|
109
|
-
|
|
110
|
-
if (/\b(blocked|cannot review|unable to review)\b|无法审查|阻塞/.test(normalized)) {
|
|
111
|
-
return "blocked";
|
|
112
|
-
}
|
|
113
|
-
if (
|
|
114
|
-
/\b(needs changes|request changes|changes requested|not approved)\b|需要修改|需修改|发现问题/.test(
|
|
115
|
-
normalized
|
|
116
|
-
)
|
|
117
|
-
) {
|
|
118
|
-
return "needs_changes";
|
|
119
|
-
}
|
|
120
|
-
if (/\b(approved|lgtm|no issues|passed)\b|通过|无问题/.test(normalized)) {
|
|
121
|
-
return "passed";
|
|
122
|
-
}
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|