nolo-cli 0.1.22 → 0.1.26

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 (128) hide show
  1. package/README.md +25 -3
  2. package/agent-runtime/agentRecordConfig.ts +4 -0
  3. package/agent-runtime/hostAdapter.ts +2 -0
  4. package/agent-runtime/hybridRecordStore.ts +30 -9
  5. package/agent-runtime/index.ts +7 -0
  6. package/agent-runtime/localLoop.ts +14 -4
  7. package/agent-runtime/localToolPolicy.ts +22 -10
  8. package/agent-runtime/localWorkspaceTools.ts +140 -374
  9. package/agent-runtime/platformChatProvider.ts +3 -0
  10. package/agent-runtime/runtimeToolPolicy.ts +133 -0
  11. package/agent-runtime/types.ts +47 -0
  12. package/agentAliases.ts +1 -1
  13. package/agentCommandSupport.ts +77 -0
  14. package/agentInternalCommandEntries.ts +34 -0
  15. package/agentListCommands.ts +123 -0
  16. package/agentListHelpers.ts +187 -0
  17. package/agentMachineCommands.ts +402 -0
  18. package/agentRecordCommands.ts +141 -0
  19. package/agentRecordHelpers.ts +395 -0
  20. package/agentRunCommand.ts +75 -3
  21. package/agentRuntimeCommands.ts +7 -773
  22. package/ai/agent/_executeModel.ts +29 -3
  23. package/ai/agent/buildSystemPrompt.ts +17 -0
  24. package/ai/agent/cliChatClient.ts +38 -4
  25. package/ai/agent/cliExecutor.ts +304 -25
  26. package/ai/agent/createAgentSchema.ts +2 -2
  27. package/ai/agent/guidedCreation/assistant.ts +82 -0
  28. package/ai/agent/guidedCreation/capabilities.ts +84 -0
  29. package/ai/agent/guidedCreation/draft.ts +62 -0
  30. package/ai/agent/guidedCreation/types.ts +38 -0
  31. package/ai/agent/machineRunPermissions.ts +21 -3
  32. package/ai/agent/runtimeGuidance.ts +1 -1
  33. package/ai/agent/server/fetchPublicAgents.ts +6 -1
  34. package/ai/agent/streamAgentChatTurn.ts +593 -36
  35. package/ai/agent/web/useGuidedAgentCreation.ts +217 -0
  36. package/ai/ai.locale.ts +14 -2
  37. package/ai/chat/fetchUtils.native.ts +2 -0
  38. package/ai/chat/fetchUtils.ts +2 -0
  39. package/ai/chat/sendOpenAICompletionsRequest.ts +82 -1
  40. package/ai/chat/sendOpenAIResponseRequest.ts +65 -0
  41. package/ai/llm/getPricing.ts +14 -0
  42. package/ai/llm/kimi.ts +4 -1
  43. package/ai/llm/modelAvatar.ts +1 -0
  44. package/ai/llm/providers.ts +4 -1
  45. package/ai/llm/reasoningModels.ts +1 -0
  46. package/ai/taskRun/taskRunProtocol.ts +25 -10
  47. package/ai/token/modelUsageQuery.ts +17 -0
  48. package/ai/tools/agent/agentTools.ts +38 -0
  49. package/ai/tools/agent/prepareAgentDraftTool.ts +159 -0
  50. package/ai/tools/agent/startAgentDialogTool.ts +53 -0
  51. package/ai/tools/checkEnvTool.ts +52 -20
  52. package/ai/tools/convertMarxistsBookTool.ts +103 -0
  53. package/ai/tools/{execBashTool.ts → execShellTool.ts} +44 -161
  54. package/ai/tools/index.ts +24 -14
  55. package/ai/tools/marxistsOfflineBook.ts +253 -0
  56. package/ai/tools/modelUsageTools.ts +9 -2
  57. package/ai/tools/readTool.ts +31 -0
  58. package/ai/tools/toolApiClient.ts +35 -1
  59. package/ai/tools/toolNameAliases.ts +13 -0
  60. package/cliCommandAdapters.ts +28 -0
  61. package/cliCommandDispatch.ts +66 -0
  62. package/cliCommandFactories.ts +34 -0
  63. package/cliCommandTypes.ts +49 -0
  64. package/cliEnvHelpers.ts +44 -0
  65. package/client/agentRun.test.ts +330 -24
  66. package/client/agentRun.ts +117 -35
  67. package/client/hybridRecordStore.test.ts +42 -0
  68. package/client/hybridRecordStore.ts +11 -0
  69. package/client/localRuntimeAdapter.test.ts +191 -21
  70. package/client/localRuntimeAdapter.ts +99 -10
  71. package/client/localRuntimeDryRun.test.ts +5 -2
  72. package/client/taskRunPrompt.ts +1 -0
  73. package/commandRegistry.ts +11 -61
  74. package/connector-experimental/capabilities.ts +1 -0
  75. package/database/actions/common.ts +4 -3
  76. package/database/config.ts +19 -0
  77. package/database/server/coreDataProxy.ts +43 -26
  78. package/index.ts +54 -191
  79. package/internalCommandEntries.ts +12 -0
  80. package/machineCommands.ts +688 -64
  81. package/offlineMarxistsAgentCommand.ts +314 -0
  82. package/package.json +22 -2
  83. package/render/canvas/canvasEditContext.ts +127 -0
  84. package/render/canvas/canvasRuntime.ts +57 -0
  85. package/render/canvas/canvasSnapshotParser.ts +76 -0
  86. package/render/canvas/canvasTree.ts +308 -0
  87. package/render/canvas/types.ts +46 -0
  88. package/render/layout/deleteBehavior.ts +52 -0
  89. package/render/layout/mainLayoutSidebar.ts +17 -0
  90. package/render/layout/mainLayoutViewMode.ts +56 -0
  91. package/render/layout/topbarUtils.ts +87 -0
  92. package/render/layout/useDevReloadPending.ts +30 -0
  93. package/render/page/createPageAction.ts +183 -0
  94. package/render/page/docSlice.ts +468 -0
  95. package/render/page/server/createPage.ts +174 -0
  96. package/render/page/server/handleCreatePage.ts +91 -0
  97. package/render/page/server/index.ts +4 -0
  98. package/render/page/types.ts +17 -0
  99. package/render/page/useKeyboardSave.ts +48 -0
  100. package/render/styles/zIndex.ts +12 -0
  101. package/render/surf/WeatherIconStyles.ts +17 -0
  102. package/render/surf/color.ts +9 -0
  103. package/render/surf/config.ts +46 -0
  104. package/render/surf/screens/style.ts +1 -0
  105. package/render/surf/styles/ToggleButtonStyles.ts +8 -0
  106. package/render/surf/utils/groupedWeatherData.ts +32 -0
  107. package/render/surf/weatherUtils.ts +50 -0
  108. package/render/table/activityColumns.ts +6 -0
  109. package/render/table/createTableAction.ts +270 -0
  110. package/render/table/deleteTableAction.ts +129 -0
  111. package/render/table/fetchAndCacheTableRows.ts +174 -0
  112. package/render/table/tableSlice.ts +1106 -0
  113. package/render/table/tableView.ts +289 -0
  114. package/render/table/toolValueUtils.ts +363 -0
  115. package/render/table/types.ts +252 -0
  116. package/render/table/useCreateTable.ts +72 -0
  117. package/render/table/useTable.ts +61 -0
  118. package/render/table/utils/tableSerialization.ts +50 -0
  119. package/render/web/elements/artifactPreviewCode.ts +43 -0
  120. package/render/web/elements/artifactRuntimePreload.ts +52 -0
  121. package/render/web/elements/codeBlockAutoPreview.ts +10 -0
  122. package/render/web/elements/mermaidPreview.ts +21 -0
  123. package/render/web/ui/useInlineEdit.ts +135 -0
  124. package/runtimeDoctorCommands.ts +118 -0
  125. package/scriptCommandEntries.ts +71 -0
  126. package/systemInternalCommandEntries.ts +71 -0
  127. package/tableCommands.ts +42 -5
  128. package/workflowInternalCommandEntries.ts +11 -0
package/index.ts CHANGED
@@ -1,54 +1,37 @@
1
1
  #!/usr/bin/env bun
2
-
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- import { renderHelpText, resolveCommand } from "./commandRegistry";
7
- import { runLoginCommand, runLogoutCommand, runWhoamiCommand } from "./authCommands";
2
+
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
8
6
  import {
9
- runAgentBindCurrentCommand,
10
- runAgentReadCommand,
11
- runAgentRuntimeDoctorCommand,
12
- runAgentSmokeCurrentCommand,
13
- runDoctorRuntimeCommand,
14
- } from "./agentRuntimeCommands";
15
- import { runAgentRunCommand } from "./agentRunCommand";
16
- import { runAgentPullCommand } from "./agentPullCommand";
7
+ createCliRuntimeContext,
8
+ looksLikeDaemonShortcut,
9
+ renderHelpText,
10
+ resolveCommand,
11
+ runResolvedCommand,
12
+ } from "./commandRegistry";
17
13
  import { buildEnvFromProfile, loadProfileConfig } from "./client/profileConfig";
18
14
  import { resolveTuiLaunchMode } from "./runtimeModeArgs";
19
- import {
20
- runMachineConnectCommand,
21
- runMachineStatusCommand,
22
- } from "./machineCommands";
23
- import { runTaskRunCommand } from "./taskRunCommand";
24
- import { runTableQueryCommand } from "./tableCommands";
25
- import { startTuiWorkspace } from "./tui/readlineWorkspace";
26
- import {
27
- buildCliDoctorText,
28
- buildCliVersionText,
29
- readPackageInfo,
30
- runSelfUpdate,
31
- } from "./updateCommands";
32
- import { DEFAULT_NOLO_SERVER_URL } from "./defaultServer";
33
-
34
- const CLI_DIR = dirname(fileURLToPath(import.meta.url));
35
- const ROOT_DIR = join(CLI_DIR, "..", "..");
36
- const SCRIPT_DIR = join(ROOT_DIR, "scripts");
37
- const packageInfo = readPackageInfo();
38
-
39
- async function runScript(script: string, forwardedArgs: string[], env: NodeJS.ProcessEnv) {
40
- const scriptPath = join(SCRIPT_DIR, script);
41
- const proc = Bun.spawn({
42
- cmd: [process.execPath, scriptPath, ...forwardedArgs],
43
- stdin: "inherit",
44
- stdout: "inherit",
45
- stderr: "inherit",
46
- env,
47
- });
48
- const exitCode = await proc.exited;
49
- process.exit(exitCode);
50
- }
51
-
15
+ import { startTuiWorkspace } from "./tui/readlineWorkspace";
16
+ import { readPackageInfo } from "./updateCommands";
17
+
18
+ const CLI_DIR = dirname(fileURLToPath(import.meta.url));
19
+ const ROOT_DIR = join(CLI_DIR, "..", "..");
20
+ const SCRIPT_DIR = join(ROOT_DIR, "scripts");
21
+ const packageInfo = readPackageInfo();
22
+
23
+ async function runScript(script: string, forwardedArgs: string[], env: NodeJS.ProcessEnv) {
24
+ const scriptPath = join(SCRIPT_DIR, script);
25
+ const proc = Bun.spawn({
26
+ cmd: [process.execPath, scriptPath, ...forwardedArgs],
27
+ stdin: "inherit",
28
+ stdout: "inherit",
29
+ stderr: "inherit",
30
+ env,
31
+ });
32
+ return proc.exited;
33
+ }
34
+
52
35
  const args = process.argv.slice(2);
53
36
  const profileEnv = buildEnvFromProfile(loadProfileConfig());
54
37
  const explicitServerUrl = process.env.NOLO_SERVER || process.env.NOLO_SERVER_URL || process.env.BASE_URL;
@@ -58,35 +41,23 @@ const runtimeEnv = {
58
41
  ...(explicitServerUrl ? { NOLO_SERVER: explicitServerUrl, BASE_URL: explicitServerUrl } : {}),
59
42
  NOLO_CLI_VERSION: packageInfo.version,
60
43
  };
61
-
62
- function readOption(args: string[], flag: string) {
63
- const index = args.indexOf(flag);
64
- return index >= 0 ? args[index + 1] : undefined;
65
- }
66
-
67
- function buildDaemonEnv(args: string[]) {
68
- const serverUrl = readOption(args, "--server-url") || readOption(args, "--server");
69
- const apiKey = readOption(args, "--api-key") || readOption(args, "--token");
70
- return {
71
- ...runtimeEnv,
72
- ...(serverUrl ? { NOLO_SERVER: serverUrl } : {}),
73
- ...(apiKey ? { AUTH_TOKEN: apiKey } : {}),
74
- };
75
- }
76
-
77
- function looksLikeDaemonShortcut(args: string[]) {
78
- return args.includes("--server-url") || args.includes("--api-key");
79
- }
80
-
81
- if (args.length === 0) {
82
- if (process.stdin.isTTY) {
83
- await startTuiWorkspace({ scriptDir: SCRIPT_DIR, env: runtimeEnv });
84
- } else {
85
- console.log(renderHelpText());
86
- }
87
- process.exit(0);
88
- }
89
-
44
+
45
+ const runtimeContext = createCliRuntimeContext({
46
+ env: runtimeEnv,
47
+ scriptDir: SCRIPT_DIR,
48
+ entrypointPath: fileURLToPath(import.meta.url),
49
+ packageInfo,
50
+ });
51
+
52
+ if (args.length === 0) {
53
+ if (process.stdin.isTTY) {
54
+ await startTuiWorkspace({ scriptDir: SCRIPT_DIR, env: runtimeEnv });
55
+ } else {
56
+ console.log(renderHelpText());
57
+ }
58
+ process.exit(0);
59
+ }
60
+
90
61
  const tuiLaunchMode = resolveTuiLaunchMode(args);
91
62
  if (tuiLaunchMode.shouldStartTui) {
92
63
  await startTuiWorkspace({
@@ -95,125 +66,17 @@ if (tuiLaunchMode.shouldStartTui) {
95
66
  });
96
67
  process.exit(0);
97
68
  }
98
-
99
- if (args[0] === "login") {
100
- process.exit(await runLoginCommand(args.slice(1)));
101
- }
102
-
103
- if (args[0] === "whoami") {
104
- process.exit(runWhoamiCommand());
105
- }
106
-
107
- if (args[0] === "logout") {
108
- process.exit(runLogoutCommand());
109
- }
110
-
111
- if (args[0] === "connect") {
112
- process.exit(await runMachineConnectCommand(args.slice(1), {
113
- env: runtimeEnv,
114
- cliEntrypointPath: fileURLToPath(import.meta.url),
115
- }));
116
- }
117
-
118
- if (args[0] === "task-run") {
119
- process.exit(await runTaskRunCommand(args.slice(1), { env: runtimeEnv }));
120
- }
121
-
122
- if (args[0] === "table" && args[1] === "query") {
123
- process.exit(await runTableQueryCommand(args.slice(2), { env: runtimeEnv }));
124
- }
125
-
126
- if (args[0] === "daemon" || looksLikeDaemonShortcut(args)) {
127
- const daemonArgs = args[0] === "daemon" ? args.slice(1) : args;
128
- process.exit(await runMachineConnectCommand(["--ws"], {
129
- env: buildDaemonEnv(daemonArgs),
130
- cliEntrypointPath: fileURLToPath(import.meta.url),
131
- }));
132
- }
133
-
134
- if (args[0] === "machine" && args[1] === "status") {
135
- process.exit(await runMachineStatusCommand(args.slice(2), { env: runtimeEnv }));
136
- }
137
-
138
- if (args[0] === "agent" && args[1] === "bind-current") {
139
- process.exit(await runAgentBindCurrentCommand(args.slice(2), { env: runtimeEnv }));
140
- }
141
-
142
- if (args[0] === "agent" && args[1] === "smoke-current") {
143
- process.exit(await runAgentSmokeCurrentCommand(args.slice(2), { env: runtimeEnv }));
144
- }
145
-
146
- if (args[0] === "agent" && args[1] === "run") {
147
- process.exit(await runAgentRunCommand(args.slice(2), {
148
- env: runtimeEnv,
149
- scriptDir: SCRIPT_DIR,
150
- }));
151
- }
152
-
153
- if (args[0] === "agent" && args[1] === "chat") {
154
- process.exit(await runAgentRunCommand(args.slice(2), {
155
- env: runtimeEnv,
156
- scriptDir: SCRIPT_DIR,
157
- }));
158
- }
159
-
160
- if (args[0] === "chat") {
161
- process.exit(await runAgentRunCommand(args.slice(1), {
162
- env: runtimeEnv,
163
- scriptDir: SCRIPT_DIR,
164
- }));
165
- }
166
-
167
- if (args[0] === "agent" && args[1] === "pull") {
168
- process.exit(await runAgentPullCommand(args.slice(2), { env: runtimeEnv }));
169
- }
170
-
171
- if (args[0] === "agent" && args[1] === "read") {
172
- process.exit(await runAgentReadCommand(args.slice(2), { env: runtimeEnv }));
173
- }
174
-
175
- if (args[0] === "agent" && args[1] === "runtime-doctor") {
176
- process.exit(await runAgentRuntimeDoctorCommand(args.slice(2), { env: runtimeEnv }));
177
- }
178
-
179
- if (args[0] === "doctor" && args[1] === "runtime") {
180
- process.exit(await runDoctorRuntimeCommand(args.slice(2), { env: runtimeEnv }));
181
- }
182
69
 
183
- if (args[0] === "--version" || args[0] === "-v" || args[0] === "version") {
184
- console.log(buildCliVersionText(packageInfo));
185
- process.exit(0);
186
- }
187
-
188
- if (args[0] === "doctor") {
189
- console.log(
190
- buildCliDoctorText({
191
- packageName: packageInfo.name,
192
- version: packageInfo.version,
193
- entrypoint: fileURLToPath(import.meta.url),
194
- serverUrl: runtimeEnv.NOLO_SERVER || runtimeEnv.BASE_URL || DEFAULT_NOLO_SERVER_URL,
195
- profileName: runtimeEnv.NOLO_PROFILE || "local",
196
- })
197
- );
198
- process.exit(0);
199
- }
200
-
201
- if (args[0] === "update") {
202
- process.exit(await runSelfUpdate());
203
- }
204
-
205
- if (args[0] === "--help" || args[0] === "-h") {
206
- console.log(renderHelpText());
207
- process.exit(0);
208
- }
209
-
210
- const command = resolveCommand(args);
70
+ const commandArgs = looksLikeDaemonShortcut(args) ? ["daemon", ...args] : args;
71
+ const command = resolveCommand(commandArgs);
211
72
  if (!command) {
212
73
  console.error(`Unknown command: ${args.join(" ")}`);
213
74
  console.error("");
214
75
  console.log(renderHelpText());
215
- process.exit(1);
76
+ process.exit(1);
216
77
  }
217
78
 
218
- const forwardedArgs = [...(command.fixedArgs ?? []), ...args.slice(command.path.length)];
219
- await runScript(command.script, forwardedArgs, runtimeEnv);
79
+ const exitCode = await runResolvedCommand(command, commandArgs, runtimeContext, {
80
+ runScript,
81
+ });
82
+ process.exit(exitCode);
@@ -0,0 +1,12 @@
1
+ import { getAgentInternalCommandEntries } from "./agentInternalCommandEntries";
2
+ import type { CommandEntry } from "./cliCommandTypes";
3
+ import { getSystemInternalCommandEntries } from "./systemInternalCommandEntries";
4
+ import { getWorkflowInternalCommandEntries } from "./workflowInternalCommandEntries";
5
+
6
+ export function getInternalCommandEntries(renderHelpText: () => string): CommandEntry[] {
7
+ return [
8
+ ...getAgentInternalCommandEntries(),
9
+ ...getWorkflowInternalCommandEntries(),
10
+ ...getSystemInternalCommandEntries(renderHelpText),
11
+ ];
12
+ }