nolo-cli 0.1.32 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +4 -10
  2. package/agent-runtime/agentRecordConfig.ts +10 -0
  3. package/agent-runtime/hostAdapter.ts +10 -1
  4. package/agent-runtime/index.ts +9 -20
  5. package/agent-runtime/localLoop.ts +49 -2
  6. package/agent-runtime/localToolPolicy.ts +76 -34
  7. package/agent-runtime/localWorkspaceTools.ts +30 -333
  8. package/agent-runtime/openAiCompatibleProvider.ts +7 -3
  9. package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
  10. package/agent-runtime/platformChatProvider.ts +47 -73
  11. package/agent-runtime/providerResolution.ts +244 -0
  12. package/agent-runtime/runtimeToolPolicy.ts +77 -29
  13. package/agent-runtime/shellCommandPolicy.ts +120 -0
  14. package/agentAliases.ts +14 -83
  15. package/agentCommandSupport.ts +3 -6
  16. package/agentInternalCommandEntries.ts +4 -13
  17. package/agentListCommands.ts +18 -27
  18. package/agentMachineCommands.ts +40 -336
  19. package/agentPullCommand.ts +30 -55
  20. package/agentRecordCommands.ts +84 -1
  21. package/agentRecordHelpers.ts +102 -186
  22. package/agentRunCommand.ts +438 -107
  23. package/agentRuntimeLocal.ts +2 -9
  24. package/ai/agent/cliExecutor.ts +19 -323
  25. package/ai/tools/toolNameAliases.ts +70 -0
  26. package/authCommands.ts +2 -36
  27. package/cli/agentAliases.ts +14 -83
  28. package/cli/agentCommandSupport.ts +3 -6
  29. package/cli/agentInternalCommandEntries.ts +4 -13
  30. package/cli/agentListCommands.ts +18 -27
  31. package/cli/agentMachineCommands.ts +40 -336
  32. package/cli/agentPullCommand.ts +30 -55
  33. package/cli/agentRecordCommands.ts +84 -1
  34. package/cli/agentRecordHelpers.ts +102 -186
  35. package/cli/agentRunCommand.ts +438 -107
  36. package/cli/agentRuntimeLocal.ts +2 -9
  37. package/cli/authCommands.ts +2 -36
  38. package/cli/cliCommandDispatch.ts +2 -2
  39. package/cli/cliEnvHelpers.ts +34 -107
  40. package/cli/client/agentRun.ts +854 -57
  41. package/cli/client/localRuntimeAdapter.ts +59 -159
  42. package/cli/client/streamingOutput.ts +3 -1
  43. package/cli/client/taskRunPrompt.ts +24 -7
  44. package/cli/commandRegistry.ts +4 -5
  45. package/cli/connectorRunArtifact.ts +10 -34
  46. package/cli/connectorWebSocketTarget.ts +6 -10
  47. package/cli/internalCommandEntries.ts +0 -8
  48. package/cli/localRuntimeDb.ts +2 -39
  49. package/cli/machineCommands.ts +189 -190
  50. package/cli/machineDaemonCommands.ts +165 -9
  51. package/cli/machineHeartbeatCommands.ts +2 -1
  52. package/cli/machineStatusCommands.ts +13 -5
  53. package/cli/machineWatchCommands.ts +1 -1
  54. package/cli/machineWsRunDispatch.ts +30 -44
  55. package/cli/machineWsSession.ts +0 -2
  56. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  57. package/cli/runtimeDoctorCommands.ts +72 -15
  58. package/cli/scriptCommandEntries.ts +45 -5
  59. package/cli/tableCommands.ts +133 -33
  60. package/cli/taskRunCommand.ts +211 -16
  61. package/cli/tui/session.ts +372 -43
  62. package/cli/workflowInternalCommandEntries.ts +0 -20
  63. package/cliCommandDispatch.ts +2 -2
  64. package/cliEnvHelpers.ts +34 -107
  65. package/client/agentConfigResolver.test.ts +2 -0
  66. package/client/agentRun.test.ts +12 -208
  67. package/client/agentRun.ts +854 -57
  68. package/client/localProviderResolver.test.ts +26 -2
  69. package/client/localRuntimeAdapter.test.ts +296 -171
  70. package/client/localRuntimeAdapter.ts +59 -159
  71. package/client/localToolPolicy.test.ts +4 -28
  72. package/client/streamingOutput.ts +3 -1
  73. package/client/taskRunPrompt.ts +24 -7
  74. package/commandRegistry.ts +4 -5
  75. package/connectorRunArtifact.ts +10 -34
  76. package/connectorWebSocketTarget.ts +6 -10
  77. package/database/server/serverStoreFactory.ts +2 -8
  78. package/internalCommandEntries.ts +0 -8
  79. package/localRuntimeDb.ts +2 -39
  80. package/machineCommands.ts +189 -190
  81. package/machineDaemonCommands.ts +165 -9
  82. package/machineHeartbeatCommands.ts +2 -1
  83. package/machineStatusCommands.ts +13 -5
  84. package/machineWatchCommands.ts +1 -1
  85. package/machineWsRunDispatch.ts +30 -44
  86. package/machineWsSession.ts +0 -2
  87. package/offlineMarxistsAgentCommand.ts +314 -0
  88. package/package.json +52 -188
  89. package/runtimeDoctorCommands.ts +72 -15
  90. package/scriptCommandEntries.ts +45 -5
  91. package/tableCommands.ts +133 -33
  92. package/taskRunCommand.ts +211 -16
  93. package/tui/session.ts +372 -43
  94. package/workflowInternalCommandEntries.ts +0 -20
  95. package/agent-runtime/dialogStatus.ts +0 -139
  96. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  97. package/agentCreateCustomCommands.ts +0 -278
  98. package/agentDialogsCommands.ts +0 -227
  99. package/agentDoctorCommands.ts +0 -203
  100. package/agentRunLocalWorkspace.ts +0 -182
  101. package/agentRunParsing.ts +0 -298
  102. package/agentSuperviseCommands.ts +0 -8
  103. package/agentUnpublishCommands.ts +0 -113
  104. package/ai/agent/agentRunDialogLineage.ts +0 -56
  105. package/ai/policy/types.ts +0 -64
  106. package/ai/skills/skillSummaryMarker.ts +0 -26
  107. package/app/types.ts +0 -358
  108. package/build.ts +0 -16
  109. package/buildPublish.ts +0 -138
  110. package/buildPublishArtifactAssembly.ts +0 -724
  111. package/buildPublishImportAnalysis.ts +0 -242
  112. package/chat/messages/fetchMessages.ts +0 -84
  113. package/chat/messages/types.ts +0 -185
  114. package/cli/agentCreateCustomCommands.ts +0 -278
  115. package/cli/agentDialogsCommands.ts +0 -227
  116. package/cli/agentDoctorCommands.ts +0 -203
  117. package/cli/agentRunLocalWorkspace.ts +0 -182
  118. package/cli/agentRunParsing.ts +0 -298
  119. package/cli/agentSuperviseCommands.ts +0 -8
  120. package/cli/agentUnpublishCommands.ts +0 -113
  121. package/cli/buildPublish.ts +0 -138
  122. package/cli/buildPublishArtifactAssembly.ts +0 -724
  123. package/cli/buildPublishImportAnalysis.ts +0 -242
  124. package/cli/cliIoTypes.ts +0 -3
  125. package/cli/cliRuntimeDoctorReport.ts +0 -193
  126. package/cli/client/agentRunInput.ts +0 -10
  127. package/cli/client/agentRunLocalExecution.ts +0 -124
  128. package/cli/client/agentRunLocalExecutor.ts +0 -179
  129. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  130. package/cli/client/agentRunServerTransport.ts +0 -397
  131. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  132. package/cli/customCodingAgentFlow.ts +0 -208
  133. package/cli/customCodingAgentRecord.ts +0 -179
  134. package/cli/dialogDataAccess.ts +0 -186
  135. package/cli/dialogInternalCommandEntries.ts +0 -11
  136. package/cli/dialogReadCommands.ts +0 -180
  137. package/cli/dialogReadHelpers.ts +0 -226
  138. package/cli/dialogStatusCommands.ts +0 -123
  139. package/cli/docInternalCommandEntries.ts +0 -20
  140. package/cli/hybridReadHelpers.ts +0 -109
  141. package/cli/machineCommandPrompts.ts +0 -79
  142. package/cli/machineCommandResolution.ts +0 -43
  143. package/cli/noloReadBridgePrompt.ts +0 -16
  144. package/cli/pageCreateCommands.ts +0 -219
  145. package/cli/pageDeleteCommands.ts +0 -167
  146. package/cli/pageReadCommands.ts +0 -151
  147. package/cli/pageUpdateCommands.ts +0 -249
  148. package/cli/pageWriteHelpers.ts +0 -209
  149. package/cli/publishPackage.ts +0 -36
  150. package/cli/runtimeInternalCommandEntries.ts +0 -15
  151. package/cli/runtimePassthroughCommands.ts +0 -22
  152. package/cli/scriptPassthroughHelpers.ts +0 -28
  153. package/cli/secretScanHelpers.ts +0 -31
  154. package/cli/spaceAttachCommands.ts +0 -134
  155. package/cli/spaceCategoryCommands.ts +0 -263
  156. package/cli/spaceCommands.ts +0 -295
  157. package/cli/spaceDeleteCommands.ts +0 -312
  158. package/cli/spaceInternalCommandEntries.ts +0 -21
  159. package/cli/spaceMutationHelpers.ts +0 -135
  160. package/cli/spaceReadCommands.ts +0 -323
  161. package/cli/tableDataOutput.ts +0 -41
  162. package/cli/tableDataSafety.ts +0 -26
  163. package/cli/tableMetaCommands.ts +0 -307
  164. package/cli/tableMutationCommands.ts +0 -266
  165. package/cli/tableQueryParsing.ts +0 -90
  166. package/cli/tableQueryRequest.ts +0 -53
  167. package/cli/taskRunActions.ts +0 -122
  168. package/cli/taskRunParsing.ts +0 -86
  169. package/cli/taskRunPromptShared.ts +0 -55
  170. package/cli/tui/tuiCatalog.ts +0 -22
  171. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  172. package/cli/tui/tuiPresentation.ts +0 -146
  173. package/cliIoTypes.ts +0 -3
  174. package/cliRuntimeDoctorReport.ts +0 -193
  175. package/client/agentRunInput.ts +0 -10
  176. package/client/agentRunLocalExecution.test.ts +0 -123
  177. package/client/agentRunLocalExecution.ts +0 -124
  178. package/client/agentRunLocalExecutor.ts +0 -179
  179. package/client/agentRunRuntimeSelection.test.ts +0 -159
  180. package/client/agentRunRuntimeSelection.ts +0 -145
  181. package/client/agentRunServerTransport.ts +0 -397
  182. package/client/agentRunTaskRunRecorder.ts +0 -176
  183. package/connector-experimental/daemonLauncher.ts +0 -223
  184. package/create/space/spaceKeys.ts +0 -65
  185. package/create/types.ts +0 -21
  186. package/customCodingAgentFlow.ts +0 -208
  187. package/customCodingAgentRecord.ts +0 -179
  188. package/database/keys.ts +0 -765
  189. package/database/tombstones.ts +0 -52
  190. package/database/utils/ulid.ts +0 -1
  191. package/dialogDataAccess.ts +0 -186
  192. package/dialogInternalCommandEntries.ts +0 -11
  193. package/dialogReadCommands.ts +0 -180
  194. package/dialogReadHelpers.ts +0 -226
  195. package/dialogStatusCommands.ts +0 -123
  196. package/docInternalCommandEntries.ts +0 -20
  197. package/hybridReadHelpers.ts +0 -109
  198. package/machineCommandPrompts.ts +0 -79
  199. package/machineCommandResolution.ts +0 -43
  200. package/noloReadBridgePrompt.ts +0 -16
  201. package/pageCreateCommands.ts +0 -219
  202. package/pageDeleteCommands.ts +0 -167
  203. package/pageReadCommands.ts +0 -151
  204. package/pageUpdateCommands.ts +0 -249
  205. package/pageWriteHelpers.ts +0 -209
  206. package/publishPackage.ts +0 -36
  207. package/runtimeInternalCommandEntries.ts +0 -15
  208. package/runtimePassthroughCommands.ts +0 -22
  209. package/scriptPassthroughHelpers.ts +0 -28
  210. package/secretScanHelpers.ts +0 -31
  211. package/share/helpers.ts +0 -302
  212. package/share/keys.ts +0 -243
  213. package/share/types.ts +0 -100
  214. package/spaceAttachCommands.ts +0 -134
  215. package/spaceCategoryCommands.ts +0 -263
  216. package/spaceCommands.ts +0 -295
  217. package/spaceDeleteCommands.ts +0 -312
  218. package/spaceInternalCommandEntries.ts +0 -21
  219. package/spaceMutationHelpers.ts +0 -135
  220. package/spaceReadCommands.ts +0 -323
  221. package/tableDataOutput.ts +0 -41
  222. package/tableDataSafety.ts +0 -26
  223. package/tableMetaCommands.ts +0 -307
  224. package/tableMutationCommands.ts +0 -266
  225. package/tableQueryParsing.ts +0 -90
  226. package/tableQueryRequest.ts +0 -53
  227. package/taskRunActions.ts +0 -122
  228. package/taskRunParsing.ts +0 -86
  229. package/taskRunPromptShared.ts +0 -55
  230. package/tui/tuiCatalog.ts +0 -22
  231. package/tui/tuiCommandInterpreter.test.ts +0 -169
  232. package/tui/tuiCommandInterpreter.ts +0 -253
  233. package/tui/tuiPresentation.test.ts +0 -154
  234. package/tui/tuiPresentation.ts +0 -146
@@ -1,22 +0,0 @@
1
- export const DEFAULT_TUI_AGENT_KEY = "agent-pub-01NOLOAPPBLD000000019KCKT0";
2
-
3
- export const KNOWN_AGENTS: Array<{
4
- name: string;
5
- key: string;
6
- description: string;
7
- }> = [
8
- {
9
- name: "nolo",
10
- key: "agent-pub-01NOLOAPPBLD000000019KCKT0",
11
- description: "one assistant that routes work across your agents and data",
12
- },
13
- {
14
- name: "app-builder",
15
- key: "agent-pub-01APPBUILDER00000001YAII3I",
16
- description: "builds web apps, tools, charts, and product prototypes",
17
- },
18
- ];
19
-
20
- export const KNOWN_AGENT_ALIASES: Record<string, { name: string; key: string }> =
21
- Object.fromEntries(KNOWN_AGENTS.map((agent) => [agent.name, agent]));
22
-
@@ -1,253 +0,0 @@
1
- import type { AgentRuntimeRequestedMode } from "../agentRuntimeLocal";
2
-
3
- export type TuiInterpreterState = {
4
- agentKey: string;
5
- agentName: string;
6
- dialogId?: string;
7
- dialogLabel: string;
8
- profileName: string;
9
- serverUrl: string;
10
- cliVersion?: string;
11
- attachedDocs: string[];
12
- runtimeMode: AgentRuntimeRequestedMode;
13
- };
14
-
15
- export type TuiInterpreterAction =
16
- | {
17
- type: "chat";
18
- message: string;
19
- agentKey: string;
20
- runtimeMode: AgentRuntimeRequestedMode;
21
- continueDialogId?: string;
22
- }
23
- | {
24
- type: "compact";
25
- dialogId: string;
26
- }
27
- | {
28
- type: "self-update";
29
- }
30
- | {
31
- type: "exit";
32
- };
33
-
34
- export type TuiInterpreterResult = {
35
- nextState: TuiInterpreterState;
36
- output: string;
37
- action?: TuiInterpreterAction;
38
- };
39
-
40
- export type TuiKnownAgent = {
41
- name: string;
42
- key: string;
43
- };
44
-
45
- export type TuiCommandInterpreterDeps = {
46
- knownAgents: TuiKnownAgent[];
47
- renderHelp: () => string;
48
- renderContextPanel: (state: TuiInterpreterState) => string;
49
- renderKnownAgents: () => string;
50
- };
51
-
52
- export function resolveSwitchTarget(
53
- rawTarget: string,
54
- deps: Pick<TuiCommandInterpreterDeps, "knownAgents">
55
- ) {
56
- const target = rawTarget.trim();
57
- if (/^\d+$/.test(target)) {
58
- const agent = deps.knownAgents[Number(target) - 1];
59
- return agent ? { name: agent.name, key: agent.key } : null;
60
- }
61
-
62
- const knownAgentAliases: Record<string, TuiKnownAgent> = Object.fromEntries(
63
- deps.knownAgents.map((agent) => [agent.name.toLowerCase(), agent])
64
- );
65
- const alias = knownAgentAliases[target.toLowerCase()];
66
- if (alias) return alias;
67
-
68
- if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
69
- return { name: target, key: target };
70
- }
71
-
72
- return null;
73
- }
74
-
75
- export function handleTuiInput(
76
- input: string,
77
- state: TuiInterpreterState,
78
- deps: TuiCommandInterpreterDeps
79
- ): TuiInterpreterResult {
80
- const trimmed = input.trim();
81
- if (!trimmed) {
82
- return { nextState: state, output: "" };
83
- }
84
-
85
- if (!trimmed.startsWith("/")) {
86
- return {
87
- nextState: state,
88
- output: "",
89
- action: {
90
- type: "chat",
91
- message: trimmed,
92
- agentKey: state.agentKey,
93
- runtimeMode: state.runtimeMode,
94
- ...(state.dialogId ? { continueDialogId: state.dialogId } : {}),
95
- },
96
- };
97
- }
98
-
99
- const [command = "", ...rest] = trimmed.split(/\s+/);
100
- const argText = rest.join(" ").trim();
101
-
102
- switch (command) {
103
- case "/help":
104
- return { nextState: state, output: deps.renderHelp() };
105
- case "/context":
106
- case "/ctx":
107
- return { nextState: state, output: deps.renderContextPanel(state) };
108
- case "/runtime": {
109
- if (argText !== "auto" && argText !== "local" && argText !== "server") {
110
- return {
111
- nextState: state,
112
- output: "Usage: /runtime <auto|local|server>",
113
- };
114
- }
115
-
116
- return {
117
- nextState: { ...state, runtimeMode: argText },
118
- output: `Runtime: ${argText}`,
119
- };
120
- }
121
- case "/exit":
122
- case "/quit":
123
- return { nextState: state, output: "Bye.", action: { type: "exit" } };
124
- case "/new":
125
- return {
126
- nextState: {
127
- ...state,
128
- dialogId: undefined,
129
- dialogLabel: "new",
130
- attachedDocs: [],
131
- },
132
- output: "Started a fresh dialog.",
133
- };
134
- case "/compact":
135
- if (argText) {
136
- return {
137
- nextState: state,
138
- output: `Unknown command: ${trimmed}\n\n${deps.renderHelp()}`,
139
- };
140
- }
141
- if (!state.dialogId) {
142
- return {
143
- nextState: state,
144
- output: "Current dialog: new (nothing to compact yet)",
145
- };
146
- }
147
- return {
148
- nextState: state,
149
- output: "Compacting current dialog...",
150
- action: { type: "compact", dialogId: state.dialogId },
151
- };
152
- case "/agent":
153
- return {
154
- nextState: state,
155
- output: `Current agent: ${state.agentName} (${state.agentKey})`,
156
- };
157
- case "/agents":
158
- return {
159
- nextState: state,
160
- output: deps.renderKnownAgents(),
161
- };
162
- case "/switch": {
163
- if (!argText) {
164
- return {
165
- nextState: state,
166
- output: "Usage: /switch <agent-key|alias>",
167
- };
168
- }
169
- const resolvedTarget = resolveSwitchTarget(argText, deps);
170
- if (!resolvedTarget) {
171
- return {
172
- nextState: state,
173
- output:
174
- `I don't know agent shortcut "${argText}" yet.\n` +
175
- "Use /switch nolo, /switch app-builder, or a full agent key like agent-pub-...",
176
- };
177
- }
178
- return {
179
- nextState: {
180
- ...state,
181
- agentName: resolvedTarget.name,
182
- agentKey: resolvedTarget.key,
183
- },
184
- output: `Switched to ${resolvedTarget.name}.`,
185
- };
186
- }
187
- case "/dialog":
188
- return {
189
- nextState: state,
190
- output: state.dialogId
191
- ? `Current dialog: ${state.dialogId}`
192
- : "Current dialog: new",
193
- };
194
- case "/doc": {
195
- if (rest[0] === "attach") {
196
- const docName = rest.slice(1).join(" ").trim();
197
- if (!docName) {
198
- return { nextState: state, output: "Usage: /doc attach <doc>" };
199
- }
200
- const attachedDocs = state.attachedDocs.includes(docName)
201
- ? state.attachedDocs
202
- : [...state.attachedDocs, docName];
203
- return {
204
- nextState: { ...state, attachedDocs },
205
- output: `Attached doc: ${docName}`,
206
- };
207
- }
208
- return {
209
- nextState: state,
210
- output:
211
- state.attachedDocs.length > 0
212
- ? `Attached docs: ${state.attachedDocs.join(", ")}`
213
- : "No docs attached. Use /doc attach <doc>.",
214
- };
215
- }
216
- case "/customize":
217
- return {
218
- nextState: state,
219
- output:
220
- "Tell nolo what to change, for example: /customize make my default agent more concise.",
221
- };
222
- case "/login":
223
- return {
224
- nextState: state,
225
- output:
226
- "MVP login uses profile/env auth. Set AUTH_TOKEN, NOLO_SERVER, or NOLO_PROFILE before starting nolo.",
227
- };
228
- case "/profile":
229
- return {
230
- nextState: state,
231
- output: `Profile: ${state.profileName}`,
232
- };
233
- case "/update":
234
- return {
235
- nextState: state,
236
- output: "Starting self-update...",
237
- action: { type: "self-update" },
238
- };
239
- case "/version":
240
- return {
241
- nextState: state,
242
- output:
243
- `nolo ${state.cliVersion || "unknown version"}\n` +
244
- "Update this install with: nolo update\n" +
245
- "If repo-local output differs, publish/install the latest npm package first.",
246
- };
247
- default:
248
- return {
249
- nextState: state,
250
- output: `Unknown command: ${command}\n\n${deps.renderHelp()}`,
251
- };
252
- }
253
- }
@@ -1,146 +0,0 @@
1
- import { DEFAULT_NOLO_SERVER_URL } from "../defaultServer";
2
- import type { AgentRuntimeRequestedMode } from "../agentRuntimeLocal";
3
- import type { EnvLike } from "../cliEnvHelpers";
4
- import { DEFAULT_TUI_AGENT_KEY, KNOWN_AGENTS } from "./tuiCatalog";
5
-
6
- export const DEFAULT_TUI_SERVER_URL = DEFAULT_NOLO_SERVER_URL;
7
-
8
- export type TuiState = {
9
- agentKey: string;
10
- agentName: string;
11
- dialogId?: string;
12
- dialogLabel: string;
13
- profileName: string;
14
- serverUrl: string;
15
- cliVersion?: string;
16
- attachedDocs: string[];
17
- runtimeMode: AgentRuntimeRequestedMode;
18
- };
19
-
20
- export function shortenDialogId(dialogId: string) {
21
- return dialogId.length > 12
22
- ? `${dialogId.slice(0, 6)}...${dialogId.slice(-4)}`
23
- : dialogId;
24
- }
25
-
26
- export function resolveDialogLabel(
27
- state: Pick<TuiState, "dialogId" | "dialogLabel">
28
- ) {
29
- return state.dialogId ? shortenDialogId(state.dialogId) : state.dialogLabel;
30
- }
31
-
32
- export function createInitialTuiState(env: EnvLike): TuiState {
33
- const agentKey = env.NOLO_AGENT?.trim() || DEFAULT_TUI_AGENT_KEY;
34
- const agentName = env.NOLO_AGENT_NAME?.trim() || "nolo";
35
-
36
- return {
37
- agentKey,
38
- agentName,
39
- dialogId: env.NOLO_DIALOG_ID?.trim() || undefined,
40
- dialogLabel: env.NOLO_DIALOG?.trim() || "new",
41
- profileName: env.NOLO_PROFILE?.trim() || "local",
42
- serverUrl: (env.NOLO_SERVER || env.BASE_URL || DEFAULT_TUI_SERVER_URL).replace(
43
- /\/+$/,
44
- ""
45
- ),
46
- cliVersion: env.NOLO_CLI_VERSION?.trim() || undefined,
47
- attachedDocs: [],
48
- runtimeMode:
49
- env.NOLO_RUNTIME_MODE === "local" || env.NOLO_RUNTIME_MODE === "server"
50
- ? env.NOLO_RUNTIME_MODE
51
- : "auto",
52
- };
53
- }
54
-
55
- export function renderStatusLine(state: TuiState) {
56
- const docs =
57
- state.attachedDocs.length > 0
58
- ? String(state.attachedDocs.length)
59
- : "0";
60
-
61
- return [
62
- `agent ${state.agentName}`,
63
- `dialog ${resolveDialogLabel(state)}`,
64
- `docs ${docs}`,
65
- `runtime ${state.runtimeMode}`,
66
- `profile ${state.profileName}`,
67
- ].join(" | ");
68
- }
69
-
70
- export function renderWelcome(state: TuiState) {
71
- const docs =
72
- state.attachedDocs.length > 0
73
- ? `${state.attachedDocs.length} attached`
74
- : "none";
75
- return [
76
- "",
77
- `Nolo workspace${state.cliVersion ? ` nolo ${state.cliVersion}` : ""}`,
78
- `agent ${state.agentName} | dialog ${resolveDialogLabel(state)} | docs ${docs} | profile ${state.profileName}`,
79
- `server ${state.serverUrl}`,
80
- "",
81
- "Tell nolo what you want. Use /help for commands. Use /version if this install feels stale.",
82
- "",
83
- ].join("\n");
84
- }
85
-
86
- export function renderPrompt(_state: TuiState) {
87
- return "you > ";
88
- }
89
-
90
- export function renderTuiHelp() {
91
- return [
92
- "Commands:",
93
- " /help Show this help",
94
- " /new Start a fresh dialog",
95
- " /compact Compact current dialog and fork a new one",
96
- " /context Show workspace context and next actions",
97
- " /runtime <mode> Use auto, local, or server runtime",
98
- " /agent Show the current agent",
99
- " /agents List built-in agent shortcuts",
100
- " /switch <agent> Switch the current agent",
101
- " /dialog Show the current dialog",
102
- " /doc List attached docs",
103
- " /doc attach <doc> Attach a doc to this workspace",
104
- " /customize Describe how you want to tune nolo",
105
- " /login Show login/profile hint",
106
- " /profile Show active profile",
107
- " /update Update the global nolo install",
108
- " /version Show version/update hint",
109
- " /exit Leave the workspace",
110
- "",
111
- "You can also type normally. nolo will send it to the current agent.",
112
- ].join("\n");
113
- }
114
-
115
- export function renderContextPanel(state: TuiState) {
116
- const docs = state.attachedDocs.length
117
- ? state.attachedDocs.join(", ")
118
- : "none";
119
- return [
120
- "Workspace context",
121
- "-----------------",
122
- `agent ${state.agentName}`,
123
- `dialog ${resolveDialogLabel(state)}`,
124
- `docs ${docs}`,
125
- `profile ${state.profileName}`,
126
- `runtime ${state.runtimeMode}`,
127
- `server ${state.serverUrl}`,
128
- "",
129
- "Next:",
130
- " /agents see specialist shortcuts",
131
- " /doc attach <doc> add working context",
132
- " /new start a clean dialog",
133
- ].join("\n");
134
- }
135
-
136
- export function renderKnownAgents() {
137
- return [
138
- "Agents:",
139
- ...KNOWN_AGENTS.map(
140
- (agent, index) =>
141
- ` ${index + 1} ${agent.name.padEnd(11)} ${agent.description}`
142
- ),
143
- "",
144
- "Tip: stay on nolo for the one-assistant feel; switch only when you want a specialist directly.",
145
- ].join("\n");
146
- }
package/cliIoTypes.ts DELETED
@@ -1,3 +0,0 @@
1
- export type OutputLike = {
2
- write(chunk: string): unknown;
3
- };
@@ -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
- }