@dofy/namo 0.0.0-stage → 0.7.0

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 (276) hide show
  1. package/README.md +54 -2
  2. package/README.zh-CN.md +55 -0
  3. package/assets/fonts/Caveat-OFL.txt +93 -0
  4. package/assets/fonts/JetBrainsMono-OFL.txt +93 -0
  5. package/assets/fonts/README.md +29 -0
  6. package/assets/namo-logo.png +0 -0
  7. package/bin/namo.js +13 -0
  8. package/config.example.json +31 -0
  9. package/dist/scripts/changelog.js +104 -0
  10. package/dist/scripts/changelog.js.map +1 -0
  11. package/dist/scripts/smoke-codex.js +25 -0
  12. package/dist/scripts/smoke-codex.js.map +1 -0
  13. package/dist/scripts/smoke-skills.js +60 -0
  14. package/dist/scripts/smoke-skills.js.map +1 -0
  15. package/dist/src/access-contract.js +2 -0
  16. package/dist/src/access-contract.js.map +1 -0
  17. package/dist/src/access.js +53 -0
  18. package/dist/src/access.js.map +1 -0
  19. package/dist/src/agent-registry.js +102 -0
  20. package/dist/src/agent-registry.js.map +1 -0
  21. package/dist/src/agents.js +83 -0
  22. package/dist/src/agents.js.map +1 -0
  23. package/dist/src/approval-service.js +189 -0
  24. package/dist/src/approval-service.js.map +1 -0
  25. package/dist/src/approvals.js +423 -0
  26. package/dist/src/approvals.js.map +1 -0
  27. package/dist/src/artifact-delivery.js +242 -0
  28. package/dist/src/artifact-delivery.js.map +1 -0
  29. package/dist/src/artifacts.js +223 -0
  30. package/dist/src/artifacts.js.map +1 -0
  31. package/dist/src/assistant-setup.js +23 -0
  32. package/dist/src/assistant-setup.js.map +1 -0
  33. package/dist/src/assistant.js +245 -0
  34. package/dist/src/assistant.js.map +1 -0
  35. package/dist/src/auto-memory.js +309 -0
  36. package/dist/src/auto-memory.js.map +1 -0
  37. package/dist/src/background-work.js +16 -0
  38. package/dist/src/background-work.js.map +1 -0
  39. package/dist/src/browse.js +202 -0
  40. package/dist/src/browse.js.map +1 -0
  41. package/dist/src/business-storage.js +54 -0
  42. package/dist/src/business-storage.js.map +1 -0
  43. package/dist/src/cards.js +341 -0
  44. package/dist/src/cards.js.map +1 -0
  45. package/dist/src/changelog-contract.js +2 -0
  46. package/dist/src/changelog-contract.js.map +1 -0
  47. package/dist/src/cli.js +316 -0
  48. package/dist/src/cli.js.map +1 -0
  49. package/dist/src/codex-connection.js +294 -0
  50. package/dist/src/codex-connection.js.map +1 -0
  51. package/dist/src/codex-distribution.js +425 -0
  52. package/dist/src/codex-distribution.js.map +1 -0
  53. package/dist/src/codex-installation.js +65 -0
  54. package/dist/src/codex-installation.js.map +1 -0
  55. package/dist/src/codex-items.js +15 -0
  56. package/dist/src/codex-items.js.map +1 -0
  57. package/dist/src/codex-mcp-import.js +86 -0
  58. package/dist/src/codex-mcp-import.js.map +1 -0
  59. package/dist/src/codex-updates.js +287 -0
  60. package/dist/src/codex-updates.js.map +1 -0
  61. package/dist/src/config-prompts.js +355 -0
  62. package/dist/src/config-prompts.js.map +1 -0
  63. package/dist/src/config-reload.js +144 -0
  64. package/dist/src/config-reload.js.map +1 -0
  65. package/dist/src/config.js +164 -0
  66. package/dist/src/config.js.map +1 -0
  67. package/dist/src/control-classifier.js +86 -0
  68. package/dist/src/control-classifier.js.map +1 -0
  69. package/dist/src/control-display.js +30 -0
  70. package/dist/src/control-display.js.map +1 -0
  71. package/dist/src/conversation-control.js +308 -0
  72. package/dist/src/conversation-control.js.map +1 -0
  73. package/dist/src/directory-approval.js +122 -0
  74. package/dist/src/directory-approval.js.map +1 -0
  75. package/dist/src/docs-site.js +75 -0
  76. package/dist/src/docs-site.js.map +1 -0
  77. package/dist/src/doctor.js +61 -0
  78. package/dist/src/doctor.js.map +1 -0
  79. package/dist/src/ego-browser-prototype.js +105 -0
  80. package/dist/src/ego-browser-prototype.js.map +1 -0
  81. package/dist/src/engine.js +1458 -0
  82. package/dist/src/engine.js.map +1 -0
  83. package/dist/src/evidence.js +237 -0
  84. package/dist/src/evidence.js.map +1 -0
  85. package/dist/src/external-wait-bridge.js +129 -0
  86. package/dist/src/external-wait-bridge.js.map +1 -0
  87. package/dist/src/external-waits.js +666 -0
  88. package/dist/src/external-waits.js.map +1 -0
  89. package/dist/src/feedback.js +351 -0
  90. package/dist/src/feedback.js.map +1 -0
  91. package/dist/src/feishu-setup.js +115 -0
  92. package/dist/src/feishu-setup.js.map +1 -0
  93. package/dist/src/feishu.js +323 -0
  94. package/dist/src/feishu.js.map +1 -0
  95. package/dist/src/generated-images.js +46 -0
  96. package/dist/src/generated-images.js.map +1 -0
  97. package/dist/src/github-access.js +222 -0
  98. package/dist/src/github-access.js.map +1 -0
  99. package/dist/src/github-api.js +246 -0
  100. package/dist/src/github-api.js.map +1 -0
  101. package/dist/src/github-local.js +75 -0
  102. package/dist/src/github-local.js.map +1 -0
  103. package/dist/src/github-review.js +129 -0
  104. package/dist/src/github-review.js.map +1 -0
  105. package/dist/src/i18n.js +27 -0
  106. package/dist/src/i18n.js.map +1 -0
  107. package/dist/src/image-inputs.js +334 -0
  108. package/dist/src/image-inputs.js.map +1 -0
  109. package/dist/src/inbox-retention.js +48 -0
  110. package/dist/src/inbox-retention.js.map +1 -0
  111. package/dist/src/legacy-config.js +28 -0
  112. package/dist/src/legacy-config.js.map +1 -0
  113. package/dist/src/live-runtime.js +37 -0
  114. package/dist/src/live-runtime.js.map +1 -0
  115. package/dist/src/live-upgrade.js +192 -0
  116. package/dist/src/live-upgrade.js.map +1 -0
  117. package/dist/src/locale.js +9 -0
  118. package/dist/src/locale.js.map +1 -0
  119. package/dist/src/locales/en.js +1429 -0
  120. package/dist/src/locales/en.js.map +1 -0
  121. package/dist/src/locales/zh-CN.js +1428 -0
  122. package/dist/src/locales/zh-CN.js.map +1 -0
  123. package/dist/src/management-operations.js +107 -0
  124. package/dist/src/management-operations.js.map +1 -0
  125. package/dist/src/management.js +910 -0
  126. package/dist/src/management.js.map +1 -0
  127. package/dist/src/materials.js +280 -0
  128. package/dist/src/materials.js.map +1 -0
  129. package/dist/src/mcp-connections.js +279 -0
  130. package/dist/src/mcp-connections.js.map +1 -0
  131. package/dist/src/mcp-endpoint-contract.js +17 -0
  132. package/dist/src/mcp-endpoint-contract.js.map +1 -0
  133. package/dist/src/mcp-oauth-flow.js +83 -0
  134. package/dist/src/mcp-oauth-flow.js.map +1 -0
  135. package/dist/src/mcp-oauth.js +322 -0
  136. package/dist/src/mcp-oauth.js.map +1 -0
  137. package/dist/src/mcp-operation.js +27 -0
  138. package/dist/src/mcp-operation.js.map +1 -0
  139. package/dist/src/mcp-public-network.js +58 -0
  140. package/dist/src/mcp-public-network.js.map +1 -0
  141. package/dist/src/mcp-write-approval.js +153 -0
  142. package/dist/src/mcp-write-approval.js.map +1 -0
  143. package/dist/src/memory-access.js +7 -0
  144. package/dist/src/memory-access.js.map +1 -0
  145. package/dist/src/memory-commands.js +52 -0
  146. package/dist/src/memory-commands.js.map +1 -0
  147. package/dist/src/memory-extractor.js +87 -0
  148. package/dist/src/memory-extractor.js.map +1 -0
  149. package/dist/src/memory.js +755 -0
  150. package/dist/src/memory.js.map +1 -0
  151. package/dist/src/messages.js +2 -0
  152. package/dist/src/messages.js.map +1 -0
  153. package/dist/src/migration-cli.js +54 -0
  154. package/dist/src/migration-cli.js.map +1 -0
  155. package/dist/src/migration-memory.js +261 -0
  156. package/dist/src/migration-memory.js.map +1 -0
  157. package/dist/src/migration.js +534 -0
  158. package/dist/src/migration.js.map +1 -0
  159. package/dist/src/model-catalog.js +58 -0
  160. package/dist/src/model-catalog.js.map +1 -0
  161. package/dist/src/model-preferences.js +29 -0
  162. package/dist/src/model-preferences.js.map +1 -0
  163. package/dist/src/onboarding.js +231 -0
  164. package/dist/src/onboarding.js.map +1 -0
  165. package/dist/src/path-policy.js +6 -0
  166. package/dist/src/path-policy.js.map +1 -0
  167. package/dist/src/paths.js +85 -0
  168. package/dist/src/paths.js.map +1 -0
  169. package/dist/src/presentation.js +86 -0
  170. package/dist/src/presentation.js.map +1 -0
  171. package/dist/src/profiles.js +87 -0
  172. package/dist/src/profiles.js.map +1 -0
  173. package/dist/src/prompts.js +51 -0
  174. package/dist/src/prompts.js.map +1 -0
  175. package/dist/src/public-progress.js +71 -0
  176. package/dist/src/public-progress.js.map +1 -0
  177. package/dist/src/record-table.js +48 -0
  178. package/dist/src/record-table.js.map +1 -0
  179. package/dist/src/recovery.js +105 -0
  180. package/dist/src/recovery.js.map +1 -0
  181. package/dist/src/release-check.js +12 -0
  182. package/dist/src/release-check.js.map +1 -0
  183. package/dist/src/release.js +200 -0
  184. package/dist/src/release.js.map +1 -0
  185. package/dist/src/repository.js +4 -0
  186. package/dist/src/repository.js.map +1 -0
  187. package/dist/src/richtext.js +165 -0
  188. package/dist/src/richtext.js.map +1 -0
  189. package/dist/src/runner-store.js +100 -0
  190. package/dist/src/runner-store.js.map +1 -0
  191. package/dist/src/runner-worker.js +326 -0
  192. package/dist/src/runner-worker.js.map +1 -0
  193. package/dist/src/runner.js +130 -0
  194. package/dist/src/runner.js.map +1 -0
  195. package/dist/src/runtime-config.js +40 -0
  196. package/dist/src/runtime-config.js.map +1 -0
  197. package/dist/src/runtime-contract.js +10 -0
  198. package/dist/src/runtime-contract.js.map +1 -0
  199. package/dist/src/runtime-host.js +84 -0
  200. package/dist/src/runtime-host.js.map +1 -0
  201. package/dist/src/runtime-version.js +38 -0
  202. package/dist/src/runtime-version.js.map +1 -0
  203. package/dist/src/runtime.js +593 -0
  204. package/dist/src/runtime.js.map +1 -0
  205. package/dist/src/safety.js +95 -0
  206. package/dist/src/safety.js.map +1 -0
  207. package/dist/src/schedules.js +211 -0
  208. package/dist/src/schedules.js.map +1 -0
  209. package/dist/src/schema-directory-migration.js +75 -0
  210. package/dist/src/schema-directory-migration.js.map +1 -0
  211. package/dist/src/schema-migrations.js +56 -0
  212. package/dist/src/schema-migrations.js.map +1 -0
  213. package/dist/src/schema.js +241 -0
  214. package/dist/src/schema.js.map +1 -0
  215. package/dist/src/service-bootstrap.js +53 -0
  216. package/dist/src/service-bootstrap.js.map +1 -0
  217. package/dist/src/service.js +416 -0
  218. package/dist/src/service.js.map +1 -0
  219. package/dist/src/session-list.js +58 -0
  220. package/dist/src/session-list.js.map +1 -0
  221. package/dist/src/skill-access.js +97 -0
  222. package/dist/src/skill-access.js.map +1 -0
  223. package/dist/src/store.js +172 -0
  224. package/dist/src/store.js.map +1 -0
  225. package/dist/src/task-context.js +40 -0
  226. package/dist/src/task-context.js.map +1 -0
  227. package/dist/src/task-materials.js +197 -0
  228. package/dist/src/task-materials.js.map +1 -0
  229. package/dist/src/task-progress.js +63 -0
  230. package/dist/src/task-progress.js.map +1 -0
  231. package/dist/src/tasks.js +384 -0
  232. package/dist/src/tasks.js.map +1 -0
  233. package/dist/src/terminal-config.js +132 -0
  234. package/dist/src/terminal-config.js.map +1 -0
  235. package/dist/src/terminal-forms.js +252 -0
  236. package/dist/src/terminal-forms.js.map +1 -0
  237. package/dist/src/terminal-mcp.js +123 -0
  238. package/dist/src/terminal-mcp.js.map +1 -0
  239. package/dist/src/terminal-settings.js +106 -0
  240. package/dist/src/terminal-settings.js.map +1 -0
  241. package/dist/src/theme-contract.js +8 -0
  242. package/dist/src/theme-contract.js.map +1 -0
  243. package/dist/src/title-summary.js +96 -0
  244. package/dist/src/title-summary.js.map +1 -0
  245. package/dist/src/ui-contract.js +3 -0
  246. package/dist/src/ui-contract.js.map +1 -0
  247. package/dist/src/ui.js +352 -0
  248. package/dist/src/ui.js.map +1 -0
  249. package/dist/src/upgrade-backup.js +159 -0
  250. package/dist/src/upgrade-backup.js.map +1 -0
  251. package/dist/src/version.js +4 -0
  252. package/dist/src/version.js.map +1 -0
  253. package/dist/src/waits.js +279 -0
  254. package/dist/src/waits.js.map +1 -0
  255. package/dist/ui/assets/caveat-latin-500-WbB_DO0N.woff2 +0 -0
  256. package/dist/ui/assets/index-CJAhDqDy.css +1 -0
  257. package/dist/ui/assets/index-DkhjblIL.js +131 -0
  258. package/dist/ui/assets/jetbrains-mono-latin-D000Msq0.woff2 +0 -0
  259. package/dist/ui/index.html +18 -0
  260. package/docs/README.md +22 -0
  261. package/docs/architecture.md +145 -0
  262. package/docs/development-plan.md +59 -0
  263. package/docs/getting-started.md +86 -0
  264. package/docs/operations.md +128 -0
  265. package/docs/release-notes.md +66 -0
  266. package/docs/technical-guide-zh-cn.md +153 -0
  267. package/docs/technical-guide.md +153 -0
  268. package/docs/ui-design.md +44 -0
  269. package/docs-site/README.md +15 -0
  270. package/docs-site/assets/namo-logo.png +0 -0
  271. package/docs-site/content.js +34 -0
  272. package/docs-site/index.html +27 -0
  273. package/docs-site/main.js +26 -0
  274. package/docs-site/style.css +1 -0
  275. package/docs-site/vite.config.mjs +4 -0
  276. package/package.json +71 -3
@@ -0,0 +1,910 @@
1
+ import { directoryConfiguration } from './legacy-config.js';
2
+ import { addsDuplicateMcpEndpoint } from './mcp-endpoint-contract.js';
3
+ import { listCodexMcp, selectCodexMcp, CodexMcpImportError } from './codex-mcp-import.js';
4
+ import { serviceLogs, listApprovals, changeApproval } from './management-operations.js';
5
+ import { ApprovalError } from './approvals.js';
6
+ import { inspectOpenClawSource, MigrationError } from './migration.js';
7
+ import { t as tr } from './locale.js';
8
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
9
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
10
+ import { homedir } from 'node:os';
11
+ import { randomUUID } from 'node:crypto';
12
+ import { loadConfig, parseConfig } from './config.js';
13
+ import { resolveAgent } from './agent-registry.js';
14
+ import { ConfigEditor, digest, readJson } from './paths.js';
15
+ import { Store, SCHEMA_VERSION } from './store.js';
16
+ import { Tasks } from './tasks.js';
17
+ import { Recovery, RecoveryError } from './recovery.js';
18
+ import { serviceAction, serviceStatus, activeData, waitForService } from './service.js';
19
+ import { doctor } from './doctor.js';
20
+ import { acquireLock, makeRedactor, chatWorkspace } from './safety.js';
21
+ import { Schedules } from './schedules.js';
22
+ import { executionPolicy } from './access.js';
23
+ import { selectAgent, selectedPolicyHash } from './agent-registry.js';
24
+ import { scopeOf } from './tasks.js';
25
+ import { AssistantSettings, AssistantSettingsError } from './assistant.js';
26
+ import { Memories, MemoryError, MEMORY_LIMITS } from './memory.js';
27
+ import { MEMORY_EXTRACTION_MAX_ATTEMPTS } from './auto-memory.js';
28
+ import { MigrationMemory, MigrationMemoryError, migrationMemoryStatus } from './migration-memory.js';
29
+ import { Profiles, ProfileError } from './profiles.js';
30
+ import { userModel, setUserModel, ModelPreferenceError } from './model-preferences.js';
31
+ import { listCodexModels } from './codex-connection.js';
32
+ import { CodexUpdates } from './codex-updates.js';
33
+ import { Browse, BrowseError } from './browse.js';
34
+ import { isOAuthReference, resolveMcpCredential, discoverMcpOAuthScopes } from './mcp-oauth.js';
35
+ import { parseMcpConnections, publicMcpConnections, remoteRead, stdioRead } from './mcp-connections.js';
36
+ import { parseGitHubAccessConfig, publicGitHubAccess } from './github-access.js';
37
+ import { FeishuTransport } from './feishu.js';
38
+ import { discoverLocalGh } from './github-local.js';
39
+ export class ManagementError extends Error {
40
+ status;
41
+ constructor(message, status = 409) {
42
+ super(message);
43
+ this.status = status;
44
+ }
45
+ }
46
+ const defaults = { status: serviceStatus, action: serviceAction, wait: waitForService, diagnose: doctor, localGh: discoverLocalGh, mcpReader: remoteRead };
47
+ export class Management {
48
+ file;
49
+ dataDir;
50
+ deps;
51
+ codexUpdater;
52
+ updateOperations = new Set();
53
+ async close() { await Promise.allSettled([...this.updateOperations].map(updater => updater.close())); }
54
+ constructor(file, deps = {}) {
55
+ this.file = file;
56
+ const raw = readJson(file), path = raw.dataDir ?? './data';
57
+ if (typeof path !== 'string')
58
+ throw new ManagementError(tr("management.invalidDataDirectoryConfigurationFixNamoInit"));
59
+ this.dataDir = path.startsWith('~/') ? resolve(homedir(), path.slice(2)) : resolve(dirname(file), path);
60
+ this.deps = { ...defaults, ...deps };
61
+ }
62
+ source() {
63
+ const text = readFileSync(this.file, 'utf8'), raw = JSON.parse(text);
64
+ const path = raw.dataDir ?? './data';
65
+ if (typeof path !== 'string' || (path.startsWith('~/') ? resolve(homedir(), path.slice(2)) : resolve(dirname(this.file), path)) !== this.dataDir)
66
+ throw new ManagementError(tr("management.dataDirectoryChangedExternallyCloseRestartWorkbench"));
67
+ return { raw: directoryConfiguration(raw), revision: digest(text) };
68
+ }
69
+ status() {
70
+ try {
71
+ return this.deps.status(loadConfig(this.file));
72
+ }
73
+ catch {
74
+ return { running: activeData(this.dataDir), ready: false, connection: 'unknown', configInvalid: true };
75
+ }
76
+ }
77
+ redactor() {
78
+ const { raw } = this.source(), f = raw.feishu ?? {};
79
+ let token = typeof raw.github?.token === 'string' ? raw.github.token : '';
80
+ try {
81
+ token = parseGitHubAccessConfig(raw.github, process.env)?.token ?? '';
82
+ }
83
+ catch {
84
+ const key = raw.github?.tokenEnv;
85
+ if (typeof key === 'string' && /^NAMO_GITHUB_[A-Z][A-Z0-9_]*$/.test(key))
86
+ token = process.env[key] ?? token;
87
+ }
88
+ return makeRedactor([typeof f.appSecret === 'string' ? f.appSecret : '', process.env[f.appSecretEnv ?? 'FEISHU_APP_SECRET'] ?? '', token, ...(Array.isArray(raw.mcpConnections) ? raw.mcpConnections.map((v) => typeof v?.token === 'string' ? v.token : '') : [])]);
89
+ }
90
+ read(fn) {
91
+ const path = join(this.dataDir, 'bot.sqlite');
92
+ if (!existsSync(path))
93
+ return;
94
+ const s = new Store(path, true);
95
+ try {
96
+ return fn(s);
97
+ }
98
+ finally {
99
+ s.close();
100
+ }
101
+ }
102
+ readCurrent(fn) {
103
+ return this.read(s => {
104
+ if (Number(s.db.prepare('PRAGMA user_version').get()?.user_version) !== SCHEMA_VERSION)
105
+ throw new ManagementError(tr('management.databaseSchemaUnsupported'), 409);
106
+ return fn(s);
107
+ });
108
+ }
109
+ sanitize(value) {
110
+ const redact = this.redactor();
111
+ const visit = (item) => typeof item === 'string' ? redact(item) : Array.isArray(item) ? item.map(visit)
112
+ : item && typeof item === 'object' ? Object.fromEntries(Object.entries(item).map(([key, entry]) => [key, visit(entry)])) : item;
113
+ return visit(value);
114
+ }
115
+ write(fn) {
116
+ const version = this.read(s => Number(s.db.prepare('PRAGMA user_version').get()?.user_version));
117
+ if (version !== SCHEMA_VERSION)
118
+ throw new ManagementError(tr("management.databaseSchemaUnsupported"));
119
+ const s = new Store(join(this.dataDir, 'bot.sqlite'));
120
+ try {
121
+ return fn(s);
122
+ }
123
+ finally {
124
+ s.close();
125
+ }
126
+ }
127
+ async organization() { return new FeishuTransport(loadConfig(this.file).feishu, () => { }).organization(); }
128
+ config() {
129
+ const { raw, revision } = this.source(), c = raw.codex ?? {}, f = raw.feishu ?? {};
130
+ let valid = true;
131
+ try {
132
+ parseConfig(raw, this.file);
133
+ }
134
+ catch {
135
+ valid = false;
136
+ }
137
+ let github = publicGitHubAccess();
138
+ try {
139
+ github = publicGitHubAccess(parseGitHubAccessConfig(raw.github, process.env));
140
+ }
141
+ catch { /* Keep an invalid credential out of the projection. */ }
142
+ let mcpConnections;
143
+ try {
144
+ mcpConnections = publicMcpConnections(parseMcpConnections(raw.mcpConnections));
145
+ }
146
+ catch {
147
+ mcpConnections = [];
148
+ }
149
+ const service = this.status();
150
+ let applied, automaticConfiguration = false, configurationReload;
151
+ try {
152
+ const h = readJson(join(this.dataDir, 'health.json'));
153
+ if (service.running && h.pid === service.pid) {
154
+ applied = h.configRevision;
155
+ automaticConfiguration = h.automaticConfiguration === true;
156
+ configurationReload = h.configurationReload;
157
+ }
158
+ }
159
+ catch { /* Not yet instrumented. */ }
160
+ let activeModelDefault;
161
+ if (valid && service.running && applied === revision) {
162
+ try {
163
+ const agent = resolveAgent(parseConfig(raw, this.file));
164
+ activeModelDefault = { model: agent.model ?? '', profile: agent.id };
165
+ }
166
+ catch { /* Unavailable profiles must not be presented as active. */ }
167
+ }
168
+ return { revision, valid, github, mcpConnections, activeModelDefault, automaticConfiguration, configurationReload, application: !service.running ? 'stopped' : !applied ? 'unknown' : applied === revision ? 'applied' : 'pending',
169
+ values: { directories: c.directories ?? [], sandbox: 'workspace-write', networkAccess: c.networkAccess ?? false, allowLocalCommits: true,
170
+ concurrency: Number.isInteger(raw.concurrency) && raw.concurrency >= 1 && raw.concurrency < 4 ? 4 : raw.concurrency ?? 8, model: c.model ?? '', bin: c.bin ?? 'codex', timeoutMs: c.timeoutMs ?? 600000, readPaths: c.readPaths ?? [], denyPaths: c.denyPaths ?? [], cards: f.cards === true, requireMention: f.requireMention !== false,
171
+ reactions: f.reactions !== false, progressUpdates: f.progressUpdates !== false, progressDelayMs: f.progressDelayMs ?? 200, progressIntervalMs: f.progressIntervalMs ?? 5000, progressHeartbeatMs: f.progressHeartbeatMs ?? 30000 },
172
+ feishu: { appId: f.appId ?? '', domain: f.domain ?? 'feishu', secretConfigured: !!f.appSecret || !!process.env[f.appSecretEnv ?? 'FEISHU_APP_SECRET'], pairedUsers: Array.isArray(f.allowedUserIds) ? f.allowedUserIds.length : 0,
173
+ restrictedChats: Array.isArray(f.allowedChatIds) ? f.allowedChatIds.length : 0, access: f.access ?? null, allowedUserIds: f.allowedUserIds ?? [], allowedChatIds: f.allowedChatIds ?? [] }, file: this.file };
174
+ }
175
+ state() {
176
+ const day = new Date().toISOString().slice(0, 10), limit = loadConfig(this.file).codex.dailyTurnLimit ?? 0;
177
+ const db = this.read(s => {
178
+ const schema = Number(s.db.prepare('PRAGMA user_version').get()?.user_version);
179
+ if (schema !== SCHEMA_VERSION)
180
+ return { schema, tasks: [], issues: [], workstreams: [] };
181
+ return { schema, tasks: s.db.prepare('SELECT id,workstreamId,cwd,state,inputVersion,startedAt,finishedAt,error FROM tasks ORDER BY rowid DESC LIMIT 50').all(),
182
+ workstreams: s.db.prepare('SELECT id,cwd,createdAt FROM workstreams ORDER BY createdAt DESC LIMIT 30').all(),
183
+ issues: schema === SCHEMA_VERSION ? new Recovery(s).list() : [], queue: s.status(), usage: { day, turns: Number(s.db.prepare('SELECT value FROM settings WHERE key=?').get(`daily-turns:${day}`)?.value ?? 0), limit } };
184
+ });
185
+ return this.sanitize({ service: this.status(), config: this.config(), database: db ?? { schema: 0, tasks: [], issues: [], workstreams: [] }, recoveryAvailable: db?.schema === SCHEMA_VERSION, profiles: this.profiles(), assistant: db?.schema === SCHEMA_VERSION ? this.read(s => new AssistantSettings(s).read()) : undefined });
186
+ }
187
+ assistant(action, version, values) {
188
+ try {
189
+ return this.write(s => {
190
+ const settings = new AssistantSettings(s);
191
+ if (action === 'preview')
192
+ return settings.preview(values);
193
+ if (action === 'reset')
194
+ return settings.reset(version, { kind: 'local-owner', authenticated: true });
195
+ if (action === 'save')
196
+ return settings.save(version, values, { kind: 'local-owner', authenticated: true });
197
+ throw new ManagementError('Unsupported assistant operation', 400);
198
+ });
199
+ }
200
+ catch (e) {
201
+ if (e instanceof AssistantSettingsError)
202
+ throw new ManagementError(e.message, e.code === 'invalid' ? 400 : e.code === 'forbidden' ? 403 : e.code === 'conflict' || e.code === 'run_already_adopted' ? 409 : 503);
203
+ throw e;
204
+ }
205
+ }
206
+ memoryIdentity(ownerId) {
207
+ let config;
208
+ try {
209
+ config = loadConfig(this.file);
210
+ }
211
+ catch {
212
+ throw new ManagementError(tr("common.configurationValidationFailedCheckDirectoriesPermissions"), 409);
213
+ }
214
+ const f = config.feishu, ids = f.access ? this.profiles().entries.map(p => p.userId) : [...new Set(f.allowedUserIds)];
215
+ if (!ids.length)
216
+ throw new ManagementError(tr("management.completeAppSetupUserPairingFirst"), 409);
217
+ if (ownerId !== undefined && (typeof ownerId !== 'string' || !ids.includes(ownerId)))
218
+ throw new ManagementError(tr("management.pairedUsersCurrentAppMayMemoryManaged"), 403);
219
+ const selected = typeof ownerId === 'string' ? ownerId : ids[0];
220
+ const names = this.readCurrent(s => {
221
+ const account = s.db.prepare("SELECT value FROM settings WHERE key='account'").get()?.value;
222
+ if (account && account !== f.appId)
223
+ throw new ManagementError(tr("common.appDataDirectoryNotMatchProfilesCannot"), 409);
224
+ if (!s.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='user_profiles'").get())
225
+ return new Map();
226
+ return new Map(s.db.prepare('SELECT userId,name FROM user_profiles WHERE channel=? AND appId=?').all(f.domain, f.appId)
227
+ .map(row => [String(row.userId), String(row.name)]));
228
+ }) ?? new Map();
229
+ const redact = this.redactor();
230
+ return { ownerId: selected, owners: ids.map(id => ({ id, label: redact(names.get(id) ?? '') || id })), directories: config.codex.directories ?? [],
231
+ appId: f.appId, channel: f.domain, secret: f.appSecret };
232
+ }
233
+ memoryChats(s, ownerId, directories) {
234
+ const allowed = new Set(directories), seen = new Set(), result = [];
235
+ const add = (chatKey, directory) => { if (typeof chatKey !== 'string' || !chatKey)
236
+ return; const p = typeof directory === 'string' && allowed.has(directory) ? directory : null, key = JSON.stringify([chatKey, p]); if (!seen.has(key)) {
237
+ seen.add(key);
238
+ result.push({ chatKey, directory: p });
239
+ } };
240
+ for (const row of s.db.prepare('SELECT DISTINCT i.chatKey,t.cwd AS directory FROM inbox i LEFT JOIN tasks t ON t.id=i.taskId WHERE i.senderId=?').all(ownerId))
241
+ add(row.chatKey, row.directory);
242
+ for (const row of s.db.prepare('SELECT DISTINCT chatKey,cwd AS directory FROM workstreams WHERE ownerId=?').all(ownerId))
243
+ add(row.chatKey, row.directory);
244
+ return result.sort((a, b) => a.chatKey.localeCompare(b.chatKey) || (a.directory ?? '').localeCompare(b.directory ?? ''));
245
+ }
246
+ memories(ownerId) {
247
+ try {
248
+ const identity = this.memoryIdentity(ownerId), result = this.read(s => {
249
+ if (Number(s.db.prepare('PRAGMA user_version').get()?.user_version) !== SCHEMA_VERSION)
250
+ throw new ManagementError(tr("management.databaseSchemaUnsupported"), 409);
251
+ return this.memoryState(s, identity);
252
+ });
253
+ if (!result)
254
+ throw new ManagementError(tr("management.noServiceDatabaseCompleteSetupFirst"), 409);
255
+ return result;
256
+ }
257
+ catch (e) {
258
+ if (e instanceof MemoryError)
259
+ throw this.memoryError(e);
260
+ if (e instanceof MigrationMemoryError)
261
+ throw new ManagementError(e.message, migrationMemoryStatus(e));
262
+ throw e;
263
+ }
264
+ }
265
+ memory(action, ownerId, input) {
266
+ const identity = this.memoryIdentity(ownerId);
267
+ try {
268
+ return this.write(s => {
269
+ const account = s.db.prepare("SELECT value FROM settings WHERE key='account'").get()?.value;
270
+ if (account && account !== identity.appId)
271
+ throw new ManagementError(tr("common.appDataDirectoryNotMatchProfilesCannot"), 409);
272
+ const redactor = this.redactor(), memory = new Memories(s, redactor), chats = this.memoryChats(s, identity.ownerId, identity.directories);
273
+ if (!input || typeof input !== 'object' || Array.isArray(input))
274
+ throw new ManagementError(tr("common.invalidRequestBody"), 400);
275
+ const value = input, authority = { kind: 'local-owner', authenticated: true, ownerId: identity.ownerId,
276
+ source: { kind: 'local-owner', ref: `workbench:${randomUUID()}` } };
277
+ if (action === 'save') {
278
+ const scope = this.validMemoryScope(value.scope, identity.ownerId, identity.directories, chats), text = value.text;
279
+ if (typeof text === 'string' && redactor(text) !== text)
280
+ throw new ManagementError(tr("management.memoryCannotContainCredentialsRemoveThemRetry"), 400);
281
+ memory.save({ kind: value.kind, scope, text: text }, authority);
282
+ }
283
+ else if (action === 'import') {
284
+ const scope = this.validMemoryScope(value.scope, identity.ownerId, identity.directories, chats);
285
+ new MigrationMemory(s, { dataDir: this.dataDir, configFile: this.file, appId: identity.appId }, redactor).importPending({
286
+ migrationId: value.migrationId, candidateId: value.candidateId, fingerprint: value.fingerprint, scope,
287
+ }, { kind: 'local-owner', authenticated: true, ownerId: identity.ownerId });
288
+ }
289
+ else {
290
+ if (typeof value.id !== 'string' || !Number.isSafeInteger(value.version))
291
+ throw new ManagementError(tr("management.invalidMemoryIdVersion"), 400);
292
+ if (action === 'correct') {
293
+ if (typeof value.text === 'string' && redactor(value.text) !== value.text)
294
+ throw new ManagementError(tr("management.memoryCannotContainCredentialsRemoveThemRetry"), 400);
295
+ memory.correct(value.id, Number(value.version), { text: value.text }, authority);
296
+ }
297
+ else if (action === 'disable')
298
+ memory.disable(value.id, Number(value.version), authority);
299
+ else if (action === 'delete')
300
+ memory.delete(value.id, Number(value.version), authority);
301
+ else if (action === 'activate')
302
+ memory.activatePending(value.id, Number(value.version), authority);
303
+ else
304
+ throw new ManagementError(tr("common.actionNotFound"), 400);
305
+ }
306
+ return this.memoryState(s, identity);
307
+ });
308
+ }
309
+ catch (e) {
310
+ if (e instanceof MemoryError)
311
+ throw this.memoryError(e);
312
+ if (e instanceof MigrationMemoryError)
313
+ throw new ManagementError(e.message, migrationMemoryStatus(e));
314
+ throw e;
315
+ }
316
+ }
317
+ memoryState(s, identity) {
318
+ const memory = new Memories(s, this.redactor());
319
+ const redact = this.redactor();
320
+ return { available: true, ownerId: identity.ownerId, owners: identity.owners, directories: identity.directories, chats: this.memoryChats(s, identity.ownerId, identity.directories),
321
+ extraction: this.memoryExtraction(s, identity.ownerId),
322
+ imports: new MigrationMemory(s, { dataDir: this.dataDir, configFile: this.file, appId: identity.appId }, redact).list(),
323
+ items: memory.manage({ kind: 'local-owner', authenticated: true, ownerId: identity.ownerId }), limits: { entryChars: MEMORY_LIMITS.entryChars,
324
+ ownerEntries: MEMORY_LIMITS.ownerEntries, ownerChars: MEMORY_LIMITS.ownerChars, scopeEntries: MEMORY_LIMITS.scopeEntries, scopeChars: MEMORY_LIMITS.scopeChars } };
325
+ }
326
+ memoryExtraction(s, ownerId) {
327
+ const counts = { pending: 0, running: 0, failed: 0 };
328
+ for (const row of s.db.prepare("SELECT state,COUNT(*) AS n FROM memory_jobs WHERE ownerId=? AND state IN ('pending','running','failed') GROUP BY state").all(ownerId)) {
329
+ counts[row.state] = Number(row.n);
330
+ }
331
+ const errors = new Set(['extraction_failed', 'timeout', 'connection_failed', 'invalid_output', 'tool_rejected', 'capacity']);
332
+ const rows = s.db.prepare(`SELECT id,directory,state,createdAt,attempts,dueAt,leaseUntil,accepted,rejected,error
333
+ FROM memory_jobs WHERE ownerId=? ORDER BY createdAt DESC,id DESC LIMIT 21`).all(ownerId);
334
+ const redact = this.redactor();
335
+ const recent = rows.slice(0, 20).map(row => ({
336
+ id: String(row.id), directory: row.directory === null ? null : redact(String(row.directory)), state: row.state,
337
+ createdAt: Number(row.createdAt), attempts: Number(row.attempts), dueAt: Number(row.dueAt), leaseUntil: Number(row.leaseUntil),
338
+ accepted: row.accepted === null ? null : Number(row.accepted), rejected: row.rejected === null ? null : Number(row.rejected),
339
+ error: row.error === null ? null : errors.has(row.error) ? row.error : 'extraction_failed',
340
+ }));
341
+ return { ...counts, maxAttempts: MEMORY_EXTRACTION_MAX_ATTEMPTS, recent, hasMore: rows.length > 20 };
342
+ }
343
+ validMemoryScope(raw, ownerId, directories, chats) {
344
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
345
+ throw new ManagementError(tr("management.invalidMemoryScope"), 400);
346
+ const scope = raw;
347
+ if (scope.ownerId !== ownerId)
348
+ throw new ManagementError(tr("management.selectedUsersMemoryMayManaged"), 403);
349
+ if (scope.kind === 'owner' && scope.directory === null && scope.chatKey === null)
350
+ return scope;
351
+ if (scope.kind === 'directory' && typeof scope.directory === 'string' && directories.includes(scope.directory) && scope.chatKey === null)
352
+ return scope;
353
+ if (scope.kind === 'chat' && typeof scope.chatKey === 'string' && (scope.directory === null || typeof scope.directory === 'string')
354
+ && chats.some(chat => chat.chatKey === scope.chatKey && (scope.directory === null || chat.directory === scope.directory)))
355
+ return scope;
356
+ throw new ManagementError(tr("management.memoryScopeNotAvailableSelectedPairedUser"), 403);
357
+ }
358
+ memoryError(error) {
359
+ const status = error.code === 'invalid' ? 400 : error.code === 'forbidden' ? 403 : error.code === 'missing' ? 404 : error.code === 'capacity' ? 413 : error.code === 'storage_invalid' ? 503 : 409;
360
+ return new ManagementError(error.message, status);
361
+ }
362
+ projections(s) {
363
+ const { raw } = this.source(), f = raw.feishu ?? {};
364
+ return new Browse(s, { appId: f.appId ?? '', channel: f.domain ?? 'feishu' }, this.redactor());
365
+ }
366
+ scheduleAction(input) {
367
+ if (!input || typeof input !== 'object' || Array.isArray(input))
368
+ throw new ManagementError(tr('schedules.invalidAction'), 400);
369
+ const v = input;
370
+ if (Object.keys(v).some(k => !['id', 'action', 'state', 'nextAt'].includes(k)) || typeof v.id !== 'string' || !/^S-[A-F0-9]{12}$/.test(v.id)
371
+ || !['pause', 'resume', 'delete'].includes(String(v.action)) || !['active', 'paused', 'completed'].includes(String(v.state)) || !Number.isSafeInteger(v.nextAt))
372
+ throw new ManagementError(tr('schedules.invalidAction'), 400);
373
+ const action = v.action, config = loadConfig(this.file);
374
+ if (action === 'resume' && this.status().running && this.config().application !== 'applied')
375
+ throw new ManagementError(tr('schedules.configurationPending'));
376
+ try {
377
+ this.write(s => new Schedules(s).changeFromWorkbench(v.id, v.state, v.nextAt, action, source => {
378
+ const policy = executionPolicy(config.codex, config.feishu, source), tasks = new Tasks(s), bound = tasks.binding(source), saved = bound ? tasks.selection(bound.id) : undefined;
379
+ const selection = saved && saved.profileId !== 'codex' ? saved : selectAgent(config, bound ? 'codex' : undefined);
380
+ const workspace = chatWorkspace(config.dataDir, source.envelope ? `${scopeOf(source)}:user:${source.senderId}` : source.chatKey);
381
+ return { cwd: realpathSync(workspace), directories: config.codex.directories ?? [], policyHash: selectedPolicyHash({ ...config, codex: policy }, selection), ...(selection.profileId !== 'codex' ? { agentSelection: selection } : {}) };
382
+ }));
383
+ }
384
+ catch (error) {
385
+ if (error instanceof ManagementError)
386
+ throw error;
387
+ throw new ManagementError(error instanceof Error && [tr('schedules.conflict'), tr('schedules.invalidAction'), tr('schedules.resumeUnavailable')].includes(error.message) ? error.message : tr('schedules.resumeUnavailable'));
388
+ }
389
+ return { ok: true };
390
+ }
391
+ browse(kind, params = new URLSearchParams()) {
392
+ const result = this.read(s => {
393
+ const schema = Number(s.db.prepare('PRAGMA user_version').get()?.user_version);
394
+ if (schema !== SCHEMA_VERSION)
395
+ throw new BrowseError(tr("management.databaseSchemaUnsupported"));
396
+ // A deferred read transaction keeps totals and rows consistent without
397
+ // migrating the database or taking a writer reservation from the receiver.
398
+ s.db.exec('BEGIN');
399
+ try {
400
+ const view = this.projections(s);
401
+ const value = kind === 'tasks' ? view.tasks(params) : kind === 'schedules' ? view.schedules(params) : kind === 'sessions' ? view.sessions(params) : kind === 'dashboard' ? view.dashboard() : view.options();
402
+ s.db.exec('COMMIT');
403
+ return value;
404
+ }
405
+ catch (e) {
406
+ s.db.exec('ROLLBACK');
407
+ throw e;
408
+ }
409
+ });
410
+ if (result === undefined)
411
+ throw new BrowseError(tr("management.noTaskDatabaseCompleteNamoSetupFirst"));
412
+ return result;
413
+ }
414
+ profiles() {
415
+ const { raw, revision } = this.source(), f = raw.feishu ?? {};
416
+ const unavailable = (reason) => ({ available: false, reason, configRevision: revision, entries: [] });
417
+ if (typeof f.appId !== 'string' || !f.appId || !['feishu', 'lark'].includes(f.domain ?? 'feishu') || !Array.isArray(f.allowedUserIds) || f.allowedUserIds.some((id) => typeof id !== 'string' || !id))
418
+ return unavailable(tr("management.completeAppSetupUserPairingFirst"));
419
+ try {
420
+ return this.read(s => {
421
+ if (Number(s.db.prepare('PRAGMA user_version').get()?.user_version) !== SCHEMA_VERSION)
422
+ return unavailable(tr("management.databaseSchemaUnsupported"));
423
+ return this.sanitize({ available: true, configRevision: revision, entries: [...new Set([...f.allowedUserIds, ...(f.access ? s.db.prepare("SELECT DISTINCT senderId FROM inbox WHERE chatKey LIKE ? AND json_extract(envelope,'$.tenantKey')=? LIMIT 1000").all(`${f.appId}:%`, f.access.tenantKey).map(r => String(r.senderId)) : [])])].map(userId => { const identity = { channel: f.domain ?? 'feishu', appId: f.appId, userId }; return { ...new Profiles(s, identity).get(), defaultModel: userModel(s, identity) }; }) });
424
+ }) ?? unavailable(tr("management.noServiceDatabaseCompleteSetupFirst"));
425
+ }
426
+ catch (e) {
427
+ if (e instanceof ProfileError)
428
+ return unavailable(e.message);
429
+ throw e;
430
+ }
431
+ }
432
+ saveUserModel(configRevision, userId, expected, model) {
433
+ const release = acquireLock(join(this.dataDir, 'config-edit.lock'));
434
+ try {
435
+ const { raw, revision } = this.source(), f = raw.feishu ?? {};
436
+ if (configRevision !== revision)
437
+ throw new ManagementError(tr("management.appConfigurationChangedRefreshSelectUserAgain"));
438
+ if (typeof userId !== 'string' || !this.profiles().entries.some(p => p.userId === userId))
439
+ throw new ManagementError(tr("management.profilesUsersPairedAppCanManaged"));
440
+ const identity = { channel: f.domain ?? 'feishu', appId: f.appId, userId };
441
+ try {
442
+ return this.write(s => s.transaction(() => {
443
+ if (typeof expected !== 'string' || userModel(s, identity) !== expected)
444
+ throw new ManagementError('模型设置已变化,请刷新后重试。');
445
+ return setUserModel(s, identity, model);
446
+ }));
447
+ }
448
+ catch (e) {
449
+ if (e instanceof ModelPreferenceError)
450
+ throw new ManagementError(e.message, 400);
451
+ throw e;
452
+ }
453
+ }
454
+ finally {
455
+ release();
456
+ }
457
+ }
458
+ saveProfile(configRevision, userId, version, patch) {
459
+ const release = acquireLock(join(this.dataDir, 'config-edit.lock'));
460
+ try {
461
+ const { raw, revision } = this.source(), f = raw.feishu ?? {};
462
+ if (configRevision !== revision)
463
+ throw new ManagementError(tr("management.appConfigurationChangedRefreshSelectUserAgain"));
464
+ if (typeof userId !== 'string' || !Array.isArray(f.allowedUserIds) || !(f.access ? this.profiles().entries.some(p => p.userId === userId) : f.allowedUserIds.includes(userId)))
465
+ throw new ManagementError(tr("management.profilesUsersPairedAppCanManaged"));
466
+ if (typeof f.appId !== 'string' || !f.appId || !['feishu', 'lark'].includes(f.domain ?? 'feishu'))
467
+ throw new ManagementError(tr("management.invalidAppIdentity"));
468
+ const redact = this.redactor();
469
+ if (JSON.stringify(patch) !== redact(JSON.stringify(patch) ?? ''))
470
+ throw new ManagementError(tr("management.profilesCannotContainCredentialsRemoveThemTry"));
471
+ return this.write(s => new Profiles(s, { channel: f.domain ?? 'feishu', appId: f.appId, userId }).update(version, patch, { source: 'local-owner' }));
472
+ }
473
+ catch (e) {
474
+ if (e instanceof ProfileError)
475
+ throw new ManagementError(e.message);
476
+ throw e;
477
+ }
478
+ finally {
479
+ release();
480
+ }
481
+ }
482
+ async models() {
483
+ try {
484
+ return await listCodexModels(loadConfig(this.file).codex);
485
+ }
486
+ catch {
487
+ throw new ManagementError('模型列表暂不可用,请检查 Codex 登录和服务配置。', 503);
488
+ }
489
+ }
490
+ async codexUpdate(input) {
491
+ const { revision } = this.source();
492
+ if (input && input.configRevision !== revision)
493
+ throw new ManagementError('update_config_changed');
494
+ if (!this.codexUpdater || this.codexUpdater.revision !== revision) {
495
+ this.codexUpdater = { revision, updates: new CodexUpdates(loadConfig(this.file), {}, revision) };
496
+ this.updateOperations.add(this.codexUpdater.updates);
497
+ }
498
+ try {
499
+ return input ? await this.codexUpdater.updates.action(input.action, input.enabled) : await this.codexUpdater.updates.status();
500
+ }
501
+ catch (error) {
502
+ throw new ManagementError(error instanceof Error && /^update_[a-z_]+$/.test(error.message) ? error.message : 'update_failed');
503
+ }
504
+ }
505
+ async mcpOAuthScopes(revision, url) {
506
+ if (typeof revision !== 'string' || this.source().revision !== revision)
507
+ throw new ManagementError('mcp_config_changed');
508
+ if (typeof url !== 'string' || url.length > 2048)
509
+ throw new ManagementError('mcp_invalid_config', 400);
510
+ try {
511
+ const result = await discoverMcpOAuthScopes(url);
512
+ if (this.source().revision !== revision)
513
+ throw new ManagementError('mcp_config_changed');
514
+ return result;
515
+ }
516
+ catch (error) {
517
+ if (error instanceof ManagementError)
518
+ throw error;
519
+ throw new ManagementError('mcp_oauth_discovery_failed', 400);
520
+ }
521
+ }
522
+ async testMcp(revision, id) {
523
+ if (typeof revision !== 'string' || typeof id !== 'string' || this.source().revision !== revision)
524
+ throw new ManagementError('mcp_config_changed');
525
+ const connection = loadConfig(this.file).mcpConnections?.find(c => c.id === id);
526
+ if (!connection)
527
+ throw new ManagementError('mcp_connection_not_found', 400);
528
+ try {
529
+ const signal = AbortSignal.timeout(30000), credential = connection.type === 'stdio' ? { token: '' } : await resolveMcpCredential(this.dataDir, connection.token, connection.url, signal, undefined, connection.oauthScope);
530
+ // Admin diagnostics may list tools before the connection is enabled for tasks.
531
+ const result = await (connection.type === 'stdio' ? stdioRead : this.deps.mcpReader)({ ...connection, token: credential.token }, { operation: 'list' }, signal);
532
+ if (this.source().revision !== revision)
533
+ throw new ManagementError('mcp_config_changed');
534
+ return { toolCount: Array.isArray(result) ? result.length : 0 };
535
+ }
536
+ catch (error) {
537
+ if (error instanceof ManagementError)
538
+ throw error;
539
+ throw new ManagementError('mcp_connection_failed', 400);
540
+ }
541
+ }
542
+ codexMcpCatalog() { try {
543
+ return listCodexMcp(this.deps.codexMcpConfig, parseMcpConnections(this.source().raw.mcpConnections));
544
+ }
545
+ catch {
546
+ throw new ManagementError('codex_mcp_config_invalid', 400);
547
+ } }
548
+ importCodexMcp(revision, sourceRevision, ids) {
549
+ if (typeof revision !== 'string' || this.source().revision !== revision)
550
+ throw new ManagementError('mcp_config_changed');
551
+ if (typeof sourceRevision !== 'string' || !Array.isArray(ids) || !ids.length || ids.length > 20 || ids.some(id => typeof id !== 'string'))
552
+ throw new ManagementError('codex_mcp_selection_invalid', 400);
553
+ const current = parseMcpConnections(this.source().raw.mcpConnections), used = new Set(current.map(c => c.id));
554
+ try {
555
+ const additions = ids.map(id => { const selected = selectCodexMcp(id, sourceRevision, this.deps.codexMcpConfig), normalized = selected.id.toLowerCase(); if (used.has(normalized))
556
+ throw new ManagementError('codex_mcp_duplicate', 400); used.add(normalized); return { id: normalized, type: 'remote', url: selected.url }; });
557
+ return this.save(revision, { mcpConnections: [...current.map(({ token: _token, ...value }) => value), ...additions] });
558
+ }
559
+ catch (error) {
560
+ if (error instanceof ManagementError)
561
+ throw error;
562
+ if (error instanceof CodexMcpImportError)
563
+ throw new ManagementError(error.code, 400);
564
+ throw error;
565
+ }
566
+ }
567
+ prepareMcpOAuth(revision, id, draft) {
568
+ const { raw, revision: current } = this.source();
569
+ if (current !== revision)
570
+ throw new ManagementError('mcp_config_changed');
571
+ const connections = parseMcpConnections(raw.mcpConnections), prior = connections.find(c => c.id === id);
572
+ if (draft === undefined) {
573
+ if (!prior)
574
+ throw new ManagementError('mcp_config_changed');
575
+ const { token: _token, ...value } = prior;
576
+ return value;
577
+ }
578
+ if (!draft || typeof draft !== 'object' || Array.isArray(draft) || Object.keys(draft).some(k => !['id', 'type', 'url', 'oauthScope', 'ownerUserId'].includes(k)))
579
+ throw new ManagementError('mcp_invalid_config', 400);
580
+ const value = draft;
581
+ if (id && (!prior || id !== value.id) || !id && connections.some(c => c.id === value.id))
582
+ throw new ManagementError('mcp_config_changed');
583
+ let parsed;
584
+ try {
585
+ parsed = parseMcpConnections([{ ...value, token: '' }])[0];
586
+ const existing = connections.filter(c => c.id !== id).map(c => { if (c.type !== 'stdio')
587
+ return c; const { url: _url, ...local } = c; return local; });
588
+ parseConfig({ ...raw, mcpConnections: [...existing, parsed] }, this.file);
589
+ }
590
+ catch {
591
+ throw new ManagementError('mcp_invalid_config', 400);
592
+ }
593
+ if (addsDuplicateMcpEndpoint(connections, [...connections.filter(c => c.id !== id), parsed]))
594
+ throw new ManagementError('mcp_duplicate_endpoint', 400);
595
+ const { token: _token, ...safe } = parsed;
596
+ return { ...safe, ...(Object.hasOwn(value, 'ownerUserId') && !value.ownerUserId ? { ownerUserId: '' } : {}) };
597
+ }
598
+ saveMcpOAuth(revision, id, reference, draft) {
599
+ if (!isOAuthReference(reference))
600
+ throw new ManagementError('mcp_oauth_invalid', 400);
601
+ const { raw, revision: current } = this.source();
602
+ if (current !== revision)
603
+ throw new ManagementError('mcp_config_changed');
604
+ const connections = parseMcpConnections(raw.mcpConnections);
605
+ const selected = this.prepareMcpOAuth(revision, id, draft);
606
+ const values = connections.filter(c => c.id !== id).map(({ token: _token, ...value }) => value);
607
+ this.save(revision, { mcpConnections: [...values, { ...selected, newToken: reference }] }, undefined, true);
608
+ }
609
+ async saveGitHub(revision, patch) {
610
+ if (patch?.github?.source !== 'gh')
611
+ return this.save(revision, patch);
612
+ const { raw, revision: current } = this.source();
613
+ if (revision !== current)
614
+ throw new ManagementError(tr("management.configurationChangedAnotherPageProgramRefreshTry"));
615
+ const owners = patch.github.allowedUserIds;
616
+ if (patch.github.mode !== 'shared' && (patch.github.mode === 'simple' ? !raw.feishu?.allowedUserIds?.includes(patch.github.ownerUserId)
617
+ : patch.github.grants === undefined && (!Array.isArray(owners) || owners.length !== 1 || !raw.feishu?.allowedUserIds?.includes(owners[0]))))
618
+ throw new ManagementError(tr("management.localGithubLoginMustLinkedExactlyOne"), 400);
619
+ let local;
620
+ try {
621
+ local = await this.deps.localGh();
622
+ }
623
+ catch {
624
+ throw new ManagementError(tr("management.localGithubLoginUnavailableRunGhAuth"), 400);
625
+ }
626
+ return this.save(revision, patch, local);
627
+ }
628
+ save(revision, patch, localGh, internalOAuth = false) {
629
+ const release = acquireLock(join(this.dataDir, 'config-edit.lock'));
630
+ try {
631
+ const { raw, revision: current } = this.source();
632
+ if (current !== revision)
633
+ throw new ManagementError(tr("management.configurationChangedAnotherPageProgramRefreshTry"));
634
+ if (!patch || typeof patch !== 'object' || Array.isArray(patch))
635
+ throw new ManagementError(tr("management.invalidConfigurationContent"));
636
+ const allowed = ['directories', 'serviceAccess', 'sandbox', 'networkAccess', 'allowLocalCommits', 'concurrency', 'model', 'bin', 'timeoutMs', 'readPaths', 'denyPaths', 'cards', 'requireMention', 'reactions', 'progressUpdates', 'progressDelayMs', 'progressIntervalMs', 'progressHeartbeatMs', 'newSecret', 'github', 'newGithubToken', 'clearGithubToken', 'mcpConnections'];
637
+ if (Object.keys(patch).some(k => !allowed.includes(k)))
638
+ throw new ManagementError(tr("management.configurationIncludesFieldsCannotEdited"));
639
+ const next = structuredClone(raw);
640
+ next.codex ??= {};
641
+ next.feishu ??= {};
642
+ for (const key of allowed.filter(k => !['serviceAccess', 'concurrency', 'cards', 'requireMention', 'reactions', 'progressUpdates', 'progressDelayMs', 'progressIntervalMs', 'progressHeartbeatMs', 'newSecret', 'github', 'newGithubToken', 'clearGithubToken', 'mcpConnections'].includes(k)))
643
+ if (Object.hasOwn(patch, key))
644
+ next.codex[key] = patch[key];
645
+ if (patch.serviceAccess !== undefined) {
646
+ const a = patch.serviceAccess;
647
+ if (!a || typeof a !== 'object' || Array.isArray(a) || Object.keys(a).some(k => !['access', 'allowedUserIds', 'allowedChatIds'].includes(k)))
648
+ throw new ManagementError(tr("management.invalidOrganizationAccessSettings"), 400);
649
+ next.feishu.access = a.access;
650
+ next.feishu.allowedUserIds = a.allowedUserIds;
651
+ next.feishu.allowedChatIds = a.allowedChatIds;
652
+ }
653
+ if (Object.hasOwn(patch, 'concurrency')) {
654
+ if (!Number.isInteger(patch.concurrency) || patch.concurrency < 4 || patch.concurrency > 64)
655
+ throw new ManagementError(tr('config.concurrencyMustBetween'), 400);
656
+ next.concurrency = patch.concurrency;
657
+ }
658
+ for (const k of ['cards', 'requireMention', 'reactions', 'progressUpdates', 'progressDelayMs', 'progressIntervalMs', 'progressHeartbeatMs'])
659
+ if (Object.hasOwn(patch, k))
660
+ next.feishu[k] = patch[k];
661
+ if (patch.newSecret !== undefined) {
662
+ if (typeof patch.newSecret !== 'string' || patch.newSecret.length > 256)
663
+ throw new ManagementError(tr("management.invalidSecretFormat"));
664
+ if (patch.newSecret)
665
+ next.feishu.appSecret = patch.newSecret;
666
+ }
667
+ if (patch.github !== undefined) {
668
+ if (!patch.github || typeof patch.github !== 'object' || Array.isArray(patch.github) || Object.keys(patch.github).some(k => !['mode', 'ownerUserId', 'source', 'repositories', 'allowedUserIds', 'grants'].includes(k)))
669
+ throw new ManagementError(tr("management.invalidGithubConfiguration"), 400);
670
+ const retainedGrants = patch.github.grants === undefined && patch.github.mode === 'simple' && raw.github?.mode === 'simple' ? raw.github.grants : patch.github.grants;
671
+ next.github = { ...next.github, ...patch.github };
672
+ if (retainedGrants === undefined)
673
+ delete next.github.grants;
674
+ else
675
+ next.github.grants = retainedGrants;
676
+ if (patch.github.mode === 'shared') {
677
+ delete next.github.ownerUserId;
678
+ delete next.github.grants;
679
+ next.github.repositories = [];
680
+ next.github.allowedUserIds = [];
681
+ }
682
+ if (patch.github.mode === undefined) {
683
+ delete next.github.mode;
684
+ delete next.github.ownerUserId;
685
+ }
686
+ if (patch.github.source === 'gh') {
687
+ if (!localGh || patch.newGithubToken || patch.clearGithubToken || patch.github.repositories?.length)
688
+ throw new ManagementError(tr("management.invalidGithubConfiguration"), 400);
689
+ next.github = { source: 'gh', localGh, repositories: [], allowedUserIds: patch.github.allowedUserIds, ...(patch.github.mode === 'shared' ? { mode: 'shared' } : patch.github.mode === 'simple' ? { mode: 'simple', ownerUserId: patch.github.ownerUserId } : {}), ...(retainedGrants === undefined ? {} : { grants: retainedGrants }) };
690
+ }
691
+ else if (patch.github.source === 'anonymous') {
692
+ if (patch.newGithubToken)
693
+ throw new ManagementError(tr("management.invalidGithubConfiguration"), 400);
694
+ next.github = { source: 'anonymous', repositories: [], allowedUserIds: [], ...(patch.github.grants === undefined ? {} : { grants: patch.github.grants }) };
695
+ }
696
+ else if (patch.github.source === 'token') {
697
+ delete next.github.localGh;
698
+ delete next.github.source;
699
+ }
700
+ }
701
+ if (patch.mcpConnections !== undefined) {
702
+ if (!Array.isArray(patch.mcpConnections) || patch.mcpConnections.length > 20)
703
+ throw new ManagementError('mcp_invalid_config', 400);
704
+ const previous = parseMcpConnections(raw.mcpConnections);
705
+ next.mcpConnections = patch.mcpConnections.map((entry) => {
706
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry) || Object.keys(entry).some(k => !['id', 'type', 'url', 'command', 'args', 'oauthScope', 'ownerUserId', 'newToken', 'clearToken'].includes(k))
707
+ || entry.newToken !== undefined && typeof entry.newToken !== 'string' || entry.clearToken !== undefined && typeof entry.clearToken !== 'boolean'
708
+ || entry.clearToken && entry.newToken || !internalOAuth && typeof entry.newToken === 'string' && isOAuthReference(entry.newToken))
709
+ throw new ManagementError('mcp_invalid_config', 400);
710
+ const prior = previous.find(v => v.id === entry.id);
711
+ if (prior?.token && (prior.type !== entry.type || prior.type === 'remote' && prior.url !== entry.url) && !entry.clearToken && !entry.newToken)
712
+ throw new ManagementError('mcp_credential_target_changed', 400);
713
+ if (prior?.token && isOAuthReference(prior.token) && (prior.oauthScope ?? '') !== (entry.oauthScope ?? '') && !entry.clearToken && !entry.newToken)
714
+ throw new ManagementError('mcp_credential_target_changed', 400);
715
+ const owner = entry.ownerUserId === undefined ? prior?.ownerUserId : entry.ownerUserId;
716
+ return { id: entry.id, type: entry.type, ...(owner ? { ownerUserId: owner } : {}), ...(entry.type === 'remote' ? { url: entry.url, ...(entry.oauthScope ? { oauthScope: entry.oauthScope } : {}) } : entry.type === 'stdio' ? { command: entry.command, args: entry.args } : {}),
717
+ token: entry.clearToken ? '' : entry.newToken || prior?.token || '' };
718
+ });
719
+ }
720
+ if (patch.clearGithubToken !== undefined && typeof patch.clearGithubToken !== 'boolean')
721
+ throw new ManagementError(tr("management.invalidGithubConfiguration"), 400);
722
+ if (patch.newGithubToken !== undefined && (typeof patch.newGithubToken !== 'string' || patch.newGithubToken.length > 4096))
723
+ throw new ManagementError(tr("management.invalidGithubCredentialFormat"), 400);
724
+ if (patch.clearGithubToken && patch.newGithubToken)
725
+ throw new ManagementError(tr("management.cannotClearReplaceGithubCredentialTogether"), 400);
726
+ if (next.github?.source === 'gh' && (patch.newGithubToken || patch.clearGithubToken))
727
+ throw new ManagementError(tr("management.invalidGithubConfiguration"), 400);
728
+ if (patch.newGithubToken || patch.clearGithubToken) {
729
+ next.github ??= {};
730
+ delete next.github.tokenEnv;
731
+ delete next.github.token;
732
+ if (patch.newGithubToken)
733
+ next.github.token = patch.newGithubToken;
734
+ }
735
+ try {
736
+ parseConfig(next, this.file);
737
+ }
738
+ catch {
739
+ throw new ManagementError(tr("management.configurationValidationFailedCheckDirectorySettings"));
740
+ }
741
+ if (patch.mcpConnections !== undefined && addsDuplicateMcpEndpoint(parseMcpConnections(raw.mcpConnections), parseMcpConnections(next.mcpConnections)))
742
+ throw new ManagementError('mcp_duplicate_endpoint', 400);
743
+ const editor = new ConfigEditor(this.file);
744
+ if (digest(readFileSync(this.file, 'utf8')) !== revision)
745
+ throw new ManagementError(tr("management.configurationChangedRefreshContinue"));
746
+ editor.save(next);
747
+ return this.config();
748
+ }
749
+ finally {
750
+ release();
751
+ }
752
+ }
753
+ async apply(revision, confirmed) {
754
+ if (!confirmed)
755
+ throw new ManagementError(tr("management.applyingConfigurationRequiresExplicitConfirmationRestartReceiver"));
756
+ const release = acquireLock(join(this.dataDir, 'config-edit.lock'));
757
+ const maintenance = randomUUID();
758
+ let paused = false;
759
+ try {
760
+ if (this.source().revision !== revision)
761
+ throw new ManagementError(tr("management.configurationChangedReviewAgainApplying"));
762
+ const c = loadConfig(this.file), service = this.deps.status(c);
763
+ if (!service.installed || service.mode === 'foreground')
764
+ throw new ManagementError(tr("management.manageForegroundInstanceTerminalInstallBackgroundService"));
765
+ if (service.running) {
766
+ let h;
767
+ try {
768
+ h = readJson(join(this.dataDir, 'health.json'));
769
+ }
770
+ catch { }
771
+ if (h?.pid !== service.pid || h?.managementVersion !== 2)
772
+ throw new ManagementError(tr("management.runningVersionNotSupportSafeApplyUpgrade"));
773
+ }
774
+ this.write(s => s.transaction(() => {
775
+ if (s.db.prepare("SELECT 1 FROM inbox WHERE state IN ('queued','running','waiting','awaiting_reply')").get() || s.db.prepare("SELECT 1 FROM outbox WHERE state IN ('pending','sending')").get())
776
+ throw new ManagementError(tr("management.tasksOutgoingMessagesStillPendingWaitCompletion"));
777
+ if (s.db.prepare("SELECT 1 FROM runner_jobs WHERE state IN ('starting','running','lost')").get())
778
+ throw new ManagementError(tr("management.independentRunnersLostRunnerSlotsRemainFinish"));
779
+ if (s.db.prepare("SELECT 1 FROM settings WHERE key='maintenance'").get())
780
+ throw new ManagementError(tr("management.maintenanceOperationAlreadyProgress"));
781
+ s.db.prepare("INSERT INTO settings VALUES('maintenance',?)").run(maintenance);
782
+ paused = true;
783
+ }));
784
+ if (this.source().revision !== revision)
785
+ throw new ManagementError(tr("management.configurationChangedExternallyServiceWasNotRestarted"));
786
+ await this.deps.action(service.registered ? 'restart' : 'start', c);
787
+ const ready = await this.deps.wait(c, 30000);
788
+ return { ready, config: this.config(), message: ready ? tr("management.serviceReconnectedCheckSavedConfigurationActive") : tr("management.serviceStartAttemptedButConnectionNotReady") };
789
+ }
790
+ finally {
791
+ try {
792
+ if (paused)
793
+ this.write(s => { s.db.prepare("DELETE FROM settings WHERE key='maintenance' AND value=?").run(maintenance); });
794
+ }
795
+ finally {
796
+ release();
797
+ }
798
+ }
799
+ }
800
+ detail(id) {
801
+ if (!/^N-[A-F0-9]{12}$/.test(id))
802
+ throw new ManagementError(tr("management.invalidTaskId"));
803
+ return this.readCurrent(s => {
804
+ const tasks = new Tasks(s), t = tasks.get(id);
805
+ if (!t)
806
+ throw new ManagementError(tr("tasks.notFound"));
807
+ const summary = this.projections(s).taskSummary(id);
808
+ return this.sanitize({ ...tasks.detail(t), title: summary?.title, ownerId: summary?.ownerId, ownerName: summary?.ownerName, createdAt: summary?.createdAt,
809
+ results: s.db.prepare("SELECT content,state,part FROM outbox WHERE inboxKey=? AND kind='result' ORDER BY part").all(t.inboxKey) });
810
+ });
811
+ }
812
+ issue(id) {
813
+ return this.read(s => {
814
+ if (Number(s.db.prepare('PRAGMA user_version').get()?.user_version) !== SCHEMA_VERSION)
815
+ throw new ManagementError(tr("management.databaseSchemaUnsupported"));
816
+ const { snapshot: _s, inboxKey: _k, ...safe } = new Recovery(s).inspect(id);
817
+ return this.sanitize(safe);
818
+ });
819
+ }
820
+ reconcile(request) {
821
+ loadConfig(this.file);
822
+ request = { ...request, note: this.redactor()(request.note ?? '') };
823
+ try {
824
+ return this.write(s => new Recovery(s).resolve(request, { id: 'local-owner' }, true));
825
+ }
826
+ catch (e) {
827
+ if (e instanceof RecoveryError)
828
+ throw new ManagementError(e.message);
829
+ throw e;
830
+ }
831
+ }
832
+ cancel(id, inputVersion, requestId) {
833
+ if (!/^N-[A-F0-9]{12}$/.test(id) || !requestId || requestId.length > 100)
834
+ throw new ManagementError(tr("management.invalidCancellationRequest"));
835
+ return this.write(s => s.transaction(() => {
836
+ const old = s.db.prepare('SELECT subject,action,actor FROM reconciliations WHERE requestId=?').get(requestId);
837
+ if (old) {
838
+ if (old.subject === id && old.action === 'cancel' && old.actor === 'local-owner')
839
+ return { duplicate: true };
840
+ throw new ManagementError(tr("management.operationIdAlreadyUsed"));
841
+ }
842
+ const tasks = new Tasks(s), t = tasks.get(id);
843
+ if (!t || !['queued', 'running', 'waiting'].includes(t.state) || t.inputVersion !== inputVersion)
844
+ throw new ManagementError(tr("management.taskChangedRefreshActing"));
845
+ if (t.state === 'running') {
846
+ const job = s.db.prepare(`SELECT j.state FROM runner_jobs j JOIN task_runs r ON r.id=j.runId WHERE r.taskId=? AND r.state='running' ORDER BY r.startedAt DESC LIMIT 1`).get(t.id);
847
+ if (!job && !this.status().running)
848
+ throw new ManagementError(tr("management.runnerStateNeedsReviewServiceNotRunning"));
849
+ }
850
+ if (!tasks.cancel(t))
851
+ throw new ManagementError(tr("management.taskChangedItsRunnerFinishedLostContact"));
852
+ s.db.prepare('INSERT INTO reconciliations(requestId,subject,actor,action,note,beforeState,createdAt) VALUES(?,?,?,?,?,?,?)')
853
+ .run(requestId, id, 'local-owner', 'cancel', tr("management.localUserRequestedStop"), JSON.stringify({ state: t.state, inputVersion }), Date.now());
854
+ return { duplicate: false };
855
+ }));
856
+ }
857
+ logs() { return serviceLogs(this.dataDir, this.redactor()); }
858
+ inspectMigration(input) {
859
+ if (typeof input.sourceFile !== 'string' || !isAbsolute(input.sourceFile) || input.sourceFile.length > 4096
860
+ || typeof input.sourceInstanceId !== 'string' || !input.sourceInstanceId.trim() || input.sourceInstanceId.length > 100)
861
+ throw new ManagementError(tr('operations.migrationInputInvalid'), 400);
862
+ try {
863
+ return this.sanitize(inspectOpenClawSource({ sourceFile: input.sourceFile, sourceInstanceId: input.sourceInstanceId }));
864
+ }
865
+ catch (error) {
866
+ if (error instanceof MigrationError)
867
+ throw new ManagementError(this.redactor()(error.message), 400);
868
+ throw error;
869
+ }
870
+ }
871
+ approvals() {
872
+ const { revision } = this.source(), config = loadConfig(this.file);
873
+ return this.sanitize({ configured: !!config.gitApprovals?.gitBin && !!config.gitApprovals.remotes.length,
874
+ configRevision: revision, remotes: config.gitApprovals?.remotes.map(remote => remote.name) ?? [], items: this.readCurrent(listApprovals) ?? [] });
875
+ }
876
+ async approval(input) {
877
+ if (!input || !['request', 'push', 'approve', 'reject', 'execute', 'reconcile'].includes(input.action))
878
+ throw new ManagementError(tr('common.actionNotFound'), 400);
879
+ const { revision } = this.source(), config = loadConfig(this.file);
880
+ if (input.confirmed !== true)
881
+ throw new ManagementError(tr('operations.confirmRequired'), 400);
882
+ if (this.source().revision !== revision)
883
+ throw new ManagementError(tr('management.configurationChangedReviewAgainApplying'));
884
+ if (!/^[a-f0-9]{64}$/.test(input.configRevision ?? '') || ((input.action === 'request' || input.action === 'push')
885
+ ? typeof input.taskId !== 'string' || !/^N-[A-F0-9]{12}$/.test(input.taskId) || typeof input.remote !== 'string' || typeof input.ref !== 'string' || input.directory !== undefined && (typeof input.directory !== 'string' || input.directory.length > 4096)
886
+ : typeof input.id !== 'string' || !/^AP-[A-F0-9]{12}$/.test(input.id) || !Number.isSafeInteger(input.revision)))
887
+ throw new ManagementError(tr('operations.approvalInputInvalid'), 400);
888
+ const schema = this.read(s => Number(s.db.prepare('PRAGMA user_version').get()?.user_version));
889
+ if (schema !== SCHEMA_VERSION)
890
+ throw new ManagementError(tr('management.databaseSchemaUnsupported'));
891
+ const store = new Store(join(this.dataDir, 'bot.sqlite'));
892
+ try {
893
+ return this.sanitize(await changeApproval(store, config, revision, () => this.source().revision, input));
894
+ }
895
+ catch (error) {
896
+ if (error instanceof ApprovalError)
897
+ throw new ManagementError(this.redactor()(error.message));
898
+ throw error;
899
+ }
900
+ finally {
901
+ store.close();
902
+ }
903
+ }
904
+ async diagnose(live = false, confirmed = false) {
905
+ if (live && !confirmed)
906
+ throw new ManagementError(tr('operations.confirmRequired'), 400);
907
+ return this.sanitize(await this.deps.diagnose(this.file, live));
908
+ }
909
+ }
910
+ //# sourceMappingURL=management.js.map