dsh-taskbridge 1.9.0 → 1.9.2

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.
@@ -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
@@ -647,7 +647,7 @@ export const GRANT_KIND_LABELS = Object.freeze({
647
647
  * standing permission, and the panel must not read like an approval workflow.
648
648
  */
649
649
  export const PERMISSION_STATE_LABELS = Object.freeze({
650
- pending: '等待本机指挥官决定(仅这一次调用)',
650
+ pending: '等待宿主端决定(仅这一次调用)',
651
651
  decided: '已决定',
652
652
  expired: '已超时(未决定即为拒绝)',
653
653
  cancelled: '已撤回',
@@ -1434,8 +1434,8 @@ export function permissionSummary(task) {
1434
1434
  waiting: true,
1435
1435
  label: '等待本次调用授权决定',
1436
1436
  note: access === null || access === undefined
1437
- ? `工作进程暂停在 ${tool} 这一次调用上,等待本机指挥官决定。任务仍在运行,未失败,也未完成。`
1438
- : `工作进程暂停在 ${tool} 这一次调用上,请求把该次调用的沙箱权限提升到 ${access},等待本机指挥官决定。`
1437
+ ? `工作进程暂停在 ${tool} 这一次调用上,等待宿主端决定。任务仍在运行,未失败,也未完成。`
1438
+ : `工作进程暂停在 ${tool} 这一次调用上,请求把该次调用的沙箱权限提升到 ${access},等待宿主端决定。`
1439
1439
  + '无论是否允许,会话的常规权限(workspace-write)保持不变。',
1440
1440
  detail: `请求编号 ${pending?.requestId ?? '—'} · 调用 ${pending?.callId ?? '—'}`,
1441
1441
  };
@@ -1806,7 +1806,7 @@ export function taskOutcome(task) {
1806
1806
  } else if (state === 'awaiting-host-review') {
1807
1807
  label = '等待宿主审查';
1808
1808
  tone = 'warn';
1809
- note = '执行已完成,等待宿主(Codex)审查;插件不会自行验收。';
1809
+ note = '执行已完成,等待宿主端审查;插件不会自行验收。';
1810
1810
  // Stated once, as the headline above; a second identical phase badge is noise.
1811
1811
  phaseLabel = null;
1812
1812
  } else if (state === 'failed') {
@@ -2222,7 +2222,7 @@ function TaskDetail({ store, task }) {
2222
2222
  {`${entry.requestId} · ${entry.toolName ?? '—'} · `
2223
2223
  + `${PERMISSION_STATE_LABELS[entry.state] ?? entry.state ?? '—'} · `
2224
2224
  + `${PERMISSION_OUTCOME_LABELS[entry.outcome] ?? entry.outcome ?? '—'}`
2225
- + `${entry.decidedBy === 'commander' ? ` · ${PERMISSION_DECISION_LABELS[entry.outcome === 'allowed-once' ? 'allow-once' : 'reject'] ?? '本机指挥官'}` : ''}`}
2225
+ + `${entry.decidedBy === 'commander' ? ` · ${PERMISSION_DECISION_LABELS[entry.outcome === 'allowed-once' ? 'allow-once' : 'reject'] ?? '宿主端'}` : ''}`}
2226
2226
  </li>
2227
2227
  ))}
2228
2228
  </ul>
@@ -2230,7 +2230,7 @@ function TaskDetail({ store, task }) {
2230
2230
  )}
2231
2231
  <p className="dshdg-hint">
2232
2232
  逐次授权只覆盖当前调用。后续调用如需扩大权限,须重新核对参数并审批。它不能创建或扩大任何跨任务或长期有效的授权(“长期有效”指跨会话持久的授权),不能修改设置、凭据、本机调用开关、提供方、模型或隔离方式;
2233
- 工作进程的常规沙箱权限始终保持 workspace-write。此界面不提供手工批准按钮,决定由本机 MCP 指挥官通过
2233
+ 工作进程的常规沙箱权限始终保持 workspace-write。此界面不提供手工批准按钮,决定由宿主端通过
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 或 Antigravity)单独给出结论。</p>
3319
+ <p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主端单独给出结论。</p>
3320
3320
  <span className="dshdg-spacer" />
3321
3321
  <span className="dshdg-hint" data-dshdg-refresh-hint="">
3322
3322
  {changing !== true