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.
Files changed (230) hide show
  1. package/README.md +0 -6
  2. package/agent-runtime/agentRecordConfig.ts +2 -0
  3. package/agent-runtime/hostAdapter.ts +1 -0
  4. package/agent-runtime/index.ts +0 -21
  5. package/agent-runtime/localToolPolicy.ts +6 -13
  6. package/agent-runtime/localWorkspaceTools.ts +30 -333
  7. package/agent-runtime/platformChatProvider.ts +1 -4
  8. package/agent-runtime/runtimeToolPolicy.ts +47 -32
  9. package/agentAliases.ts +14 -83
  10. package/agentCommandSupport.ts +3 -6
  11. package/agentInternalCommandEntries.ts +2 -13
  12. package/agentListCommands.ts +19 -28
  13. package/agentMachineCommands.ts +40 -336
  14. package/agentPullCommand.ts +36 -56
  15. package/agentRecordCommands.ts +3 -5
  16. package/agentRecordHelpers.ts +22 -189
  17. package/agentRunCommand.ts +438 -107
  18. package/agentRuntimeLocal.ts +0 -10
  19. package/ai/agent/cliExecutor.ts +19 -323
  20. package/authCommands.ts +2 -36
  21. package/cli/agentAliases.ts +14 -83
  22. package/cli/agentCommandSupport.ts +3 -6
  23. package/cli/agentInternalCommandEntries.ts +2 -13
  24. package/cli/agentListCommands.ts +19 -28
  25. package/cli/agentMachineCommands.ts +40 -336
  26. package/cli/agentPullCommand.ts +36 -56
  27. package/cli/agentRecordCommands.ts +3 -5
  28. package/cli/agentRecordHelpers.ts +22 -189
  29. package/cli/agentRunCommand.ts +438 -107
  30. package/cli/agentRuntimeLocal.ts +0 -10
  31. package/cli/authCommands.ts +2 -36
  32. package/cli/cliEnvHelpers.ts +21 -162
  33. package/cli/client/agentRun.ts +853 -57
  34. package/cli/client/localRuntimeAdapter.ts +22 -159
  35. package/cli/client/streamingOutput.ts +3 -1
  36. package/cli/client/taskRunPrompt.ts +24 -7
  37. package/cli/commandRegistry.ts +2 -3
  38. package/cli/connectorRunArtifact.ts +10 -34
  39. package/cli/connectorWebSocketTarget.ts +6 -10
  40. package/cli/internalCommandEntries.ts +0 -8
  41. package/cli/localRuntimeDb.ts +2 -39
  42. package/cli/machineCommands.ts +189 -190
  43. package/cli/machineDaemonCommands.ts +165 -9
  44. package/cli/machineHeartbeatCommands.ts +2 -1
  45. package/cli/machineStatusCommands.ts +13 -5
  46. package/cli/machineWatchCommands.ts +1 -1
  47. package/cli/machineWsRunDispatch.ts +14 -48
  48. package/cli/machineWsSession.ts +0 -2
  49. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  50. package/cli/runtimeDoctorCommands.ts +69 -18
  51. package/cli/scriptCommandEntries.ts +45 -5
  52. package/cli/tableCommands.ts +133 -33
  53. package/cli/taskRunCommand.ts +211 -16
  54. package/cli/tui/session.ts +372 -43
  55. package/cli/workflowInternalCommandEntries.ts +0 -20
  56. package/cliEnvHelpers.ts +21 -162
  57. package/client/agentConfigResolver.test.ts +2 -0
  58. package/client/agentRun.test.ts +12 -208
  59. package/client/agentRun.ts +853 -57
  60. package/client/localRuntimeAdapter.test.ts +9 -168
  61. package/client/localRuntimeAdapter.ts +22 -159
  62. package/client/localToolPolicy.test.ts +4 -28
  63. package/client/streamingOutput.ts +3 -1
  64. package/client/taskRunPrompt.ts +24 -7
  65. package/commandRegistry.ts +2 -3
  66. package/connectorRunArtifact.ts +10 -34
  67. package/connectorWebSocketTarget.ts +6 -10
  68. package/database/server/db.ts +34 -15
  69. package/internalCommandEntries.ts +0 -8
  70. package/localRuntimeDb.ts +2 -39
  71. package/machineCommands.ts +189 -190
  72. package/machineDaemonCommands.ts +165 -9
  73. package/machineHeartbeatCommands.ts +2 -1
  74. package/machineStatusCommands.ts +13 -5
  75. package/machineWatchCommands.ts +1 -1
  76. package/machineWsRunDispatch.ts +14 -48
  77. package/machineWsSession.ts +0 -2
  78. package/offlineMarxistsAgentCommand.ts +314 -0
  79. package/package.json +49 -193
  80. package/runtimeDoctorCommands.ts +69 -18
  81. package/scriptCommandEntries.ts +45 -5
  82. package/tableCommands.ts +133 -33
  83. package/taskRunCommand.ts +211 -16
  84. package/tui/session.ts +372 -43
  85. package/workflowInternalCommandEntries.ts +0 -20
  86. package/agent-runtime/dialogStatus.ts +0 -139
  87. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  88. package/agentCreateCustomCommands.ts +0 -278
  89. package/agentDialogsCommands.ts +0 -227
  90. package/agentDoctorCommands.ts +0 -203
  91. package/agentRunLocalWorkspace.ts +0 -182
  92. package/agentRunParsing.ts +0 -298
  93. package/agentSuperviseCommands.ts +0 -8
  94. package/agentUnpublishCommands.ts +0 -113
  95. package/ai/agent/agentRunDialogLineage.ts +0 -56
  96. package/ai/policy/types.ts +0 -64
  97. package/ai/skills/skillSummaryMarker.ts +0 -26
  98. package/app/types.ts +0 -358
  99. package/build.ts +0 -16
  100. package/buildPublish.ts +0 -138
  101. package/buildPublishArtifactAssembly.ts +0 -724
  102. package/buildPublishImportAnalysis.ts +0 -242
  103. package/chat/messages/fetchMessages.ts +0 -84
  104. package/chat/messages/types.ts +0 -185
  105. package/cli/agentCreateCustomCommands.ts +0 -278
  106. package/cli/agentDialogsCommands.ts +0 -227
  107. package/cli/agentDoctorCommands.ts +0 -203
  108. package/cli/agentRunLocalWorkspace.ts +0 -182
  109. package/cli/agentRunParsing.ts +0 -298
  110. package/cli/agentSuperviseCommands.ts +0 -8
  111. package/cli/agentUnpublishCommands.ts +0 -113
  112. package/cli/buildPublish.ts +0 -138
  113. package/cli/buildPublishArtifactAssembly.ts +0 -724
  114. package/cli/buildPublishImportAnalysis.ts +0 -242
  115. package/cli/cliIoTypes.ts +0 -3
  116. package/cli/cliRuntimeDoctorReport.ts +0 -193
  117. package/cli/client/agentRunInput.ts +0 -10
  118. package/cli/client/agentRunLocalExecution.ts +0 -124
  119. package/cli/client/agentRunLocalExecutor.ts +0 -179
  120. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  121. package/cli/client/agentRunServerTransport.ts +0 -397
  122. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  123. package/cli/customCodingAgentFlow.ts +0 -208
  124. package/cli/customCodingAgentRecord.ts +0 -179
  125. package/cli/dialogDataAccess.ts +0 -186
  126. package/cli/dialogInternalCommandEntries.ts +0 -11
  127. package/cli/dialogReadCommands.ts +0 -180
  128. package/cli/dialogReadHelpers.ts +0 -226
  129. package/cli/dialogStatusCommands.ts +0 -123
  130. package/cli/docInternalCommandEntries.ts +0 -20
  131. package/cli/hybridReadHelpers.ts +0 -109
  132. package/cli/machineCommandPrompts.ts +0 -79
  133. package/cli/machineCommandResolution.ts +0 -43
  134. package/cli/noloReadBridgePrompt.ts +0 -16
  135. package/cli/pageCreateCommands.ts +0 -219
  136. package/cli/pageDeleteCommands.ts +0 -167
  137. package/cli/pageReadCommands.ts +0 -151
  138. package/cli/pageUpdateCommands.ts +0 -249
  139. package/cli/pageWriteHelpers.ts +0 -209
  140. package/cli/publishPackage.ts +0 -36
  141. package/cli/runtimeInternalCommandEntries.ts +0 -15
  142. package/cli/runtimePassthroughCommands.ts +0 -22
  143. package/cli/scriptPassthroughHelpers.ts +0 -28
  144. package/cli/secretScanHelpers.ts +0 -31
  145. package/cli/spaceAttachCommands.ts +0 -134
  146. package/cli/spaceCategoryCommands.ts +0 -263
  147. package/cli/spaceCommands.ts +0 -295
  148. package/cli/spaceDeleteCommands.ts +0 -312
  149. package/cli/spaceInternalCommandEntries.ts +0 -21
  150. package/cli/spaceMutationHelpers.ts +0 -135
  151. package/cli/spaceReadCommands.ts +0 -323
  152. package/cli/tableDataOutput.ts +0 -41
  153. package/cli/tableDataSafety.ts +0 -26
  154. package/cli/tableMetaCommands.ts +0 -307
  155. package/cli/tableMutationCommands.ts +0 -266
  156. package/cli/tableQueryParsing.ts +0 -90
  157. package/cli/tableQueryRequest.ts +0 -53
  158. package/cli/taskRunActions.ts +0 -122
  159. package/cli/taskRunParsing.ts +0 -86
  160. package/cli/taskRunPromptShared.ts +0 -55
  161. package/cli/tui/tuiCatalog.ts +0 -22
  162. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  163. package/cli/tui/tuiPresentation.ts +0 -146
  164. package/cliIoTypes.ts +0 -3
  165. package/cliRuntimeDoctorReport.ts +0 -193
  166. package/client/agentRunInput.ts +0 -10
  167. package/client/agentRunLocalExecution.test.ts +0 -123
  168. package/client/agentRunLocalExecution.ts +0 -124
  169. package/client/agentRunLocalExecutor.ts +0 -179
  170. package/client/agentRunRuntimeSelection.test.ts +0 -159
  171. package/client/agentRunRuntimeSelection.ts +0 -145
  172. package/client/agentRunServerTransport.ts +0 -397
  173. package/client/agentRunTaskRunRecorder.ts +0 -176
  174. package/connector-experimental/daemonLauncher.ts +0 -223
  175. package/create/space/spaceKeys.ts +0 -65
  176. package/create/types.ts +0 -21
  177. package/customCodingAgentFlow.ts +0 -208
  178. package/customCodingAgentRecord.ts +0 -179
  179. package/database/keys.ts +0 -765
  180. package/database/server/authorityStoreTypes.ts +0 -31
  181. package/database/server/legacyServerDb.ts +0 -58
  182. package/database/server/levelAuthorityStore.ts +0 -75
  183. package/database/server/memoryAuthorityStore.ts +0 -133
  184. package/database/server/serverStoreFactory.ts +0 -124
  185. package/database/tombstones.ts +0 -52
  186. package/database/utils/ulid.ts +0 -1
  187. package/dialogDataAccess.ts +0 -186
  188. package/dialogInternalCommandEntries.ts +0 -11
  189. package/dialogReadCommands.ts +0 -180
  190. package/dialogReadHelpers.ts +0 -226
  191. package/dialogStatusCommands.ts +0 -123
  192. package/docInternalCommandEntries.ts +0 -20
  193. package/hybridReadHelpers.ts +0 -109
  194. package/machineCommandPrompts.ts +0 -79
  195. package/machineCommandResolution.ts +0 -43
  196. package/noloReadBridgePrompt.ts +0 -16
  197. package/pageCreateCommands.ts +0 -219
  198. package/pageDeleteCommands.ts +0 -167
  199. package/pageReadCommands.ts +0 -151
  200. package/pageUpdateCommands.ts +0 -249
  201. package/pageWriteHelpers.ts +0 -209
  202. package/publishPackage.ts +0 -36
  203. package/runtimeInternalCommandEntries.ts +0 -15
  204. package/runtimePassthroughCommands.ts +0 -22
  205. package/scriptPassthroughHelpers.ts +0 -28
  206. package/secretScanHelpers.ts +0 -31
  207. package/share/helpers.ts +0 -302
  208. package/share/keys.ts +0 -243
  209. package/share/types.ts +0 -100
  210. package/spaceAttachCommands.ts +0 -134
  211. package/spaceCategoryCommands.ts +0 -263
  212. package/spaceCommands.ts +0 -295
  213. package/spaceDeleteCommands.ts +0 -312
  214. package/spaceInternalCommandEntries.ts +0 -21
  215. package/spaceMutationHelpers.ts +0 -135
  216. package/spaceReadCommands.ts +0 -323
  217. package/tableDataOutput.ts +0 -41
  218. package/tableDataSafety.ts +0 -26
  219. package/tableMetaCommands.ts +0 -307
  220. package/tableMutationCommands.ts +0 -266
  221. package/tableQueryParsing.ts +0 -90
  222. package/tableQueryRequest.ts +0 -53
  223. package/taskRunActions.ts +0 -122
  224. package/taskRunParsing.ts +0 -86
  225. package/taskRunPromptShared.ts +0 -55
  226. package/tui/tuiCatalog.ts +0 -22
  227. package/tui/tuiCommandInterpreter.test.ts +0 -169
  228. package/tui/tuiCommandInterpreter.ts +0 -253
  229. package/tui/tuiPresentation.test.ts +0 -154
  230. package/tui/tuiPresentation.ts +0 -146
package/tui/session.ts CHANGED
@@ -1,50 +1,379 @@
1
- import {
2
- type TuiInterpreterAction,
3
- type TuiInterpreterResult,
4
- type TuiCommandInterpreterDeps,
5
- handleTuiInput as handleTuiInputWithDeps,
6
- } from "./tuiCommandInterpreter";
7
- import {
8
- DEFAULT_TUI_SERVER_URL,
9
- type EnvLike,
10
- type TuiState,
11
- createInitialTuiState,
12
- renderContextPanel,
13
- renderKnownAgents,
14
- renderPrompt,
15
- renderStatusLine,
16
- renderTuiHelp,
17
- renderWelcome,
18
- resolveDialogLabel,
19
- } from "./tuiPresentation";
20
- import { DEFAULT_TUI_AGENT_KEY, KNOWN_AGENTS, KNOWN_AGENT_ALIASES } from "./tuiCatalog";
21
-
22
- export { DEFAULT_TUI_AGENT_KEY, DEFAULT_TUI_SERVER_URL, KNOWN_AGENTS, KNOWN_AGENT_ALIASES };
23
- export type { EnvLike, TuiState } from "./tuiPresentation";
24
-
25
- export type TuiAction = TuiInterpreterAction;
26
- export type TuiInputResult = TuiInterpreterResult;
27
-
28
- function createInterpreterDeps(): TuiCommandInterpreterDeps {
1
+ import { DEFAULT_NOLO_SERVER_URL } from "../defaultServer";
2
+ import type { AgentRuntimeRequestedMode } from "../agentRuntimeLocal";
3
+
4
+ export const DEFAULT_TUI_AGENT_KEY = "agent-pub-01NOLOAPPBLD000000019KCKT0";
5
+ export const DEFAULT_TUI_SERVER_URL = DEFAULT_NOLO_SERVER_URL;
6
+
7
+ const KNOWN_AGENTS: Array<{
8
+ name: string;
9
+ key: string;
10
+ description: string;
11
+ }> = [
12
+ {
13
+ name: "nolo",
14
+ key: "agent-pub-01NOLOAPPBLD000000019KCKT0",
15
+ description: "one assistant that routes work across your agents and data",
16
+ },
17
+ {
18
+ name: "app-builder",
19
+ key: "agent-pub-01APPBUILDER00000001YAII3I",
20
+ description: "builds web apps, tools, charts, and product prototypes",
21
+ },
22
+ ];
23
+
24
+ const KNOWN_AGENT_ALIASES: Record<string, { name: string; key: string }> =
25
+ Object.fromEntries(KNOWN_AGENTS.map((agent) => [agent.name, agent]));
26
+
27
+ function shortenDialogId(dialogId: string) {
28
+ return dialogId.length > 12
29
+ ? `${dialogId.slice(0, 6)}...${dialogId.slice(-4)}`
30
+ : dialogId;
31
+ }
32
+
33
+ export function resolveDialogLabel(
34
+ state: Pick<TuiState, "dialogId" | "dialogLabel">
35
+ ) {
36
+ return state.dialogId ? shortenDialogId(state.dialogId) : state.dialogLabel;
37
+ }
38
+
39
+ export type TuiState = {
40
+ agentKey: string;
41
+ agentName: string;
42
+ dialogId?: string;
43
+ dialogLabel: string;
44
+ profileName: string;
45
+ serverUrl: string;
46
+ cliVersion?: string;
47
+ attachedDocs: string[];
48
+ runtimeMode: AgentRuntimeRequestedMode;
49
+ };
50
+
51
+ export type TuiAction =
52
+ | {
53
+ type: "chat";
54
+ message: string;
55
+ agentKey: string;
56
+ runtimeMode: AgentRuntimeRequestedMode;
57
+ continueDialogId?: string;
58
+ }
59
+ | {
60
+ type: "compact";
61
+ dialogId: string;
62
+ }
63
+ | {
64
+ type: "self-update";
65
+ }
66
+ | {
67
+ type: "exit";
68
+ };
69
+
70
+ export type TuiInputResult = {
71
+ nextState: TuiState;
72
+ output: string;
73
+ action?: TuiAction;
74
+ };
75
+
76
+ type EnvLike = Record<string, string | undefined>;
77
+
78
+ export function createInitialTuiState(env: EnvLike = process.env): TuiState {
79
+ const agentKey = env.NOLO_AGENT?.trim() || DEFAULT_TUI_AGENT_KEY;
80
+ const agentName = env.NOLO_AGENT_NAME?.trim() || "nolo";
81
+
29
82
  return {
30
- knownAgents: KNOWN_AGENTS,
31
- renderHelp: renderTuiHelp,
32
- renderContextPanel,
33
- renderKnownAgents,
83
+ agentKey,
84
+ agentName,
85
+ dialogId: env.NOLO_DIALOG_ID?.trim() || undefined,
86
+ dialogLabel: env.NOLO_DIALOG?.trim() || "new",
87
+ profileName: env.NOLO_PROFILE?.trim() || "local",
88
+ serverUrl: (env.NOLO_SERVER || env.BASE_URL || DEFAULT_TUI_SERVER_URL).replace(
89
+ /\/+$/,
90
+ ""
91
+ ),
92
+ cliVersion: env.NOLO_CLI_VERSION?.trim() || undefined,
93
+ attachedDocs: [],
94
+ runtimeMode: env.NOLO_RUNTIME_MODE === "local" || env.NOLO_RUNTIME_MODE === "server"
95
+ ? env.NOLO_RUNTIME_MODE
96
+ : "auto",
34
97
  };
35
98
  }
36
99
 
37
- export {
38
- createInitialTuiState,
39
- renderContextPanel,
40
- renderKnownAgents,
41
- renderPrompt,
42
- renderStatusLine,
43
- renderTuiHelp,
44
- renderWelcome,
45
- resolveDialogLabel,
46
- };
100
+ export function renderStatusLine(state: TuiState) {
101
+ const docs =
102
+ state.attachedDocs.length > 0
103
+ ? String(state.attachedDocs.length)
104
+ : "0";
105
+
106
+ return [
107
+ `agent ${state.agentName}`,
108
+ `dialog ${resolveDialogLabel(state)}`,
109
+ `docs ${docs}`,
110
+ `runtime ${state.runtimeMode}`,
111
+ `profile ${state.profileName}`,
112
+ ].join(" | ");
113
+ }
114
+
115
+ export function renderWelcome(state: TuiState) {
116
+ const docs = state.attachedDocs.length > 0
117
+ ? `${state.attachedDocs.length} attached`
118
+ : "none";
119
+ return [
120
+ "",
121
+ `Nolo workspace${state.cliVersion ? ` nolo ${state.cliVersion}` : ""}`,
122
+ `agent ${state.agentName} | dialog ${resolveDialogLabel(state)} | docs ${docs} | profile ${state.profileName}`,
123
+ `server ${state.serverUrl}`,
124
+ "",
125
+ "Tell nolo what you want. Use /help for commands. Use /version if this install feels stale.",
126
+ "",
127
+ ].join("\n");
128
+ }
129
+
130
+ export function renderPrompt(_state: TuiState) {
131
+ return "you > ";
132
+ }
133
+
134
+ export function renderTuiHelp() {
135
+ return [
136
+ "Commands:",
137
+ " /help Show this help",
138
+ " /new Start a fresh dialog",
139
+ " /compact Compact current dialog and fork a new one",
140
+ " /context Show workspace context and next actions",
141
+ " /runtime <mode> Use auto, local, or server runtime",
142
+ " /agent Show the current agent",
143
+ " /agents List built-in agent shortcuts",
144
+ " /switch <agent> Switch the current agent",
145
+ " /dialog Show the current dialog",
146
+ " /doc List attached docs",
147
+ " /doc attach <doc> Attach a doc to this workspace",
148
+ " /customize Describe how you want to tune nolo",
149
+ " /login Show login/profile hint",
150
+ " /profile Show active profile",
151
+ " /update Update the global nolo install",
152
+ " /version Show version/update hint",
153
+ " /exit Leave the workspace",
154
+ "",
155
+ "You can also type normally. nolo will send it to the current agent.",
156
+ ].join("\n");
157
+ }
158
+
159
+ export function renderContextPanel(state: TuiState) {
160
+ const docs = state.attachedDocs.length
161
+ ? state.attachedDocs.join(", ")
162
+ : "none";
163
+ return [
164
+ "Workspace context",
165
+ "-----------------",
166
+ `agent ${state.agentName}`,
167
+ `dialog ${resolveDialogLabel(state)}`,
168
+ `docs ${docs}`,
169
+ `profile ${state.profileName}`,
170
+ `runtime ${state.runtimeMode}`,
171
+ `server ${state.serverUrl}`,
172
+ "",
173
+ "Next:",
174
+ " /agents see specialist shortcuts",
175
+ " /doc attach <doc> add working context",
176
+ " /new start a clean dialog",
177
+ ].join("\n");
178
+ }
179
+
180
+ export function renderKnownAgents() {
181
+ return [
182
+ "Agents:",
183
+ ...KNOWN_AGENTS.map(
184
+ (agent, index) =>
185
+ ` ${index + 1} ${agent.name.padEnd(11)} ${agent.description}`
186
+ ),
187
+ "",
188
+ "Tip: stay on nolo for the one-assistant feel; switch only when you want a specialist directly.",
189
+ ].join("\n");
190
+ }
191
+
192
+ function resolveSwitchTarget(rawTarget: string) {
193
+ const target = rawTarget.trim();
194
+ if (/^\d+$/.test(target)) {
195
+ const agent = KNOWN_AGENTS[Number(target) - 1];
196
+ return agent ? { name: agent.name, key: agent.key } : null;
197
+ }
198
+ const alias = KNOWN_AGENT_ALIASES[target.toLowerCase()];
199
+ if (alias) return alias;
200
+ if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
201
+ return { name: target, key: target };
202
+ }
203
+ return null;
204
+ }
47
205
 
48
206
  export function handleTuiInput(input: string, state: TuiState): TuiInputResult {
49
- return handleTuiInputWithDeps(input, state, createInterpreterDeps());
207
+ const trimmed = input.trim();
208
+ if (!trimmed) {
209
+ return { nextState: state, output: "" };
210
+ }
211
+
212
+ if (!trimmed.startsWith("/")) {
213
+ return {
214
+ nextState: state,
215
+ output: "",
216
+ action: {
217
+ type: "chat",
218
+ message: trimmed,
219
+ agentKey: state.agentKey,
220
+ runtimeMode: state.runtimeMode,
221
+ ...(state.dialogId ? { continueDialogId: state.dialogId } : {}),
222
+ },
223
+ };
224
+ }
225
+
226
+ const [command = "", ...rest] = trimmed.split(/\s+/);
227
+ const argText = rest.join(" ").trim();
228
+
229
+ switch (command) {
230
+ case "/help":
231
+ return { nextState: state, output: renderTuiHelp() };
232
+ case "/context":
233
+ case "/ctx":
234
+ return { nextState: state, output: renderContextPanel(state) };
235
+ case "/runtime": {
236
+ if (argText !== "auto" && argText !== "local" && argText !== "server") {
237
+ return {
238
+ nextState: state,
239
+ output: "Usage: /runtime <auto|local|server>",
240
+ };
241
+ }
242
+ return {
243
+ nextState: { ...state, runtimeMode: argText },
244
+ output: `Runtime: ${argText}`,
245
+ };
246
+ }
247
+ case "/exit":
248
+ case "/quit":
249
+ return { nextState: state, output: "Bye.", action: { type: "exit" } };
250
+ case "/new":
251
+ return {
252
+ nextState: {
253
+ ...state,
254
+ dialogId: undefined,
255
+ dialogLabel: "new",
256
+ attachedDocs: [],
257
+ },
258
+ output: "Started a fresh dialog.",
259
+ };
260
+ case "/compact":
261
+ if (argText) {
262
+ return {
263
+ nextState: state,
264
+ output: `Unknown command: ${trimmed}\n\n${renderTuiHelp()}`,
265
+ };
266
+ }
267
+ if (!state.dialogId) {
268
+ return {
269
+ nextState: state,
270
+ output: "Current dialog: new (nothing to compact yet)",
271
+ };
272
+ }
273
+ return {
274
+ nextState: state,
275
+ output: "Compacting current dialog...",
276
+ action: { type: "compact", dialogId: state.dialogId },
277
+ };
278
+ case "/agent":
279
+ return {
280
+ nextState: state,
281
+ output: `Current agent: ${state.agentName} (${state.agentKey})`,
282
+ };
283
+ case "/agents":
284
+ return {
285
+ nextState: state,
286
+ output: renderKnownAgents(),
287
+ };
288
+ case "/switch": {
289
+ if (!argText) {
290
+ return {
291
+ nextState: state,
292
+ output: "Usage: /switch <agent-key|alias>",
293
+ };
294
+ }
295
+ const resolvedTarget = resolveSwitchTarget(argText);
296
+ if (!resolvedTarget) {
297
+ return {
298
+ nextState: state,
299
+ output:
300
+ `I don't know agent shortcut "${argText}" yet.\n` +
301
+ "Use /switch nolo, /switch app-builder, or a full agent key like agent-pub-...",
302
+ };
303
+ }
304
+ return {
305
+ nextState: {
306
+ ...state,
307
+ agentName: resolvedTarget.name,
308
+ agentKey: resolvedTarget.key,
309
+ },
310
+ output: `Switched to ${resolvedTarget.name}.`,
311
+ };
312
+ }
313
+ case "/dialog":
314
+ return {
315
+ nextState: state,
316
+ output: state.dialogId
317
+ ? `Current dialog: ${state.dialogId}`
318
+ : "Current dialog: new",
319
+ };
320
+ case "/doc": {
321
+ if (rest[0] === "attach") {
322
+ const docName = rest.slice(1).join(" ").trim();
323
+ if (!docName) {
324
+ return { nextState: state, output: "Usage: /doc attach <doc>" };
325
+ }
326
+ const attachedDocs = state.attachedDocs.includes(docName)
327
+ ? state.attachedDocs
328
+ : [...state.attachedDocs, docName];
329
+ return {
330
+ nextState: { ...state, attachedDocs },
331
+ output: `Attached doc: ${docName}`,
332
+ };
333
+ }
334
+ return {
335
+ nextState: state,
336
+ output:
337
+ state.attachedDocs.length > 0
338
+ ? `Attached docs: ${state.attachedDocs.join(", ")}`
339
+ : "No docs attached. Use /doc attach <doc>.",
340
+ };
341
+ }
342
+ case "/customize":
343
+ return {
344
+ nextState: state,
345
+ output:
346
+ "Tell nolo what to change, for example: /customize make my default agent more concise.",
347
+ };
348
+ case "/login":
349
+ return {
350
+ nextState: state,
351
+ output:
352
+ "MVP login uses profile/env auth. Set AUTH_TOKEN, NOLO_SERVER, or NOLO_PROFILE before starting nolo.",
353
+ };
354
+ case "/profile":
355
+ return {
356
+ nextState: state,
357
+ output: `Profile: ${state.profileName}`,
358
+ };
359
+ case "/update":
360
+ return {
361
+ nextState: state,
362
+ output: "Starting self-update...",
363
+ action: { type: "self-update" },
364
+ };
365
+ case "/version":
366
+ return {
367
+ nextState: state,
368
+ output:
369
+ `nolo ${state.cliVersion || "unknown version"}\n` +
370
+ "Update this install with: nolo update\n" +
371
+ "If repo-local output differs, publish/install the latest npm package first.",
372
+ };
373
+ default:
374
+ return {
375
+ nextState: state,
376
+ output: `Unknown command: ${command}\n\n${renderTuiHelp()}`,
377
+ };
378
+ }
50
379
  }
@@ -1,31 +1,11 @@
1
1
  import { createEnvCommand } from "./cliCommandFactories";
2
2
  import type { CommandEntry } from "./cliCommandTypes";
3
- import { runTableMetaCommand } from "./tableMetaCommands";
4
- import {
5
- runTableAddColumnCommand,
6
- runTableAddRowCommand,
7
- runTableAddRowsCommand,
8
- runTableDataCommand,
9
- runTableDeleteRowCommand,
10
- runTableDeleteRowsCommand,
11
- runTableUpdateRowCommand,
12
- runTableUpdateRowsCommand,
13
- } from "./tableMutationCommands";
14
3
  import { runTableQueryCommand } from "./tableCommands";
15
4
  import { runTaskRunCommand } from "./taskRunCommand";
16
5
 
17
6
  export function getWorkflowInternalCommandEntries(): CommandEntry[] {
18
7
  return [
19
8
  createEnvCommand(["table", "query"], "Query table rows", runTableQueryCommand),
20
- createEnvCommand(["table", "meta"], "Create or update table metadata", runTableMetaCommand),
21
- createEnvCommand(["table", "add-column"], "Add one table column", runTableAddColumnCommand),
22
- createEnvCommand(["table", "add-row"], "Add one table row", runTableAddRowCommand),
23
- createEnvCommand(["table", "add-rows"], "Add table rows", runTableAddRowsCommand),
24
- createEnvCommand(["table", "update-row"], "Update one table row", runTableUpdateRowCommand),
25
- createEnvCommand(["table", "update-rows"], "Update table rows", runTableUpdateRowsCommand),
26
- createEnvCommand(["table", "delete-row"], "Delete one table row", runTableDeleteRowCommand),
27
- createEnvCommand(["table", "delete-rows"], "Delete table rows", runTableDeleteRowsCommand),
28
- createEnvCommand(["table", "data"], "Low-level table row command", runTableDataCommand),
29
9
  createEnvCommand(["task-run"], "Update durable task-run state through the runner bridge", runTaskRunCommand),
30
10
  ];
31
11
  }
@@ -1,139 +0,0 @@
1
- export type DialogStatusSnapshot = {
2
- dialogId: string;
3
- dialogKey?: string;
4
- base?: string;
5
- title?: string | null;
6
- status?: string | null;
7
- parentDialogId?: string | null;
8
- rootDialogId?: string | null;
9
- subjectRefs?: Array<{ kind?: string; id?: string; role?: string }>;
10
- runtimeCheckpoint?: Record<string, any> | null;
11
- artifacts?: any;
12
- writtenFiles?: string[];
13
- toolsUsed?: string[];
14
- toolErrors?: string[];
15
- durationMs?: number | null;
16
- updatedAt?: string | number | null;
17
- finishedAt?: string | number | null;
18
- };
19
-
20
- const ACTIVE_STALE_AFTER_MS = 5 * 60_000;
21
-
22
- function compact(value: unknown, max = 180) {
23
- const text = typeof value === "string" ? value.trim() : "";
24
- if (!text) return "";
25
- return text.length > max ? `${text.slice(0, max - 3)}...` : text;
26
- }
27
-
28
- function list(values: unknown, max = 8) {
29
- if (!Array.isArray(values)) return [];
30
- return values
31
- .map((value) => (typeof value === "string" ? value.trim() : ""))
32
- .filter(Boolean)
33
- .slice(0, max);
34
- }
35
-
36
- function artifactFiles(artifacts: any) {
37
- if (!artifacts || typeof artifacts !== "object") return [];
38
- return list(artifacts.changedFiles ?? artifacts.writtenFiles ?? artifacts.files);
39
- }
40
-
41
- function formatSubjectRefs(refs: DialogStatusSnapshot["subjectRefs"], max = 8) {
42
- if (!Array.isArray(refs)) return [];
43
- return refs
44
- .map((ref) => {
45
- const kind = typeof ref?.kind === "string" ? ref.kind.trim() : "";
46
- const id = typeof ref?.id === "string" ? ref.id.trim() : "";
47
- if (!kind || !id) return "";
48
- const role = typeof ref?.role === "string" && ref.role.trim() ? `#${ref.role.trim()}` : "";
49
- return `${kind}:${id}${role}`;
50
- })
51
- .filter(Boolean)
52
- .slice(0, max);
53
- }
54
-
55
- export function resolveDialogTerminalState(snapshot: DialogStatusSnapshot) {
56
- const checkpointStatus =
57
- typeof snapshot.runtimeCheckpoint?.status === "string"
58
- ? snapshot.runtimeCheckpoint.status
59
- : null;
60
- if (checkpointStatus === "done" || checkpointStatus === "completed") return "done";
61
- if (checkpointStatus === "failed" || checkpointStatus === "error") return "failed";
62
-
63
- const status = snapshot.status ?? checkpointStatus ?? "unknown";
64
- if (status === "done" || status === "completed") return "done";
65
- if (status === "failed" || status === "error") return "failed";
66
- if (status === "running" || status === "pending" || status === "queued") return "active";
67
- return "unknown";
68
- }
69
-
70
- function parseTimeMs(value: unknown): number | null {
71
- if (typeof value === "number" && Number.isFinite(value)) return value;
72
- if (typeof value === "string" && value.trim()) {
73
- const parsed = Date.parse(value);
74
- return Number.isFinite(parsed) ? parsed : null;
75
- }
76
- return null;
77
- }
78
-
79
- export function resolveDialogActiveHealth(snapshot: DialogStatusSnapshot, nowMs = Date.now()) {
80
- if (resolveDialogTerminalState(snapshot) !== "active") return null;
81
- const checkpointUpdatedAt = parseTimeMs(snapshot.runtimeCheckpoint?.updatedAt);
82
- const dialogUpdatedAt = parseTimeMs(snapshot.updatedAt);
83
- const latest = checkpointUpdatedAt ?? dialogUpdatedAt;
84
- if (!snapshot.runtimeCheckpoint) return "no-checkpoint";
85
- if (!checkpointUpdatedAt) return "checkpoint-without-updatedAt";
86
- if (latest && nowMs - latest > ACTIVE_STALE_AFTER_MS) return "stale-running";
87
- return "running";
88
- }
89
-
90
- export function renderDialogStatus(snapshot: DialogStatusSnapshot) {
91
- const checkpoint = snapshot.runtimeCheckpoint ?? {};
92
- const files = list(snapshot.writtenFiles).length
93
- ? list(snapshot.writtenFiles)
94
- : artifactFiles(snapshot.artifacts);
95
- const tools = list(snapshot.toolsUsed).length
96
- ? list(snapshot.toolsUsed)
97
- : list(checkpoint.lastToolNames);
98
- const errors = list(snapshot.toolErrors);
99
- const errorMessage = compact(checkpoint.errorMessage ?? (snapshot as any).errorMessage);
100
- const subjectRefs = formatSubjectRefs(snapshot.subjectRefs);
101
- const terminal = resolveDialogTerminalState(snapshot);
102
- const activeHealth = resolveDialogActiveHealth(snapshot);
103
- const lines = [
104
- `dialog: ${snapshot.dialogId}`,
105
- ...(snapshot.base ? [`base: ${snapshot.base}`] : []),
106
- ...(snapshot.title ? [`title: ${snapshot.title}`] : []),
107
- ...(snapshot.parentDialogId ? [`parentDialogId: ${snapshot.parentDialogId}`] : []),
108
- ...(snapshot.rootDialogId ? [`rootDialogId: ${snapshot.rootDialogId}`] : []),
109
- `status: ${snapshot.status ?? "unknown"}`,
110
- ...(typeof checkpoint.status === "string" ? [`checkpoint: ${checkpoint.status}`] : []),
111
- `state: ${terminal}`,
112
- ...(activeHealth ? [`activeHealth: ${activeHealth}`] : []),
113
- ...(typeof snapshot.durationMs === "number" ? [`durationMs: ${snapshot.durationMs}`] : []),
114
- ...(snapshot.updatedAt ? [`updatedAt: ${snapshot.updatedAt}`] : []),
115
- ...(snapshot.finishedAt ? [`finishedAt: ${snapshot.finishedAt}`] : []),
116
- ...(compact(checkpoint.lastUserInput) ? [`lastUserInput: ${compact(checkpoint.lastUserInput)}`] : []),
117
- ...(compact(checkpoint.lastAssistantText) ? [`lastAssistantText: ${compact(checkpoint.lastAssistantText)}`] : []),
118
- ...(errorMessage ? [`error: ${errorMessage}`] : []),
119
- ...(tools.length ? [`tools: ${tools.join(", ")}`] : []),
120
- ...(files.length ? [`files: ${files.join(", ")}`] : []),
121
- ...(subjectRefs.length ? [`subjects: ${subjectRefs.join(", ")}`] : []),
122
- ...(errors.length ? [`toolErrors: ${errors.join(", ")}`] : []),
123
- "",
124
- "next:",
125
- `- read full dialog: nolo dialog read ${snapshot.dialogId} 120`,
126
- ];
127
-
128
- if (terminal === "active") {
129
- lines.push(`- poll again: nolo dialog status ${snapshot.dialogId}`);
130
- } else if (terminal === "failed") {
131
- lines.push(`- inspect failure and rerun/continue with: nolo agent run <agent> --continue ${snapshot.dialogId} --msg "..."`);
132
- } else if (terminal === "done") {
133
- lines.push("- use artifacts/files above for review, handoff, or alpha integration.");
134
- } else {
135
- lines.push("- inspect meta/messages before deciding whether to continue or rerun.");
136
- }
137
-
138
- return `${lines.join("\n")}\n`;
139
- }
@@ -1,86 +0,0 @@
1
- type EnvLike = Record<string, string | undefined>;
2
-
3
- export type HostRuntimeSurface =
4
- | "cli-local"
5
- | "desktop"
6
- | "connector-local"
7
- | "connector-cli";
8
-
9
- export type HostRuntimeWorkspaceBinding =
10
- | "explicit-cwd"
11
- | "default-cwd";
12
-
13
- export type HostRuntimeCapabilities = {
14
- allowShell: boolean;
15
- };
16
-
17
- export type HostRuntimeConfig = {
18
- surface: HostRuntimeSurface;
19
- workspaceBinding: HostRuntimeWorkspaceBinding;
20
- capabilities: HostRuntimeCapabilities;
21
- };
22
-
23
- const SHELL_ENABLED_BY_DEFAULT_SURFACES = new Set<HostRuntimeSurface>([
24
- "cli-local",
25
- "desktop",
26
- ]);
27
-
28
- function defaultAllowShellForSurface(surface: HostRuntimeSurface) {
29
- return SHELL_ENABLED_BY_DEFAULT_SURFACES.has(surface);
30
- }
31
-
32
- function readAllowShellOverrideFromEnv(env: EnvLike) {
33
- const rawMode = (env.NOLO_LOCAL_SHELL_MODE || "").trim().toLowerCase();
34
- if (!rawMode) return undefined;
35
- if (["worktree", "dangerous", "1", "true"].includes(rawMode)) return true;
36
- if (["0", "false", "off", "none", "disabled"].includes(rawMode)) return false;
37
- return undefined;
38
- }
39
-
40
- export function createHostRuntimeCapabilities(args: {
41
- allowShell?: boolean;
42
- } = {}): HostRuntimeCapabilities {
43
- return {
44
- allowShell: args.allowShell === true,
45
- };
46
- }
47
-
48
- export function createHostRuntimeConfig(args: {
49
- surface: HostRuntimeSurface;
50
- workspaceBinding: HostRuntimeWorkspaceBinding;
51
- allowShell?: boolean;
52
- }): HostRuntimeConfig {
53
- return {
54
- surface: args.surface,
55
- workspaceBinding: args.workspaceBinding,
56
- capabilities: createHostRuntimeCapabilities({
57
- allowShell: args.allowShell,
58
- }),
59
- };
60
- }
61
-
62
- export function resolveHostRuntimeCapabilitiesFromEnv(
63
- env: EnvLike,
64
- args: { surface?: HostRuntimeSurface } = {},
65
- ): HostRuntimeCapabilities {
66
- const allowShellOverride = readAllowShellOverrideFromEnv(env);
67
- return createHostRuntimeCapabilities({
68
- allowShell:
69
- allowShellOverride ??
70
- (args.surface ? defaultAllowShellForSurface(args.surface) : false),
71
- });
72
- }
73
-
74
- export function resolveHostRuntimeConfigFromEnv(args: {
75
- env: EnvLike;
76
- surface: HostRuntimeSurface;
77
- workspaceBinding: HostRuntimeWorkspaceBinding;
78
- }): HostRuntimeConfig {
79
- return {
80
- surface: args.surface,
81
- workspaceBinding: args.workspaceBinding,
82
- capabilities: resolveHostRuntimeCapabilitiesFromEnv(args.env, {
83
- surface: args.surface,
84
- }),
85
- };
86
- }