@nocobase/plugin-ai 2.1.0-beta.29 → 2.1.0-beta.32

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 (159) hide show
  1. package/client-v2.d.ts +1 -0
  2. package/client-v2.js +1 -0
  3. package/dist/ai/docs/nocobase/ai/index.md +1 -1
  4. package/dist/ai/docs/nocobase/ai-employees/built-in/atlas.md +24 -0
  5. package/dist/ai/docs/nocobase/ai-employees/built-in/dara.md +22 -0
  6. package/dist/ai/docs/nocobase/ai-employees/built-in/dex.md +32 -0
  7. package/dist/ai/docs/nocobase/ai-employees/built-in/ellis.md +22 -0
  8. package/dist/ai/docs/nocobase/ai-employees/built-in/index.md +25 -0
  9. package/dist/ai/docs/nocobase/ai-employees/built-in/lexi.md +26 -0
  10. package/dist/ai/docs/nocobase/ai-employees/built-in/lina.md +142 -0
  11. package/dist/ai/docs/nocobase/ai-employees/built-in/nathan.md +36 -0
  12. package/dist/ai/docs/nocobase/ai-employees/built-in/vera.md +22 -0
  13. package/dist/ai/docs/nocobase/ai-employees/built-in/viz.md +25 -0
  14. package/dist/ai/docs/nocobase/ai-employees/features/built-in-employee.md +1 -29
  15. package/dist/ai/docs/nocobase/ai-employees/features/collaborate.md +17 -7
  16. package/dist/ai/docs/nocobase/ai-employees/features/enable-ai-employee.md +4 -4
  17. package/dist/ai/docs/nocobase/ai-employees/features/model-settings.md +87 -0
  18. package/dist/ai/docs/nocobase/ai-employees/index.md +1 -1
  19. package/dist/ai/docs/nocobase/ai-employees/scenarios/localization-hy-mt.md +241 -0
  20. package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/employee/configuration.md +1 -1
  21. package/dist/ai/docs/nocobase/api/cli/api/dynamic.md +7 -0
  22. package/dist/ai/docs/nocobase/api/cli/api/resource/index.md +3 -0
  23. package/dist/ai/docs/nocobase/api/cli/app/down.md +7 -3
  24. package/dist/ai/docs/nocobase/api/cli/app/index.md +1 -1
  25. package/dist/ai/docs/nocobase/api/cli/app/logs.md +3 -0
  26. package/dist/ai/docs/nocobase/api/cli/app/restart.md +4 -0
  27. package/dist/ai/docs/nocobase/api/cli/app/start.md +4 -0
  28. package/dist/ai/docs/nocobase/api/cli/app/stop.md +3 -0
  29. package/dist/ai/docs/nocobase/api/cli/app/upgrade.md +5 -0
  30. package/dist/ai/docs/nocobase/api/cli/env/add.md +11 -3
  31. package/dist/ai/docs/nocobase/api/cli/env/auth.md +1 -1
  32. package/dist/ai/docs/nocobase/api/cli/env/current.md +29 -0
  33. package/dist/ai/docs/nocobase/api/cli/env/index.md +22 -4
  34. package/dist/ai/docs/nocobase/api/cli/env/info.md +1 -5
  35. package/dist/ai/docs/nocobase/api/cli/env/list.md +11 -6
  36. package/dist/ai/docs/nocobase/api/cli/env/remove.md +4 -1
  37. package/dist/ai/docs/nocobase/api/cli/env/status.md +52 -0
  38. package/dist/ai/docs/nocobase/api/cli/env/update.md +1 -1
  39. package/dist/ai/docs/nocobase/api/cli/env/use.md +11 -1
  40. package/dist/ai/docs/nocobase/api/cli/index.md +13 -1
  41. package/dist/ai/docs/nocobase/api/cli/license/activate.md +4 -1
  42. package/dist/ai/docs/nocobase/api/cli/license/id.md +4 -0
  43. package/dist/ai/docs/nocobase/api/cli/license/plugins/clean.md +5 -1
  44. package/dist/ai/docs/nocobase/api/cli/license/plugins/list.md +4 -0
  45. package/dist/ai/docs/nocobase/api/cli/license/plugins/sync.md +5 -1
  46. package/dist/ai/docs/nocobase/api/cli/license/status.md +4 -0
  47. package/dist/ai/docs/nocobase/api/cli/plugin/disable.md +4 -0
  48. package/dist/ai/docs/nocobase/api/cli/plugin/enable.md +4 -0
  49. package/dist/ai/docs/nocobase/api/cli/plugin/list.md +4 -0
  50. package/dist/ai/docs/nocobase/api/cli/session/id.md +28 -0
  51. package/dist/ai/docs/nocobase/api/cli/session/index.md +41 -0
  52. package/dist/ai/docs/nocobase/api/cli/session/remove.md +35 -0
  53. package/dist/ai/docs/nocobase/api/cli/session/setup.md +47 -0
  54. package/dist/ai/docs/nocobase/interface-builder/actions/types/js-action.md +1 -1
  55. package/dist/ai/docs/nocobase/interface-builder/actions/types/js-item.md +1 -1
  56. package/dist/ai/docs/nocobase/interface-builder/blocks/other-blocks/js-block.md +1 -1
  57. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-column.md +1 -1
  58. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-field.md +1 -1
  59. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-item.md +1 -1
  60. package/dist/ai/docs/nocobase/security/guide.md +13 -1
  61. package/dist/ai/docs/nocobase/system-management/localization/index.md +25 -1
  62. package/dist/client/119.c6bf8c6433167d81.js +10 -0
  63. package/dist/client/228.b4b709f93b86b6b9.js +10 -0
  64. package/dist/client/462.1708385b148779cd.js +10 -0
  65. package/dist/client/{486.afbed6b132b3c0dd.js → 486.dcac8f3fcec19c33.js} +1 -1
  66. package/dist/client/{559.39872901b9053629.js → 559.585f80c3bcea0bed.js} +1 -1
  67. package/dist/client/597.b0d64948d74cf6cb.js +10 -0
  68. package/dist/client/646.b0ed728921b007d4.js +10 -0
  69. package/dist/client/711.92cd94681fde7e05.js +10 -0
  70. package/dist/client/768.5177bff46ae71a5b.js +10 -0
  71. package/dist/client/792.abb57765453bcbcc.js +10 -0
  72. package/dist/client/820.f72ef2462b61d812.js +10 -0
  73. package/dist/client/927.d95c74ebb8fd51c9.js +10 -0
  74. package/dist/client/ai-employees/admin/ModelSettings.d.ts +10 -0
  75. package/dist/client/ai-employees/admin/hooks.d.ts +1 -1
  76. package/dist/client/ai-employees/avatars.d.ts +9 -783
  77. package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +1 -15
  78. package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +1 -21
  79. package/dist/client/ai-employees/chatbox/hooks/useChat.d.ts +125 -0
  80. package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +1 -1
  81. package/dist/client/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +13 -1
  82. package/dist/client/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +8 -8
  83. package/dist/client/ai-employees/chatbox/model.d.ts +6 -3
  84. package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
  85. package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +77 -50
  86. package/dist/client/ai-employees/chatbox/stores/chat-tool-call.d.ts +24 -16
  87. package/dist/client/ai-employees/types.d.ts +24 -0
  88. package/dist/client/features/vector-database-provider.d.ts +1 -1
  89. package/dist/client/index.d.ts +2 -0
  90. package/dist/client/index.js +3 -3
  91. package/dist/client/llm-services/component/EnabledModelsSelect.d.ts +1 -14
  92. package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +21 -0
  93. package/dist/client-v2/ai-employees/ProfileCard.d.ts +17 -0
  94. package/dist/client-v2/ai-employees/avatars.d.ts +783 -0
  95. package/dist/client-v2/ai-employees/types.d.ts +20 -0
  96. package/dist/client-v2/index.d.ts +17 -0
  97. package/dist/client-v2/index.js +10 -0
  98. package/dist/client-v2/llm-services/model-label.d.ts +22 -0
  99. package/dist/collections/ai-employees.d.ts +2 -1
  100. package/dist/collections/ai-employees.js +1 -1
  101. package/dist/externalVersion.js +17 -16
  102. package/dist/locale/en-US.json +16 -1
  103. package/dist/locale/zh-CN.json +16 -1
  104. package/dist/node_modules/@langchain/xai/package.json +1 -1
  105. package/dist/node_modules/fs-extra/package.json +1 -1
  106. package/dist/node_modules/jsonrepair/package.json +1 -1
  107. package/dist/node_modules/just-bash/package.json +1 -1
  108. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  109. package/dist/node_modules/openai/package.json +1 -1
  110. package/dist/node_modules/zod/package.json +1 -1
  111. package/dist/server/ai-employees/ai-conversations.d.ts +4 -1
  112. package/dist/server/ai-employees/ai-conversations.js +44 -4
  113. package/dist/server/ai-employees/ai-employee.d.ts +31 -15
  114. package/dist/server/ai-employees/ai-employee.js +205 -52
  115. package/dist/server/ai-employees/ai-employees-manager.d.ts +4 -0
  116. package/dist/server/ai-employees/ai-employees-manager.js +41 -0
  117. package/dist/server/ai-employees/ai-knowledge-base.js +7 -7
  118. package/dist/server/ai-employees/middleware/conversation.d.ts +1 -0
  119. package/dist/server/ai-employees/middleware/conversation.js +15 -11
  120. package/dist/server/ai-employees/sub-agents/dispatcher.js +2 -4
  121. package/dist/server/ai-employees/utils.d.ts +6 -3
  122. package/dist/server/ai-employees/utils.js +7 -1
  123. package/dist/server/collections/ai-conversations.js +6 -0
  124. package/dist/server/features/knowledge-base.d.ts +3 -2
  125. package/dist/server/index.d.ts +2 -0
  126. package/dist/server/index.js +3 -0
  127. package/dist/server/llm-providers/common/reasoning.d.ts +2 -0
  128. package/dist/server/llm-providers/common/reasoning.js +15 -2
  129. package/dist/server/llm-providers/dashscope.d.ts +2 -1
  130. package/dist/server/llm-providers/dashscope.js +39 -0
  131. package/dist/server/llm-providers/deepseek.js +2 -0
  132. package/dist/server/llm-providers/provider.d.ts +15 -1
  133. package/dist/server/llm-providers/provider.js +21 -2
  134. package/dist/server/manager/ai-chat-conversation.js +3 -4
  135. package/dist/server/manager/ai-manager.d.ts +17 -0
  136. package/dist/server/manager/ai-manager.js +65 -0
  137. package/dist/server/manager/llm-stream-manager.d.ts +37 -0
  138. package/dist/server/manager/llm-stream-manager.js +142 -0
  139. package/dist/server/migrations/20260407170416-ai-employee-knowledge-base-add-key.d.ts +14 -0
  140. package/dist/server/migrations/20260407170416-ai-employee-knowledge-base-add-key.js +61 -0
  141. package/dist/server/plugin.d.ts +2 -0
  142. package/dist/server/plugin.js +3 -0
  143. package/dist/server/resource/ai.js +1 -41
  144. package/dist/server/resource/aiConversations.d.ts +8 -0
  145. package/dist/server/resource/aiConversations.js +141 -10
  146. package/dist/server/resource/aiEmployees.js +32 -1
  147. package/dist/server/types/knowledge-base.type.d.ts +3 -2
  148. package/dist/server/workflow/nodes/employee/index.js +4 -2
  149. package/package.json +2 -2
  150. package/dist/client/119.78774f3ad953af49.js +0 -10
  151. package/dist/client/228.a3df2921c8beb766.js +0 -10
  152. package/dist/client/343.6f36d97dd122c5b6.js +0 -10
  153. package/dist/client/597.aa363881a325b5c0.js +0 -10
  154. package/dist/client/646.217a40387efbd163.js +0 -10
  155. package/dist/client/711.266b8f1c520d467a.js +0 -10
  156. package/dist/client/768.973ce32e15099a48.js +0 -10
  157. package/dist/client/792.2e48eab4767d662a.js +0 -10
  158. package/dist/client/820.6a26239ea96c075a.js +0 -10
  159. package/dist/client/927.ff5cd05b14901ae6.js +0 -10
@@ -0,0 +1,241 @@
1
+ ---
2
+ pkg: '@nocobase/plugin-ai'
3
+ title: 'Use Lina and local HY-MT to translate localization entries'
4
+ description: 'Deploy the HY-MT1.5 GGUF translation model with llama-server and configure it for Lina to batch translate NocoBase localization entries.'
5
+ keywords: 'Lina,localization,HY-MT,GGUF,llama-server,OpenAI compatible,AI translation,NocoBase'
6
+ ---
7
+
8
+ # Use Lina and local HY-MT1.5-1.8B to translate localization entries
9
+
10
+ This guide describes a localization translation practice: deploy a translation-specific small model locally, expose it as an OpenAI-compatible service, and configure it for Lina to translate localization entries in batches.
11
+
12
+ This approach is suitable for translating many system entries, plugin text, menus, collection titles, and field labels. Compared with online models, local models are not affected by external API RPM, TPM, or concurrency limits, and concurrency can be tuned according to machine and model capability.
13
+
14
+ ## Overview
15
+
16
+ This guide uses:
17
+
18
+ - Model: `tencent/HY-MT1.5-1.8B-GGUF`
19
+ - Inference service: `llama-server`
20
+ - Integration: OpenAI-compatible API
21
+ - AI Employee: Lina
22
+ - Entry point: Localization Management page
23
+
24
+ :::info{title=Note}
25
+ HY-MT1.5-1.8B is a translation-specific small model. It is more suitable for short entries, UI text, and batch translation. General chat models are not recommended as the first choice for localization tasks.
26
+ :::
27
+
28
+ ## Prerequisites
29
+
30
+ Before starting, prepare:
31
+
32
+ - The **Localization Management** plugin is enabled.
33
+ - Target language is enabled.
34
+ - Localization entries have been synchronized.
35
+ - The local machine or server can run [`llama-server`](https://github.com/ggml-org/llama.cpp).
36
+ - The NocoBase service can access the HTTP address of `llama-server`.
37
+
38
+ ## Deploy HY-MT GGUF
39
+
40
+ ### Install llama.cpp
41
+
42
+ On macOS, you can install it with Homebrew:
43
+
44
+ ```bash
45
+ brew install llama.cpp
46
+ ```
47
+
48
+ You can also use a prebuilt llama.cpp binary or build it from source. The final requirement is that `llama-server` is available.
49
+
50
+ ### Start an OpenAI-compatible service
51
+
52
+ Start the service with the GGUF model from Hugging Face:
53
+
54
+ ```bash
55
+ llama-server \
56
+ -hf tencent/HY-MT1.5-1.8B-GGUF:Q4_K_M \
57
+ --host 0.0.0.0 \
58
+ --port 8000 \
59
+ -c 2048 \
60
+ -np 4
61
+ ```
62
+
63
+ | Parameter | Description |
64
+ | --- | --- |
65
+ | `-hf` | Load the model from Hugging Face. |
66
+ | `--host` | Listening address. Use `127.0.0.1` for local testing or `0.0.0.0` for container or remote access. |
67
+ | `--port` | HTTP service port. |
68
+ | `-c` | Context length. Localization entries are usually short, so `2048` is usually enough. |
69
+ | `-np` | Number of parallel slots. Adjust according to machine performance. |
70
+
71
+ :::info{title=Tip}
72
+ If server resources are limited, start with `-np 1` or `-np 2`, then increase gradually after verifying stability.
73
+ :::
74
+
75
+ ## Test the Model Service
76
+
77
+ After `llama-server` starts, check service health:
78
+
79
+ ```bash
80
+ curl http://127.0.0.1:8000/health
81
+ ```
82
+
83
+ Then test translation through the OpenAI-compatible API:
84
+
85
+ ```bash
86
+ curl http://127.0.0.1:8000/v1/chat/completions \
87
+ -H "Content-Type: application/json" \
88
+ -d '{
89
+ "model": "tencent/HY-MT1.5-1.8B-GGUF:Q4_K_M",
90
+ "messages": [
91
+ {
92
+ "role": "user",
93
+ "content": "Translate the following text into Chinese. Output only the translated result without any additional explanation:\n\nSave"
94
+ }
95
+ ]
96
+ }'
97
+ ```
98
+
99
+ If you start from a local model file, change `model` to the actual model name returned or configured by the service.
100
+
101
+ :::warning{title=Note}
102
+ If a request does not respond for a long time, the model may be too slow, concurrency may be too high, or context may be too large. Lower `-np` and NocoBase translation concurrency first, then observe response time.
103
+ :::
104
+
105
+ ## Configure an LLM Service in NocoBase
106
+
107
+ Go to `System Settings -> AI Employees -> LLM service` and add an LLM service.
108
+
109
+ Example configuration:
110
+
111
+ | Setting | Example |
112
+ | --- | --- |
113
+ | Provider | OpenAI (completions) |
114
+ | Title | HY-MT Local |
115
+ | Base URL | `http://127.0.0.1:8000/v1` |
116
+ | API Key | If llama-server has no authentication, use a placeholder such as `dummy`. |
117
+ | Enabled Models | Select `tencent/HY-MT1.5-1.8B-GGUF:Q4_K_M`, or enter the actual model name. |
118
+
119
+ After configuration, use `Test flight` to verify the model.
120
+
121
+ :::info{title=Tip}
122
+ If NocoBase runs in Docker, `127.0.0.1` points to the container itself and may not access the host service. Use the host IP, container network address, or `host.docker.internal`.
123
+ :::
124
+
125
+ ## Configure Lina's Dedicated Model
126
+
127
+ Go to `System Settings -> AI Employees -> AI employees`, open Lina, and switch to `Model settings`.
128
+
129
+ 1. Enable `Enable dedicated model configuration`.
130
+ 2. Select the HY-MT local model in `Models`.
131
+ 3. Save the configuration.
132
+
133
+ After this, Lina uses this model for localization translation tasks, preventing users or tasks from switching to general chat models.
134
+
135
+ For details, see [Configure AI Employee Models](/ai-employees/features/model-settings).
136
+
137
+ ## Configure Translation Concurrency
138
+
139
+ Localization translation task concurrency is controlled by `AI_LOCALIZATION_CONCURRENCY`:
140
+
141
+ ```bash
142
+ AI_LOCALIZATION_CONCURRENCY=10
143
+ ```
144
+
145
+ Rules:
146
+
147
+ - Default: `10`
148
+ - Minimum: `1`
149
+ - Maximum: `20`
150
+ - Values outside the range use the default
151
+
152
+ The best concurrency depends on CPU, GPU, memory, model quantization, and `llama-server -np`. If the default concurrency causes issues:
153
+
154
+ 1. Start with `AI_LOCALIZATION_CONCURRENCY=1` and verify single-entry translation.
155
+ 2. Set both `llama-server -np` and `AI_LOCALIZATION_CONCURRENCY` to `2` or `4`.
156
+ 3. Observe response time, CPU/GPU usage, and task progress.
157
+ 4. Increase concurrency gradually only if stable.
158
+
159
+ :::warning{title=Note}
160
+ Do not set concurrency too high at the beginning. If concurrency exceeds actual model capacity, tasks may become slower due to queuing, timeout, or service stalls.
161
+ :::
162
+
163
+ ## Execute Localization Translation
164
+
165
+ Go to `System Management -> Localization Management`.
166
+
167
+ 1. Switch to the target language.
168
+ 2. Click `Synchronize` to ensure entries are synchronized.
169
+ 3. Click Lina's avatar.
170
+ 4. Choose a task scope:
171
+ - `Incremental translation`: translate entries without translations.
172
+ - `Selected translation`: translate selected entries in the table.
173
+ - `Full translation`: translate all entries in the current language.
174
+ 5. Check entry count, provider, and model in the confirmation dialog.
175
+ 6. Confirm to create the async task.
176
+ 7. Wait for completion, review translations, and publish.
177
+
178
+ Start with `Selected translation` for a few entries to verify output style and speed before running incremental or full translation.
179
+
180
+ ## How Lina Builds Translation Requests
181
+
182
+ Lina builds requests from entries and reference translations. For short entries, existing references are used to improve consistency:
183
+
184
+ - Built-in entries prefer Chinese translations as references.
185
+ - Non-built-in entries prefer the system default language as references.
186
+ - If an English reference exists, English is used as source text.
187
+ - Translation results are written to the target language but are not published automatically.
188
+
189
+ Prompt semantics are similar to:
190
+
191
+ ```text
192
+ Refer to the following translation:
193
+ {source_term} is translated as {target_term}
194
+
195
+ Translate the following text into {target_language}. Output only the translated result without any additional explanation:
196
+
197
+ {source_text}
198
+ ```
199
+
200
+ ## Troubleshooting
201
+
202
+ ### No progress after creating a task
203
+
204
+ Check whether `llama-server` received requests. View service logs or call `/v1/chat/completions` with `curl`.
205
+
206
+ If the model receives requests but does not return, reduce:
207
+
208
+ - `AI_LOCALIZATION_CONCURRENCY`
209
+ - `llama-server -np`
210
+ - `llama-server -c`
211
+
212
+ ### The model returns explanations instead of translations
213
+
214
+ Local translation models are usually more stable than general chat models. If explanations still appear, test the same prompt with `curl` first to verify the model's output style.
215
+
216
+ You can also translate shorter entries first or reduce sampling parameters such as temperature.
217
+
218
+ ### NocoBase cannot connect to the model service
219
+
220
+ Check:
221
+
222
+ - Whether Base URL includes `/v1`.
223
+ - Whether the NocoBase runtime environment can access the address.
224
+ - Whether firewall or container networking blocks the port.
225
+ - Whether `llama-server` is still running.
226
+
227
+ ## Review Before Publishing
228
+
229
+ After AI translation finishes, review before publishing:
230
+
231
+ - Filter by module and check short entries such as menus, buttons, field names, and statuses.
232
+ - Check variables, placeholders, HTML tags, and formatting symbols.
233
+ - Check key business terminology consistency.
234
+ - If built-in entry translations are overwritten, resynchronize in Localization Management and select `Reset system built-in entry translations` to restore defaults. To contribute default translations for the system and official plugins, see [Translation Contribution](/get-started/translations).
235
+ - Publish in a test environment first, then sync to production.
236
+
237
+ ## References
238
+
239
+ - [tencent/HY-MT1.5-1.8B-GGUF](https://huggingface.co/tencent/HY-MT1.5-1.8B-GGUF)
240
+ - [llama-server documentation](https://www.mintlify.com/ggml-org/llama.cpp/inference/server)
241
+ - [Lina: Localization Engineer](/ai-employees/built-in/lina)
@@ -18,7 +18,7 @@ You can refer to the following documents:
18
18
 
19
19
  - [Workflow](/workflow)
20
20
  - [Configure LLM Service](/ai-employees/features/llm-service)
21
- - [Built-in AI Employees](/ai-employees/features/built-in-employee)
21
+ - [Built-in AI Employees](/ai-employees/built-in/)
22
22
  - [New AI Employee](/ai-employees/features/new-ai-employees)
23
23
 
24
24
  ### Task
@@ -41,6 +41,13 @@ Dynamic commands with request bodies support:
41
41
 
42
42
  `--body` and `--body-file` are mutually exclusive.
43
43
 
44
+ Dynamic API commands also support:
45
+
46
+ - `--env`, `-e`: CLI env name to send the request to; when omitted, the current env is used
47
+ - `--yes`, `-y`: When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt
48
+
49
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
50
+
44
51
  ## Related Commands
45
52
 
46
53
  - [`nb env update`](../env/update.md)
@@ -32,6 +32,7 @@ nb api resource <command>
32
32
  | `--api-base-url` | string | NocoBase API URL, for example `http://localhost:13000/api` |
33
33
  | `--verbose` | boolean | Show detailed progress |
34
34
  | `--env`, `-e` | string | Env name |
35
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
35
36
  | `--role` | string | Role override sent as the `X-Role` request header |
36
37
  | `--token`, `-t` | string | API key override |
37
38
  | `--json-output`, `-j` / `--no-json-output` | boolean | Whether to output raw JSON; enabled by default |
@@ -49,6 +50,8 @@ nb api resource create --resource users --values '{"nickname":"Ada"}'
49
50
  nb api resource list --resource posts.comments --source-id 1 --fields id --fields content
50
51
  ```
51
52
 
53
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
54
+
52
55
  ## Related Commands
53
56
 
54
57
  - [`nb api`](../index.md)
@@ -6,7 +6,7 @@ keywords: "nb app down,NocoBase CLI,cleanup,remove containers,storage"
6
6
 
7
7
  # nb app down
8
8
 
9
- Stop and clean up local runtime resources for a selected env. Storage data and env configuration are kept by default; pass `--all --yes` explicitly to delete everything.
9
+ Stop and clean up local runtime resources for a selected env. Storage data and env configuration are kept by default; pass `--all --force` explicitly to delete everything.
10
10
 
11
11
  ## Usage
12
12
 
@@ -20,16 +20,20 @@ nb app down [flags]
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to clean up; uses the current env if omitted |
22
22
  | `--all` | boolean | Delete all content for the env, including storage data and saved env configuration |
23
- | `--yes`, `-y` | boolean | Skip destructive-operation confirmation; usually used with `--all` |
23
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
24
+ | `--force`, `-f` | boolean | Force destructive cleanup, such as `--all` or other high-risk cleanup in non-interactive mode |
24
25
  | `--verbose` | boolean | Show underlying stop and cleanup command output |
25
26
 
26
27
  ## Examples
27
28
 
28
29
  ```bash
29
30
  nb app down --env app1
30
- nb app down --env app1 --all --yes
31
+ nb app down --env app1 --all --force
32
+ nb app down --env app1 --force
31
33
  ```
32
34
 
35
+ `--yes` only skips the interactive confirmation when an explicitly passed `--env` targets a different env than the current env. `--force` is for actually forcing destructive cleanup, such as `--all` or other high-risk cleanup in non-interactive mode.
36
+
33
37
  ## Related Commands
34
38
 
35
39
  - [`nb app stop`](./stop.md)
@@ -32,7 +32,7 @@ nb app start --env app1
32
32
  nb app restart --env app1
33
33
  nb app logs --env app1
34
34
  nb app stop --env app1
35
- nb app down --env app1 --all --yes
35
+ nb app down --env app1 --all --force
36
36
  ```
37
37
 
38
38
  ## Related Commands
@@ -19,6 +19,7 @@ nb app logs [flags]
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to view logs for; uses the current env if omitted |
22
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
22
23
  | `--tail` | integer | Number of recent log lines to show before following, default `100` |
23
24
  | `--follow`, `-f` / `--no-follow` | boolean | Whether to keep following new log output |
24
25
 
@@ -31,6 +32,8 @@ nb app logs --env app1 --tail 200
31
32
  nb app logs --env app1 --no-follow
32
33
  ```
33
34
 
35
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
36
+
34
37
  ## Related Commands
35
38
 
36
39
  - [`nb app start`](./start.md)
@@ -19,6 +19,7 @@ nb app restart [flags]
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to restart; uses the current env if omitted |
22
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
22
23
  | `--quickstart` | boolean | Start the app in quickstart mode after stopping |
23
24
  | `--port`, `-p` | string | Override the `appPort` saved in env config |
24
25
  | `--daemon`, `-d` / `--no-daemon` | boolean | Whether to run in daemon mode after stopping; enabled by default |
@@ -36,9 +37,12 @@ nb app restart --env local --port 12000
36
37
  nb app restart --env local --no-daemon
37
38
  nb app restart --env local --instances 2
38
39
  nb app restart --env local --launch-mode pm2
40
+ nb app restart --env local --verbose
39
41
  nb app restart --env local-docker
40
42
  ```
41
43
 
44
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
45
+
42
46
  ## Related Commands
43
47
 
44
48
  - [`nb app start`](./start.md)
@@ -19,6 +19,7 @@ nb app start [flags]
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to start; uses the current env if omitted |
22
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
22
23
  | `--quickstart` | boolean | Start the app in quickstart mode |
23
24
  | `--port`, `-p` | string | Override the `appPort` saved in env config |
24
25
  | `--daemon`, `-d` / `--no-daemon` | boolean | Whether to run in daemon mode; enabled by default |
@@ -37,9 +38,12 @@ nb app start --env local --daemon
37
38
  nb app start --env local --no-daemon
38
39
  nb app start --env local --instances 2
39
40
  nb app start --env local --launch-mode pm2
41
+ nb app start --env local --verbose
40
42
  nb app start --env local-docker
41
43
  ```
42
44
 
45
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
46
+
43
47
  ## Related Commands
44
48
 
45
49
  - [`nb app stop`](./stop.md)
@@ -19,6 +19,7 @@ nb app stop [flags]
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to stop; uses the current env if omitted |
22
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
22
23
  | `--verbose` | boolean | Show underlying local or Docker command output |
23
24
 
24
25
  ## Examples
@@ -30,6 +31,8 @@ nb app stop --env local --verbose
30
31
  nb app stop --env local-docker
31
32
  ```
32
33
 
34
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
35
+
33
36
  ## Related Commands
34
37
 
35
38
  - [`nb app start`](./start.md)
@@ -19,7 +19,9 @@ nb app upgrade [flags]
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
21
  | `--env`, `-e` | string | CLI env name to upgrade; uses the current env if omitted |
22
+ | `--yes`, `-y` | boolean | When an explicitly passed `--env` targets a different env than the current env, skip the interactive confirmation prompt |
22
23
  | `--skip-code-update`, `-s` | boolean | Restart from the saved local source or Docker image without downloading updates |
24
+ | `--version` | string | Override the saved `downloadVersion`; when the upgrade succeeds, the new version is written back to the env config |
23
25
  | `--verbose` | boolean | Show underlying update and restart command output |
24
26
 
25
27
  ## Examples
@@ -28,10 +30,13 @@ nb app upgrade [flags]
28
30
  nb app upgrade
29
31
  nb app upgrade --env local
30
32
  nb app upgrade --env local -s
33
+ nb app upgrade --env local --version beta
31
34
  nb app upgrade --env local --verbose
32
35
  nb app upgrade --env local-docker -s
33
36
  ```
34
37
 
38
+ If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
39
+
35
40
  ## Related Commands
36
41
 
37
42
  - [`nb source download`](../source/download.md)
@@ -1,13 +1,20 @@
1
1
  ---
2
2
  title: "nb env add"
3
- description: "nb env add command reference: save a NocoBase API URL and authentication method, then switch to it as the current env."
4
- keywords: "nb env add,NocoBase CLI,add environment,API URL,authentication"
3
+ description: "nb env add command reference: save a NocoBase API URL and authentication method, then switch to that env."
4
+ keywords: "nb env add,NocoBase CLI,add environment,API Base URL,authentication"
5
5
  ---
6
6
 
7
7
  # nb env add
8
8
 
9
9
  Save a named NocoBase API endpoint and switch the CLI to use that env. When `oauth` authentication is selected, [`nb env auth`](./auth.md) is started automatically.
10
10
 
11
+ This command does two things:
12
+
13
+ - Save the env configuration
14
+ - Switch the current env to the newly added env
15
+
16
+ When session mode is enabled for the current shell or runtime, it updates the session `current env`. It also updates the global `last env` as the fallback for shells or runtimes without session mode.
17
+
11
18
  ## Usage
12
19
 
13
20
  ```bash
@@ -18,7 +25,7 @@ nb env add [name] [flags]
18
25
 
19
26
  | Parameter | Type | Description |
20
27
  | --- | --- | --- |
21
- | `[name]` | string | Env name; prompted in TTY when omitted, required in non-TTY mode |
28
+ | `[name]` | string | Environment name to save; prompted in TTY when omitted, required in non-TTY mode |
22
29
  | `--verbose` | boolean | Show detailed progress when writing config |
23
30
  | `--locale` | string | CLI prompt language: `en-US` or `zh-CN` |
24
31
  | `--api-base-url`, `-u` | string | NocoBase API URL, including the `/api` prefix |
@@ -37,5 +44,6 @@ nb env add local --api-base-url http://localhost:13000/api --auth-type token --a
37
44
  ## Related Commands
38
45
 
39
46
  - [`nb env auth`](./auth.md)
47
+ - [`nb env current`](./current.md)
40
48
  - [`nb env update`](./update.md)
41
49
  - [`nb env list`](./list.md)
@@ -18,7 +18,7 @@ nb env auth [name]
18
18
 
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
- | `[name]` | string | Env name; uses the current env if omitted |
21
+ | `[name]` | string | Configured environment name to sign in to; uses the current env if omitted |
22
22
 
23
23
  ## Notes
24
24
 
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: "nb env current"
3
+ description: "nb env current command reference: show the currently effective NocoBase CLI env."
4
+ keywords: "nb env current,NocoBase CLI,current env,session env"
5
+ ---
6
+
7
+ # nb env current
8
+
9
+ Show the name of the currently effective env.
10
+
11
+ By default, this command first reads the session env for the current `NB_SESSION_ID`. If session mode is not enabled for the current shell or runtime, it falls back to the global `last env`.
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ nb env current
17
+ ```
18
+
19
+ ## Examples
20
+
21
+ ```bash
22
+ nb env current
23
+ ```
24
+
25
+ ## Related Commands
26
+
27
+ - [`nb env use`](./use.md)
28
+ - [`nb env status`](./status.md)
29
+ - [`nb session setup`](../session/setup.md)
@@ -1,13 +1,18 @@
1
1
  ---
2
2
  title: "nb env"
3
- description: "nb env command reference: manage NocoBase CLI envs, including add, refresh, inspect, switch, authenticate, and remove."
4
- keywords: "nb env,NocoBase CLI,environment management,env,authentication,OpenAPI"
3
+ description: "nb env command reference: manage NocoBase CLI envs, including add, inspect current env, check status, switch, authenticate, and remove."
4
+ keywords: "nb env,NocoBase CLI,environment management,env,current env,authentication,OpenAPI"
5
5
  ---
6
6
 
7
7
  # nb env
8
8
 
9
9
  Manage saved NocoBase CLI envs. An env stores API URL, authentication info, local app paths, database config, and runtime command cache.
10
10
 
11
+ In the current model, the CLI separates two concepts:
12
+
13
+ - `current env`: the env currently used by the active shell or agent runtime, isolated by `NB_SESSION_ID` when available
14
+ - `last env`: the globally last-used env, used as a fallback when session mode is not enabled
15
+
11
16
  ## Usage
12
17
 
13
18
  ```bash
@@ -18,9 +23,11 @@ nb env <command>
18
23
 
19
24
  | Command | Description |
20
25
  | --- | --- |
21
- | [`nb env add`](./add.md) | Save a NocoBase API endpoint and switch to it as the current env |
26
+ | [`nb env add`](./add.md) | Save a NocoBase API endpoint and switch to that env |
27
+ | [`nb env current`](./current.md) | Show the currently effective env |
22
28
  | [`nb env update`](./update.md) | Refresh OpenAPI Schema and runtime command cache from the app |
23
- | [`nb env list`](./list.md) | List configured envs and API authentication status |
29
+ | [`nb env list`](./list.md) | List configured envs |
30
+ | [`nb env status`](./status.md) | Show status for the current env, one env, or all envs |
24
31
  | [`nb env info`](./info.md) | Show details for a single env |
25
32
  | [`nb env remove`](./remove.md) | Remove env configuration |
26
33
  | [`nb env auth`](./auth.md) | Run OAuth login for a saved env |
@@ -30,15 +37,26 @@ nb env <command>
30
37
 
31
38
  ```bash
32
39
  nb env add app1 --api-base-url http://localhost:13000/api
40
+ nb env current
33
41
  nb env list
42
+ nb env status
34
43
  nb env info app1
35
44
  nb env update app1
36
45
  nb env use app1
37
46
  nb env auth app1
38
47
  ```
39
48
 
49
+ ## Session mode
50
+
51
+ Session mode is the default recommendation. It keeps `current env` isolated across different terminals, shells, and agent runtimes, so parallel work does not affect each other.
52
+
53
+ When session mode is not enabled, `nb env use` updates the global `last env`, and other sessions without isolation may also be affected.
54
+
55
+ See [`nb session setup`](../session/setup.md) to enable it.
56
+
40
57
  ## Related Commands
41
58
 
42
59
  - [`nb init`](../init.md)
43
60
  - [`nb api`](../api/index.md)
44
61
  - [`nb app`](../app/index.md)
62
+ - [`nb session`](../session/index.md)
@@ -18,20 +18,16 @@ nb env info [name] [flags]
18
18
 
19
19
  | Parameter | Type | Description |
20
20
  | --- | --- | --- |
21
- | `[name]` | string | CLI env name to inspect; uses the current env if omitted |
22
- | `--env`, `-e` | string | CLI env name to inspect; alternative to the positional argument |
21
+ | `[name]` | string | Configured environment name to inspect; uses the current env if omitted |
23
22
  | `--json` | boolean | Output JSON |
24
23
  | `--show-secrets` | boolean | Show tokens, passwords, and other secrets in plain text |
25
24
 
26
- If both `[name]` and `--env` are passed, they must match.
27
-
28
25
  ## Examples
29
26
 
30
27
  ```bash
31
28
  nb env info app1
32
29
  nb env info app1 --json
33
30
  nb env info app1 --show-secrets
34
- nb env info --env app1
35
31
  ```
36
32
 
37
33
  ## Related Commands
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  title: "nb env list"
3
- description: "nb env list command reference: list configured NocoBase CLI envs and API authentication status."
4
- keywords: "nb env list,NocoBase CLI,environment list,authentication status"
3
+ description: "nb env list command reference: list configured NocoBase CLI envs."
4
+ keywords: "nb env list,NocoBase CLI,environment list,API Base URL"
5
5
  ---
6
6
 
7
7
  # nb env list
8
8
 
9
- List all configured envs and check app API authentication status with saved Token/OAuth credentials.
9
+ List all configured envs.
10
+
11
+ This command only shows saved configuration. Use [`nb env status`](./status.md) when you want to check current runtime or API status.
10
12
 
11
13
  ## Usage
12
14
 
@@ -16,9 +18,11 @@ nb env list
16
18
 
17
19
  ## Output
18
20
 
19
- The output table includes the current env marker, name, type, App Status, URL, authentication type, and runtime version.
21
+ The output table includes the current env marker, name, type, `API Base URL`, authentication type, and runtime version.
20
22
 
21
- `App Status` is the result of accessing the app API with the saved auth info, such as `ok`, `auth failed`, `unreachable`, or `unconfigured`. Use [`nb db ps`](../db/ps.md) to inspect database runtime status.
23
+ - `Current` marks the currently effective env with `*`
24
+ - `API Base URL` shows the saved raw API address
25
+ - `Runtime` shows cached runtime version information
22
26
 
23
27
  ## Examples
24
28
 
@@ -28,6 +32,7 @@ nb env list
28
32
 
29
33
  ## Related Commands
30
34
 
35
+ - [`nb env current`](./current.md)
36
+ - [`nb env status`](./status.md)
31
37
  - [`nb env info`](./info.md)
32
38
  - [`nb env use`](./use.md)
33
- - [`nb db ps`](../db/ps.md)
@@ -8,6 +8,8 @@ keywords: "nb env remove,NocoBase CLI,delete environment,remove config"
8
8
 
9
9
  Remove a configured env. This command only deletes CLI env configuration; use [`nb app down`](../app/down.md) to clean up local apps, containers, and storage.
10
10
 
11
+ If the removed env is also the current env, the CLI automatically selects a new current env from the remaining envs. If no envs remain, the current env is cleared.
12
+
11
13
  ## Usage
12
14
 
13
15
  ```bash
@@ -18,7 +20,7 @@ nb env remove <name> [flags]
18
20
 
19
21
  | Parameter | Type | Description |
20
22
  | --- | --- | --- |
21
- | `<name>` | string | Env name to remove |
23
+ | `<name>` | string | Configured environment name to remove |
22
24
  | `--force`, `-f` | boolean | Skip confirmation and delete directly |
23
25
  | `--verbose` | boolean | Show detailed progress |
24
26
 
@@ -32,4 +34,5 @@ nb env remove staging -f
32
34
  ## Related Commands
33
35
 
34
36
  - [`nb app down`](../app/down.md)
37
+ - [`nb env current`](./current.md)
35
38
  - [`nb env list`](./list.md)