dsh-taskbridge 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +751 -733
- package/antigravity/agents/dsh-taskbridge.md +14 -12
- package/antigravity/skills/dsh-taskbridge/SKILL.md +32 -19
- package/bin/dsh-delegate-codex-agent.js +9 -4
- package/codex/skills/dsh-taskbridge/SKILL.md +131 -0
- package/codex/skills/dsh-taskbridge/rules-reference-96027c387cb9b7587efa4aa3836235d86db1108068e007dc08196e807ca25e5d.md +114 -0
- package/docs/INTRODUCTION.md +148 -122
- package/docs/INTRODUCTION.zh.md +151 -134
- package/docs/antigravity-integration.md +47 -42
- package/docs/assets/taskbridge-workflow.en.svg +72 -0
- package/docs/assets/taskbridge-workflow.zh.png +0 -0
- package/docs/claude-code.md +18 -18
- package/docs/codex-integration.md +139 -113
- package/docs/releases/1.8.0.zh.md +16 -16
- package/docs/releases/1.8.1.zh.md +24 -24
- package/docs/releases/1.9.0.zh.md +31 -0
- package/docs/runtime-compatibility.md +7 -9
- package/docs/silent-wait.md +17 -26
- package/docs/taskbridge-upgrade.md +4 -4
- package/lib/client.d.ts +2 -2
- package/lib/client.js +7 -7
- package/locale/en.json +7 -7
- package/locale/zh.json +7 -7
- package/package.json +10 -4
- package/src/antigravity/installer.js +1099 -1068
- package/src/antigravity/seam.js +142 -142
- package/src/client/api.js +135 -13
- package/src/client/index.jsx +19 -18
- package/src/codex/agent-ownership.js +72 -12
- package/src/codex/installer.js +688 -268
- package/src/http/execution-plane.js +17 -0
- package/src/http/user-plane.js +6 -0
- package/src/index.d.ts +9 -1
- package/src/index.js +86 -64
- package/src/jobs/engine.js +278 -5
- package/src/jobs/history.js +17 -1
- package/src/jobs/record-cleanup.js +715 -641
- package/src/mcp/server.js +241 -12
- package/src/runtime/permissions.js +18 -0
- package/src/runtime/worker-prompt.js +13 -9
- package/codex/dsh-taskbridge.toml +0 -181
package/src/antigravity/seam.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
// The seam the user plane and plugin startup use to reach the Antigravity integration.
|
|
2
|
-
//
|
|
3
|
-
// Mirrors `src/codex/seam.js`: resolves the Antigravity config home per call
|
|
4
|
-
// (`ANTIGRAVITY_CONFIG_DIR` / `GEMINI_CONFIG_DIR` → remembered successful install →
|
|
5
|
-
// default `~/.gemini/config`), pins the active DSH discovery file, keeps `status`
|
|
6
|
-
// strictly read-only, and runs automatic startup refresh only on already-installed
|
|
7
|
-
// managed plugin files.
|
|
8
|
-
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
-
import { homedir } from 'node:os';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
|
|
13
|
-
import { writeFileAtomic } from '../config/store.js';
|
|
14
|
-
import { inspectDirectory } from '../codex/installer.js';
|
|
15
|
-
import { resolveEndpointDiscoveryPath } from '../runtime/endpoint-discovery.js';
|
|
16
|
-
import {
|
|
17
|
-
ANTIGRAVITY_ENV_VARS,
|
|
18
|
-
readAntigravityStatus,
|
|
19
|
-
refreshManagedAntigravityPlugin,
|
|
20
|
-
requireAntigravityHome,
|
|
21
|
-
resolveAntigravityHome,
|
|
22
|
-
runAntigravityAction,
|
|
23
|
-
} from './installer.js';
|
|
24
|
-
|
|
25
|
-
export function antigravityInstallationRecordPath(env = process.env) {
|
|
26
|
-
const configured = typeof env.DSH_HOME === 'string' ? env.DSH_HOME.trim() : '';
|
|
27
|
-
const dshHome = configured === '' ? join(homedir(), '.dsh') : configured;
|
|
28
|
-
return join(dshHome, 'data', 'dsh-delegate', 'antigravity-installation.json');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function rememberInstalledAntigravityHome(antigravityHome, env = process.env) {
|
|
32
|
-
if (typeof antigravityHome !== 'string' || antigravityHome.trim() === '') return false;
|
|
33
|
-
try {
|
|
34
|
-
const record = { schemaVersion: 1, antigravityHome, recordedAt: new Date().toISOString() };
|
|
35
|
-
await writeFileAtomic(antigravityInstallationRecordPath(env), `${JSON.stringify(record)}\n`);
|
|
36
|
-
return true;
|
|
37
|
-
} catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function readInstalledAntigravityHome(env = process.env) {
|
|
43
|
-
try {
|
|
44
|
-
const text = readFileSync(antigravityInstallationRecordPath(env), 'utf8');
|
|
45
|
-
const record = JSON.parse(text);
|
|
46
|
-
if (record === null || typeof record !== 'object' || Array.isArray(record)) return null;
|
|
47
|
-
if (record.schemaVersion !== 1) return null;
|
|
48
|
-
if (typeof record.antigravityHome !== 'string' || record.antigravityHome.trim() === '') return null;
|
|
49
|
-
return requireAntigravityHome(record.antigravityHome);
|
|
50
|
-
} catch {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function resolveHomePreference({ env, explicitHome = '', homeDirectory = undefined, forAction = false }) {
|
|
56
|
-
if (explicitHome !== '') return { home: requireAntigravityHome(explicitHome), blocked: false, source: 'explicit' };
|
|
57
|
-
for (const key of ANTIGRAVITY_ENV_VARS) {
|
|
58
|
-
const configured = typeof env?.[key] === 'string' ? env[key].trim() : '';
|
|
59
|
-
if (configured !== '') return { home: requireAntigravityHome(configured), blocked: false, source: 'explicit' };
|
|
60
|
-
}
|
|
61
|
-
const remembered = readInstalledAntigravityHome(env);
|
|
62
|
-
if (remembered !== null) {
|
|
63
|
-
const kind = await inspectDirectory(remembered);
|
|
64
|
-
if (kind.kind === 'directory') return { home: remembered, blocked: false, source: 'recorded' };
|
|
65
|
-
}
|
|
66
|
-
const fallback = resolveAntigravityHome({ env, ...(homeDirectory === undefined ? {} : { homeDirectory }) });
|
|
67
|
-
const kind = await inspectDirectory(fallback);
|
|
68
|
-
if (kind.kind === 'missing') {
|
|
69
|
-
return forAction
|
|
70
|
-
? { home: fallback, blocked: false, source: 'default' }
|
|
71
|
-
: { home: null, blocked: false, source: 'none' };
|
|
72
|
-
}
|
|
73
|
-
if (kind.kind === 'directory') return { home: fallback, blocked: false, source: 'default' };
|
|
74
|
-
// A root link is allowed on explicit status/action (the installer pins it to realpath),
|
|
75
|
-
// while startup refresh skips an unrecorded default link.
|
|
76
|
-
if (forAction) return { home: fallback, blocked: false, source: 'default' };
|
|
77
|
-
return { home: fallback, blocked: true, source: 'default' };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function createAntigravitySeam(options = {}) {
|
|
81
|
-
const env = options.env ?? process.env;
|
|
82
|
-
const requestedHome = typeof options.antigravityHome === 'string' && options.antigravityHome.trim() !== ''
|
|
83
|
-
? options.antigravityHome
|
|
84
|
-
: null;
|
|
85
|
-
const requestedDiscovery = typeof options.discoveryFile === 'string' && options.discoveryFile.trim() !== ''
|
|
86
|
-
? options.discoveryFile
|
|
87
|
-
: null;
|
|
88
|
-
const homeDirectory = options.homeDirectory;
|
|
89
|
-
const version = typeof options.version === 'string' ? options.version : null;
|
|
90
|
-
|
|
91
|
-
const discovery = () => (requestedDiscovery !== null ? requestedDiscovery : resolveEndpointDiscoveryPath(env));
|
|
92
|
-
const baseFor = (home) => ({
|
|
93
|
-
antigravityHome: home,
|
|
94
|
-
env,
|
|
95
|
-
...(homeDirectory === undefined ? {} : { homeDirectory }),
|
|
96
|
-
...(options.nodeExecutable === undefined ? {} : { nodeExecutable: options.nodeExecutable }),
|
|
97
|
-
...(options.execPath === undefined ? {} : { execPath: options.execPath }),
|
|
98
|
-
...(options.resourcesPath === undefined ? {} : { resourcesPath: options.resourcesPath }),
|
|
99
|
-
...(options.versions === undefined ? {} : { versions: options.versions }),
|
|
100
|
-
...(options.platform === undefined ? {} : { platform: options.platform }),
|
|
101
|
-
...(discovery() === undefined ? {} : { discoveryFile: discovery() }),
|
|
102
|
-
...(version === null ? {} : { version }),
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
async startupTarget() {
|
|
107
|
-
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: false });
|
|
108
|
-
const reason = resolved.home === null ? 'no-antigravity-home'
|
|
109
|
-
: (resolved.blocked === true ? 'default-is-link' : null);
|
|
110
|
-
return { home: resolved.blocked ? null : resolved.home, source: resolved.source, reason };
|
|
111
|
-
},
|
|
112
|
-
async refreshManagedIntegration(callOptions = {}) {
|
|
113
|
-
const target = callOptions?.startupTarget ?? await this.startupTarget();
|
|
114
|
-
if (typeof target?.home !== 'string' || target.home === '') {
|
|
115
|
-
return { changed: [], refused: [], status: null };
|
|
116
|
-
}
|
|
117
|
-
return await refreshManagedAntigravityPlugin(baseFor(target.home));
|
|
118
|
-
},
|
|
119
|
-
async status() {
|
|
120
|
-
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: true });
|
|
121
|
-
return {
|
|
122
|
-
changed: [],
|
|
123
|
-
refused: [],
|
|
124
|
-
status: await readAntigravityStatus(baseFor(resolved.home)),
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
async run(action) {
|
|
128
|
-
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: true });
|
|
129
|
-
const outcome = await runAntigravityAction(action, baseFor(resolved.home));
|
|
130
|
-
const home = outcome.status?.realAntigravityHome ?? outcome.status?.antigravityHome ?? resolved.home;
|
|
131
|
-
if (action === 'install' && outcome.refused.length === 0 && typeof home === 'string' && home !== '') {
|
|
132
|
-
await rememberInstalledAntigravityHome(home, env);
|
|
133
|
-
}
|
|
134
|
-
return outcome;
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function resolveAntigravityActionSeam(options = {}) {
|
|
140
|
-
if (options.disabled === true) return null;
|
|
141
|
-
return createAntigravitySeam(options);
|
|
142
|
-
}
|
|
1
|
+
// The seam the user plane and plugin startup use to reach the Antigravity integration.
|
|
2
|
+
//
|
|
3
|
+
// Mirrors `src/codex/seam.js`: resolves the Antigravity config home per call
|
|
4
|
+
// (`ANTIGRAVITY_CONFIG_DIR` / `GEMINI_CONFIG_DIR` → remembered successful install →
|
|
5
|
+
// default `~/.gemini/config`), pins the active DSH discovery file, keeps `status`
|
|
6
|
+
// strictly read-only, and runs automatic startup refresh only on already-installed
|
|
7
|
+
// managed plugin files.
|
|
8
|
+
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
import { writeFileAtomic } from '../config/store.js';
|
|
14
|
+
import { inspectDirectory } from '../codex/installer.js';
|
|
15
|
+
import { resolveEndpointDiscoveryPath } from '../runtime/endpoint-discovery.js';
|
|
16
|
+
import {
|
|
17
|
+
ANTIGRAVITY_ENV_VARS,
|
|
18
|
+
readAntigravityStatus,
|
|
19
|
+
refreshManagedAntigravityPlugin,
|
|
20
|
+
requireAntigravityHome,
|
|
21
|
+
resolveAntigravityHome,
|
|
22
|
+
runAntigravityAction,
|
|
23
|
+
} from './installer.js';
|
|
24
|
+
|
|
25
|
+
export function antigravityInstallationRecordPath(env = process.env) {
|
|
26
|
+
const configured = typeof env.DSH_HOME === 'string' ? env.DSH_HOME.trim() : '';
|
|
27
|
+
const dshHome = configured === '' ? join(homedir(), '.dsh') : configured;
|
|
28
|
+
return join(dshHome, 'data', 'dsh-delegate', 'antigravity-installation.json');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function rememberInstalledAntigravityHome(antigravityHome, env = process.env) {
|
|
32
|
+
if (typeof antigravityHome !== 'string' || antigravityHome.trim() === '') return false;
|
|
33
|
+
try {
|
|
34
|
+
const record = { schemaVersion: 1, antigravityHome, recordedAt: new Date().toISOString() };
|
|
35
|
+
await writeFileAtomic(antigravityInstallationRecordPath(env), `${JSON.stringify(record)}\n`);
|
|
36
|
+
return true;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function readInstalledAntigravityHome(env = process.env) {
|
|
43
|
+
try {
|
|
44
|
+
const text = readFileSync(antigravityInstallationRecordPath(env), 'utf8');
|
|
45
|
+
const record = JSON.parse(text);
|
|
46
|
+
if (record === null || typeof record !== 'object' || Array.isArray(record)) return null;
|
|
47
|
+
if (record.schemaVersion !== 1) return null;
|
|
48
|
+
if (typeof record.antigravityHome !== 'string' || record.antigravityHome.trim() === '') return null;
|
|
49
|
+
return requireAntigravityHome(record.antigravityHome);
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function resolveHomePreference({ env, explicitHome = '', homeDirectory = undefined, forAction = false }) {
|
|
56
|
+
if (explicitHome !== '') return { home: requireAntigravityHome(explicitHome), blocked: false, source: 'explicit' };
|
|
57
|
+
for (const key of ANTIGRAVITY_ENV_VARS) {
|
|
58
|
+
const configured = typeof env?.[key] === 'string' ? env[key].trim() : '';
|
|
59
|
+
if (configured !== '') return { home: requireAntigravityHome(configured), blocked: false, source: 'explicit' };
|
|
60
|
+
}
|
|
61
|
+
const remembered = readInstalledAntigravityHome(env);
|
|
62
|
+
if (remembered !== null) {
|
|
63
|
+
const kind = await inspectDirectory(remembered);
|
|
64
|
+
if (kind.kind === 'directory') return { home: remembered, blocked: false, source: 'recorded' };
|
|
65
|
+
}
|
|
66
|
+
const fallback = resolveAntigravityHome({ env, ...(homeDirectory === undefined ? {} : { homeDirectory }) });
|
|
67
|
+
const kind = await inspectDirectory(fallback);
|
|
68
|
+
if (kind.kind === 'missing') {
|
|
69
|
+
return forAction
|
|
70
|
+
? { home: fallback, blocked: false, source: 'default' }
|
|
71
|
+
: { home: null, blocked: false, source: 'none' };
|
|
72
|
+
}
|
|
73
|
+
if (kind.kind === 'directory') return { home: fallback, blocked: false, source: 'default' };
|
|
74
|
+
// A root link is allowed on explicit status/action (the installer pins it to realpath),
|
|
75
|
+
// while startup refresh skips an unrecorded default link.
|
|
76
|
+
if (forAction) return { home: fallback, blocked: false, source: 'default' };
|
|
77
|
+
return { home: fallback, blocked: true, source: 'default' };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function createAntigravitySeam(options = {}) {
|
|
81
|
+
const env = options.env ?? process.env;
|
|
82
|
+
const requestedHome = typeof options.antigravityHome === 'string' && options.antigravityHome.trim() !== ''
|
|
83
|
+
? options.antigravityHome
|
|
84
|
+
: null;
|
|
85
|
+
const requestedDiscovery = typeof options.discoveryFile === 'string' && options.discoveryFile.trim() !== ''
|
|
86
|
+
? options.discoveryFile
|
|
87
|
+
: null;
|
|
88
|
+
const homeDirectory = options.homeDirectory;
|
|
89
|
+
const version = typeof options.version === 'string' ? options.version : null;
|
|
90
|
+
|
|
91
|
+
const discovery = () => (requestedDiscovery !== null ? requestedDiscovery : resolveEndpointDiscoveryPath(env));
|
|
92
|
+
const baseFor = (home) => ({
|
|
93
|
+
antigravityHome: home,
|
|
94
|
+
env,
|
|
95
|
+
...(homeDirectory === undefined ? {} : { homeDirectory }),
|
|
96
|
+
...(options.nodeExecutable === undefined ? {} : { nodeExecutable: options.nodeExecutable }),
|
|
97
|
+
...(options.execPath === undefined ? {} : { execPath: options.execPath }),
|
|
98
|
+
...(options.resourcesPath === undefined ? {} : { resourcesPath: options.resourcesPath }),
|
|
99
|
+
...(options.versions === undefined ? {} : { versions: options.versions }),
|
|
100
|
+
...(options.platform === undefined ? {} : { platform: options.platform }),
|
|
101
|
+
...(discovery() === undefined ? {} : { discoveryFile: discovery() }),
|
|
102
|
+
...(version === null ? {} : { version }),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
async startupTarget() {
|
|
107
|
+
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: false });
|
|
108
|
+
const reason = resolved.home === null ? 'no-antigravity-home'
|
|
109
|
+
: (resolved.blocked === true ? 'default-is-link' : null);
|
|
110
|
+
return { home: resolved.blocked ? null : resolved.home, source: resolved.source, reason };
|
|
111
|
+
},
|
|
112
|
+
async refreshManagedIntegration(callOptions = {}) {
|
|
113
|
+
const target = callOptions?.startupTarget ?? await this.startupTarget();
|
|
114
|
+
if (typeof target?.home !== 'string' || target.home === '') {
|
|
115
|
+
return { changed: [], refused: [], status: null };
|
|
116
|
+
}
|
|
117
|
+
return await refreshManagedAntigravityPlugin(baseFor(target.home));
|
|
118
|
+
},
|
|
119
|
+
async status() {
|
|
120
|
+
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: true });
|
|
121
|
+
return {
|
|
122
|
+
changed: [],
|
|
123
|
+
refused: [],
|
|
124
|
+
status: await readAntigravityStatus(baseFor(resolved.home)),
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
async run(action) {
|
|
128
|
+
const resolved = await resolveHomePreference({ env, explicitHome: requestedHome ?? '', homeDirectory, forAction: true });
|
|
129
|
+
const outcome = await runAntigravityAction(action, baseFor(resolved.home));
|
|
130
|
+
const home = outcome.status?.realAntigravityHome ?? outcome.status?.antigravityHome ?? resolved.home;
|
|
131
|
+
if (action === 'install' && outcome.refused.length === 0 && typeof home === 'string' && home !== '') {
|
|
132
|
+
await rememberInstalledAntigravityHome(home, env);
|
|
133
|
+
}
|
|
134
|
+
return outcome;
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function resolveAntigravityActionSeam(options = {}) {
|
|
140
|
+
if (options.disabled === true) return null;
|
|
141
|
+
return createAntigravitySeam(options);
|
|
142
|
+
}
|
package/src/client/api.js
CHANGED
|
@@ -884,7 +884,7 @@ export const CODEX_ACTIONS = Object.freeze(['install', 'repair', 'remove']);
|
|
|
884
884
|
* configured, and both can be ready while the local-call switch is still off.
|
|
885
885
|
*/
|
|
886
886
|
export const CODEX_TARGETS = Object.freeze([
|
|
887
|
-
{ key: 'agent', label: 'Codex
|
|
887
|
+
{ key: 'agent', label: 'Codex 原生技能(skills/dsh-taskbridge/SKILL.md)' },
|
|
888
888
|
{ key: 'mcp', label: 'Codex MCP 条目' },
|
|
889
889
|
{ key: 'switch', label: 'DSH 本机调用开关' },
|
|
890
890
|
]);
|
|
@@ -925,7 +925,7 @@ export function codexTargetView(codex, switchState, target) {
|
|
|
925
925
|
: '已关闭:Codex 可以查询状态,但新任务会被拒绝;本页不会替你打开它。',
|
|
926
926
|
};
|
|
927
927
|
}
|
|
928
|
-
const block = target === 'agent' ? codex?.agent : codex?.mcp;
|
|
928
|
+
const block = target === 'agent' ? (codex?.skill ?? codex?.agent) : codex?.mcp;
|
|
929
929
|
if (block === null || block === undefined || typeof block !== 'object') {
|
|
930
930
|
return { key: target, label, state: 'unknown', tone: 'off', detail: '宿主尚未回报该状态。' };
|
|
931
931
|
}
|
|
@@ -961,11 +961,18 @@ export function codexTargetView(codex, switchState, target) {
|
|
|
961
961
|
*/
|
|
962
962
|
export function describeCodexOutcome(outcome) {
|
|
963
963
|
if (outcome === null || outcome === undefined) return '';
|
|
964
|
-
const names = { agent: '
|
|
965
|
-
const
|
|
964
|
+
const names = { agent: '技能文件(SKILL.md)', legacyAgent: '旧版子智能体文件', mcp: 'MCP 条目' };
|
|
965
|
+
const rawChanged = Array.isArray(outcome.changed) ? outcome.changed : [];
|
|
966
966
|
const refused = Array.isArray(outcome.refused) ? outcome.refused : [];
|
|
967
967
|
const parts = [];
|
|
968
|
-
if (
|
|
968
|
+
if (outcome.action === 'remove') {
|
|
969
|
+
if (rawChanged.length > 0) parts.push(`已移除:${rawChanged.map((key) => names[key] ?? key).join('、')}`);
|
|
970
|
+
} else {
|
|
971
|
+
const written = rawChanged.filter((key) => key !== 'legacyAgent').map((key) => names[key] ?? key);
|
|
972
|
+
const cleaned = rawChanged.filter((key) => key === 'legacyAgent').map((key) => names[key] ?? key);
|
|
973
|
+
if (written.length > 0) parts.push(`已写入:${written.join('、')}`);
|
|
974
|
+
if (cleaned.length > 0) parts.push(`已清理:${cleaned.join('、')}`);
|
|
975
|
+
}
|
|
969
976
|
if (refused.length > 0) parts.push(`未改动:${refused.map((entry) => names[entry?.target] ?? entry?.target ?? '未知').join('、')}`);
|
|
970
977
|
if (parts.length === 0) {
|
|
971
978
|
return outcome.action === 'remove' ? '没有需要移除的插件托管文件。' : '已是最新,没有需要写入的内容。';
|
|
@@ -2570,6 +2577,16 @@ export function planCreateRequest(draft) {
|
|
|
2570
2577
|
* @param {object} options - `api` transport, `now` clock.
|
|
2571
2578
|
* @returns {object} store with `subscribe`, `getSnapshot` and action methods.
|
|
2572
2579
|
*/
|
|
2580
|
+
/** Backoff schedule (ms) when `init()` hits a startup 404 right after "Enable immediately". */
|
|
2581
|
+
const DEFAULT_INIT_RETRY_DELAYS_MS = Object.freeze([250, 500, 1000, 1500, 2000, 2500, 3000]);
|
|
2582
|
+
|
|
2583
|
+
/** Whether an error indicates the plugin backend HTTP routes have not mounted yet. */
|
|
2584
|
+
function isStartupRoutePendingError(error) {
|
|
2585
|
+
return error?.code === 'HTTP_404'
|
|
2586
|
+
|| error?.code === 'USER_PLANE_UNKNOWN_ROUTE'
|
|
2587
|
+
|| error?.code === 'USER_PLANE_UNREACHABLE';
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2573
2590
|
export function createStore(options = {}) {
|
|
2574
2591
|
const api = options.api ?? createApi();
|
|
2575
2592
|
// The task-record cleanup projection. It is injected rather than imported so this
|
|
@@ -2583,6 +2600,9 @@ export function createStore(options = {}) {
|
|
|
2583
2600
|
const saveDebounceMs = Number.isFinite(options.saveDebounceMs) && options.saveDebounceMs >= 0
|
|
2584
2601
|
? Math.trunc(options.saveDebounceMs)
|
|
2585
2602
|
: 700;
|
|
2603
|
+
const initRetryDelaysMs = Array.isArray(options.initRetryDelaysMs)
|
|
2604
|
+
? options.initRetryDelaysMs.filter((ms) => Number.isFinite(ms) && ms >= 0).map((ms) => Math.trunc(ms))
|
|
2605
|
+
: DEFAULT_INIT_RETRY_DELAYS_MS;
|
|
2586
2606
|
const scheduleImpl = typeof options.schedule === 'function'
|
|
2587
2607
|
? options.schedule
|
|
2588
2608
|
: (fn, ms) => setTimeout(fn, ms);
|
|
@@ -2604,6 +2624,13 @@ export function createStore(options = {}) {
|
|
|
2604
2624
|
let saveTimer = null;
|
|
2605
2625
|
/** Explicit discard marker: the next debounce tick must not resurrect edits. */
|
|
2606
2626
|
let saveSuppressed = false;
|
|
2627
|
+
/** Coalesced in-flight `init()` promise so remounting while bootstrapping never overlaps. */
|
|
2628
|
+
let initInFlight = null;
|
|
2629
|
+
/** Pending startup retry timer handle and canceller for `dispose()`. */
|
|
2630
|
+
let initRetryTimer = null;
|
|
2631
|
+
let cancelInitRetryWait = null;
|
|
2632
|
+
/** Last startup-failure notice emitted by `init()`, cleared automatically on recovery. */
|
|
2633
|
+
let initErrorNoticeId = null;
|
|
2607
2634
|
/**
|
|
2608
2635
|
* Sequence of `openTask` calls. A detail read may only publish its answer if no
|
|
2609
2636
|
* NEWER read started meanwhile, so a slow response for an old row cannot replace the
|
|
@@ -2710,12 +2737,15 @@ export function createStore(options = {}) {
|
|
|
2710
2737
|
}
|
|
2711
2738
|
|
|
2712
2739
|
/**
|
|
2713
|
-
* Append one operator-facing message
|
|
2740
|
+
* Append one operator-facing message, deduplicating identical live notices so
|
|
2741
|
+
* parallel transient failures never stack repeated identical banners.
|
|
2714
2742
|
* @param {'info'|'error'|'success'} level - severity.
|
|
2715
2743
|
* @param {string} text - Chinese text.
|
|
2716
2744
|
* @returns {number} notice id.
|
|
2717
2745
|
*/
|
|
2718
2746
|
function notify(level, text) {
|
|
2747
|
+
const existing = state.notices.find((notice) => notice.level === level && notice.text === text);
|
|
2748
|
+
if (existing !== undefined) return existing.id;
|
|
2719
2749
|
const id = state.revision + 1 + Math.random();
|
|
2720
2750
|
patch({ notices: [...state.notices, { id, level, text }].slice(-6) });
|
|
2721
2751
|
return id;
|
|
@@ -2725,6 +2755,31 @@ export function createStore(options = {}) {
|
|
|
2725
2755
|
patch({ notices: state.notices.filter((notice) => notice.id !== id) });
|
|
2726
2756
|
}
|
|
2727
2757
|
|
|
2758
|
+
/** Wait `ms` before retrying startup readiness; resolves `false` if disposed meanwhile. */
|
|
2759
|
+
function waitForInitRetry(ms) {
|
|
2760
|
+
return new Promise((resolve) => {
|
|
2761
|
+
if (disposed) {
|
|
2762
|
+
resolve(false);
|
|
2763
|
+
return;
|
|
2764
|
+
}
|
|
2765
|
+
let settled = false;
|
|
2766
|
+
const finish = (keepGoing) => {
|
|
2767
|
+
if (settled) return;
|
|
2768
|
+
settled = true;
|
|
2769
|
+
initRetryTimer = null;
|
|
2770
|
+
cancelInitRetryWait = null;
|
|
2771
|
+
resolve(keepGoing);
|
|
2772
|
+
};
|
|
2773
|
+
cancelInitRetryWait = () => {
|
|
2774
|
+
if (initRetryTimer !== null) {
|
|
2775
|
+
try { cancelScheduleImpl(initRetryTimer); } catch { /* ignore */ }
|
|
2776
|
+
}
|
|
2777
|
+
finish(false);
|
|
2778
|
+
};
|
|
2779
|
+
initRetryTimer = scheduleImpl(() => finish(!disposed), Math.max(0, ms));
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2728
2783
|
async function track(key, work) {
|
|
2729
2784
|
patch({ loading: { ...state.loading, [key]: true } });
|
|
2730
2785
|
try {
|
|
@@ -3868,20 +3923,87 @@ export function createStore(options = {}) {
|
|
|
3868
3923
|
});
|
|
3869
3924
|
},
|
|
3870
3925
|
|
|
3871
|
-
/**
|
|
3926
|
+
/**
|
|
3927
|
+
* Load everything the page needs; tolerates the short cold-start window right after
|
|
3928
|
+
* "Enable immediately" when the frontend mounts before backend HTTP routes finish
|
|
3929
|
+
* registering, retrying `/status` silently instead of stacking 404 banners.
|
|
3930
|
+
*/
|
|
3872
3931
|
async init() {
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3932
|
+
if (disposed) return;
|
|
3933
|
+
if (initInFlight !== null) return await initInFlight;
|
|
3934
|
+
const run = (async () => {
|
|
3935
|
+
let startupNoticeId = null;
|
|
3936
|
+
let statusOutcome = null;
|
|
3937
|
+
let statusReady = false;
|
|
3938
|
+
let lastStartupError = null;
|
|
3939
|
+
|
|
3940
|
+
for (let attempt = 0; attempt <= initRetryDelaysMs.length; attempt += 1) {
|
|
3941
|
+
if (disposed) return;
|
|
3942
|
+
statusOutcome = await track('status', async () => {
|
|
3943
|
+
try {
|
|
3944
|
+
const body = await api.getStatus();
|
|
3945
|
+
patch({ status: body });
|
|
3946
|
+
return { ok: true, body };
|
|
3947
|
+
} catch (error) {
|
|
3948
|
+
return { ok: false, error };
|
|
3949
|
+
}
|
|
3950
|
+
});
|
|
3951
|
+
if (statusOutcome.ok) {
|
|
3952
|
+
statusReady = true;
|
|
3953
|
+
break;
|
|
3954
|
+
}
|
|
3955
|
+
if (!isStartupRoutePendingError(statusOutcome.error) || attempt === initRetryDelaysMs.length) {
|
|
3956
|
+
lastStartupError = statusOutcome.error;
|
|
3957
|
+
break;
|
|
3958
|
+
}
|
|
3959
|
+
if (startupNoticeId === null) {
|
|
3960
|
+
startupNoticeId = notify('info', '插件服务正在启动,正在自动重试连接…');
|
|
3961
|
+
}
|
|
3962
|
+
const keepGoing = await waitForInitRetry(initRetryDelaysMs[attempt]);
|
|
3963
|
+
if (!keepGoing || disposed) return;
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
if (startupNoticeId !== null) {
|
|
3967
|
+
dismissNotice(startupNoticeId);
|
|
3968
|
+
startupNoticeId = null;
|
|
3969
|
+
}
|
|
3970
|
+
if (disposed) return;
|
|
3971
|
+
|
|
3972
|
+
if (statusReady && initErrorNoticeId !== null) {
|
|
3973
|
+
dismissNotice(initErrorNoticeId);
|
|
3974
|
+
initErrorNoticeId = null;
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
if (!statusReady) {
|
|
3978
|
+
const err = lastStartupError ?? statusOutcome?.error;
|
|
3979
|
+
if (err !== undefined && err !== null) {
|
|
3980
|
+
initErrorNoticeId = notify('error', describeError(err));
|
|
3981
|
+
if (isStartupRoutePendingError(err)) {
|
|
3982
|
+
patch({ nativeProvidersError: describeError(err), tasksError: err });
|
|
3983
|
+
return;
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
await Promise.all([store.loadSettings(), store.loadNativeProviders(), store.loadTasks()]);
|
|
3989
|
+
if (disposed) return;
|
|
3990
|
+
// Diagnostic read only. `init` must never perform a Codex write: installing
|
|
3991
|
+
// files is an explicit operator action, not a side effect of opening a page.
|
|
3992
|
+
void store.refreshCodexStatus();
|
|
3993
|
+
void store.refreshAntigravityStatus();
|
|
3994
|
+
void store.loadCatalog();
|
|
3995
|
+
})().finally(() => {
|
|
3996
|
+
if (initInFlight === run) initInFlight = null;
|
|
3997
|
+
});
|
|
3998
|
+
initInFlight = run;
|
|
3999
|
+
return await run;
|
|
3879
4000
|
},
|
|
3880
4001
|
|
|
3881
4002
|
/** Release subscriptions and drop the one-time token. */
|
|
3882
4003
|
dispose() {
|
|
3883
4004
|
cancelPendingSave();
|
|
3884
4005
|
disposed = true;
|
|
4006
|
+
if (typeof cancelInitRetryWait === 'function') cancelInitRetryWait();
|
|
3885
4007
|
state = { ...state, token: null, tokenConnectionId: null };
|
|
3886
4008
|
listeners.clear();
|
|
3887
4009
|
},
|
package/src/client/index.jsx
CHANGED
|
@@ -2136,7 +2136,7 @@ function TaskDetail({ store, task }) {
|
|
|
2136
2136
|
<dt>无进展诊断</dt>
|
|
2137
2137
|
<dd>
|
|
2138
2138
|
{activity === null || activity.selfCheck === null || activity.selfCheck.verdict === null
|
|
2139
|
-
? (activity === null ? '未采集到' : '
|
|
2139
|
+
? (activity === null ? '未采集到' : '尚未触发程序自检(开始运行时间还没到自检间隔,或已关闭自检)')
|
|
2140
2140
|
: `${SELF_CHECK_LABELS[activity.selfCheck.verdict] ?? activity.selfCheck.verdict}`
|
|
2141
2141
|
+ (activity.selfCheck.checkedAt === null ? '' : `(${formatTime(activity.selfCheck.checkedAt)})`)}
|
|
2142
2142
|
</dd>
|
|
@@ -2229,8 +2229,8 @@ function TaskDetail({ store, task }) {
|
|
|
2229
2229
|
</>
|
|
2230
2230
|
)}
|
|
2231
2231
|
<p className="dshdg-hint">
|
|
2232
|
-
|
|
2233
|
-
|
|
2232
|
+
逐次授权只覆盖当前调用。后续调用如需扩大权限,须重新核对参数并审批。它不能创建或扩大任何跨任务或长期有效的授权(“长期有效”指跨会话持久的授权),不能修改设置、凭据、本机调用开关、提供方、模型或隔离方式;
|
|
2233
|
+
工作进程的常规沙箱权限始终保持 workspace-write。此界面不提供手工批准按钮,决定由本机 MCP 指挥官通过
|
|
2234
2234
|
delegate_permission_decide 作出。
|
|
2235
2235
|
</p>
|
|
2236
2236
|
|
|
@@ -3316,7 +3316,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
3316
3316
|
return (
|
|
3317
3317
|
<div className="dshdg-panel">
|
|
3318
3318
|
<div className="dshdg-row">
|
|
3319
|
-
<p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。</p>
|
|
3319
|
+
<p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex 或 Antigravity)单独给出结论。</p>
|
|
3320
3320
|
<span className="dshdg-spacer" />
|
|
3321
3321
|
<span className="dshdg-hint" data-dshdg-refresh-hint="">
|
|
3322
3322
|
{changing !== true
|
|
@@ -3478,19 +3478,21 @@ function CodexPanel({ store, snapshot }) {
|
|
|
3478
3478
|
return (
|
|
3479
3479
|
<section className="dshdg-card" aria-labelledby="dshdg-codex-title">
|
|
3480
3480
|
<div className="dshdg-row">
|
|
3481
|
-
<h3 id="dshdg-codex-title">Codex
|
|
3481
|
+
<h3 id="dshdg-codex-title">Codex 集成(技能 Skill + MCP)</h3>
|
|
3482
3482
|
<span className="dshdg-spacer" />
|
|
3483
3483
|
<Badge tone={ready ? 'on' : 'off'}>{ready ? '已就绪' : '未就绪'}</Badge>
|
|
3484
3484
|
</div>
|
|
3485
3485
|
<p className="dshdg-muted">
|
|
3486
|
-
{'
|
|
3487
|
-
<span className="dshdg-mono">
|
|
3486
|
+
{'点下面的按钮,把原生技能 '}
|
|
3487
|
+
<span className="dshdg-mono">skills/dsh-taskbridge/SKILL.md</span>
|
|
3488
3488
|
{' 装进 Codex 目录,并在 Codex 的 '}
|
|
3489
3489
|
<span className="dshdg-mono">config.toml</span>
|
|
3490
|
-
{' 里登记本插件的 stdio MCP
|
|
3491
|
-
+ '
|
|
3492
|
-
+ '
|
|
3493
|
-
+ '
|
|
3490
|
+
{' 里登记本插件的 stdio MCP 服务(全套 11 个 delegate_* 工具:delegate_status / delegate_preflight / delegate_plan / delegate_submit / delegate_wait / delegate_permission_decide / delegate_question_answer / delegate_result / delegate_review / delegate_cancel / delegate_metrics)。'
|
|
3491
|
+
+ '首次安装只会由你点击触发:打开本页、安装或升级本插件都不会自动创建技能文件或 MCP 条目。'
|
|
3492
|
+
+ '若目录里存在早期版本写入且未经你改动的旧子智能体文件(agents/dsh-taskbridge.toml / agents/dsh-delegate.toml),'
|
|
3493
|
+
+ '插件会在升级或安装时自动迁移为原生技能并安全移除旧文件;你手动改过的旧文件会原样保留不删。'
|
|
3494
|
+
+ '已经安装过的情况下,插件下次启动也会把本插件自己写入的过期托管 MCP 条目就地更新(例如补上 tool_timeout_sec),'
|
|
3495
|
+
+ '不触碰非托管条目或 Codex 的其他设置。'}
|
|
3494
3496
|
</p>
|
|
3495
3497
|
{error === null ? null : <p className="dshdg-fail">{error}</p>}
|
|
3496
3498
|
{codex === null ? (
|
|
@@ -3511,7 +3513,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
3511
3513
|
<p className="dshdg-hint" data-dshdg-codex-drift="">
|
|
3512
3514
|
{'这个托管 MCP 条目已经过期:'}
|
|
3513
3515
|
{codexMcpDriftText(codex.mcp)}
|
|
3514
|
-
{'。插件下次启动会自动在原地更新;也可以点上面的「安装 / 更新 TaskBridge
|
|
3516
|
+
{'。插件下次启动会自动在原地更新;也可以点上面的「安装 / 更新 TaskBridge 技能」。'}
|
|
3515
3517
|
</p>
|
|
3516
3518
|
) : null}
|
|
3517
3519
|
{notes.length === 0 ? null : (
|
|
@@ -3524,7 +3526,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
3524
3526
|
{refreshing ? '读取中…' : '刷新状态'}
|
|
3525
3527
|
</button>
|
|
3526
3528
|
<button type="button" className="dshdg-primary" disabled={disabled} onClick={() => { void store.runCodexAction('install'); }}>
|
|
3527
|
-
{busy ? '处理中…' : '安装 / 更新 TaskBridge
|
|
3529
|
+
{busy ? '处理中…' : '安装 / 更新 TaskBridge 技能'}
|
|
3528
3530
|
</button>
|
|
3529
3531
|
<button type="button" disabled={disabled} onClick={() => { void store.runCodexAction('repair'); }}>
|
|
3530
3532
|
仅修复 MCP 配置
|
|
@@ -3539,11 +3541,10 @@ function CodexPanel({ store, snapshot }) {
|
|
|
3539
3541
|
</>
|
|
3540
3542
|
)}
|
|
3541
3543
|
<p className="dshdg-hint">
|
|
3542
|
-
{'安装后需要让 Codex 重新载入:新开会话或重启 Codex
|
|
3543
|
-
+ '
|
|
3544
|
-
+ '
|
|
3545
|
-
+ '
|
|
3546
|
-
+ '同名的自定义 agent 会被保留并报告为冲突;没有本插件托管标记注释的同名 MCP 条目也视为你自己写的,不会被覆盖或删除。'}
|
|
3544
|
+
{'安装后需要让 Codex 重新载入:新开会话或重启 Codex,才会读到新的原生技能和 MCP 条目。'
|
|
3545
|
+
+ 'Codex 会话在明确指派时(例如 $dsh-taskbridge 或明确要求交给 DSH / TaskBridge)会按技能规则由当前会话直接调用 delegate_submit 与单链 delegate_wait(利用 tool_timeout_sec = 3660 静默长等,不再派生子智能体并做 wait_agent 短轮询)。'
|
|
3546
|
+
+ '技能只在明确指派时派发任务,并在提交前先检查上面的本机调用开关;本页不会替你打开该开关。'
|
|
3547
|
+
+ '同名的自定义技能文件或你手动改过的旧 agents/*.toml 都会被保留而不被覆盖或删除;没有本插件托管标记注释的同名 MCP 条目也视为你自己写的,不会被覆盖或删除。'}
|
|
3547
3548
|
</p>
|
|
3548
3549
|
</section>
|
|
3549
3550
|
);
|