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,179 +0,0 @@
1
- export const DEFAULT_CODING_AGENT_PROMPT = [
2
- "你是空间里的私有代码助理。",
3
- "底层模型来自 OpenAI 兼容接口。",
4
- "默认输出中文,代码、路径和命令保持英文。",
5
- "执行命令前先判断当前环境;环境不明确时先调用 checkEnv({check:'context'})。",
6
- "Windows 默认使用 PowerShell 语法,Linux/macOS 默认使用 bash 语法。",
7
- "开始动手前先理解需求和上下文,避免无关改动。",
8
- "优先做可验证、可落地的修改,必要时先读取文件和环境。",
9
- "涉及代码改动时,尽量给出最小但完整的实现,并说明验证方式。",
10
- ].join("\n");
11
-
12
- export type BuildCodingAgentRecordOptions = {
13
- userId: string;
14
- now: number;
15
- agentId: string;
16
- name: string;
17
- provider: string;
18
- model: string;
19
- apiSource: "custom" | "platform";
20
- tools: string[];
21
- tags: string[];
22
- introduction?: string;
23
- greeting?: string;
24
- prompt?: string;
25
- providerUrl?: string;
26
- apiKey?: string;
27
- apiKeyHeader?: string;
28
- };
29
-
30
- export type CustomCodingAgentRecordPlanOptions = {
31
- agentId?: string;
32
- apiKey: string;
33
- apiKeyHeader?: string;
34
- providerUrl: string;
35
- model: string;
36
- name: string;
37
- providerTag?: string;
38
- introduction?: string;
39
- greeting?: string;
40
- prompt?: string;
41
- tags?: string[];
42
- tools: string[];
43
- };
44
-
45
- export type CustomCodingAgentRecordPlan = {
46
- agentId: string;
47
- normalizedProviderUrl: string;
48
- normalizedApiKey: string;
49
- buildRecord: (args: { userId: string; now: number }) => Record<string, any>;
50
- };
51
-
52
- export function deterministicId(prefix: string, seed: string): string {
53
- let hash = 0x811c9dc5;
54
- for (let index = 0; index < seed.length; index++) {
55
- hash ^= seed.charCodeAt(index);
56
- hash = (hash * 0x01000193) >>> 0;
57
- }
58
- const suffix = hash.toString(36).toUpperCase().padStart(14, "0");
59
- return (prefix + suffix).slice(0, 26);
60
- }
61
-
62
- export function inferHostTag(providerUrl: string): string {
63
- try {
64
- return new URL(providerUrl).hostname.replace(/^www\./, "").replace(/\./g, "-");
65
- } catch {
66
- return "custom";
67
- }
68
- }
69
-
70
- function isLocalProviderUrl(providerUrl: string | undefined): boolean {
71
- if (!providerUrl) return false;
72
- try {
73
- const hostname = new URL(providerUrl).hostname.toLowerCase();
74
- return hostname === "127.0.0.1" || hostname === "localhost" || hostname === "::1";
75
- } catch {
76
- return false;
77
- }
78
- }
79
-
80
- export function buildCodingAgentRecord(options: BuildCodingAgentRecordOptions) {
81
- const normalizedProviderUrl = options.providerUrl?.trim().replace(/\/+$/, "");
82
- return {
83
- type: "agent",
84
- id: options.agentId,
85
- userId: options.userId,
86
- name: options.name.trim(),
87
- introduction: options.introduction ?? `使用 ${options.provider} 的私有代码助理。`,
88
- greeting:
89
- options.greeting ??
90
- `你好,我是 ${options.name}。你可以直接让我读项目、改代码、查环境、写脚本。`,
91
- prompt: options.prompt ?? DEFAULT_CODING_AGENT_PROMPT,
92
- apiSource: options.apiSource,
93
- provider: options.provider,
94
- model: options.model.trim(),
95
- ...(normalizedProviderUrl ? { customProviderUrl: normalizedProviderUrl } : {}),
96
- ...(options.apiKey?.trim() ? { apiKey: options.apiKey.trim() } : {}),
97
- ...(options.apiKeyHeader?.trim() ? { apiKeyHeader: options.apiKeyHeader.trim() } : {}),
98
- useServerProxy: true,
99
- hasVision: false,
100
- inputPrice: 0,
101
- outputPrice: 0,
102
- isPublic: false,
103
- tools: [...options.tools],
104
- tags: [...new Set(options.tags.filter(Boolean))],
105
- ...(isLocalProviderUrl(normalizedProviderUrl)
106
- ? {
107
- runtimeBinding: {
108
- kind: "desktop-local-provider",
109
- providerUrl: normalizedProviderUrl,
110
- },
111
- }
112
- : {}),
113
- whitelist: [],
114
- createdAt: options.now,
115
- updatedAt: options.now,
116
- };
117
- }
118
-
119
- export function resolveCustomCodingAgentRecordPlan(
120
- options: CustomCodingAgentRecordPlanOptions
121
- ): CustomCodingAgentRecordPlan {
122
- const providerTag = options.providerTag ?? "custom";
123
- const normalizedProviderUrl = options.providerUrl.trim().replace(/\/+$/, "");
124
- const normalizedApiKey = options.apiKey.trim();
125
- const model = options.model.trim();
126
- const name = options.name.trim();
127
-
128
- if (!normalizedApiKey) {
129
- throw new Error("缺少 API key。");
130
- }
131
- if (!normalizedProviderUrl) {
132
- throw new Error("缺少 provider url。");
133
- }
134
- if (!model) {
135
- throw new Error("缺少 model。");
136
- }
137
- if (!name) {
138
- throw new Error("缺少 agent 名称。");
139
- }
140
-
141
- const agentId =
142
- options.agentId ??
143
- deterministicId(
144
- "01CUSTOMCODEA",
145
- `custom-coding-agent:${normalizedProviderUrl}:${model}:${name}`
146
- );
147
- const introduction =
148
- options.introduction ??
149
- `使用 ${providerTag} 提供的 OpenAI 兼容接口的私有代码助理,适合代码阅读、修改、命令执行与开发协作。`;
150
- const greeting =
151
- options.greeting ??
152
- `你好,我是 ${name}。你可以直接让我读项目、改代码、查环境、写脚本。`;
153
- const prompt = options.prompt ?? DEFAULT_CODING_AGENT_PROMPT;
154
- const tags = options.tags ?? [providerTag, inferHostTag(normalizedProviderUrl), "coding"];
155
-
156
- return {
157
- agentId,
158
- normalizedProviderUrl,
159
- normalizedApiKey,
160
- buildRecord: ({ userId, now }) =>
161
- buildCodingAgentRecord({
162
- userId,
163
- now,
164
- agentId,
165
- name,
166
- introduction,
167
- greeting,
168
- prompt,
169
- apiSource: "custom",
170
- provider: "custom",
171
- model,
172
- providerUrl: normalizedProviderUrl,
173
- apiKey: normalizedApiKey,
174
- apiKeyHeader: options.apiKeyHeader,
175
- tools: options.tools,
176
- tags,
177
- }),
178
- };
179
- }