codexmate 0.0.24 → 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.
- package/README.md +416 -391
- package/README.zh.md +349 -324
- package/cli/agents-files.js +224 -224
- package/cli/archive-helpers.js +446 -446
- package/cli/auth-profiles.js +375 -375
- package/cli/builtin-proxy.js +1079 -1044
- package/cli/claude-proxy.js +1022 -998
- package/cli/config-bootstrap.js +384 -384
- package/cli/config-health.js +338 -338
- package/cli/doctor-core.js +903 -903
- package/cli/import-skills-url.js +356 -334
- package/cli/openai-bridge.js +997 -950
- package/cli/openclaw-config.js +629 -629
- package/cli/session-convert-args.js +65 -0
- package/cli/session-convert-io.js +82 -0
- package/cli/session-convert.js +43 -0
- package/cli/session-usage.concurrent.js +28 -28
- package/cli/session-usage.js +118 -112
- package/cli/session-usage.models.js +176 -176
- package/cli/skills.js +1141 -1141
- package/cli/zip-commands.js +510 -510
- package/cli.js +15218 -13310
- package/lib/automation.js +404 -0
- package/lib/cli-file-utils.js +151 -151
- package/lib/cli-models-utils.js +379 -379
- package/lib/cli-network-utils.js +190 -190
- package/lib/cli-path-utils.js +85 -69
- package/lib/cli-session-utils.js +121 -121
- package/lib/cli-sessions.js +417 -386
- package/lib/cli-utils.js +155 -155
- package/lib/download-artifacts.js +92 -77
- package/lib/mcp-stdio.js +453 -440
- package/lib/task-orchestrator.js +869 -869
- package/lib/text-diff.js +303 -303
- package/lib/workflow-engine.js +340 -340
- package/package.json +74 -77
- package/plugins/README.md +20 -20
- package/plugins/README.zh-CN.md +20 -20
- package/plugins/prompt-templates/comment-polish/index.mjs +25 -25
- package/plugins/prompt-templates/computed.mjs +253 -253
- package/plugins/prompt-templates/index.mjs +8 -8
- package/plugins/prompt-templates/manifest.mjs +15 -15
- package/plugins/prompt-templates/methods.mjs +619 -619
- package/plugins/prompt-templates/overview.mjs +90 -90
- package/plugins/prompt-templates/ownership.mjs +19 -19
- package/plugins/prompt-templates/rule-ack/index.mjs +21 -21
- package/plugins/prompt-templates/storage.mjs +64 -64
- package/plugins/registry.mjs +16 -16
- package/web-ui/app.js +625 -609
- package/web-ui/index.html +35 -35
- package/web-ui/logic.agents-diff.mjs +386 -386
- package/web-ui/logic.claude.mjs +168 -168
- package/web-ui/logic.mjs +5 -5
- package/web-ui/logic.runtime.mjs +128 -128
- package/web-ui/logic.session-convert.mjs +70 -0
- package/web-ui/logic.sessions.mjs +709 -614
- package/web-ui/modules/api.mjs +90 -90
- package/web-ui/modules/app.computed.dashboard.mjs +171 -126
- package/web-ui/modules/app.computed.index.mjs +17 -17
- package/web-ui/modules/app.computed.main-tabs.mjs +205 -205
- package/web-ui/modules/app.computed.session.mjs +946 -653
- package/web-ui/modules/app.constants.mjs +15 -15
- package/web-ui/modules/app.methods.agents.mjs +632 -632
- package/web-ui/modules/app.methods.claude-config.mjs +179 -174
- package/web-ui/modules/app.methods.codex-config.mjs +860 -784
- package/web-ui/modules/app.methods.index.mjs +92 -92
- package/web-ui/modules/app.methods.install.mjs +205 -177
- package/web-ui/modules/app.methods.navigation.mjs +743 -695
- package/web-ui/modules/app.methods.openclaw-core.mjs +814 -814
- package/web-ui/modules/app.methods.openclaw-editing.mjs +372 -372
- package/web-ui/modules/app.methods.openclaw-persist.mjs +369 -369
- package/web-ui/modules/app.methods.providers.mjs +404 -404
- package/web-ui/modules/app.methods.runtime.mjs +345 -345
- package/web-ui/modules/app.methods.session-actions.mjs +596 -537
- package/web-ui/modules/app.methods.session-browser.mjs +985 -698
- package/web-ui/modules/app.methods.session-timeline.mjs +479 -448
- package/web-ui/modules/app.methods.session-trash.mjs +424 -422
- package/web-ui/modules/app.methods.startup-claude.mjs +522 -417
- package/web-ui/modules/app.methods.task-orchestration.mjs +556 -556
- package/web-ui/modules/config-mode.computed.mjs +124 -124
- package/web-ui/modules/config-template-confirm-pref.mjs +33 -33
- package/web-ui/modules/i18n.dict.mjs +2113 -2039
- package/web-ui/modules/i18n.mjs +56 -56
- package/web-ui/modules/plugins.computed.mjs +3 -3
- package/web-ui/modules/plugins.methods.mjs +3 -3
- package/web-ui/modules/plugins.storage.mjs +11 -11
- package/web-ui/modules/sessions-filters-url.mjs +85 -85
- package/web-ui/modules/skills.computed.mjs +107 -107
- package/web-ui/modules/skills.methods.mjs +481 -481
- package/web-ui/partials/index/layout-footer.html +13 -13
- package/web-ui/partials/index/layout-header.html +475 -465
- package/web-ui/partials/index/modal-config-template-agents.html +174 -174
- package/web-ui/partials/index/modal-confirm-toast.html +32 -32
- package/web-ui/partials/index/modal-health-check.html +45 -45
- package/web-ui/partials/index/modal-openclaw-config.html +280 -280
- package/web-ui/partials/index/modal-skills.html +200 -200
- package/web-ui/partials/index/modals-basic.html +165 -165
- package/web-ui/partials/index/panel-config-claude.html +184 -179
- package/web-ui/partials/index/panel-config-codex.html +283 -283
- package/web-ui/partials/index/panel-config-openclaw.html +83 -83
- package/web-ui/partials/index/panel-dashboard.html +186 -186
- package/web-ui/partials/index/panel-docs.html +147 -147
- package/web-ui/partials/index/panel-market.html +177 -177
- package/web-ui/partials/index/panel-orchestration.html +391 -391
- package/web-ui/partials/index/panel-plugins.html +279 -279
- package/web-ui/partials/index/panel-sessions.html +326 -301
- package/web-ui/partials/index/panel-settings.html +258 -258
- package/web-ui/partials/index/panel-usage.html +342 -354
- package/{res → web-ui/res}/json5.min.js +1 -1
- package/{res → web-ui/res}/vue.global.prod.js +13 -13
- package/web-ui/session-helpers.mjs +576 -573
- package/web-ui/source-bundle.cjs +233 -233
- package/web-ui/styles/base-theme.css +268 -264
- package/web-ui/styles/controls-forms.css +423 -376
- package/web-ui/styles/dashboard.css +274 -274
- package/web-ui/styles/docs-panel.css +247 -247
- package/web-ui/styles/feedback.css +108 -108
- package/web-ui/styles/health-check-dialog.css +144 -144
- package/web-ui/styles/layout-shell.css +603 -602
- package/web-ui/styles/modals-core.css +464 -464
- package/web-ui/styles/navigation-panels.css +390 -390
- package/web-ui/styles/openclaw-structured.css +266 -266
- package/web-ui/styles/plugins-panel.css +523 -523
- package/web-ui/styles/responsive.css +454 -456
- package/web-ui/styles/sessions-list.css +415 -400
- package/web-ui/styles/sessions-preview.css +411 -411
- package/web-ui/styles/sessions-toolbar-trash.css +330 -268
- package/web-ui/styles/sessions-usage.css +945 -888
- package/web-ui/styles/settings-panel.css +166 -166
- package/web-ui/styles/skills-list.css +303 -303
- package/web-ui/styles/skills-market.css +406 -406
- package/web-ui/styles/task-orchestration.css +822 -822
- package/web-ui/styles/titles-cards.css +408 -408
- package/web-ui/styles.css +21 -21
- package/web-ui.html +17 -17
- /package/{res → web-ui/res}/logo-pack.webp +0 -0
|
@@ -1,537 +1,596 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeConfigTemplateDiffConfirmEnabled,
|
|
3
|
-
persistConfigTemplateDiffConfirmEnabledToStorage
|
|
4
|
-
} from './config-template-confirm-pref.mjs';
|
|
5
|
-
|
|
6
|
-
export function createSessionActionMethods(options = {}) {
|
|
7
|
-
const {
|
|
8
|
-
api,
|
|
9
|
-
apiBase
|
|
10
|
-
} = options;
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const sessionId =
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (!
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
this.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
1
|
+
import {
|
|
2
|
+
normalizeConfigTemplateDiffConfirmEnabled,
|
|
3
|
+
persistConfigTemplateDiffConfirmEnabledToStorage
|
|
4
|
+
} from './config-template-confirm-pref.mjs';
|
|
5
|
+
|
|
6
|
+
export function createSessionActionMethods(options = {}) {
|
|
7
|
+
const {
|
|
8
|
+
api,
|
|
9
|
+
apiBase
|
|
10
|
+
} = options;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
isDerivedSessionId(value) {
|
|
14
|
+
const sessionId = typeof value === 'string' ? value.trim() : String(value || '');
|
|
15
|
+
if (!sessionId) return false;
|
|
16
|
+
return /-\d{8}-\d{6}-[0-9a-f]{6}$/i.test(sessionId);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
isDerivedSession(session) {
|
|
20
|
+
if (!session || typeof session !== 'object') return false;
|
|
21
|
+
if (session.derived === true) return true;
|
|
22
|
+
if (this.isDerivedSessionId(session.sessionId)) return true;
|
|
23
|
+
const rawFilePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
|
|
24
|
+
if (!rawFilePath) return false;
|
|
25
|
+
const normalized = rawFilePath.replace(/\\/g, '/');
|
|
26
|
+
if (normalized.includes('/.codexmate/sessions/derived/')) return true;
|
|
27
|
+
if (normalized.includes('/codexmate-derived/')) return true;
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getSessionStandaloneContext() {
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(window.location.href);
|
|
34
|
+
if (url.pathname !== '/session') {
|
|
35
|
+
return { requested: false, params: null, error: '' };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const source = (url.searchParams.get('source') || '').trim().toLowerCase();
|
|
39
|
+
const sessionId = (url.searchParams.get('sessionId') || url.searchParams.get('id') || '').trim();
|
|
40
|
+
const filePath = (url.searchParams.get('filePath') || url.searchParams.get('path') || '').trim();
|
|
41
|
+
const maxMessagesRaw = (url.searchParams.get('maxMessages') || '').trim();
|
|
42
|
+
const maxMessages = Number(maxMessagesRaw);
|
|
43
|
+
let error = '';
|
|
44
|
+
if (!source) {
|
|
45
|
+
error = '缺少 source 参数';
|
|
46
|
+
} else if (source !== 'codex' && source !== 'claude') {
|
|
47
|
+
error = 'source 仅支持 codex 或 claude';
|
|
48
|
+
}
|
|
49
|
+
if (!sessionId && !filePath) {
|
|
50
|
+
error = error ? `${error},还缺少 sessionId 或 filePath` : '缺少 sessionId 或 filePath 参数';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (error) {
|
|
54
|
+
return { requested: true, params: null, error };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
requested: true,
|
|
59
|
+
params: {
|
|
60
|
+
source,
|
|
61
|
+
sessionId,
|
|
62
|
+
filePath,
|
|
63
|
+
maxMessages: Number.isFinite(maxMessages) && maxMessages > 0 ? Math.floor(maxMessages) : 0
|
|
64
|
+
},
|
|
65
|
+
error: ''
|
|
66
|
+
};
|
|
67
|
+
} catch (_) {
|
|
68
|
+
return { requested: false, params: null, error: '' };
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
initSessionStandalone() {
|
|
73
|
+
const context = this.getSessionStandaloneContext();
|
|
74
|
+
if (!context.requested) return;
|
|
75
|
+
|
|
76
|
+
this.sessionStandalone = true;
|
|
77
|
+
this.mainTab = 'sessions';
|
|
78
|
+
this.prepareSessionTabRender();
|
|
79
|
+
|
|
80
|
+
if (context.error || !context.params) {
|
|
81
|
+
this.sessionStandaloneError = `会话链接参数不完整:${context.error || '参数解析失败'}`;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const sourceLabel = context.params.source === 'codex' ? 'Codex' : 'Claude Code';
|
|
86
|
+
this.activeSession = {
|
|
87
|
+
source: context.params.source,
|
|
88
|
+
sourceLabel,
|
|
89
|
+
sessionId: context.params.sessionId,
|
|
90
|
+
filePath: context.params.filePath,
|
|
91
|
+
title: context.params.sessionId || context.params.filePath || '会话',
|
|
92
|
+
maxMessages: context.params.maxMessages || 50
|
|
93
|
+
};
|
|
94
|
+
this.activeSessionMessages = [];
|
|
95
|
+
this.activeSessionDetailError = '';
|
|
96
|
+
this.activeSessionDetailClipped = false;
|
|
97
|
+
this.cancelSessionTimelineSync();
|
|
98
|
+
this.sessionTimelineActiveKey = '';
|
|
99
|
+
this.clearSessionTimelineRefs();
|
|
100
|
+
this.sessionStandaloneError = '';
|
|
101
|
+
this.sessionStandaloneText = '';
|
|
102
|
+
this.sessionStandaloneTitle = this.activeSession.title || '会话';
|
|
103
|
+
this.sessionStandaloneSourceLabel = sourceLabel;
|
|
104
|
+
this.loadSessionStandalonePlain();
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
buildSessionStandaloneUrl(session) {
|
|
108
|
+
if (!session) return '';
|
|
109
|
+
const source = typeof session.source === 'string' ? session.source.trim().toLowerCase() : '';
|
|
110
|
+
if (!source || (source !== 'codex' && source !== 'claude')) return '';
|
|
111
|
+
const sessionId = typeof session.sessionId === 'string' ? session.sessionId.trim() : '';
|
|
112
|
+
const filePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
|
|
113
|
+
if (!sessionId && !filePath) return '';
|
|
114
|
+
const origin = window.location.origin && window.location.origin !== 'null'
|
|
115
|
+
? window.location.origin
|
|
116
|
+
: (typeof apiBase === 'string' ? apiBase.trim() : '');
|
|
117
|
+
if (!origin) return '';
|
|
118
|
+
const params = new URLSearchParams();
|
|
119
|
+
params.set('source', source);
|
|
120
|
+
if (sessionId) params.set('sessionId', sessionId);
|
|
121
|
+
if (filePath) params.set('filePath', filePath);
|
|
122
|
+
return `${origin}/session?${params.toString()}`;
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
openSessionStandalone(session) {
|
|
126
|
+
const url = this.buildSessionStandaloneUrl(session);
|
|
127
|
+
if (!url) {
|
|
128
|
+
this.showMessage('无法生成链接', 'error');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
window.open(url, '_blank', 'noopener');
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
getSessionExportKey(session) {
|
|
135
|
+
return `${session.source || 'unknown'}:${session.sessionId || ''}:${session.filePath || ''}`;
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
isResumeCommandAvailable(session) {
|
|
139
|
+
if (!session) return false;
|
|
140
|
+
const source = String(session.source || '').trim().toLowerCase();
|
|
141
|
+
const sessionId = typeof session.sessionId === 'string' ? session.sessionId.trim() : '';
|
|
142
|
+
const filePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
|
|
143
|
+
if (source === 'claude') {
|
|
144
|
+
return !!sessionId || !!this.extractClaudeResumeKeyFromFilePath(filePath);
|
|
145
|
+
}
|
|
146
|
+
if (source === 'gemini') {
|
|
147
|
+
return !!sessionId || !!this.extractClaudeResumeKeyFromFilePath(filePath);
|
|
148
|
+
}
|
|
149
|
+
return (source === 'codex' || source === 'codebuddy' || source === 'gemini') && !!sessionId;
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
isCloneAvailable(session) {
|
|
153
|
+
if (!session) return false;
|
|
154
|
+
const source = String(session.source || '').trim().toLowerCase();
|
|
155
|
+
const sessionId = typeof session.sessionId === 'string' ? session.sessionId.trim() : '';
|
|
156
|
+
const filePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
|
|
157
|
+
return source === 'codex' && (!!sessionId || !!filePath);
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
isDeleteAvailable(session) {
|
|
161
|
+
if (!session) return false;
|
|
162
|
+
const source = String(session.source || '').trim().toLowerCase();
|
|
163
|
+
if (source !== 'codex' && source !== 'claude') return false;
|
|
164
|
+
const sessionId = typeof session.sessionId === 'string' ? session.sessionId.trim() : '';
|
|
165
|
+
const filePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
|
|
166
|
+
return !!sessionId || !!filePath;
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
buildResumeCommand(session) {
|
|
170
|
+
const source = session && session.source ? String(session.source).trim().toLowerCase() : '';
|
|
171
|
+
const sessionId = session && session.sessionId ? String(session.sessionId).trim() : '';
|
|
172
|
+
const filePath = session && session.filePath ? String(session.filePath).trim() : '';
|
|
173
|
+
const resumeKey = (source === 'claude' || source === 'gemini')
|
|
174
|
+
? (sessionId || this.extractClaudeResumeKeyFromFilePath(filePath))
|
|
175
|
+
: sessionId;
|
|
176
|
+
const arg = this.quoteResumeArg(resumeKey);
|
|
177
|
+
if (source === 'codebuddy') {
|
|
178
|
+
return `codebuddy -r ${arg}`;
|
|
179
|
+
}
|
|
180
|
+
if (source === 'gemini') {
|
|
181
|
+
return `gemini -r ${arg}`;
|
|
182
|
+
}
|
|
183
|
+
if (source === 'claude') {
|
|
184
|
+
return `claude -r ${arg}`;
|
|
185
|
+
}
|
|
186
|
+
if (this.sessionResumeWithYolo) {
|
|
187
|
+
return `codex --yolo resume ${arg}`;
|
|
188
|
+
}
|
|
189
|
+
return `codex resume ${arg}`;
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
extractClaudeResumeKeyFromFilePath(filePath) {
|
|
193
|
+
const value = typeof filePath === 'string' ? filePath.trim() : '';
|
|
194
|
+
if (!value) return '';
|
|
195
|
+
const normalized = value.replace(/\\/g, '/');
|
|
196
|
+
const base = normalized.split('/').pop() || '';
|
|
197
|
+
if (!base) return '';
|
|
198
|
+
const lower = base.toLowerCase();
|
|
199
|
+
if (lower.endsWith('.jsonl')) {
|
|
200
|
+
return base.slice(0, -6);
|
|
201
|
+
}
|
|
202
|
+
if (lower.endsWith('.json')) {
|
|
203
|
+
return base.slice(0, -5);
|
|
204
|
+
}
|
|
205
|
+
return base;
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
quoteShellArg(value) {
|
|
209
|
+
const text = typeof value === 'string' ? value : String(value || '');
|
|
210
|
+
if (!text) return "''";
|
|
211
|
+
if (/^[a-zA-Z0-9._-]+$/.test(text)) return text;
|
|
212
|
+
const escaped = text.replace(/'/g, "'\\''");
|
|
213
|
+
return `'${escaped}'`;
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
quoteResumeArg(value) {
|
|
217
|
+
return this.quoteShellArg(value);
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
normalizeShareCommandPrefix(value) {
|
|
221
|
+
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
222
|
+
if (normalized === 'codexmate') {
|
|
223
|
+
return 'codexmate';
|
|
224
|
+
}
|
|
225
|
+
return 'npm start';
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
normalizeSessionTrashEnabled(value) {
|
|
229
|
+
if (value === false) return false;
|
|
230
|
+
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
231
|
+
if (normalized === '0' || normalized === 'false' || normalized === 'off' || normalized === 'no') {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
normalizeConfigTemplateDiffConfirmEnabled(value) {
|
|
238
|
+
return normalizeConfigTemplateDiffConfirmEnabled(value);
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
setSessionTrashEnabled(value) {
|
|
242
|
+
const enabled = this.normalizeSessionTrashEnabled(value);
|
|
243
|
+
this.sessionTrashEnabled = enabled;
|
|
244
|
+
try {
|
|
245
|
+
localStorage.setItem('codexmateSessionTrashEnabled', enabled ? 'true' : 'false');
|
|
246
|
+
} catch (_) {}
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
setConfigTemplateDiffConfirmEnabled(value) {
|
|
250
|
+
const enabled = this.normalizeConfigTemplateDiffConfirmEnabled(value);
|
|
251
|
+
this.configTemplateDiffConfirmEnabled = enabled;
|
|
252
|
+
persistConfigTemplateDiffConfirmEnabledToStorage(enabled);
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
getShareCommandPrefixInvocation() {
|
|
256
|
+
const prefix = this.normalizeShareCommandPrefix(this.shareCommandPrefix);
|
|
257
|
+
return prefix === 'codexmate' ? 'codexmate' : 'npm start';
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
setShareCommandPrefix(value) {
|
|
261
|
+
const normalized = this.normalizeShareCommandPrefix(value);
|
|
262
|
+
this.shareCommandPrefix = normalized;
|
|
263
|
+
try {
|
|
264
|
+
localStorage.setItem('codexmateShareCommandPrefix', normalized);
|
|
265
|
+
} catch (_) {}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
fallbackCopyText(text) {
|
|
269
|
+
let textarea = null;
|
|
270
|
+
try {
|
|
271
|
+
textarea = document.createElement('textarea');
|
|
272
|
+
textarea.value = text;
|
|
273
|
+
textarea.setAttribute('readonly', '');
|
|
274
|
+
textarea.style.position = 'fixed';
|
|
275
|
+
textarea.style.top = '-9999px';
|
|
276
|
+
textarea.style.left = '-9999px';
|
|
277
|
+
textarea.style.opacity = '0';
|
|
278
|
+
document.body.appendChild(textarea);
|
|
279
|
+
textarea.select();
|
|
280
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
281
|
+
return document.execCommand('copy');
|
|
282
|
+
} catch (_) {
|
|
283
|
+
return false;
|
|
284
|
+
} finally {
|
|
285
|
+
if (textarea && textarea.parentNode) {
|
|
286
|
+
textarea.parentNode.removeChild(textarea);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
copyAgentsContent() {
|
|
292
|
+
const text = typeof this.agentsContent === 'string' ? this.agentsContent : '';
|
|
293
|
+
if (!text) {
|
|
294
|
+
this.showMessage('没有可复制内容', 'info');
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const ok = this.fallbackCopyText(text);
|
|
298
|
+
if (ok) {
|
|
299
|
+
this.showMessage('已复制', 'success');
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
this.showMessage('复制失败', 'error');
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
exportAgentsContent() {
|
|
306
|
+
const text = typeof this.agentsContent === 'string' ? this.agentsContent : '';
|
|
307
|
+
if (!text) {
|
|
308
|
+
this.showMessage('没有可导出内容', 'info');
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const now = new Date();
|
|
312
|
+
const year = String(now.getFullYear());
|
|
313
|
+
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
314
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
315
|
+
const hour = String(now.getHours()).padStart(2, '0');
|
|
316
|
+
const minute = String(now.getMinutes()).padStart(2, '0');
|
|
317
|
+
const second = String(now.getSeconds()).padStart(2, '0');
|
|
318
|
+
const fileName = `agent-${year}${month}${day}-${hour}${minute}${second}.txt`;
|
|
319
|
+
this.downloadTextFile(fileName, text, 'text/plain;charset=utf-8');
|
|
320
|
+
this.showMessage(`已导出 ${fileName}`, 'success');
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
async copyInstallCommand(cmd) {
|
|
324
|
+
const text = typeof cmd === 'string' ? cmd.trim() : '';
|
|
325
|
+
if (!text) {
|
|
326
|
+
this.showMessage('没有可复制内容', 'info');
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
331
|
+
await navigator.clipboard.writeText(text);
|
|
332
|
+
this.showMessage('已复制命令', 'success');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
} catch (_) {}
|
|
336
|
+
const ok = this.fallbackCopyText(text);
|
|
337
|
+
if (ok) {
|
|
338
|
+
this.showMessage('已复制命令', 'success');
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
this.showMessage('复制失败', 'error');
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
async copyResumeCommand(session) {
|
|
345
|
+
if (!this.isResumeCommandAvailable(session)) {
|
|
346
|
+
this.showMessage('不支持此操作', 'error');
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const command = this.buildResumeCommand(session);
|
|
350
|
+
const ok = this.fallbackCopyText(command);
|
|
351
|
+
if (ok) {
|
|
352
|
+
this.showMessage('已复制', 'success');
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
357
|
+
await navigator.clipboard.writeText(command);
|
|
358
|
+
this.showMessage('已复制', 'success');
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
} catch (_) {}
|
|
362
|
+
this.showMessage('复制失败', 'error');
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
buildProviderShareCommand(payload) {
|
|
366
|
+
if (!payload || typeof payload !== 'object') return '';
|
|
367
|
+
const name = typeof payload.name === 'string' ? payload.name.trim() : '';
|
|
368
|
+
const baseUrl = typeof payload.baseUrl === 'string' ? payload.baseUrl.trim() : '';
|
|
369
|
+
const apiKey = typeof payload.apiKey === 'string' ? payload.apiKey : '';
|
|
370
|
+
const model = typeof payload.model === 'string' ? payload.model.trim() : '';
|
|
371
|
+
const bridge = typeof payload.bridge === 'string' ? payload.bridge.trim() : '';
|
|
372
|
+
if (!name || !baseUrl) return '';
|
|
373
|
+
|
|
374
|
+
const cli = this.getShareCommandPrefixInvocation();
|
|
375
|
+
const nameArg = this.quoteShellArg(name);
|
|
376
|
+
const urlArg = this.quoteShellArg(baseUrl);
|
|
377
|
+
const keyArg = apiKey ? this.quoteShellArg(apiKey) : '';
|
|
378
|
+
const switchCmd = `${cli} switch ${nameArg}`;
|
|
379
|
+
const bridgeArgs = bridge ? ` --bridge ${this.quoteShellArg(bridge)}` : '';
|
|
380
|
+
const addCmd = apiKey
|
|
381
|
+
? `${cli} add ${nameArg} ${urlArg} ${keyArg}${bridgeArgs}`
|
|
382
|
+
: `${cli} add ${nameArg} ${urlArg}${bridgeArgs}`;
|
|
383
|
+
const modelCmd = model ? ` && ${cli} use ${this.quoteShellArg(model)}` : '';
|
|
384
|
+
return `${addCmd} && ${switchCmd}${modelCmd}`;
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
buildClaudeShareCommand(payload) {
|
|
388
|
+
if (!payload || typeof payload !== 'object') return '';
|
|
389
|
+
const baseUrl = typeof payload.baseUrl === 'string' ? payload.baseUrl.trim() : '';
|
|
390
|
+
const apiKey = typeof payload.apiKey === 'string' ? payload.apiKey : '';
|
|
391
|
+
const model = typeof payload.model === 'string' && payload.model.trim()
|
|
392
|
+
? payload.model.trim()
|
|
393
|
+
: 'glm-4.7';
|
|
394
|
+
if (!baseUrl || !apiKey) return '';
|
|
395
|
+
const urlArg = this.quoteShellArg(baseUrl);
|
|
396
|
+
const keyArg = this.quoteShellArg(apiKey);
|
|
397
|
+
const modelArg = this.quoteShellArg(model);
|
|
398
|
+
return `${this.getShareCommandPrefixInvocation()} claude ${urlArg} ${keyArg} ${modelArg}`;
|
|
399
|
+
},
|
|
400
|
+
|
|
401
|
+
async copyProviderShareCommand(provider) {
|
|
402
|
+
const name = provider && typeof provider.name === 'string' ? provider.name.trim() : '';
|
|
403
|
+
if (!name) {
|
|
404
|
+
this.showMessage('参数无效', 'error');
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (!this.shouldAllowProviderShare(provider)) {
|
|
408
|
+
this.showMessage('不可分享', 'info');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (this.providerShareLoading[name]) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
this.providerShareLoading[name] = true;
|
|
415
|
+
try {
|
|
416
|
+
const res = await api('export-provider', { name });
|
|
417
|
+
if (res && res.error) {
|
|
418
|
+
this.showMessage(res.error, 'error');
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const command = this.buildProviderShareCommand(res && res.payload ? res.payload : null);
|
|
422
|
+
if (!command) {
|
|
423
|
+
this.showMessage('生成命令失败', 'error');
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const ok = this.fallbackCopyText(command);
|
|
427
|
+
if (ok) {
|
|
428
|
+
this.showMessage('已复制', 'success');
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
433
|
+
await navigator.clipboard.writeText(command);
|
|
434
|
+
this.showMessage('已复制', 'success');
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
} catch (_) {}
|
|
438
|
+
this.showMessage('复制失败', 'error');
|
|
439
|
+
} catch (_) {
|
|
440
|
+
this.showMessage('生成命令失败', 'error');
|
|
441
|
+
} finally {
|
|
442
|
+
this.providerShareLoading[name] = false;
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
async copyClaudeShareCommand(name) {
|
|
447
|
+
const config = this.claudeConfigs[name];
|
|
448
|
+
if (!config) {
|
|
449
|
+
this.showMessage('配置不存在', 'error');
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (this.claudeShareLoading[name]) return;
|
|
453
|
+
this.claudeShareLoading[name] = true;
|
|
454
|
+
try {
|
|
455
|
+
const res = await api('export-claude-share', { config });
|
|
456
|
+
if (res && res.error) {
|
|
457
|
+
this.showMessage(res.error, 'error');
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const command = this.buildClaudeShareCommand(res && res.payload ? res.payload : null);
|
|
461
|
+
if (!command) {
|
|
462
|
+
this.showMessage('生成命令失败', 'error');
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const ok = this.fallbackCopyText(command);
|
|
466
|
+
if (ok) {
|
|
467
|
+
this.showMessage('已复制', 'success');
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
472
|
+
await navigator.clipboard.writeText(command);
|
|
473
|
+
this.showMessage('已复制', 'success');
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
} catch (_) {}
|
|
477
|
+
this.showMessage('复制失败', 'error');
|
|
478
|
+
} catch (_) {
|
|
479
|
+
this.showMessage('生成命令失败', 'error');
|
|
480
|
+
} finally {
|
|
481
|
+
this.claudeShareLoading[name] = false;
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
async cloneSession(session) {
|
|
486
|
+
if (!this.isCloneAvailable(session)) {
|
|
487
|
+
this.showMessage('不支持此操作', 'error');
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const key = this.getSessionExportKey(session);
|
|
491
|
+
if (this.sessionCloning[key]) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.sessionCloning[key] = true;
|
|
495
|
+
try {
|
|
496
|
+
const res = await api('clone-session', {
|
|
497
|
+
source: session.source,
|
|
498
|
+
sessionId: session.sessionId,
|
|
499
|
+
filePath: session.filePath
|
|
500
|
+
});
|
|
501
|
+
if (res.error) {
|
|
502
|
+
this.showMessage(res.error, 'error');
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
this.showMessage('操作成功', 'success');
|
|
507
|
+
if (typeof this.invalidateSessionsUsageData === 'function') {
|
|
508
|
+
this.invalidateSessionsUsageData({ preserveList: true });
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
await this.loadSessions();
|
|
512
|
+
if (res.sessionId) {
|
|
513
|
+
const matched = this.sessionsList.find(item => item.source === 'codex' && item.sessionId === res.sessionId);
|
|
514
|
+
if (matched) {
|
|
515
|
+
await this.selectSession(matched);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} catch (_) {
|
|
519
|
+
// The clone already succeeded remotely; keep the success result.
|
|
520
|
+
}
|
|
521
|
+
} catch (_) {
|
|
522
|
+
this.showMessage('克隆失败', 'error');
|
|
523
|
+
} finally {
|
|
524
|
+
this.sessionCloning[key] = false;
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
async deleteSession(session) {
|
|
529
|
+
if (!this.isDeleteAvailable(session)) {
|
|
530
|
+
this.showMessage('不支持此操作', 'error');
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const useTrash = this.sessionTrashEnabled !== false;
|
|
534
|
+
if (!useTrash && typeof this.requestConfirmDialog === 'function') {
|
|
535
|
+
const confirmed = await this.requestConfirmDialog({
|
|
536
|
+
title: '直接删除会话',
|
|
537
|
+
message: '关闭回收站后,删除会话将直接永久删除,且无法恢复。',
|
|
538
|
+
confirmText: '直接删除',
|
|
539
|
+
cancelText: '取消',
|
|
540
|
+
danger: true
|
|
541
|
+
});
|
|
542
|
+
if (!confirmed) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const key = this.getSessionExportKey(session);
|
|
547
|
+
if (this.sessionDeleting[key]) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
this.sessionDeleting[key] = true;
|
|
551
|
+
try {
|
|
552
|
+
const action = useTrash ? 'trash-session' : 'delete-session';
|
|
553
|
+
const res = await api(action, {
|
|
554
|
+
source: session.source,
|
|
555
|
+
sessionId: session.sessionId,
|
|
556
|
+
filePath: session.filePath
|
|
557
|
+
});
|
|
558
|
+
if (!res || res.error) {
|
|
559
|
+
this.showMessage((res && res.error) || '删除失败', 'error');
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
this.removeSessionPin(session);
|
|
563
|
+
if (useTrash) {
|
|
564
|
+
this.invalidateSessionTrashRequests();
|
|
565
|
+
this.showMessage('已移入回收站', 'success');
|
|
566
|
+
if (this.sessionTrashLoadedOnce) {
|
|
567
|
+
this.prependSessionTrashItem(this.buildSessionTrashItemFromSession(session, res), {
|
|
568
|
+
totalCount: res && res.totalCount !== undefined ? res.totalCount : undefined
|
|
569
|
+
});
|
|
570
|
+
} else {
|
|
571
|
+
this.sessionTrashTotalCount = this.normalizeSessionTrashTotalCount(
|
|
572
|
+
res && res.totalCount !== undefined
|
|
573
|
+
? res.totalCount
|
|
574
|
+
: (this.normalizeSessionTrashTotalCount(this.sessionTrashTotalCount, this.sessionTrashItems) + 1),
|
|
575
|
+
this.sessionTrashItems
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
this.showMessage('已删除', 'success');
|
|
580
|
+
}
|
|
581
|
+
if (typeof this.invalidateSessionsUsageData === 'function') {
|
|
582
|
+
this.invalidateSessionsUsageData({ preserveList: true });
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
await this.removeSessionFromCurrentList(session);
|
|
586
|
+
} catch (_) {
|
|
587
|
+
// The delete already succeeded remotely; keep the success result.
|
|
588
|
+
}
|
|
589
|
+
} catch (_) {
|
|
590
|
+
this.showMessage('删除失败', 'error');
|
|
591
|
+
} finally {
|
|
592
|
+
this.sessionDeleting[key] = false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
}
|