dsh-taskbridge 1.7.1 → 1.8.1
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/CHANGELOG.md +24 -0
- package/LICENSE +21 -21
- package/README.md +733 -877
- package/THIRD_PARTY_NOTICES.txt +23 -23
- package/antigravity/agents/dsh-taskbridge.md +32 -0
- package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
- package/codex/dsh-taskbridge.toml +181 -631
- package/cordis.patch.yml +6 -6
- package/docs/INTRODUCTION.md +122 -295
- package/docs/INTRODUCTION.zh.md +134 -279
- package/docs/antigravity-integration.md +42 -0
- package/docs/auth-contract.md +138 -138
- package/docs/claude-code.md +6 -11
- package/docs/codex-integration.md +2 -2
- package/docs/contracts-stage-b.md +443 -443
- package/docs/conversation-placement.md +7 -6
- package/docs/plugin-market.md +30 -30
- package/docs/redaction-contract.md +170 -170
- package/docs/releases/1.7.0.zh.md +11 -11
- package/docs/releases/1.8.0.zh.md +16 -0
- package/docs/releases/1.8.1.zh.md +24 -0
- package/docs/runtime-compatibility.md +1 -1
- package/docs/taskbridge-upgrade.md +28 -28
- package/docs/taskdispatch-upgrade.md +25 -25
- package/docs/workspace-contract.md +538 -538
- package/docs/workspace-grouping.md +126 -126
- package/icon.svg +1 -1
- package/lib/client.d.ts +804 -699
- package/lib/client.js +7 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +150 -144
- package/src/antigravity/installer.js +1068 -0
- package/src/antigravity/seam.js +142 -0
- package/src/auth/fence.js +361 -361
- package/src/auth/grants.js +789 -789
- package/src/client/api.js +266 -3
- package/src/client/index.jsx +224 -11
- package/src/client/sidebar.jsx +862 -862
- package/src/client/styles.js +624 -624
- package/src/client/task-cleanup.js +429 -304
- package/src/client/task-records-table.jsx +217 -217
- package/src/client/task-view.js +307 -307
- package/src/client/workspace-groups.js +482 -482
- package/src/client/workspaces-browser.jsx +770 -770
- package/src/codex/agent-ownership.js +270 -270
- package/src/codex/installer.js +6 -0
- package/src/codex/toml.js +784 -784
- package/src/config/defaults.js +11 -15
- package/src/config/redact.js +245 -245
- package/src/config/store.js +186 -186
- package/src/credentials/seam.js +202 -202
- package/src/http/respond.js +6 -5
- package/src/http/user-plane.js +83 -1
- package/src/index.js +25 -0
- package/src/jobs/diagnostics.js +15 -15
- package/src/jobs/engine.js +1 -0
- package/src/jobs/history.js +1 -1
- package/src/jobs/plan-store.js +1103 -1020
- package/src/jobs/record-cleanup.js +452 -7
- package/src/jobs/review-note.js +63 -63
- package/src/jobs/task-descriptions.js +82 -82
- package/src/jobs/task-display.js +73 -73
- package/src/jobs/task-tree.js +786 -786
- package/src/jobs/title.js +134 -134
- package/src/mcp/continuation.js +317 -317
- package/src/mcp/server.js +34 -27
- package/src/mcp/wait.js +34 -15
- package/src/model/connectivity.js +371 -371
- package/src/model/discovery.js +582 -582
- package/src/model/native-catalog.js +68 -68
- package/src/model/openai-adapter.js +671 -671
- package/src/model/probe.js +264 -264
- package/src/model/providers.js +756 -756
- package/src/model/routing.js +321 -321
- package/src/runtime/agent-runner.js +1 -0
- package/src/runtime/permissions.js +1619 -1619
- package/src/runtime/question-call.js +162 -162
- package/src/runtime/questions.js +909 -909
- package/src/runtime/session-placement.js +36 -1
- package/src/runtime/worker-prompt.js +61 -55
- package/src/workspace/audit.js +775 -775
- package/src/workspace/preflight.js +424 -424
- package/src/workspace/worktrees.js +833 -679
package/src/client/api.js
CHANGED
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
// `createStore`'s caller in `index.jsx` to `cleanupProjection()`).
|
|
34
34
|
export {
|
|
35
35
|
CLEANUP_BLOCKER_LABELS,
|
|
36
|
+
CLEANUP_PRESETS,
|
|
36
37
|
MAX_CLEANUP_CHAINS,
|
|
37
38
|
cleanupBlockerLabel,
|
|
38
39
|
cleanupCandidates,
|
|
40
|
+
cleanupConfirmText,
|
|
39
41
|
cleanupOutcome,
|
|
40
42
|
cleanupProjection,
|
|
41
43
|
cleanupRequest,
|
|
@@ -43,7 +45,9 @@ export {
|
|
|
43
45
|
cleanupSelectionSummary,
|
|
44
46
|
cleanupWarningText,
|
|
45
47
|
describeCleanupOutcome,
|
|
48
|
+
describeOrphanCleanupOutcome,
|
|
46
49
|
pruneCleanupSelection,
|
|
50
|
+
selectCleanupCandidatesByPreset,
|
|
47
51
|
toggleCleanupSelection,
|
|
48
52
|
withSelectionState,
|
|
49
53
|
} from './task-cleanup.js';
|
|
@@ -96,6 +100,7 @@ export const ROUTES = Object.freeze({
|
|
|
96
100
|
// execution chains. It is a `POST`, never a load-time or refresh-time write, and it
|
|
97
101
|
// only ever names chains and their exact rounds.
|
|
98
102
|
tasksCleanup: `${USER_PLANE_PREFIX}/tasks/cleanup`,
|
|
103
|
+
tasksCleanupOrphans: `${USER_PLANE_PREFIX}/tasks/cleanup-orphans`,
|
|
99
104
|
// The one planning write the page has: a batch of planning nodes. It creates
|
|
100
105
|
// records only — it cannot dispatch, authorize or review anything.
|
|
101
106
|
plans: `${USER_PLANE_PREFIX}/plans`,
|
|
@@ -111,6 +116,7 @@ export const ROUTES = Object.freeze({
|
|
|
111
116
|
connectivity: `${USER_PLANE_PREFIX}/connectivity`,
|
|
112
117
|
// One path, two methods: `GET` diagnoses, `POST` performs one explicit action.
|
|
113
118
|
codex: `${USER_PLANE_PREFIX}/codex`,
|
|
119
|
+
antigravity: `${USER_PLANE_PREFIX}/antigravity`,
|
|
114
120
|
});
|
|
115
121
|
|
|
116
122
|
/** A refusal or transport failure carrying the contract's stable code. */
|
|
@@ -356,7 +362,17 @@ export function createApi(options = {}) {
|
|
|
356
362
|
*/
|
|
357
363
|
async cleanupTasks(body) {
|
|
358
364
|
const chains = Array.isArray(body?.chains) ? body.chains : [];
|
|
359
|
-
|
|
365
|
+
const payload = { confirm: true, chains };
|
|
366
|
+
if (body?.archiveSessions === true) payload.archiveSessions = true;
|
|
367
|
+
if (body?.removeWorktrees === true) payload.removeWorktrees = true;
|
|
368
|
+
if (body?.cleanPlans === true) payload.cleanPlans = true;
|
|
369
|
+
return await request('POST', ROUTES.tasksCleanup, payload);
|
|
370
|
+
},
|
|
371
|
+
async cleanupOrphans(options = {}) {
|
|
372
|
+
const payload = { confirm: true };
|
|
373
|
+
if (typeof options?.archiveSessions === 'boolean') payload.archiveSessions = options.archiveSessions;
|
|
374
|
+
if (typeof options?.removeWorktrees === 'boolean') payload.removeWorktrees = options.removeWorktrees;
|
|
375
|
+
return await request('POST', ROUTES.tasksCleanupOrphans, payload);
|
|
360
376
|
},
|
|
361
377
|
/**
|
|
362
378
|
* Create a batch of planning nodes.
|
|
@@ -440,6 +456,14 @@ export function createApi(options = {}) {
|
|
|
440
456
|
async runCodexAction(action) {
|
|
441
457
|
return await request('POST', ROUTES.codex, { action });
|
|
442
458
|
},
|
|
459
|
+
/** Diagnose the Antigravity plugin integration. Read-only on the host. */
|
|
460
|
+
async getAntigravityStatus() {
|
|
461
|
+
return await request('GET', ROUTES.antigravity);
|
|
462
|
+
},
|
|
463
|
+
/** Perform one explicit Antigravity integration action (`install`, `repair`, `remove`). */
|
|
464
|
+
async runAntigravityAction(action) {
|
|
465
|
+
return await request('POST', ROUTES.antigravity, { action });
|
|
466
|
+
},
|
|
443
467
|
};
|
|
444
468
|
}
|
|
445
469
|
|
|
@@ -949,6 +973,68 @@ export function describeCodexOutcome(outcome) {
|
|
|
949
973
|
return parts.join(';') + '。';
|
|
950
974
|
}
|
|
951
975
|
|
|
976
|
+
export const ANTIGRAVITY_ACTIONS = Object.freeze(['install', 'repair', 'remove']);
|
|
977
|
+
|
|
978
|
+
export const ANTIGRAVITY_TARGETS = Object.freeze([
|
|
979
|
+
{ key: 'plugin', label: 'Antigravity 插件与规则(Skill + 子智能体)' },
|
|
980
|
+
{ key: 'mcp', label: 'Antigravity 插件 MCP 配置' },
|
|
981
|
+
{ key: 'switch', label: 'DSH 本机调用开关' },
|
|
982
|
+
]);
|
|
983
|
+
|
|
984
|
+
export function antigravityTargetView(antigravity, switchState, target) {
|
|
985
|
+
const label = ANTIGRAVITY_TARGETS.find((entry) => entry.key === target)?.label ?? target;
|
|
986
|
+
if (target === 'switch') {
|
|
987
|
+
const authorized = switchState?.authorized === true;
|
|
988
|
+
return {
|
|
989
|
+
key: 'switch',
|
|
990
|
+
label,
|
|
991
|
+
state: authorized ? 'on' : 'off',
|
|
992
|
+
tone: authorized ? 'on' : 'off',
|
|
993
|
+
detail: authorized
|
|
994
|
+
? '已开启:Antigravity 可以通过 MCP 提交任务。'
|
|
995
|
+
: '已关闭:Antigravity 可以查询状态,但新任务会被拒绝;本页不会替你打开它。',
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
const block = target === 'plugin' ? antigravity?.plugin : antigravity?.mcp;
|
|
999
|
+
if (block === null || block === undefined || typeof block !== 'object') {
|
|
1000
|
+
return { key: target, label, state: 'unknown', tone: 'off', detail: '宿主尚未回报该状态。' };
|
|
1001
|
+
}
|
|
1002
|
+
const state = String(block.state ?? 'unknown');
|
|
1003
|
+
const done = target === 'plugin' ? block.installed === true : block.configured === true;
|
|
1004
|
+
const detailParts = [];
|
|
1005
|
+
if (typeof block.path === 'string' && block.path !== '') detailParts.push(block.path);
|
|
1006
|
+
if (target === 'mcp' && typeof block.script === 'string' && block.script !== '') {
|
|
1007
|
+
detailParts.push(`入口:${block.script}`);
|
|
1008
|
+
}
|
|
1009
|
+
if (target === 'mcp') {
|
|
1010
|
+
if (typeof block.node === 'string' && block.node !== '') detailParts.push(`Node:${block.node}`);
|
|
1011
|
+
else if (block.nodeResolved === false) detailParts.push('Node:未确定(不会写入桌面应用自身的 exe)');
|
|
1012
|
+
}
|
|
1013
|
+
return {
|
|
1014
|
+
key: target,
|
|
1015
|
+
label,
|
|
1016
|
+
state,
|
|
1017
|
+
tone: done ? 'on' : (state === 'conflict' || state === 'unreadable' || state === 'modified') ? 'warn' : 'off',
|
|
1018
|
+
detail: CODEX_STATE_LABELS[state] ?? state,
|
|
1019
|
+
path: typeof block.path === 'string' ? block.path : '',
|
|
1020
|
+
paths: detailParts,
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
export function describeAntigravityOutcome(outcome) {
|
|
1025
|
+
if (outcome === null || outcome === undefined) return '';
|
|
1026
|
+
const names = { plugin: '插件与规则文件', mcp: 'MCP 配置' };
|
|
1027
|
+
const changed = Array.isArray(outcome.changed) ? outcome.changed.map((key) => names[key] ?? key) : [];
|
|
1028
|
+
const refused = Array.isArray(outcome.refused) ? outcome.refused : [];
|
|
1029
|
+
const parts = [];
|
|
1030
|
+
if (changed.length > 0) parts.push(`已写入:${changed.join('、')}`);
|
|
1031
|
+
if (refused.length > 0) parts.push(`未改动:${refused.map((entry) => names[entry?.target] ?? entry?.target ?? '未知').join('、')}`);
|
|
1032
|
+
if (parts.length === 0) {
|
|
1033
|
+
return outcome.action === 'remove' ? '没有需要移除的插件托管文件。' : '已是最新,没有需要写入的内容。';
|
|
1034
|
+
}
|
|
1035
|
+
return parts.join(';') + '。';
|
|
1036
|
+
}
|
|
1037
|
+
|
|
952
1038
|
/** Provider protocols this stage supports. */
|
|
953
1039
|
export const SUPPORTED_PROTOCOLS = Object.freeze(['openai-chat']);
|
|
954
1040
|
|
|
@@ -2197,6 +2283,15 @@ export function describeError(error) {
|
|
|
2197
2283
|
CLEANUP_REVIEW_WRITE: '该任务的审查意见正在写入,未删除任何记录;请稍后重试。',
|
|
2198
2284
|
CLEANUP_UNAVAILABLE: '当前宿主不提供记录清理能力(或记录暂时无法读取),未删除任何记录。',
|
|
2199
2285
|
CLEANUP_FAILED: '记录写入失败,未删除任何记录;旧记录仍会显示。',
|
|
2286
|
+
CODEX_INTEGRATION_UNAVAILABLE: '当前宿主未提供 Codex 集成接口。',
|
|
2287
|
+
CODEX_HOME_INVALID: 'Codex 配置目录路径不合法(必须为绝对路径)。',
|
|
2288
|
+
CODEX_ACTION_INVALID: '不支持的 Codex 集成操作。',
|
|
2289
|
+
CODEX_CONFIG_UNSUPPORTED: 'Codex 配置文件存在冲突或不受支持的格式,插件未改动。',
|
|
2290
|
+
ANTIGRAVITY_INTEGRATION_UNAVAILABLE: '当前宿主未提供 Antigravity 集成接口。',
|
|
2291
|
+
ANTIGRAVITY_HOME_INVALID: 'Antigravity 配置目录路径不合法(必须为绝对路径)。',
|
|
2292
|
+
ANTIGRAVITY_HOME_UNUSABLE: 'Antigravity 配置目录不可用(非普通目录或链接无法解析)。',
|
|
2293
|
+
ANTIGRAVITY_ACTION_INVALID: '不支持的 Antigravity 集成操作。',
|
|
2294
|
+
ANTIGRAVITY_PATH_CONFLICT: 'Antigravity 插件目录存在冲突或符号链接边界,插件未写入。',
|
|
2200
2295
|
};
|
|
2201
2296
|
const known = messages[code];
|
|
2202
2297
|
if (known !== undefined) return `${known}(${code})`;
|
|
@@ -2590,6 +2685,9 @@ export function createStore(options = {}) {
|
|
|
2590
2685
|
codex: null,
|
|
2591
2686
|
codexError: null,
|
|
2592
2687
|
codexOutcome: null,
|
|
2688
|
+
antigravity: null,
|
|
2689
|
+
antigravityError: null,
|
|
2690
|
+
antigravityOutcome: null,
|
|
2593
2691
|
};
|
|
2594
2692
|
/** @type {Set<() => void>} */
|
|
2595
2693
|
const listeners = new Set();
|
|
@@ -3351,6 +3449,65 @@ export function createStore(options = {}) {
|
|
|
3351
3449
|
});
|
|
3352
3450
|
},
|
|
3353
3451
|
|
|
3452
|
+
/** Read the Antigravity integration status. Strictly read-only. */
|
|
3453
|
+
async refreshAntigravityStatus() {
|
|
3454
|
+
if (typeof api.getAntigravityStatus !== 'function') {
|
|
3455
|
+
patch({
|
|
3456
|
+
antigravity: null,
|
|
3457
|
+
antigravityError: '当前宿主未提供 Antigravity 集成接口(插件版本可能较旧)。',
|
|
3458
|
+
});
|
|
3459
|
+
return { ok: false };
|
|
3460
|
+
}
|
|
3461
|
+
return await track('antigravityStatus', async () => {
|
|
3462
|
+
try {
|
|
3463
|
+
const body = await api.getAntigravityStatus();
|
|
3464
|
+
patch({ antigravity: body.antigravity ?? null, antigravityError: null });
|
|
3465
|
+
return { ok: true, antigravity: body.antigravity ?? null, switch: body.switch ?? null };
|
|
3466
|
+
} catch (error) {
|
|
3467
|
+
const unavailable = error?.code === 'HTTP_404' || error?.code === 'USER_PLANE_UNKNOWN_ROUTE';
|
|
3468
|
+
patch({
|
|
3469
|
+
antigravity: null,
|
|
3470
|
+
antigravityError: unavailable
|
|
3471
|
+
? '当前宿主未提供 Antigravity 集成接口(插件版本可能较旧)。'
|
|
3472
|
+
: describeError(error),
|
|
3473
|
+
});
|
|
3474
|
+
return { ok: false, error };
|
|
3475
|
+
}
|
|
3476
|
+
});
|
|
3477
|
+
},
|
|
3478
|
+
|
|
3479
|
+
/** Perform one explicit Antigravity integration action (`install`, `repair`, `remove`). */
|
|
3480
|
+
async runAntigravityAction(action) {
|
|
3481
|
+
if (!ANTIGRAVITY_ACTIONS.includes(action)) {
|
|
3482
|
+
notify('error', `未知的 Antigravity 操作:${String(action)}`);
|
|
3483
|
+
return { ok: false };
|
|
3484
|
+
}
|
|
3485
|
+
if (typeof api.runAntigravityAction !== 'function') {
|
|
3486
|
+
notify('error', '当前宿主未提供 Antigravity 集成接口。');
|
|
3487
|
+
return { ok: false };
|
|
3488
|
+
}
|
|
3489
|
+
return await track('antigravityAction', async () => {
|
|
3490
|
+
try {
|
|
3491
|
+
const body = await api.runAntigravityAction(action);
|
|
3492
|
+
const outcome = {
|
|
3493
|
+
action: body.action ?? action,
|
|
3494
|
+
changed: Array.isArray(body.changed) ? body.changed : [],
|
|
3495
|
+
refused: Array.isArray(body.refused) ? body.refused : [],
|
|
3496
|
+
};
|
|
3497
|
+
const antigravity = body.antigravity ?? state.antigravity;
|
|
3498
|
+
patch({ antigravity, antigravityError: null, antigravityOutcome: outcome });
|
|
3499
|
+
const summary = describeAntigravityOutcome(outcome);
|
|
3500
|
+
const failed = outcome.refused.length > 0;
|
|
3501
|
+
notify(failed ? 'error' : 'success', summary === '' ? '操作完成。' : summary);
|
|
3502
|
+
return { ok: !failed, outcome, antigravity };
|
|
3503
|
+
} catch (error) {
|
|
3504
|
+
patch({ antigravityOutcome: null });
|
|
3505
|
+
notify('error', describeError(error));
|
|
3506
|
+
return { ok: false, error };
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3509
|
+
},
|
|
3510
|
+
|
|
3354
3511
|
/**
|
|
3355
3512
|
* Replace the silence thresholds, the progress-check cadence and the repeated-failure count.
|
|
3356
3513
|
*
|
|
@@ -3644,10 +3801,10 @@ export function createStore(options = {}) {
|
|
|
3644
3801
|
},
|
|
3645
3802
|
|
|
3646
3803
|
/** Remove a confirmed selection whose exact rounds still match the current tree. */
|
|
3647
|
-
async cleanupTasks(selection) {
|
|
3804
|
+
async cleanupTasks(selection, options = {}) {
|
|
3648
3805
|
const view = cleanup;
|
|
3649
3806
|
const candidates = view.candidates(state.tree ?? null);
|
|
3650
|
-
const prepared = view.request(selection ?? {}, candidates);
|
|
3807
|
+
const prepared = view.request(selection ?? {}, candidates, options);
|
|
3651
3808
|
if (prepared.problems.length > 0) {
|
|
3652
3809
|
notify('error', prepared.problems[0]);
|
|
3653
3810
|
return { ok: false, error: new ApiError('CLEANUP_INVALID', prepared.problems[0]) };
|
|
@@ -3655,6 +3812,9 @@ export function createStore(options = {}) {
|
|
|
3655
3812
|
return await track('cleanup', async () => {
|
|
3656
3813
|
try {
|
|
3657
3814
|
const outcome = await api.cleanupTasks(prepared.body);
|
|
3815
|
+
if (outcome?.cleaned && options?.hostWorkspaces) {
|
|
3816
|
+
await reconcileHostWorkspacesWithCleaned(options.hostWorkspaces, outcome.cleaned);
|
|
3817
|
+
}
|
|
3658
3818
|
const deleted = view.outcome(outcome);
|
|
3659
3819
|
const sentence = view.describe(outcome);
|
|
3660
3820
|
if (sentence === '') throw new ApiError('CLEANUP_RESULT_UNCONFIRMED', '宿主未确认删除结果');
|
|
@@ -3680,12 +3840,41 @@ export function createStore(options = {}) {
|
|
|
3680
3840
|
});
|
|
3681
3841
|
},
|
|
3682
3842
|
|
|
3843
|
+
/** Sweep residual worktrees and dispatched sessions whose task records were already removed. */
|
|
3844
|
+
async cleanupOrphans(options = {}) {
|
|
3845
|
+
if (typeof api.cleanupOrphans !== 'function') {
|
|
3846
|
+
notify('error', '当前宿主未提供残留清理接口。');
|
|
3847
|
+
return { ok: false };
|
|
3848
|
+
}
|
|
3849
|
+
return await track('cleanupOrphans', async () => {
|
|
3850
|
+
try {
|
|
3851
|
+
const outcome = await api.cleanupOrphans({
|
|
3852
|
+
archiveSessions: options?.archiveSessions !== false,
|
|
3853
|
+
removeWorktrees: options?.removeWorktrees !== false,
|
|
3854
|
+
});
|
|
3855
|
+
if (outcome?.cleaned && options?.hostWorkspaces) {
|
|
3856
|
+
await reconcileHostWorkspacesWithCleaned(options.hostWorkspaces, outcome.cleaned);
|
|
3857
|
+
}
|
|
3858
|
+
const sentence = typeof cleanup.describeOrphans === 'function'
|
|
3859
|
+
? cleanup.describeOrphans(outcome)
|
|
3860
|
+
: '已完成残留隔离工作树与已删记录派工对话清理。';
|
|
3861
|
+
notify('success', sentence || '已完成残留清理。');
|
|
3862
|
+
await store.refreshTasks('manual');
|
|
3863
|
+
return { ok: true, outcome };
|
|
3864
|
+
} catch (error) {
|
|
3865
|
+
notify('error', describeError(error));
|
|
3866
|
+
return { ok: false, error };
|
|
3867
|
+
}
|
|
3868
|
+
});
|
|
3869
|
+
},
|
|
3870
|
+
|
|
3683
3871
|
/** Load everything the page needs; the catalog is loaded but not awaited. */
|
|
3684
3872
|
async init() {
|
|
3685
3873
|
await Promise.all([store.refreshStatus(), store.loadSettings(), store.loadNativeProviders(), store.loadTasks()]);
|
|
3686
3874
|
// Diagnostic read only. `init` must never perform a Codex write: installing
|
|
3687
3875
|
// files is an explicit operator action, not a side effect of opening a page.
|
|
3688
3876
|
void store.refreshCodexStatus();
|
|
3877
|
+
void store.refreshAntigravityStatus();
|
|
3689
3878
|
void store.loadCatalog();
|
|
3690
3879
|
},
|
|
3691
3880
|
|
|
@@ -3700,3 +3889,77 @@ export function createStore(options = {}) {
|
|
|
3700
3889
|
|
|
3701
3890
|
return store;
|
|
3702
3891
|
}
|
|
3892
|
+
|
|
3893
|
+
function normalizeClientPathKey(pathValue) {
|
|
3894
|
+
if (typeof pathValue !== 'string') return '';
|
|
3895
|
+
const trimmed = pathValue.trim().replace(/[\\/]+$/u, '');
|
|
3896
|
+
return trimmed.toLowerCase();
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
async function reconcileHostWorkspacesWithCleaned(hostWorkspacesOrGetter, cleaned) {
|
|
3900
|
+
if (!cleaned || typeof cleaned !== 'object') return;
|
|
3901
|
+
let wsService = null;
|
|
3902
|
+
try {
|
|
3903
|
+
wsService = typeof hostWorkspacesOrGetter === 'function' ? hostWorkspacesOrGetter() : hostWorkspacesOrGetter;
|
|
3904
|
+
} catch {
|
|
3905
|
+
wsService = null;
|
|
3906
|
+
}
|
|
3907
|
+
if (!wsService || typeof wsService !== 'object') return;
|
|
3908
|
+
|
|
3909
|
+
if (typeof wsService.archiveSession === 'function' && Array.isArray(cleaned.archivedSessionIds)) {
|
|
3910
|
+
for (const sessionId of cleaned.archivedSessionIds) {
|
|
3911
|
+
if (typeof sessionId === 'string' && sessionId !== '') {
|
|
3912
|
+
try {
|
|
3913
|
+
await wsService.archiveSession(sessionId);
|
|
3914
|
+
} catch {
|
|
3915
|
+
// Best-effort client-side session archive.
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
let snapshot = null;
|
|
3922
|
+
try {
|
|
3923
|
+
snapshot = wsService.list?.getSnapshot?.() ?? null;
|
|
3924
|
+
} catch {
|
|
3925
|
+
snapshot = null;
|
|
3926
|
+
}
|
|
3927
|
+
const items = Array.isArray(snapshot?.items) ? snapshot.items : [];
|
|
3928
|
+
const itemById = new Map();
|
|
3929
|
+
for (const item of items) {
|
|
3930
|
+
if (typeof item?.workspaceId === 'string' && item.workspaceId !== '') {
|
|
3931
|
+
itemById.set(item.workspaceId, item);
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
const removedWorkspaceIds = Array.isArray(cleaned.removedWorkspaceIds) ? cleaned.removedWorkspaceIds : [];
|
|
3936
|
+
const workspaceSet = new Set(removedWorkspaceIds);
|
|
3937
|
+
|
|
3938
|
+
if (Array.isArray(cleaned.removedWorktreePaths) && cleaned.removedWorktreePaths.length > 0 && items.length > 0) {
|
|
3939
|
+
const removedPathKeys = new Set(cleaned.removedWorktreePaths.map(normalizeClientPathKey).filter(Boolean));
|
|
3940
|
+
for (const item of items) {
|
|
3941
|
+
const key = normalizeClientPathKey(item?.path);
|
|
3942
|
+
if (key !== '' && removedPathKeys.has(key) && typeof item.workspaceId === 'string' && !workspaceSet.has(item.workspaceId)) {
|
|
3943
|
+
workspaceSet.add(item.workspaceId);
|
|
3944
|
+
removedWorkspaceIds.push(item.workspaceId);
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
cleaned.removedWorkspaceIds = removedWorkspaceIds;
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
if (typeof wsService.delete === 'function' && removedWorkspaceIds.length > 0) {
|
|
3951
|
+
for (const workspaceId of removedWorkspaceIds) {
|
|
3952
|
+
if (typeof workspaceId !== 'string' || workspaceId === '') continue;
|
|
3953
|
+
const item = itemById.get(workspaceId) ?? null;
|
|
3954
|
+
if (item !== null && typeof item.path === 'string' && /[\\/]worktrees[\\/]*$/iu.test(item.path.trim())) {
|
|
3955
|
+
// Never remove the parent TaskBridge worktrees root container workspace itself.
|
|
3956
|
+
continue;
|
|
3957
|
+
}
|
|
3958
|
+
try {
|
|
3959
|
+
await wsService.delete(workspaceId);
|
|
3960
|
+
} catch {
|
|
3961
|
+
// Best-effort client-side workspace removal.
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
}
|