codexmate 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +416 -413
  2. package/README.zh.md +349 -346
  3. package/cli/agents-files.js +224 -224
  4. package/cli/archive-helpers.js +446 -446
  5. package/cli/auth-profiles.js +375 -375
  6. package/cli/builtin-proxy.js +1079 -1079
  7. package/cli/claude-proxy.js +1022 -1022
  8. package/cli/config-bootstrap.js +384 -384
  9. package/cli/config-health.js +338 -338
  10. package/cli/doctor-core.js +903 -903
  11. package/cli/import-skills-url.js +356 -356
  12. package/cli/openai-bridge.js +997 -997
  13. package/cli/openclaw-config.js +629 -629
  14. package/cli/session-convert-args.js +65 -0
  15. package/cli/session-convert-io.js +82 -0
  16. package/cli/session-convert.js +43 -0
  17. package/cli/session-usage.concurrent.js +28 -28
  18. package/cli/session-usage.js +118 -118
  19. package/cli/session-usage.models.js +176 -176
  20. package/cli/skills.js +1141 -1141
  21. package/cli/zip-commands.js +510 -510
  22. package/cli.js +15218 -14736
  23. package/lib/automation.js +404 -404
  24. package/lib/cli-file-utils.js +151 -151
  25. package/lib/cli-models-utils.js +379 -379
  26. package/lib/cli-network-utils.js +190 -190
  27. package/lib/cli-path-utils.js +85 -85
  28. package/lib/cli-session-utils.js +121 -121
  29. package/lib/cli-sessions.js +417 -417
  30. package/lib/cli-utils.js +155 -155
  31. package/lib/download-artifacts.js +92 -92
  32. package/lib/mcp-stdio.js +453 -453
  33. package/lib/task-orchestrator.js +869 -869
  34. package/lib/text-diff.js +303 -303
  35. package/lib/workflow-engine.js +340 -340
  36. package/package.json +74 -74
  37. package/plugins/README.md +20 -20
  38. package/plugins/README.zh-CN.md +20 -20
  39. package/plugins/prompt-templates/comment-polish/index.mjs +25 -25
  40. package/plugins/prompt-templates/computed.mjs +253 -253
  41. package/plugins/prompt-templates/index.mjs +8 -8
  42. package/plugins/prompt-templates/manifest.mjs +15 -15
  43. package/plugins/prompt-templates/methods.mjs +619 -619
  44. package/plugins/prompt-templates/overview.mjs +90 -90
  45. package/plugins/prompt-templates/ownership.mjs +19 -19
  46. package/plugins/prompt-templates/rule-ack/index.mjs +21 -21
  47. package/plugins/prompt-templates/storage.mjs +64 -64
  48. package/plugins/registry.mjs +16 -16
  49. package/web-ui/app.js +625 -612
  50. package/web-ui/index.html +35 -35
  51. package/web-ui/logic.agents-diff.mjs +386 -386
  52. package/web-ui/logic.claude.mjs +168 -168
  53. package/web-ui/logic.mjs +5 -5
  54. package/web-ui/logic.runtime.mjs +128 -128
  55. package/web-ui/logic.session-convert.mjs +70 -0
  56. package/web-ui/logic.sessions.mjs +709 -614
  57. package/web-ui/modules/api.mjs +90 -90
  58. package/web-ui/modules/app.computed.dashboard.mjs +171 -128
  59. package/web-ui/modules/app.computed.index.mjs +17 -17
  60. package/web-ui/modules/app.computed.main-tabs.mjs +205 -205
  61. package/web-ui/modules/app.computed.session.mjs +946 -670
  62. package/web-ui/modules/app.constants.mjs +15 -15
  63. package/web-ui/modules/app.methods.agents.mjs +632 -632
  64. package/web-ui/modules/app.methods.claude-config.mjs +179 -174
  65. package/web-ui/modules/app.methods.codex-config.mjs +860 -784
  66. package/web-ui/modules/app.methods.index.mjs +92 -92
  67. package/web-ui/modules/app.methods.install.mjs +205 -205
  68. package/web-ui/modules/app.methods.navigation.mjs +743 -695
  69. package/web-ui/modules/app.methods.openclaw-core.mjs +814 -814
  70. package/web-ui/modules/app.methods.openclaw-editing.mjs +372 -372
  71. package/web-ui/modules/app.methods.openclaw-persist.mjs +369 -369
  72. package/web-ui/modules/app.methods.providers.mjs +404 -404
  73. package/web-ui/modules/app.methods.runtime.mjs +345 -345
  74. package/web-ui/modules/app.methods.session-actions.mjs +596 -544
  75. package/web-ui/modules/app.methods.session-browser.mjs +985 -722
  76. package/web-ui/modules/app.methods.session-timeline.mjs +479 -448
  77. package/web-ui/modules/app.methods.session-trash.mjs +424 -424
  78. package/web-ui/modules/app.methods.startup-claude.mjs +522 -417
  79. package/web-ui/modules/app.methods.task-orchestration.mjs +556 -556
  80. package/web-ui/modules/config-mode.computed.mjs +124 -124
  81. package/web-ui/modules/config-template-confirm-pref.mjs +33 -33
  82. package/web-ui/modules/i18n.dict.mjs +2113 -2055
  83. package/web-ui/modules/i18n.mjs +56 -56
  84. package/web-ui/modules/plugins.computed.mjs +3 -3
  85. package/web-ui/modules/plugins.methods.mjs +3 -3
  86. package/web-ui/modules/plugins.storage.mjs +11 -11
  87. package/web-ui/modules/sessions-filters-url.mjs +85 -85
  88. package/web-ui/modules/skills.computed.mjs +107 -107
  89. package/web-ui/modules/skills.methods.mjs +481 -481
  90. package/web-ui/partials/index/layout-footer.html +13 -13
  91. package/web-ui/partials/index/layout-header.html +475 -475
  92. package/web-ui/partials/index/modal-config-template-agents.html +174 -174
  93. package/web-ui/partials/index/modal-confirm-toast.html +32 -32
  94. package/web-ui/partials/index/modal-health-check.html +45 -45
  95. package/web-ui/partials/index/modal-openclaw-config.html +280 -280
  96. package/web-ui/partials/index/modal-skills.html +200 -200
  97. package/web-ui/partials/index/modals-basic.html +165 -165
  98. package/web-ui/partials/index/panel-config-claude.html +184 -179
  99. package/web-ui/partials/index/panel-config-codex.html +283 -283
  100. package/web-ui/partials/index/panel-config-openclaw.html +83 -83
  101. package/web-ui/partials/index/panel-dashboard.html +186 -186
  102. package/web-ui/partials/index/panel-docs.html +147 -147
  103. package/web-ui/partials/index/panel-market.html +177 -177
  104. package/web-ui/partials/index/panel-orchestration.html +391 -391
  105. package/web-ui/partials/index/panel-plugins.html +279 -279
  106. package/web-ui/partials/index/panel-sessions.html +326 -303
  107. package/web-ui/partials/index/panel-settings.html +258 -258
  108. package/web-ui/partials/index/panel-usage.html +342 -361
  109. package/web-ui/res/json5.min.js +1 -1
  110. package/web-ui/res/vue.global.prod.js +13 -13
  111. package/web-ui/session-helpers.mjs +576 -573
  112. package/web-ui/source-bundle.cjs +233 -233
  113. package/web-ui/styles/base-theme.css +268 -264
  114. package/web-ui/styles/controls-forms.css +423 -423
  115. package/web-ui/styles/dashboard.css +274 -274
  116. package/web-ui/styles/docs-panel.css +247 -247
  117. package/web-ui/styles/feedback.css +108 -108
  118. package/web-ui/styles/health-check-dialog.css +144 -144
  119. package/web-ui/styles/layout-shell.css +603 -603
  120. package/web-ui/styles/modals-core.css +464 -464
  121. package/web-ui/styles/navigation-panels.css +390 -390
  122. package/web-ui/styles/openclaw-structured.css +266 -266
  123. package/web-ui/styles/plugins-panel.css +523 -523
  124. package/web-ui/styles/responsive.css +454 -454
  125. package/web-ui/styles/sessions-list.css +415 -398
  126. package/web-ui/styles/sessions-preview.css +411 -411
  127. package/web-ui/styles/sessions-toolbar-trash.css +330 -268
  128. package/web-ui/styles/sessions-usage.css +945 -912
  129. package/web-ui/styles/settings-panel.css +166 -166
  130. package/web-ui/styles/skills-list.css +303 -303
  131. package/web-ui/styles/skills-market.css +406 -406
  132. package/web-ui/styles/task-orchestration.css +822 -822
  133. package/web-ui/styles/titles-cards.css +408 -408
  134. package/web-ui/styles.css +21 -21
  135. package/web-ui.html +17 -17
package/web-ui/app.js CHANGED
@@ -1,612 +1,625 @@
1
- import {
2
- DEFAULT_MODEL_AUTO_COMPACT_TOKEN_LIMIT,
3
- DEFAULT_MODEL_CONTEXT_WINDOW,
4
- DEFAULT_OPENCLAW_TEMPLATE,
5
- SESSION_TRASH_PAGE_SIZE
6
- } from './modules/app.constants.mjs';
7
- import { createAppComputed } from './modules/app.computed.index.mjs';
8
- import { createAppMethods } from './modules/app.methods.index.mjs';
9
- import { loadConfigTemplateDiffConfirmEnabledFromStorage } from './modules/config-template-confirm-pref.mjs';
10
-
11
- document.addEventListener('DOMContentLoaded', () => {
12
- if (typeof Vue === 'undefined') {
13
- console.error('Vue 库未能在 DOMContentLoaded 触发前加载完成。');
14
- const fallbackTarget = document.querySelector('#app') || document.querySelector('[v-cloak]');
15
- if (fallbackTarget) {
16
- fallbackTarget.removeAttribute('v-cloak');
17
- fallbackTarget.classList.remove('v-cloak');
18
- fallbackTarget.innerHTML = '';
19
- const notice = document.createElement('div');
20
- notice.className = 'fallback-message';
21
- notice.textContent = 'Web UI 加载失败:Vue 未加载。请检查网络或刷新页面。';
22
- fallbackTarget.appendChild(notice);
23
- }
24
- return;
25
- }
26
-
27
- const { createApp } = Vue;
28
-
29
- const app = createApp({
30
- data() {
31
- return {
32
- lang: 'zh',
33
- mainTab: 'dashboard',
34
- configMode: 'codex',
35
- currentProvider: '',
36
- currentModel: '',
37
- serviceTier: 'fast',
38
- modelReasoningEffort: 'medium',
39
- modelContextWindowInput: String(DEFAULT_MODEL_CONTEXT_WINDOW),
40
- modelAutoCompactTokenLimitInput: String(DEFAULT_MODEL_AUTO_COMPACT_TOKEN_LIMIT),
41
- editingCodexBudgetField: '',
42
- providersList: [],
43
- models: [],
44
- codexModelsLoading: false,
45
- modelsSource: 'remote',
46
- modelsHasCurrent: true,
47
- claudeModels: [],
48
- claudeModelsSource: 'idle',
49
- claudeModelsHasCurrent: true,
50
- claudeModelsLoading: false,
51
- codexModelsRequestSeq: 0,
52
- claudeModelsRequestSeq: 0,
53
- loading: true,
54
- initError: '',
55
- message: '',
56
- messageType: '',
57
- showAddModal: false,
58
- showEditModal: false,
59
- showModelModal: false,
60
- showModelListModal: false,
61
- showClaudeConfigModal: false,
62
- showEditConfigModal: false,
63
- showOpenclawConfigModal: false,
64
- showConfigTemplateModal: false,
65
- showAgentsModal: false,
66
- showSkillsModal: false,
67
- showHealthCheckModal: false,
68
- // Plugins
69
- pluginsActiveId: 'prompt-templates',
70
- pluginsLoading: false,
71
- pluginsError: '',
72
- promptTemplatesListRaw: [],
73
- promptTemplatesLoadedOnce: false,
74
- promptTemplatesKeyword: '',
75
- promptTemplateSelectedId: '',
76
- promptTemplateDraftRaw: null,
77
- promptTemplateVarValuesRaw: {},
78
- promptTemplatesMode: 'compose',
79
- promptComposerCommand: '',
80
- promptComposerPickerVisible: false,
81
- promptComposerPickerKeyword: '',
82
- promptComposerSelectedTemplateId: '',
83
- promptComposerVarValuesRaw: {},
84
- showPromptTemplateVarModal: false,
85
- promptTemplateVarDraftName: '',
86
- promptTemplateVarDraftError: '',
87
- showConfirmDialog: false,
88
- confirmDialogTitle: '',
89
- confirmDialogMessage: '',
90
- confirmDialogConfirmText: '确认',
91
- confirmDialogCancelText: '取消',
92
- confirmDialogDanger: false,
93
- confirmDialogConfirmDisabled: false,
94
- confirmDialogDisableWhen: null,
95
- confirmDialogResolver: null,
96
- configTemplateContent: '',
97
- configTemplateApplying: false,
98
- configTemplateDiffVisible: false,
99
- configTemplateDiffLoading: false,
100
- configTemplateDiffError: '',
101
- configTemplateDiffLines: [],
102
- configTemplateDiffStats: {
103
- added: 0,
104
- removed: 0,
105
- unchanged: 0
106
- },
107
- configTemplateDiffHasChangesValue: false,
108
- configTemplateDiffFingerprint: '',
109
- _configTemplateDiffPreviewRequestToken: null,
110
- configTemplateDiffConfirmEnabled: true,
111
- codexApplying: false,
112
- _pendingCodexApplyOptions: null,
113
- agentsContent: '',
114
- agentsPath: '',
115
- agentsPath: '',
116
- agentsExists: false,
117
- agentsLineEnding: '\n',
118
- agentsLoading: false,
119
- agentsSaving: false,
120
- agentsOriginalContent: '',
121
- agentsDiffVisible: false,
122
- agentsDiffLoading: false,
123
- agentsDiffError: '',
124
- agentsDiffLines: [],
125
- agentsDiffStats: {
126
- added: 0,
127
- removed: 0,
128
- unchanged: 0
129
- },
130
- agentsDiffTruncated: false,
131
- agentsDiffHasChangesValue: false,
132
- agentsDiffFingerprint: '',
133
- agentsContext: 'codex',
134
- agentsModalTitle: 'AGENTS.md 编辑器',
135
- agentsModalHint: '保存后会写入目标 AGENTS.md(与 config.toml 同级)。',
136
- skillsTargetApp: 'codex',
137
- skillsRootPath: '',
138
- skillsList: [],
139
- skillsSelectedNames: [],
140
- skillsLoading: false,
141
- skillsDeleting: false,
142
- skillsKeyword: '',
143
- skillsStatusFilter: 'all',
144
- skillsImportList: [],
145
- skillsImportSelectedKeys: [],
146
- skillsScanningImports: false,
147
- skillsImporting: false,
148
- skillsZipImporting: false,
149
- skillsExporting: false,
150
- skillsMarketLoading: false,
151
- skillsMarketLocalLoadedOnce: false,
152
- skillsMarketImportLoadedOnce: false,
153
- sessionPinnedMap: {},
154
- __mainTabSwitchState: {
155
- intent: '',
156
- pendingTarget: '',
157
- pendingConfigMode: '',
158
- ticket: 0
159
- },
160
- sessionsViewMode: 'browser',
161
- sessionsUsageTimeRange: '7d',
162
- sessionsUsageList: [],
163
- sessionsUsageLoadedOnce: false,
164
- sessionsUsageLoadedLimit: 0,
165
- sessionsUsageLoading: false,
166
- sessionsUsageError: '',
167
- sessionsList: [],
168
- sessionsLoadedOnce: false,
169
- sessionsLoading: false,
170
- sessionFilterSource: 'all',
171
- sessionPathFilter: '',
172
- sessionQuery: '',
173
- sessionRoleFilter: 'all',
174
- sessionTimePreset: 'all',
175
- sessionResumeWithYolo: true,
176
- sessionPathOptions: [],
177
- sessionPathOptionsLoading: false,
178
- sessionPathOptionsMap: {
179
- all: [],
180
- codex: [],
181
- claude: [],
182
- gemini: []
183
- },
184
- sessionPathOptionsLoadedMap: {
185
- all: false,
186
- codex: false,
187
- claude: false,
188
- gemini: false
189
- },
190
- sessionPathRequestSeqMap: {
191
- all: 0,
192
- codex: 0,
193
- claude: 0,
194
- gemini: 0
195
- },
196
- sessionExporting: {},
197
- sessionCloning: {},
198
- sessionDeleting: {},
199
- activeSession: null,
200
- activeSessionMessages: [],
201
- activeSessionDetailError: '',
202
- activeSessionDetailClipped: false,
203
- sessionDetailLoading: false,
204
- sessionDetailRequestSeq: 0,
205
- sessionDetailInitialMessageLimit: 80,
206
- sessionDetailFetchStep: 80,
207
- sessionDetailMessageLimit: 80,
208
- sessionDetailMessageLimitCap: 1000,
209
- sessionTimelineActiveKey: '',
210
- sessionTimelineRafId: 0,
211
- sessionTimelineLastSyncAt: 0,
212
- sessionTimelineLastScrollTop: 0,
213
- sessionTimelineLastAnchorY: 0,
214
- sessionTimelineLastDirection: 0,
215
- sessionTimelineEnabled: true,
216
- sessionMessageRefMap: Object.create(null),
217
- sessionMessageRefBinderMap: Object.create(null),
218
- sessionPreviewScrollEl: null,
219
- sessionPreviewContainerEl: null,
220
- sessionPreviewHeaderEl: null,
221
- sessionPreviewHeaderResizeObserver: null,
222
- sessionListRenderEnabled: false,
223
- sessionListVisibleCount: 0,
224
- sessionListInitialBatchSize: 20,
225
- sessionListLoadStep: 40,
226
- sessionPreviewRenderEnabled: false,
227
- sessionTabRenderTicket: 0,
228
- sessionPreviewVisibleCount: 0,
229
- sessionPreviewInitialBatchSize: 12,
230
- sessionPreviewLoadStep: 24,
231
- sessionPreviewPendingVisibleCount: 0,
232
- sessionPreviewLoadingMore: false,
233
- sessionStandalone: false,
234
- sessionStandaloneError: '',
235
- sessionStandaloneText: '',
236
- sessionStandaloneTitle: '',
237
- sessionStandaloneSourceLabel: '',
238
- sessionStandaloneLoading: false,
239
- sessionStandaloneRequestSeq: 0,
240
- speedResults: {},
241
- speedLoading: {},
242
- claudeSpeedResults: {},
243
- claudeSpeedLoading: {},
244
- claudeShareLoading: {},
245
- providerShareLoading: {},
246
- shareCommandPrefix: 'npm start',
247
- providerSwitchInProgress: false,
248
- pendingProviderSwitch: '',
249
- providerSwitchDisplayTarget: '',
250
- healthCheckBatchTotal: 0,
251
- healthCheckBatchDone: 0,
252
- healthCheckBatchFailed: 0,
253
- installPackageManager: 'npm',
254
- installCommandAction: 'install',
255
- installRegistryPreset: 'default',
256
- installRegistryCustom: '',
257
- installStatusTargets: null,
258
- newProvider: { name: '', url: '', key: '', useTransform: false },
259
- resetConfigLoading: false,
260
- editingProvider: { name: '', url: '', key: '', readOnly: false, nonEditable: false },
261
- newModelName: '',
262
- currentClaudeConfig: '',
263
- currentClaudeModel: '',
264
- editingConfig: { name: '', apiKey: '', baseUrl: '', model: '' },
265
- claudeConfigs: {
266
- '智谱GLM': {
267
- apiKey: '',
268
- baseUrl: 'https://open.bigmodel.cn/api/anthropic',
269
- model: 'glm-4.7',
270
- hasKey: false
271
- }
272
- },
273
- newClaudeConfig: {
274
- name: '',
275
- apiKey: '',
276
- baseUrl: 'https://open.bigmodel.cn/api/anthropic',
277
- model: 'glm-4.7'
278
- },
279
- currentOpenclawConfig: '',
280
- openclawConfigs: {
281
- '默认配置': {
282
- content: DEFAULT_OPENCLAW_TEMPLATE
283
- }
284
- },
285
- openclawEditing: { name: '', content: '', lockName: false },
286
- openclawEditorTitle: '添加 OpenClaw 配置',
287
- openclawConfigPath: '',
288
- openclawConfigExists: false,
289
- openclawLineEnding: '\n',
290
- openclawAuthProfilesByProvider: {},
291
- openclawPendingAuthProfileUpdates: {},
292
- openclawFileLoading: false,
293
- openclawSaving: false,
294
- openclawApplying: false,
295
- openclawWorkspaceFileName: 'SOUL.md',
296
- agentsWorkspaceFileName: '',
297
- openclawStructured: {
298
- agentPrimary: '',
299
- agentFallbacks: [],
300
- workspace: '',
301
- timeout: '',
302
- contextTokens: '',
303
- maxConcurrent: '',
304
- envItems: [],
305
- toolsProfile: 'default',
306
- toolsAllow: [],
307
- toolsDeny: []
308
- },
309
- openclawQuick: {
310
- providerName: '',
311
- baseUrl: '',
312
- baseUrlReadOnly: false,
313
- baseUrlDisplayKind: 'missing',
314
- apiKey: '',
315
- apiKeyReadOnly: false,
316
- apiKeyDisplayKind: 'missing',
317
- apiKeySourceKind: '',
318
- apiKeySourceProfileId: '',
319
- apiKeySourceWriteField: '',
320
- apiKeySourceOriginalValue: '',
321
- apiKeySourceCredentialType: '',
322
- apiType: 'openai-responses',
323
- modelId: '',
324
- modelName: '',
325
- contextWindow: '',
326
- maxTokens: '',
327
- setPrimary: true,
328
- overrideProvider: true,
329
- overrideModels: true,
330
- showKey: false
331
- },
332
- openclawAgentsList: [],
333
- openclawProviders: [],
334
- openclawMissingProviders: [],
335
- healthCheckLoading: false,
336
- healthCheckResult: null,
337
- healthCheckRemote: false,
338
- claudeDownloadLoading: false,
339
- claudeDownloadProgress: 0,
340
- claudeDownloadTimer: null,
341
- codexDownloadLoading: false,
342
- codexDownloadProgress: 0,
343
- codexDownloadTimer: null,
344
- settingsTab: 'backup',
345
- sessionTrashEnabled: true,
346
- sessionTrashItems: [],
347
- sessionTrashVisibleCount: SESSION_TRASH_PAGE_SIZE,
348
- sessionTrashTotalCount: 0,
349
- sessionTrashCountLoadedOnce: false,
350
- sessionTrashLoadedOnce: false,
351
- sessionTrashLastLoadFailed: false,
352
- sessionTrashCountRequestToken: 0,
353
- sessionTrashListRequestToken: 0,
354
- sessionTrashCountPendingOptions: null,
355
- sessionTrashPendingOptions: null,
356
- sessionTrashCountLoading: false,
357
- sessionTrashLoading: false,
358
- sessionTrashRestoring: {},
359
- sessionTrashPurging: {},
360
- sessionTrashClearing: false,
361
- claudeImportLoading: false,
362
- codexImportLoading: false,
363
- codexAuthProfiles: [],
364
- forceCompactLayout: false,
365
- taskOrchestrationTabEnabled: true,
366
- taskOrchestration: {
367
- loading: false,
368
- planning: false,
369
- running: false,
370
- queueAdding: false,
371
- queueStarting: false,
372
- retrying: false,
373
- target: '',
374
- title: '',
375
- notes: '',
376
- followUpsText: '',
377
- workflowIdsText: '',
378
- selectedEngine: 'codex',
379
- runMode: 'write',
380
- concurrency: 2,
381
- autoFixRounds: 1,
382
- plan: null,
383
- planFingerprint: '',
384
- planIssues: [],
385
- planWarnings: [],
386
- overviewWarnings: [],
387
- workflows: [],
388
- queue: [],
389
- runs: [],
390
- selectedRunId: '',
391
- workspaceTab: 'queue',
392
- selectedRunDetail: null,
393
- selectedRunLoading: false,
394
- selectedRunError: '',
395
- detailRequestToken: 0,
396
- lastLoadedAt: '',
397
- lastError: ''
398
- },
399
- _taskOrchestrationPollTimer: 0
400
- };
401
- },
402
-
403
- mounted() {
404
- if (typeof this.initI18n === 'function') {
405
- this.initI18n();
406
- }
407
- if (typeof this.t === 'function') {
408
- this.confirmDialogConfirmText = this.t('confirm.ok');
409
- this.confirmDialogCancelText = this.t('confirm.cancel');
410
- this.agentsModalTitle = this.t('modal.agents.title');
411
- this.agentsModalHint = this.t('modal.agents.hint');
412
- }
413
- {
414
- const NAV_STATE_STORAGE_KEY = 'codexmateNavState.v1';
415
- const mainTabSet = new Set(['dashboard', 'config', 'sessions', 'usage', 'orchestration', 'market', 'plugins', 'docs', 'settings']);
416
- let restored = null;
417
- try {
418
- const raw = localStorage.getItem(NAV_STATE_STORAGE_KEY) || '';
419
- restored = raw ? JSON.parse(raw) : null;
420
- } catch (_) {
421
- restored = null;
422
- }
423
- const nextMainTab = restored && typeof restored.mainTab === 'string'
424
- ? restored.mainTab.trim().toLowerCase()
425
- : '';
426
- const nextConfigMode = restored && typeof restored.configMode === 'string'
427
- ? restored.configMode.trim().toLowerCase()
428
- : '';
429
- let urlMainTab = '';
430
- try {
431
- const url = new URL(window.location.href);
432
- if (url.pathname !== '/session') {
433
- urlMainTab = String(url.searchParams.get('tab') || '').trim().toLowerCase();
434
- }
435
- } catch (_) {
436
- urlMainTab = '';
437
- }
438
- const resolvedMainTab = urlMainTab && mainTabSet.has(urlMainTab)
439
- ? urlMainTab
440
- : nextMainTab;
441
- if (nextConfigMode && typeof this.switchConfigMode === 'function') {
442
- this.__navStateRestoring = true;
443
- try {
444
- if (nextConfigMode === 'codex' || nextConfigMode === 'claude' || nextConfigMode === 'openclaw') {
445
- this.configMode = nextConfigMode;
446
- }
447
- if (resolvedMainTab && mainTabSet.has(resolvedMainTab) && resolvedMainTab !== this.mainTab) {
448
- this.switchMainTab(resolvedMainTab);
449
- }
450
- } finally {
451
- this.__navStateRestoring = false;
452
- }
453
- } else if (resolvedMainTab && mainTabSet.has(resolvedMainTab) && resolvedMainTab !== this.mainTab) {
454
- this.__navStateRestoring = true;
455
- try {
456
- this.switchMainTab(resolvedMainTab);
457
- } finally {
458
- this.__navStateRestoring = false;
459
- }
460
- }
461
- }
462
- this.initSessionStandalone();
463
- this.updateCompactLayoutMode();
464
- if (!this.taskOrchestrationTabEnabled && this.mainTab === 'orchestration') {
465
- this.mainTab = 'config';
466
- }
467
- const savedSessionYolo = localStorage.getItem('codexmateSessionResumeYolo');
468
- if (savedSessionYolo === '0' || savedSessionYolo === 'false') {
469
- this.sessionResumeWithYolo = false;
470
- } else if (savedSessionYolo === '1' || savedSessionYolo === 'true') {
471
- this.sessionResumeWithYolo = true;
472
- }
473
- this.restoreSessionFilterCache();
474
- this.restoreSessionPinnedMap();
475
- this.shareCommandPrefix = this.normalizeShareCommandPrefix(localStorage.getItem('codexmateShareCommandPrefix'));
476
- this.sessionTrashEnabled = this.normalizeSessionTrashEnabled(localStorage.getItem('codexmateSessionTrashEnabled'));
477
- this.configTemplateDiffConfirmEnabled = loadConfigTemplateDiffConfirmEnabledFromStorage(localStorage);
478
- window.addEventListener('resize', this.onWindowResize);
479
- window.addEventListener('keydown', this.handleGlobalKeydown);
480
- window.addEventListener('beforeunload', this.handleBeforeUnload);
481
- const savedConfigs = localStorage.getItem('claudeConfigs');
482
- if (savedConfigs) {
483
- try {
484
- this.claudeConfigs = JSON.parse(savedConfigs);
485
- for (const [name, config] of Object.entries(this.claudeConfigs)) {
486
- if (config.apiKey && config.apiKey.includes('****')) {
487
- config.apiKey = '';
488
- config.hasKey = false;
489
- }
490
- }
491
- localStorage.setItem('claudeConfigs', JSON.stringify(this.claudeConfigs));
492
- } catch (e) {
493
- console.error('加载 Claude 配置失败:', e);
494
- }
495
- }
496
- const normalizeOpenclawConfigs = (configs) => {
497
- const source = configs && typeof configs === 'object' && !Array.isArray(configs)
498
- ? configs
499
- : {};
500
- const defaultEntry = source['默认配置']
501
- && typeof source['默认配置'] === 'object'
502
- && !Array.isArray(source['默认配置'])
503
- ? source['默认配置']
504
- : { content: DEFAULT_OPENCLAW_TEMPLATE };
505
- const normalized = {
506
- '默认配置': {
507
- content: typeof defaultEntry.content === 'string' ? defaultEntry.content : DEFAULT_OPENCLAW_TEMPLATE
508
- }
509
- };
510
- for (const [name, value] of Object.entries(source)) {
511
- if (name === '默认配置') continue;
512
- normalized[name] = value;
513
- }
514
- return normalized;
515
- };
516
- const savedOpenclawConfigs = localStorage.getItem('openclawConfigs');
517
- if (savedOpenclawConfigs) {
518
- try {
519
- this.openclawConfigs = normalizeOpenclawConfigs(JSON.parse(savedOpenclawConfigs));
520
- } catch (e) {
521
- console.error('加载 OpenClaw 配置失败:', e);
522
- this.openclawConfigs = normalizeOpenclawConfigs(this.openclawConfigs);
523
- }
524
- } else {
525
- this.openclawConfigs = normalizeOpenclawConfigs(this.openclawConfigs);
526
- }
527
- const configNames = Object.keys(this.openclawConfigs);
528
- if (configNames.length > 0) {
529
- this.currentOpenclawConfig = this.openclawConfigs['默认配置'] ? '默认配置' : configNames[0];
530
- }
531
- const runInitialLoad = () => {
532
- const triggerLoad = async () => {
533
- this._initialLoadTimer = 0;
534
- const startupOk = await this.loadAll();
535
- if (!startupOk) {
536
- return;
537
- }
538
- if (this.mainTab === 'dashboard') {
539
- if (!this.__doctorLoadedOnce) {
540
- this.__doctorLoadedOnce = true;
541
- if (typeof this.runHealthCheck === 'function') {
542
- void this.runHealthCheck({ doctor: true, silent: true });
543
- }
544
- }
545
- }
546
- void this.refreshClaudeSelectionFromSettings({ silent: true });
547
- void this.syncDefaultOpenclawConfigEntry({ silent: true });
548
- };
549
- if (typeof requestAnimationFrame === 'function') {
550
- this._initialLoadRafId = requestAnimationFrame(() => {
551
- this._initialLoadRafId = 0;
552
- if (typeof setTimeout === 'function') {
553
- this._initialLoadTimer = setTimeout(triggerLoad, 120);
554
- return;
555
- }
556
- triggerLoad();
557
- });
558
- return;
559
- }
560
- if (typeof setTimeout === 'function') {
561
- this._initialLoadTimer = setTimeout(triggerLoad, 120);
562
- return;
563
- }
564
- triggerLoad();
565
- };
566
- if (document.readyState === 'complete') {
567
- runInitialLoad();
568
- } else {
569
- this._initialLoadOnWindowLoad = () => {
570
- if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {
571
- window.removeEventListener('load', this._initialLoadOnWindowLoad);
572
- }
573
- this._initialLoadOnWindowLoad = null;
574
- runInitialLoad();
575
- };
576
- window.addEventListener('load', this._initialLoadOnWindowLoad, { once: true });
577
- }
578
- },
579
-
580
- beforeUnmount() {
581
- this.teardownSessionTabRender();
582
- this.cancelScheduledSessionTabDeferredTeardown();
583
- this.disconnectSessionPreviewHeaderResizeObserver();
584
- if (this._initialLoadOnWindowLoad) {
585
- window.removeEventListener('load', this._initialLoadOnWindowLoad);
586
- this._initialLoadOnWindowLoad = null;
587
- }
588
- if (this._initialLoadRafId) {
589
- cancelAnimationFrame(this._initialLoadRafId);
590
- this._initialLoadRafId = 0;
591
- }
592
- if (this._initialLoadTimer) {
593
- clearTimeout(this._initialLoadTimer);
594
- this._initialLoadTimer = 0;
595
- }
596
- window.removeEventListener('resize', this.onWindowResize);
597
- window.removeEventListener('keydown', this.handleGlobalKeydown);
598
- window.removeEventListener('beforeunload', this.handleBeforeUnload);
599
- this.applyCompactLayoutClass(false);
600
- this.stopTaskOrchestrationPolling();
601
- this.sessionPreviewScrollEl = null;
602
- this.sessionPreviewContainerEl = null;
603
- this.sessionPreviewHeaderEl = null;
604
- this.clearSessionTimelineRefs();
605
- },
606
-
607
- computed: createAppComputed(),
608
- methods: createAppMethods()
609
- });
610
-
611
- app.mount('#app');
612
- });
1
+ import {
2
+ DEFAULT_MODEL_AUTO_COMPACT_TOKEN_LIMIT,
3
+ DEFAULT_MODEL_CONTEXT_WINDOW,
4
+ DEFAULT_OPENCLAW_TEMPLATE,
5
+ SESSION_TRASH_PAGE_SIZE
6
+ } from './modules/app.constants.mjs';
7
+ import { createAppComputed } from './modules/app.computed.index.mjs';
8
+ import { createAppMethods } from './modules/app.methods.index.mjs';
9
+ import { loadConfigTemplateDiffConfirmEnabledFromStorage } from './modules/config-template-confirm-pref.mjs';
10
+
11
+ document.addEventListener('DOMContentLoaded', () => {
12
+ if (typeof Vue === 'undefined') {
13
+ console.error('Vue 库未能在 DOMContentLoaded 触发前加载完成。');
14
+ const fallbackTarget = document.querySelector('#app') || document.querySelector('[v-cloak]');
15
+ if (fallbackTarget) {
16
+ fallbackTarget.removeAttribute('v-cloak');
17
+ fallbackTarget.classList.remove('v-cloak');
18
+ fallbackTarget.innerHTML = '';
19
+ const notice = document.createElement('div');
20
+ notice.className = 'fallback-message';
21
+ notice.textContent = 'Web UI 加载失败:Vue 未加载。请检查网络或刷新页面。';
22
+ fallbackTarget.appendChild(notice);
23
+ }
24
+ return;
25
+ }
26
+
27
+ const { createApp } = Vue;
28
+
29
+ const app = createApp({
30
+ data() {
31
+ return {
32
+ lang: 'zh',
33
+ mainTab: 'dashboard',
34
+ configMode: 'codex',
35
+ currentProvider: '',
36
+ currentModel: '',
37
+ serviceTier: 'fast',
38
+ modelReasoningEffort: 'medium',
39
+ modelContextWindowInput: String(DEFAULT_MODEL_CONTEXT_WINDOW),
40
+ modelAutoCompactTokenLimitInput: String(DEFAULT_MODEL_AUTO_COMPACT_TOKEN_LIMIT),
41
+ editingCodexBudgetField: '',
42
+ providersList: [],
43
+ models: [],
44
+ codexModelsLoading: false,
45
+ modelsSource: 'remote',
46
+ modelsHasCurrent: true,
47
+ claudeModels: [],
48
+ claudeModelsSource: 'idle',
49
+ claudeModelsHasCurrent: true,
50
+ claudeModelsLoading: false,
51
+ codexModelsRequestSeq: 0,
52
+ claudeModelsRequestSeq: 0,
53
+ loading: true,
54
+ initError: '',
55
+ message: '',
56
+ messageType: '',
57
+ showAddModal: false,
58
+ showEditModal: false,
59
+ showModelModal: false,
60
+ showModelListModal: false,
61
+ showClaudeConfigModal: false,
62
+ showEditConfigModal: false,
63
+ showOpenclawConfigModal: false,
64
+ showConfigTemplateModal: false,
65
+ showAgentsModal: false,
66
+ showSkillsModal: false,
67
+ showHealthCheckModal: false,
68
+ // Plugins
69
+ pluginsActiveId: 'prompt-templates',
70
+ pluginsLoading: false,
71
+ pluginsError: '',
72
+ promptTemplatesListRaw: [],
73
+ promptTemplatesLoadedOnce: false,
74
+ promptTemplatesKeyword: '',
75
+ promptTemplateSelectedId: '',
76
+ promptTemplateDraftRaw: null,
77
+ promptTemplateVarValuesRaw: {},
78
+ promptTemplatesMode: 'compose',
79
+ promptComposerCommand: '',
80
+ promptComposerPickerVisible: false,
81
+ promptComposerPickerKeyword: '',
82
+ promptComposerSelectedTemplateId: '',
83
+ promptComposerVarValuesRaw: {},
84
+ showPromptTemplateVarModal: false,
85
+ promptTemplateVarDraftName: '',
86
+ promptTemplateVarDraftError: '',
87
+ showConfirmDialog: false,
88
+ confirmDialogTitle: '',
89
+ confirmDialogMessage: '',
90
+ confirmDialogConfirmText: '确认',
91
+ confirmDialogCancelText: '取消',
92
+ confirmDialogDanger: false,
93
+ confirmDialogConfirmDisabled: false,
94
+ confirmDialogDisableWhen: null,
95
+ confirmDialogResolver: null,
96
+ configTemplateContent: '',
97
+ configTemplateApplying: false,
98
+ configTemplateDiffVisible: false,
99
+ configTemplateDiffLoading: false,
100
+ configTemplateDiffError: '',
101
+ configTemplateDiffLines: [],
102
+ configTemplateDiffStats: {
103
+ added: 0,
104
+ removed: 0,
105
+ unchanged: 0
106
+ },
107
+ configTemplateDiffHasChangesValue: false,
108
+ configTemplateDiffFingerprint: '',
109
+ _configTemplateDiffPreviewRequestToken: null,
110
+ configTemplateDiffConfirmEnabled: true,
111
+ codexApplying: false,
112
+ _pendingCodexApplyOptions: null,
113
+ agentsContent: '',
114
+ agentsPath: '',
115
+ agentsPath: '',
116
+ agentsExists: false,
117
+ agentsLineEnding: '\n',
118
+ agentsLoading: false,
119
+ agentsSaving: false,
120
+ agentsOriginalContent: '',
121
+ agentsDiffVisible: false,
122
+ agentsDiffLoading: false,
123
+ agentsDiffError: '',
124
+ agentsDiffLines: [],
125
+ agentsDiffStats: {
126
+ added: 0,
127
+ removed: 0,
128
+ unchanged: 0
129
+ },
130
+ agentsDiffTruncated: false,
131
+ agentsDiffHasChangesValue: false,
132
+ agentsDiffFingerprint: '',
133
+ agentsContext: 'codex',
134
+ agentsModalTitle: 'AGENTS.md 编辑器',
135
+ agentsModalHint: '保存后会写入目标 AGENTS.md(与 config.toml 同级)。',
136
+ skillsTargetApp: 'codex',
137
+ skillsRootPath: '',
138
+ skillsList: [],
139
+ skillsSelectedNames: [],
140
+ skillsLoading: false,
141
+ skillsDeleting: false,
142
+ skillsKeyword: '',
143
+ skillsStatusFilter: 'all',
144
+ skillsImportList: [],
145
+ skillsImportSelectedKeys: [],
146
+ skillsScanningImports: false,
147
+ skillsImporting: false,
148
+ skillsZipImporting: false,
149
+ skillsExporting: false,
150
+ skillsMarketLoading: false,
151
+ skillsMarketLocalLoadedOnce: false,
152
+ skillsMarketImportLoadedOnce: false,
153
+ sessionPinnedMap: {},
154
+ __mainTabSwitchState: {
155
+ intent: '',
156
+ pendingTarget: '',
157
+ pendingConfigMode: '',
158
+ ticket: 0
159
+ },
160
+ sessionsViewMode: 'browser',
161
+ sessionsUsageTimeRange: '7d',
162
+ sessionsUsageList: [],
163
+ sessionsUsageCompareEnabled: false,
164
+ sessionsUsageSelectedDayKey: '',
165
+ sessionsUsageLoadedOnce: false,
166
+ sessionsUsageLoadedLimit: 0,
167
+ sessionsUsageLoading: false,
168
+ sessionsUsageError: '',
169
+ sessionsList: [],
170
+ sessionsLoadedOnce: false,
171
+ sessionsLoading: false,
172
+ sessionFilterSource: 'all',
173
+ sessionPathFilter: '',
174
+ sessionQuery: '',
175
+ sessionRoleFilter: 'all',
176
+ sessionTimePreset: 'all',
177
+ sessionSortMode: 'time',
178
+ sessionResumeWithYolo: true,
179
+ sessionPathOptions: [],
180
+ sessionPathOptionsLoading: false,
181
+ sessionPathOptionsMap: {
182
+ all: [],
183
+ codex: [],
184
+ claude: [],
185
+ gemini: []
186
+ },
187
+ sessionPathOptionsLoadedMap: {
188
+ all: false,
189
+ codex: false,
190
+ claude: false,
191
+ gemini: false
192
+ },
193
+ sessionPathRequestSeqMap: {
194
+ all: 0,
195
+ codex: 0,
196
+ claude: 0,
197
+ gemini: 0
198
+ },
199
+ sessionExporting: {},
200
+ sessionConverting: {},
201
+ sessionCloning: {},
202
+ sessionDeleting: {},
203
+ activeSession: null,
204
+ activeSessionMessages: [],
205
+ activeSessionDetailError: '',
206
+ activeSessionDetailClipped: false,
207
+ sessionDetailLoading: false,
208
+ sessionDetailRequestSeq: 0,
209
+ sessionDetailInitialMessageLimit: 80,
210
+ sessionDetailFetchStep: 80,
211
+ sessionDetailMessageLimit: 80,
212
+ sessionDetailMessageLimitCap: 1000,
213
+ sessionTimelineActiveKey: '',
214
+ sessionTimelineRafId: 0,
215
+ sessionTimelineLastSyncAt: 0,
216
+ sessionTimelineLastScrollTop: 0,
217
+ sessionTimelineLastAnchorY: 0,
218
+ sessionTimelineLastDirection: 0,
219
+ sessionTimelineEnabled: true,
220
+ sessionMessageRefMap: Object.create(null),
221
+ sessionMessageRefBinderMap: Object.create(null),
222
+ sessionPreviewScrollEl: null,
223
+ sessionPreviewContainerEl: null,
224
+ sessionPreviewHeaderEl: null,
225
+ sessionPreviewHeaderResizeObserver: null,
226
+ sessionListRenderEnabled: false,
227
+ sessionListVisibleCount: 0,
228
+ sessionListInitialBatchSize: 20,
229
+ sessionListLoadStep: 40,
230
+ sessionPreviewRenderEnabled: false,
231
+ sessionTabRenderTicket: 0,
232
+ sessionPreviewVisibleCount: 0,
233
+ sessionPreviewInitialBatchSize: 12,
234
+ sessionPreviewLoadStep: 24,
235
+ sessionPreviewPendingVisibleCount: 0,
236
+ sessionPreviewLoadingMore: false,
237
+ sessionStandalone: false,
238
+ sessionStandaloneError: '',
239
+ sessionStandaloneText: '',
240
+ sessionStandaloneTitle: '',
241
+ sessionStandaloneSourceLabel: '',
242
+ sessionStandaloneLoading: false,
243
+ sessionStandaloneRequestSeq: 0,
244
+ speedResults: {},
245
+ speedLoading: {},
246
+ claudeSpeedResults: {},
247
+ claudeSpeedLoading: {},
248
+ claudeShareLoading: {},
249
+ providerShareLoading: {},
250
+ shareCommandPrefix: 'npm start',
251
+ providerSwitchInProgress: false,
252
+ pendingProviderSwitch: '',
253
+ providerSwitchDisplayTarget: '',
254
+ healthCheckBatchTotal: 0,
255
+ healthCheckBatchDone: 0,
256
+ healthCheckBatchFailed: 0,
257
+ installPackageManager: 'npm',
258
+ installCommandAction: 'install',
259
+ installRegistryPreset: 'default',
260
+ installRegistryCustom: '',
261
+ installStatusTargets: null,
262
+ newProvider: { name: '', url: '', key: '', useTransform: false },
263
+ resetConfigLoading: false,
264
+ editingProvider: { name: '', url: '', key: '', readOnly: false, nonEditable: false },
265
+ newModelName: '',
266
+ currentClaudeConfig: '',
267
+ currentClaudeModel: '',
268
+ claudeCustomModelDraft: '',
269
+ editingConfig: { name: '', apiKey: '', baseUrl: '', model: '' },
270
+ claudeConfigs: {
271
+ '智谱GLM': {
272
+ apiKey: '',
273
+ baseUrl: 'https://open.bigmodel.cn/api/anthropic',
274
+ model: 'glm-4.7',
275
+ hasKey: false
276
+ }
277
+ },
278
+ newClaudeConfig: {
279
+ name: '',
280
+ apiKey: '',
281
+ baseUrl: 'https://open.bigmodel.cn/api/anthropic',
282
+ model: 'glm-4.7'
283
+ },
284
+ currentOpenclawConfig: '',
285
+ openclawConfigs: {
286
+ '默认配置': {
287
+ content: DEFAULT_OPENCLAW_TEMPLATE
288
+ }
289
+ },
290
+ openclawEditing: { name: '', content: '', lockName: false },
291
+ openclawEditorTitle: '添加 OpenClaw 配置',
292
+ openclawConfigPath: '',
293
+ openclawConfigExists: false,
294
+ openclawLineEnding: '\n',
295
+ openclawAuthProfilesByProvider: {},
296
+ openclawPendingAuthProfileUpdates: {},
297
+ openclawFileLoading: false,
298
+ openclawSaving: false,
299
+ openclawApplying: false,
300
+ openclawWorkspaceFileName: 'SOUL.md',
301
+ agentsWorkspaceFileName: '',
302
+ openclawStructured: {
303
+ agentPrimary: '',
304
+ agentFallbacks: [],
305
+ workspace: '',
306
+ timeout: '',
307
+ contextTokens: '',
308
+ maxConcurrent: '',
309
+ envItems: [],
310
+ toolsProfile: 'default',
311
+ toolsAllow: [],
312
+ toolsDeny: []
313
+ },
314
+ openclawQuick: {
315
+ providerName: '',
316
+ baseUrl: '',
317
+ baseUrlReadOnly: false,
318
+ baseUrlDisplayKind: 'missing',
319
+ apiKey: '',
320
+ apiKeyReadOnly: false,
321
+ apiKeyDisplayKind: 'missing',
322
+ apiKeySourceKind: '',
323
+ apiKeySourceProfileId: '',
324
+ apiKeySourceWriteField: '',
325
+ apiKeySourceOriginalValue: '',
326
+ apiKeySourceCredentialType: '',
327
+ apiType: 'openai-responses',
328
+ modelId: '',
329
+ modelName: '',
330
+ contextWindow: '',
331
+ maxTokens: '',
332
+ setPrimary: true,
333
+ overrideProvider: true,
334
+ overrideModels: true,
335
+ showKey: false
336
+ },
337
+ openclawAgentsList: [],
338
+ openclawProviders: [],
339
+ openclawMissingProviders: [],
340
+ healthCheckLoading: false,
341
+ healthCheckResult: null,
342
+ healthCheckRemote: false,
343
+ claudeDownloadLoading: false,
344
+ claudeDownloadProgress: 0,
345
+ claudeDownloadTimer: null,
346
+ codexDownloadLoading: false,
347
+ codexDownloadProgress: 0,
348
+ codexDownloadTimer: null,
349
+ settingsTab: 'backup',
350
+ sessionTrashEnabled: true,
351
+ sessionTrashItems: [],
352
+ sessionTrashVisibleCount: SESSION_TRASH_PAGE_SIZE,
353
+ sessionTrashTotalCount: 0,
354
+ sessionTrashCountLoadedOnce: false,
355
+ sessionTrashLoadedOnce: false,
356
+ sessionTrashLastLoadFailed: false,
357
+ sessionTrashCountRequestToken: 0,
358
+ sessionTrashListRequestToken: 0,
359
+ sessionTrashCountPendingOptions: null,
360
+ sessionTrashPendingOptions: null,
361
+ sessionTrashCountLoading: false,
362
+ sessionTrashLoading: false,
363
+ sessionTrashRestoring: {},
364
+ sessionTrashPurging: {},
365
+ sessionTrashClearing: false,
366
+ claudeImportLoading: false,
367
+ codexImportLoading: false,
368
+ codexAuthProfiles: [],
369
+ forceCompactLayout: false,
370
+ taskOrchestrationTabEnabled: true,
371
+ taskOrchestration: {
372
+ loading: false,
373
+ planning: false,
374
+ running: false,
375
+ queueAdding: false,
376
+ queueStarting: false,
377
+ retrying: false,
378
+ target: '',
379
+ title: '',
380
+ notes: '',
381
+ followUpsText: '',
382
+ workflowIdsText: '',
383
+ selectedEngine: 'codex',
384
+ runMode: 'write',
385
+ concurrency: 2,
386
+ autoFixRounds: 1,
387
+ plan: null,
388
+ planFingerprint: '',
389
+ planIssues: [],
390
+ planWarnings: [],
391
+ overviewWarnings: [],
392
+ workflows: [],
393
+ queue: [],
394
+ runs: [],
395
+ selectedRunId: '',
396
+ workspaceTab: 'queue',
397
+ selectedRunDetail: null,
398
+ selectedRunLoading: false,
399
+ selectedRunError: '',
400
+ detailRequestToken: 0,
401
+ lastLoadedAt: '',
402
+ lastError: ''
403
+ },
404
+ _taskOrchestrationPollTimer: 0
405
+ };
406
+ },
407
+
408
+ mounted() {
409
+ if (typeof this.initI18n === 'function') {
410
+ this.initI18n();
411
+ }
412
+ if (typeof this.t === 'function') {
413
+ this.confirmDialogConfirmText = this.t('confirm.ok');
414
+ this.confirmDialogCancelText = this.t('confirm.cancel');
415
+ this.agentsModalTitle = this.t('modal.agents.title');
416
+ this.agentsModalHint = this.t('modal.agents.hint');
417
+ }
418
+ {
419
+ const NAV_STATE_STORAGE_KEY = 'codexmateNavState.v1';
420
+ const mainTabSet = new Set(['dashboard', 'config', 'sessions', 'usage', 'orchestration', 'market', 'plugins', 'docs', 'settings']);
421
+ let restored = null;
422
+ try {
423
+ const raw = localStorage.getItem(NAV_STATE_STORAGE_KEY) || '';
424
+ restored = raw ? JSON.parse(raw) : null;
425
+ } catch (_) {
426
+ restored = null;
427
+ }
428
+ const nextMainTab = restored && typeof restored.mainTab === 'string'
429
+ ? restored.mainTab.trim().toLowerCase()
430
+ : '';
431
+ const nextConfigMode = restored && typeof restored.configMode === 'string'
432
+ ? restored.configMode.trim().toLowerCase()
433
+ : '';
434
+ let urlMainTab = '';
435
+ try {
436
+ const url = new URL(window.location.href);
437
+ if (url.pathname !== '/session') {
438
+ urlMainTab = String(url.searchParams.get('tab') || '').trim().toLowerCase();
439
+ }
440
+ } catch (_) {
441
+ urlMainTab = '';
442
+ }
443
+ const resolvedMainTab = urlMainTab && mainTabSet.has(urlMainTab)
444
+ ? urlMainTab
445
+ : nextMainTab;
446
+ if (nextConfigMode && typeof this.switchConfigMode === 'function') {
447
+ this.__navStateRestoring = true;
448
+ try {
449
+ if (nextConfigMode === 'codex' || nextConfigMode === 'claude' || nextConfigMode === 'openclaw') {
450
+ this.configMode = nextConfigMode;
451
+ }
452
+ if (resolvedMainTab && mainTabSet.has(resolvedMainTab) && resolvedMainTab !== this.mainTab) {
453
+ this.switchMainTab(resolvedMainTab);
454
+ }
455
+ } finally {
456
+ this.__navStateRestoring = false;
457
+ }
458
+ } else if (resolvedMainTab && mainTabSet.has(resolvedMainTab) && resolvedMainTab !== this.mainTab) {
459
+ this.__navStateRestoring = true;
460
+ try {
461
+ this.switchMainTab(resolvedMainTab);
462
+ } finally {
463
+ this.__navStateRestoring = false;
464
+ }
465
+ }
466
+ }
467
+ this.initSessionStandalone();
468
+ this.updateCompactLayoutMode();
469
+ if (!this.taskOrchestrationTabEnabled && this.mainTab === 'orchestration') {
470
+ this.mainTab = 'config';
471
+ }
472
+ const savedSessionYolo = localStorage.getItem('codexmateSessionResumeYolo');
473
+ if (savedSessionYolo === '0' || savedSessionYolo === 'false') {
474
+ this.sessionResumeWithYolo = false;
475
+ } else if (savedSessionYolo === '1' || savedSessionYolo === 'true') {
476
+ this.sessionResumeWithYolo = true;
477
+ }
478
+ this.restoreSessionFilterCache();
479
+ this.restoreSessionPinnedMap();
480
+ this.shareCommandPrefix = this.normalizeShareCommandPrefix(localStorage.getItem('codexmateShareCommandPrefix'));
481
+ this.sessionTrashEnabled = this.normalizeSessionTrashEnabled(localStorage.getItem('codexmateSessionTrashEnabled'));
482
+ this.configTemplateDiffConfirmEnabled = loadConfigTemplateDiffConfirmEnabledFromStorage(localStorage);
483
+ window.addEventListener('resize', this.onWindowResize);
484
+ window.addEventListener('keydown', this.handleGlobalKeydown);
485
+ window.addEventListener('beforeunload', this.handleBeforeUnload);
486
+ const savedConfigs = localStorage.getItem('claudeConfigs');
487
+ if (savedConfigs) {
488
+ try {
489
+ this.claudeConfigs = JSON.parse(savedConfigs);
490
+ for (const [name, config] of Object.entries(this.claudeConfigs)) {
491
+ if (config.apiKey && config.apiKey.includes('****')) {
492
+ config.apiKey = '';
493
+ config.hasKey = false;
494
+ }
495
+ }
496
+ localStorage.setItem('claudeConfigs', JSON.stringify(this.claudeConfigs));
497
+ } catch (e) {
498
+ console.error('加载 Claude 配置失败:', e);
499
+ }
500
+ }
501
+ if (!this.currentClaudeConfig) {
502
+ const claudeConfigNames = Object.keys(this.claudeConfigs || {});
503
+ if (claudeConfigNames.length > 0) {
504
+ this.currentClaudeConfig = claudeConfigNames[0];
505
+ const initialClaudeConfig = this.claudeConfigs[this.currentClaudeConfig];
506
+ this.currentClaudeModel = initialClaudeConfig && initialClaudeConfig.model ? initialClaudeConfig.model : '';
507
+ }
508
+ }
509
+ const normalizeOpenclawConfigs = (configs) => {
510
+ const source = configs && typeof configs === 'object' && !Array.isArray(configs)
511
+ ? configs
512
+ : {};
513
+ const defaultEntry = source['默认配置']
514
+ && typeof source['默认配置'] === 'object'
515
+ && !Array.isArray(source['默认配置'])
516
+ ? source['默认配置']
517
+ : { content: DEFAULT_OPENCLAW_TEMPLATE };
518
+ const normalized = {
519
+ '默认配置': {
520
+ content: typeof defaultEntry.content === 'string' ? defaultEntry.content : DEFAULT_OPENCLAW_TEMPLATE
521
+ }
522
+ };
523
+ for (const [name, value] of Object.entries(source)) {
524
+ if (name === '默认配置') continue;
525
+ normalized[name] = value;
526
+ }
527
+ return normalized;
528
+ };
529
+ const savedOpenclawConfigs = localStorage.getItem('openclawConfigs');
530
+ if (savedOpenclawConfigs) {
531
+ try {
532
+ this.openclawConfigs = normalizeOpenclawConfigs(JSON.parse(savedOpenclawConfigs));
533
+ } catch (e) {
534
+ console.error('加载 OpenClaw 配置失败:', e);
535
+ this.openclawConfigs = normalizeOpenclawConfigs(this.openclawConfigs);
536
+ }
537
+ } else {
538
+ this.openclawConfigs = normalizeOpenclawConfigs(this.openclawConfigs);
539
+ }
540
+ const configNames = Object.keys(this.openclawConfigs);
541
+ if (configNames.length > 0) {
542
+ this.currentOpenclawConfig = this.openclawConfigs['默认配置'] ? '默认配置' : configNames[0];
543
+ }
544
+ const runInitialLoad = () => {
545
+ const triggerLoad = async () => {
546
+ this._initialLoadTimer = 0;
547
+ const startupOk = await this.loadAll();
548
+ if (!startupOk) {
549
+ return;
550
+ }
551
+ if (this.mainTab === 'dashboard') {
552
+ if (!this.__doctorLoadedOnce) {
553
+ this.__doctorLoadedOnce = true;
554
+ if (typeof this.runHealthCheck === 'function') {
555
+ void this.runHealthCheck({ doctor: true, silent: true });
556
+ }
557
+ }
558
+ }
559
+ void this.refreshClaudeSelectionFromSettings({ silent: true });
560
+ void this.syncDefaultOpenclawConfigEntry({ silent: true });
561
+ };
562
+ if (typeof requestAnimationFrame === 'function') {
563
+ this._initialLoadRafId = requestAnimationFrame(() => {
564
+ this._initialLoadRafId = 0;
565
+ if (typeof setTimeout === 'function') {
566
+ this._initialLoadTimer = setTimeout(triggerLoad, 120);
567
+ return;
568
+ }
569
+ triggerLoad();
570
+ });
571
+ return;
572
+ }
573
+ if (typeof setTimeout === 'function') {
574
+ this._initialLoadTimer = setTimeout(triggerLoad, 120);
575
+ return;
576
+ }
577
+ triggerLoad();
578
+ };
579
+ if (document.readyState === 'complete') {
580
+ runInitialLoad();
581
+ } else {
582
+ this._initialLoadOnWindowLoad = () => {
583
+ if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {
584
+ window.removeEventListener('load', this._initialLoadOnWindowLoad);
585
+ }
586
+ this._initialLoadOnWindowLoad = null;
587
+ runInitialLoad();
588
+ };
589
+ window.addEventListener('load', this._initialLoadOnWindowLoad, { once: true });
590
+ }
591
+ },
592
+
593
+ beforeUnmount() {
594
+ this.teardownSessionTabRender();
595
+ this.cancelScheduledSessionTabDeferredTeardown();
596
+ this.disconnectSessionPreviewHeaderResizeObserver();
597
+ if (this._initialLoadOnWindowLoad) {
598
+ window.removeEventListener('load', this._initialLoadOnWindowLoad);
599
+ this._initialLoadOnWindowLoad = null;
600
+ }
601
+ if (this._initialLoadRafId) {
602
+ cancelAnimationFrame(this._initialLoadRafId);
603
+ this._initialLoadRafId = 0;
604
+ }
605
+ if (this._initialLoadTimer) {
606
+ clearTimeout(this._initialLoadTimer);
607
+ this._initialLoadTimer = 0;
608
+ }
609
+ window.removeEventListener('resize', this.onWindowResize);
610
+ window.removeEventListener('keydown', this.handleGlobalKeydown);
611
+ window.removeEventListener('beforeunload', this.handleBeforeUnload);
612
+ this.applyCompactLayoutClass(false);
613
+ this.stopTaskOrchestrationPolling();
614
+ this.sessionPreviewScrollEl = null;
615
+ this.sessionPreviewContainerEl = null;
616
+ this.sessionPreviewHeaderEl = null;
617
+ this.clearSessionTimelineRefs();
618
+ },
619
+
620
+ computed: createAppComputed(),
621
+ methods: createAppMethods()
622
+ });
623
+
624
+ app.mount('#app');
625
+ });