@ai-workbench/connect 0.7.21 → 0.7.22
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 +10 -3
- package/client/index.cjs +4 -4
- package/lib/host-directories.js +2 -2
- package/lib/host-session-projects.d.ts +1 -0
- package/lib/host-session-projects.js +2 -6
- package/lib/needs.js +1 -1
- package/lib/profile-runtime.js +4 -3
- package/lib/workspace-locations.d.ts +4 -2
- package/lib/workspace-locations.js +100 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
安装:在官方 DSH「插件 → 添加插件」中选择编排已核验的 tgz 绝对路径。已由编排发布的版本也可按其提供的精确包版本安装;本轮0.7.
|
|
1
|
+
安装:在官方 DSH「插件 → 添加插件」中选择编排已核验的 tgz 绝对路径。已由编排发布的版本也可按其提供的精确包版本安装;本轮0.7.22只提供固定tgz,本项目不自行 publish。
|
|
2
2
|
|
|
3
3
|
# 远程主机连接插件(L)
|
|
4
4
|
|
|
@@ -43,7 +43,7 @@ openssl s_client -connect registry.npmjs.org:443 -servername registry.npmjs.org
|
|
|
43
43
|
|
|
44
44
|
D13已通过[PR15](https://github.com/yzsnstotz/ai-workbench-connect/pull/15)合推main7915df5,移除前为909eabb;五项被拒产物及清单引用已撤除。不再生成新的聚合整包或验收ZIP,交付物为插件本身。
|
|
45
45
|
|
|
46
|
-
**插件版本0.7.
|
|
46
|
+
**插件版本0.7.22,API保持0.7.0/native-local-v1。** 本轮沿用现有N/X公开API,真实组合由编排验证。L导入动作固定使用官方系统目录窗口:自动能力为native时直接消费其pick;SSH等启动上下文提供browse时,明确调用同一官方原生包的公开pickNativeDirectory,不修改全局选择器。失败原因与临时登录路径只在本节技术详情准确投影。js-yaml/yauzl及其传递运行依赖随tgz打包,官方宿主peer由已安装官方程序提供,员工不另装npm依赖。真实中文GUI/授权及leo E门分别留证。旧140测试/46图只属于前任draft.3;本轮证据独立记录于[第2轮证据](docs/evidence/2026-10-21-L-round2-draft4/)。不得拿旧0.6.3 tgz当native-local-v1的输入。
|
|
47
47
|
|
|
48
48
|
开发使用Node24.13.1,依赖/缓存/构建和临时HOME放自有外接APFS。工程检查为`npm test`、`npm run check`、`npm run build`;它们不替代真实产品路径。安装走官方插件管理,本包自身只声明一个官方bundle条目,不使用wrapper或员工启动器。工人GUI按[SELFTEST](docs/SELFTEST.md)的PID和三项获准偏离执行,不操作owner实例。
|
|
49
49
|
|
|
@@ -53,7 +53,7 @@ L0.7.4按owner最新纠正分开供给和授权:Electron组件从自身官方
|
|
|
53
53
|
|
|
54
54
|
官方Electron内置Node会把.asar视作虚拟目录;组件缓存/解压专用physical-fs在Electron中使用original-fs核验物理归档,不修改全局process.noAsar。真实官方运行时新建及跨Node复用缓存均有回归。
|
|
55
55
|
|
|
56
|
-
0.7.5仅调整公开 npm 发布元数据和包内容:运行依赖继续随包,合同、源码、测试与证据不进包;无安装脚本。源码与合同见[项目仓库](https://github.com/yzsnstotz/ai-workbench-connect)。发布前可用官方插件页安装已核验的tgz绝对路径。0.7.
|
|
56
|
+
0.7.5仅调整公开 npm 发布元数据和包内容:运行依赖继续随包,合同、源码、测试与证据不进包;无安装脚本。源码与合同见[项目仓库](https://github.com/yzsnstotz/ai-workbench-connect)。发布前可用官方插件页安装已核验的tgz绝对路径。0.7.22本轮提供固定tgz,由编排决定发布;L不执行publish。
|
|
57
57
|
|
|
58
58
|
0.7.6:L设置节可显式选择 GitHub 官方源或 npmmirror(Electron 官方文档列出的中国镜像),显示所选来源与理由。未保存选择/未显式配置时默认 npmmirror,依据为编排在leo的可达性实测,不代表自动测速。优先级:本profile设置节已保存选择 → helper.componentDownloadSource初值 → 旧helper.source显式URL → 默认npmmirror;坏设置/保存失败明确报错,不静默切源。预设仍校验原Electron44.0.0固定SHA256。helper.componentObservationIntervalMs默认1000毫秒,只刷新“已N秒无进展”,不触发超时/重试/换源。Claude网页登录的当前流向见下节;Codex本版保留原有N主机代理方式。
|
|
59
59
|
|
|
@@ -136,3 +136,10 @@ payload 仅有七个必填字段:phase 固定 `workspace-source-admission`;s
|
|
|
136
136
|
写入技术详情使用紧凑内存索引,避免每条都重读整个域的JSON及重复打开相同接纳关系;正文仍保存在原私有文件中,按页读取全部原始字段。每次核文件身份/权限及变更元数据,新增或变化文件重验完整schema与摘要;作用域证明仅在本次操作内按完整归属合并,返回正文前重核原记录关系,不能借同会话另一关系读取悬空记录。跨会话eventId幂等、全历史序号、原子写和文件/目录fsync、未知结果只读核实保持。
|
|
137
137
|
|
|
138
138
|
不增加Config、权限层、超时或业务重试。性能数据来自本地夹具,不代表leo已安装或已消除全部失败收尾耗时;X适配器、网络与真实员工复验分别留证。本轮仍只交固定tgz,由编排决定发布,L不publish。
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## 0.7.22 主机目录重连恢复
|
|
142
|
+
|
|
143
|
+
连接恢复后自动只读复核原主机目录,未变则恢复原选择。只有实际核实的目录身份或权限变化才撤销绑定,并在工作区来源栏显示具体原因;SSH传输失败及未观测的权限仅失败本次。已撤销目录可按正常浏览与选择重新确认并生成新绑定;原会话须新建会话继续,原详情历史保持只读。
|
|
144
|
+
|
|
145
|
+
每次真实主机解析核目录一次,技术详情写入不逐条发SSH,仍保留当前连接、来源绑定及持久提交守卫。正确性复核不可关闭,无新增Config/权限层/超时/重试。0.7.22候选工程与独审证据见本轮交付目录;真实leo门单独留证,未跑不标通过。
|
package/client/index.cjs
CHANGED
|
@@ -128,16 +128,16 @@ window.__ModuleLoader__.load({id:'@ai-workbench/connect',factory:(require)=>{
|
|
|
128
128
|
const live=React.useRef(true),sequence=React.useRef(0),context={instanceId:locations.instanceId,epoch:locations.epoch,workspaceId:item.workspaceId,expectedBindingId:item.bindingId};
|
|
129
129
|
React.useEffect(()=>()=>{live.current=false;sequence.current++;},[]);
|
|
130
130
|
const current=()=>live.current&&sameLocationContext(workbench.getSnapshot().value?.workspaceLocations,context);
|
|
131
|
-
const browse=async(query={})=>{const at=++sequence.current;setLoading(true);setError('');setPage(null);try{const size=Number(pageSize);if(!/^\d+$/.test(pageSize)||!Number.isSafeInteger(size)||size<1){setError('每页条数需要正安全整数。');return;}const result=await workbench.browseWorkspaceHostDirectories({...context,pageSize:size,...query});if(at!==sequence.current||!current())return;if(!result?.ok){setError(result?.error?.message||'主机目录读取失败,未自动重试。');return;}const value=result.value;if(value.instanceId!==context.instanceId||value.epoch!==context.epoch||value.workspaceId!==context.workspaceId||value.bindingId!==context.expectedBindingId){setError('
|
|
132
|
-
const select=async(choice)=>{const at=++sequence.current;setLoading(true);setError('');setPage(null);try{const result=await workbench.selectWorkspaceLocation({...context,...choice});if(at!==sequence.current||!current())return;if(!result?.ok)setError(result?.error?.message||'
|
|
133
|
-
const execution=item.execution==='local-pending'?'已选择本机文件夹;运行前会核验本机执行条件。':item.execution==='host-pending'?'已选择主机文件夹;运行前会重新核对目录与权限。':item.execution==='legacy-confirmed'?'已明确确认原有主机关联;继续使用原有执行入口。':'尚未选择文件来源。';
|
|
131
|
+
const browse=async(query={})=>{const at=++sequence.current;setLoading(true);setError('');setPage(null);try{const size=Number(pageSize);if(!/^\d+$/.test(pageSize)||!Number.isSafeInteger(size)||size<1){setError('每页条数需要正安全整数。');return;}const result=await workbench.browseWorkspaceHostDirectories({...context,pageSize:size,...query});if(at!==sequence.current||!current())return;if(!result?.ok){setError(result?.error?.message||'主机目录读取失败,未自动重试。');return;}const value=result.value;if(value.instanceId!==context.instanceId||value.epoch!==context.epoch||value.workspaceId!==context.workspaceId||value.bindingId!==context.expectedBindingId){setError('工作区或连接已变化,请刷新位置。');return;}setPage(value);}catch{if(at===sequence.current&¤t())setError('主机目录读取失败,未自动重试。');}finally{if(at===sequence.current&¤t())setLoading(false);}};
|
|
132
|
+
const select=async(choice)=>{const at=++sequence.current;setLoading(true);setError('');setPage(null);try{const result=await workbench.selectWorkspaceLocation({...context,...choice});if(at!==sequence.current||!current())return;if(!result?.ok)setError(result?.error?.message||'位置未保存,请刷新位置。');}catch{if(at===sequence.current&¤t())setError('位置保存结果无法确认,请刷新后核实;未自动重试。');}finally{if(at===sequence.current&¤t())setLoading(false);}};
|
|
133
|
+
const execution=item.status==='invalid'?'工作区位置当前不可用,请查看具体原因。':item.execution==='local-pending'?'已选择本机文件夹;运行前会核验本机执行条件。':item.execution==='host-pending'?'已选择主机文件夹;运行前会重新核对目录与权限。':item.execution==='legacy-confirmed'?'已明确确认原有主机关联;继续使用原有执行入口。':'尚未选择文件来源。';
|
|
134
134
|
const identity=locations.host,host=identity?identity.username+'@'+identity.host+':'+identity.port:'主机标识尚未核实';
|
|
135
135
|
return h('fieldset',null,h('legend',null,item.workspaceName),h('p',null,'原生本地工作区:'+item.localPath),h('p',null,'远程主机:'+host),h('p',{role:'status'},execution),item.need?h('p',{role:'alert'},item.need.message):null,item.status==='legacy-confirmation-required'?h(React.Fragment,null,h('p',null,'此工作区有旧主机映射,必须明确确认;不会自动沿用。'),item.remote||item.legacyPath?h('p',null,'原有主机目录:'+(item.remote?.path??item.legacyPath)):null,h('button',{type:'button',disabled:loading,onClick:()=>select({source:'legacy-host',confirmLegacy:true})},'确认沿用旧主机关联')):null,h('button',{type:'button',disabled:loading,onClick:()=>select({source:'local'})},'使用本地文件夹'),h('button',{type:'button',disabled:loading,onClick:()=>browse()},'浏览主机文件夹'),h('label',null,'主机绝对目录',h('input',{type:'text',value:path,disabled:loading,onChange:event=>setPath(event.target.value)})),h('button',{type:'button',disabled:loading||!path.startsWith('/'),onClick:()=>browse({path})},'打开主机目录'),h('label',null,'主机目录每页条数',h('input',{type:'number',min:1,max:Number.MAX_SAFE_INTEGER,step:1,value:pageSize,disabled:loading,onChange:event=>setPageSize(event.target.value)})),h('p',null,'默认每页 '+locations.pageSize+' 条;可填写1至9007199254740991整数。只浏览和选择已有目录,不创建目录;本地文件不会自动上传。'),loading?h('p',{role:'status'},'正在核实工作区位置…'):null,error?h('p',{role:'alert'},error):null,page?h(React.Fragment,null,h('p',null,'请求目录:'+page.requestedPath),h('p',null,'规范路径:'+page.path),h('p',null,'父级:'+(page.parentPath??'无')),h('p',null,'符号链接:'+(page.isSymlink?'是':'否')),h(DirectoryPermissions,{permissions:page.permissions}),page.parentPath?h('button',{type:'button',disabled:loading,onClick:()=>browse({path:page.parentPath})},'打开父级目录'):null,h('button',{type:'button',disabled:loading||!page.selectionToken,onClick:()=>select({source:'host',selectionToken:page.selectionToken})},'选择当前主机文件夹'),...page.entries.map(entry=>h('div',{key:entry.requestedPath},h('p',null,entry.name+' · '+(entry.path??entry.requestedPath)+';符号链接:'+(entry.isSymlink?'是':'否')),h(DirectoryPermissions,{permissions:entry.permissions}),entry.errorCode?h('p',{role:'alert'},'目录无法使用:'+entry.errorCode):null,h('button',{type:'button',disabled:loading||!!entry.errorCode,onClick:()=>browse({path:entry.requestedPath})},'打开 '+entry.name),h('button',{type:'button',disabled:loading||!entry.selectionToken,onClick:()=>select({source:'host',selectionToken:entry.selectionToken})},'选择 '+entry.name))),page.nextCursor?h('button',{type:'button',disabled:loading,onClick:()=>browse({cursor:page.nextCursor})},'继续加载目录'):null):null);
|
|
136
136
|
}
|
|
137
137
|
function WorkspaceLocations({state,workbench}){
|
|
138
138
|
const locations=state?.workspaceLocations,[error,setError]=React.useState(''),[refreshing,setRefreshing]=React.useState(false);if(!locations)return null;
|
|
139
139
|
const refresh=async()=>{setRefreshing(true);setError('');try{const result=await workbench.refreshWorkspaceLocations();if(!result?.ok)setError(result?.error?.message||'原生工作区列表读取失败。');}catch{setError('原生工作区列表读取失败,未自动重试。');}finally{setRefreshing(false);}};
|
|
140
|
-
return h('details',null,h('summary',null,'工作区文件来源'),h('p',null,'先通过默认添加工作区选择真实本地文件夹,再逐个明确选择来源;本节不替换原生目录选择器。没有默认来源。'),h('p',null,'
|
|
140
|
+
return h('details',null,h('summary',null,'工作区文件来源'),h('p',null,'先通过默认添加工作区选择真实本地文件夹,再逐个明确选择来源;本节不替换原生目录选择器。没有默认来源。'),h('p',null,'每轮主机执行解析与连接恢复时必须核对目录身份和权限,以免操作被替换的文件夹;此正确性核对不可关闭。技术详情写入只核对当前连接、绑定和撤销状态,不逐条连接主机。连接恢复后会自动只读核实原选择。文件写入仍由主机系统权限决定。'),h('button',{type:'button',disabled:refreshing,onClick:refresh},'刷新原生工作区列表'),error?h('p',{role:'alert'},error):null,locations.phase!=='ready'?h('p',{role:'status'},locations.need?.message||'工作区位置尚未核实。'):locations.items.length?locations.items.map(item=>h(WorkspaceLocationRow,{key:JSON.stringify([locations.instanceId,locations.epoch,item.workspaceId,item.bindingId,item.source,item.localPath]),item,locations,workbench})):h('p',null,'当前没有原生工作区,请先通过默认添加工作区选择文件夹。'));
|
|
141
141
|
}
|
|
142
142
|
function ComponentSource({state,action}){const c=state?.loginComponent?.source;if(!c)return null;const busy=c.changing||c.phase!=='ready'||['downloading','verifying','unpacking'].includes(state?.loginComponent?.download?.phase)||state?.startup?.phase==='authorizing';return h('div',null,h('p',null,c.phase==='ready'?'登录组件下载源:'+c.selectedLabel:c.phase==='loading'?'正在读取登录组件下载源设置…':'登录组件下载源设置不可用;未切换到其他来源。'),h('p',null,c.reason),c.selectionErrorCode?h('p',{role:'alert'},c.selectionErrorCode==='COMPONENT_PIN_MISMATCH'?'下载源未更改:当前组件版本或 SHA256 与预设不符,请查看技术详情。':'下载源未更改,请查看技术详情。'):null,...(c.choices??[]).map(choice=>h('button',{key:choice.id,type:'button',disabled:busy||c.selectedId===choice.id,onClick:()=>void action('/component-source/'+choice.id)},'使用 '+choice.label)),h('p',null,'Electron '+c.version+';两项预设使用同一固定 SHA256,不会因下载失败自动换源。'));}
|
|
143
143
|
function DownloadProgress({state,action}){const d=state?.loginComponent?.download;const [,refresh]=React.useState(0),interval=state?.loginComponent?.observationIntervalMs,observing=d?.phase==='downloading'&&Number.isFinite(d.lastProgressAt);React.useEffect(()=>{if(!observing||!Number.isSafeInteger(interval)||interval<1||interval>2147483647)return;const timer=setInterval(()=>refresh(x=>x+1),interval);return()=>clearInterval(timer);},[observing,interval,d?.attemptId]);if(!d)return null;const seconds=Number.isFinite(d.lastProgressAt)?Math.max(0,Math.floor((Date.now()-d.lastProgressAt)/1000)):null;const text=d.phase==='downloading'?'正在从'+(d.sourceLabel||'所选地址')+'下载登录组件:已下载 '+d.receivedBytes+' 字节'+(d.totalBytes===null?'(总大小未知)':',共 '+d.totalBytes+' 字节')+'。'+(seconds===null?'':'已 '+seconds+' 秒无进展;仅观察,不会自动重试或换源。')+'Claude、Codex 登录网页都使用本机网络;Codex 设备码需复制后粘贴到官方页面。':d.phase==='verifying'?'正在校验登录组件…':d.phase==='unpacking'?'正在解压登录组件…':d.phase==='failed'?(typeof d.errorCode==='string'&&d.errorCode.startsWith('COMPONENT_DOWNLOAD_TLS_')?'当前网络的安全证书验证失败,组件无法下载;请换个网络或联系网管。':'登录组件准备失败,请查看技术详情;未重试或换源。'):d.phase==='cancelled'?'登录组件下载已取消。':null;return text?h(React.Fragment,null,h('p',{role:'status'},text),['downloading','verifying','unpacking'].includes(d.phase)&&d.attemptId?h('button',{type:'button',onClick:()=>void action('/component-download/cancel/'+d.attemptId)},'取消组件下载'):null):null;}
|
package/lib/host-directories.js
CHANGED
|
@@ -34,7 +34,7 @@ export function createHostDirectories(runner, maxOutputBytes) {
|
|
|
34
34
|
if (signal.aborted)
|
|
35
35
|
return fail('CONNECTION_LOST');
|
|
36
36
|
if (raw.exitCode !== 0 || raw.stderr !== '')
|
|
37
|
-
return fail('
|
|
37
|
+
return fail('CONNECTION_LOST');
|
|
38
38
|
if (Buffer.byteLength(raw.stdout, 'utf8') > maxOutputBytes)
|
|
39
39
|
return fail('HOST_DIRECTORY_PAGE_TOO_LARGE');
|
|
40
40
|
let result;
|
|
@@ -69,7 +69,7 @@ export function createHostDirectories(runner, maxOutputBytes) {
|
|
|
69
69
|
if (error.diagnostic.stage === 'remote-frame')
|
|
70
70
|
return fail('PROJECT_PROTOCOL_INVALID');
|
|
71
71
|
}
|
|
72
|
-
return fail('
|
|
72
|
+
return fail('CONNECTION_LOST');
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return { browse: (target, data, signal) => request(target, 'browse', data, signal), inspect: (target, path, signal) => request(target, 'inspect', { path }, signal) };
|
|
@@ -44,6 +44,7 @@ interface Options {
|
|
|
44
44
|
identity: string;
|
|
45
45
|
guard?: () => void;
|
|
46
46
|
}>>;
|
|
47
|
+
isHostBindingRevoked: (id: string) => boolean;
|
|
47
48
|
withHostBinding: ReturnType<typeof createWorkspaceLocations>['withHostBinding'];
|
|
48
49
|
}
|
|
49
50
|
export declare function changedSessionBinding(): never;
|
|
@@ -192,8 +192,6 @@ export function createHostSessionProjects(o) {
|
|
|
192
192
|
}, () => commit());
|
|
193
193
|
if (result.ok)
|
|
194
194
|
c.guard();
|
|
195
|
-
if (!result.ok && ['HOST_DIRECTORY_INVALID', 'HOST_DIRECTORY_CHANGED', 'HOST_DIRECTORY_UNREADABLE', 'WORKSPACE_LOCATION_INVALID'].includes(result.error.code))
|
|
196
|
-
revoke(location.expectedBindingId);
|
|
197
195
|
return result;
|
|
198
196
|
}
|
|
199
197
|
catch (e) {
|
|
@@ -263,11 +261,9 @@ export function createHostSessionProjects(o) {
|
|
|
263
261
|
guard();
|
|
264
262
|
finalGuard = guard;
|
|
265
263
|
return run({ identity: r.identity, hostBindingRef: r.id, guard });
|
|
266
|
-
}, () => finalGuard());
|
|
264
|
+
}, () => finalGuard(), false);
|
|
267
265
|
if (result.ok)
|
|
268
266
|
finalGuard();
|
|
269
|
-
if (!result.ok && ['HOST_DIRECTORY_INVALID', 'HOST_DIRECTORY_CHANGED', 'HOST_DIRECTORY_UNREADABLE', 'WORKSPACE_LOCATION_INVALID'].includes(result.error.code))
|
|
270
|
-
revoke(r.bindingId);
|
|
271
267
|
return result;
|
|
272
268
|
}
|
|
273
269
|
catch (e) {
|
|
@@ -281,7 +277,7 @@ export function createHostSessionProjects(o) {
|
|
|
281
277
|
if (!o.registry.get(r.workspaceId))
|
|
282
278
|
revoke(binding);
|
|
283
279
|
}
|
|
284
|
-
else if (item.bindingId !== binding || item.source !== 'host')
|
|
280
|
+
else if (item.bindingId !== binding || item.source !== 'host' || o.isHostBindingRevoked(binding))
|
|
285
281
|
revoke(binding);
|
|
286
282
|
} }
|
|
287
283
|
function observeSessionDisposed(session) { for (const r of store.read())
|
package/lib/needs.js
CHANGED
|
@@ -8,7 +8,7 @@ const entries = {
|
|
|
8
8
|
HOST_DIRECTORY_PAGE_TOO_LARGE: { layer: 'projects', message: '本页目录元数据超过 commandOutputMaxBytes,请减小每页条数或联系管理员调整。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
9
9
|
WORKSPACE_LOCATION_REQUIRED: { layer: 'projects', message: '请先在远程主机连接设置中选择此工作区的文件来源;旧关联需要确认。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
10
10
|
WORKSPACE_LOCATION_INVALID: { layer: 'projects', message: '工作区位置与当前目录或主机身份不符,请重新选择。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
11
|
-
WORKSPACE_LOCATION_CONFLICT: { layer: 'projects', message: '
|
|
11
|
+
WORKSPACE_LOCATION_CONFLICT: { layer: 'projects', message: '工作区或连接已变化,请刷新位置。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
12
12
|
WORKSPACE_LOCATION_PROVIDER_REQUIRED: { layer: 'projects', message: '主机文件夹已记录,等待远程提供方接入位置合同后才能执行。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
13
13
|
WORKSPACE_EXECUTION_UNAVAILABLE: { layer: 'projects', message: '本地文件夹已记录,按需远程文件与命令执行尚未接通。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
|
14
14
|
WORKSPACE_LOCATION_STORAGE_FAILED: { layer: 'projects', message: '工作区位置记录无法读取或保存,已停止操作,请联系管理员。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
|
package/lib/profile-runtime.js
CHANGED
|
@@ -57,7 +57,8 @@ export function attachProfileRuntime(ctx, api, ports, config, network) {
|
|
|
57
57
|
};
|
|
58
58
|
const bindings = createWorkspaceBindings({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, api, registry,
|
|
59
59
|
readHeader, nextRevision: () => ++workspaceRevision, onState: state => ctx.emit('ai-workbench/workspace-binding-state', state), diagnostic: error => { lastWorkspaceError = error; ctx.emit('ai-workbench/workspace-diagnostic', error); } });
|
|
60
|
-
const
|
|
60
|
+
const hostLedger = hostProjectStore(profile.dir, config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes);
|
|
61
|
+
const locations = createWorkspaceLocations({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, pageSize: config.workspaceLocations?.pageSize ?? WORKSPACE_LOCATION_DEFAULTS.pageSize, isHostBindingRevoked: id => hostLedger.read().some(r => r.bindingId === id && r.revoked), nextRevision: () => ++locationRevision, api, registry, readLegacy: bindings.readLegacyLocations, hostDirectories: ports.hostDirectories, onState: state => ctx.emit('ai-workbench/workspace-location-state', state) });
|
|
61
62
|
if (process.platform === 'darwin')
|
|
62
63
|
api.getLocalWorkspaceContext = locations.getLocalWorkspaceContext;
|
|
63
64
|
api.getWorkspaceLocationState = locations.getWorkspaceLocationState;
|
|
@@ -95,11 +96,11 @@ export function attachProfileRuntime(ctx, api, ports, config, network) {
|
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
const nativeSessions = native.get('sessions'), nativePersistence = native.get('sessionPersistence');
|
|
98
|
-
const
|
|
99
|
+
const localLedger = acceptanceStore(profile.dir, config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes);
|
|
99
100
|
const assertHostBinding = (id, header) => { if (hostLedger.read().some(r => r.sessionId === id && sameSessionHeader(r.header, header)))
|
|
100
101
|
changedSessionBinding(); };
|
|
101
102
|
const officialServices = () => ({ sessions: native.get('sessions'), persistence: native.get('sessionPersistence') });
|
|
102
|
-
const hostAcceptance = typeof ports.hostDirectories?.inspect === 'function' && typeof ports.hostDirectories?.browse === 'function' && typeof nativeSessions?.flush === 'function' && typeof nativePersistence?.open === 'function' && typeof nativePersistence?.identity === 'symbol' ? createHostSessionProjects({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, api, registry, services: officialServices, readHeader, readLegacy: bindings.readLegacyLocations, context, withHostBinding: locations.withHostBinding }) : undefined;
|
|
103
|
+
const hostAcceptance = typeof ports.hostDirectories?.inspect === 'function' && typeof ports.hostDirectories?.browse === 'function' && typeof nativeSessions?.flush === 'function' && typeof nativePersistence?.open === 'function' && typeof nativePersistence?.identity === 'symbol' ? createHostSessionProjects({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, api, registry, services: officialServices, readHeader, readLegacy: bindings.readLegacyLocations, context, withHostBinding: locations.withHostBinding, isHostBindingRevoked: locations.isHostBindingRevoked }) : undefined;
|
|
103
104
|
if (hostAcceptance) {
|
|
104
105
|
native.on('session/event', (session, event) => hostAcceptance.observe(session, event));
|
|
105
106
|
native.on('session/disposed', (session) => hostAcceptance.observeSessionDisposed(session));
|
|
@@ -29,6 +29,7 @@ interface Options {
|
|
|
29
29
|
hostDirectories?: ReturnType<typeof createHostDirectories>;
|
|
30
30
|
onState?: (s: WorkspaceLocationState) => void;
|
|
31
31
|
nextRevision?: () => number;
|
|
32
|
+
isHostBindingRevoked?: (bindingId: string) => boolean;
|
|
32
33
|
}
|
|
33
34
|
export declare function createWorkspaceLocations(o: Options): {
|
|
34
35
|
withHostBinding: <T>(input: import("./workspace-location-types.ts").HostWorkspaceResolveContext, run: (value: {
|
|
@@ -40,7 +41,8 @@ export declare function createWorkspaceLocations(o: Options): {
|
|
|
40
41
|
inode: number;
|
|
41
42
|
};
|
|
42
43
|
revision: number;
|
|
43
|
-
}, guard: () => void) => Promise<Result<T>>, finalize?: () => void) => Promise<Result<T>>;
|
|
44
|
+
}, guard: () => void) => Promise<Result<T>>, finalize?: () => void, inspectRemote?: boolean) => Promise<Result<T>>;
|
|
45
|
+
isHostBindingRevoked: (id: string) => boolean;
|
|
44
46
|
withLocalBinding: <T>(c: LocalWorkspaceContextRequest, run: (directory: {
|
|
45
47
|
path: string;
|
|
46
48
|
device: number;
|
|
@@ -67,7 +69,7 @@ export declare function createWorkspaceLocations(o: Options): {
|
|
|
67
69
|
selectWorkspaceLocation: (c: WorkspaceSelectRequest) => Promise<Result<WorkspaceLocationState>>;
|
|
68
70
|
guardLegacySession: (id: string) => Promise<Result<void>>;
|
|
69
71
|
resolveLegacySession: <T>(id: string, resolve: () => Promise<Result<T>>) => Promise<Result<T>>;
|
|
70
|
-
observeConnection():
|
|
72
|
+
observeConnection(): Promise<Result<WorkspaceLocationState>> | undefined;
|
|
71
73
|
dispose(): Promise<unknown>;
|
|
72
74
|
};
|
|
73
75
|
export {};
|
|
@@ -9,11 +9,11 @@ const queues = new Map();
|
|
|
9
9
|
const hash = (v) => createHash('sha256').update(JSON.stringify(v)).digest('hex');
|
|
10
10
|
const token = (v) => typeof v === 'string' && v.length > 0 && !/[\x00-\x1f\x7f]/.test(v);
|
|
11
11
|
const obj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
12
|
-
const checksum = (r) => hash([r.workspaceId, r.localPath, r.localDev, r.localIno, r.bindingId, r.source, r.active, r.remote, r.identity, r.host, r.legacyBindingId]);
|
|
12
|
+
const checksum = (r) => hash([r.workspaceId, r.localPath, r.localDev, r.localIno, r.bindingId, r.source, r.active, r.remote, r.identity, r.host, r.legacyBindingId, ...(r.revoked === undefined ? [] : [r.revoked])]);
|
|
13
13
|
const sameNative = (a, b) => a.workspaceId === b.workspaceId && a.localPath === b.localPath && a.localDev === b.localDev && a.localIno === b.localIno;
|
|
14
14
|
const sameDirectory = (a, b) => a.path === b.path && a.requestedPath === b.requestedPath && a.isSymlink === b.isSymlink && JSON.stringify(a.identity) === JSON.stringify(b.identity) && JSON.stringify(a.entryIdentity) === JSON.stringify(b.entryIdentity);
|
|
15
15
|
export function createWorkspaceLocations(o) {
|
|
16
|
-
const controllers = new Set();
|
|
16
|
+
const controllers = new Set(), revokedBindings = new Map();
|
|
17
17
|
const root = join(o.profileDir, 'ai-workbench-connect'), file = join(root, 'locations.json'), secret = randomBytes(32), listeners = new Set();
|
|
18
18
|
let disposed = false, revision = 0, tail = Promise.resolve();
|
|
19
19
|
let snapshot = { ...connection(), host: currentHost(), revision: 0, phase: 'loading', pageSize: o.pageSize, items: [] };
|
|
@@ -29,9 +29,23 @@ export function createWorkspaceLocations(o) {
|
|
|
29
29
|
}
|
|
30
30
|
function publish(items, error) {
|
|
31
31
|
snapshot = { ...connection(), host: currentHost(), revision: (revision = o.nextRevision?.() ?? revision + 1), phase: disposed ? 'disposed' : error ? 'failed' : 'ready', pageSize: o.pageSize, items, ...(error ? { need: need(error) } : {}) };
|
|
32
|
-
|
|
32
|
+
// An internal durability failure must not hide invalidation from settings.
|
|
33
|
+
let failed = false, firstError;
|
|
34
|
+
const notify = (listener) => { try {
|
|
33
35
|
listener(structuredClone(snapshot));
|
|
34
|
-
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (!failed) {
|
|
39
|
+
failed = true;
|
|
40
|
+
firstError = e;
|
|
41
|
+
}
|
|
42
|
+
} };
|
|
43
|
+
for (const listener of listeners)
|
|
44
|
+
notify(listener);
|
|
45
|
+
if (o.onState)
|
|
46
|
+
notify(o.onState);
|
|
47
|
+
if (failed)
|
|
48
|
+
throw firstError;
|
|
35
49
|
}
|
|
36
50
|
function serial(fn) {
|
|
37
51
|
const before = queues.get(file) ?? Promise.resolve();
|
|
@@ -78,7 +92,7 @@ export function createWorkspaceLocations(o) {
|
|
|
78
92
|
reject('WORKSPACE_LOCATION_STORAGE_FAILED');
|
|
79
93
|
const ids = new Set(), active = new Set();
|
|
80
94
|
for (const r of data.items) {
|
|
81
|
-
if (!obj(r) || !token(r.bindingId) || !token(r.workspaceId) || !isAbsolute(r.localPath) || !Number.isSafeInteger(r.localDev) || !Number.isSafeInteger(r.localIno) || !['local', 'host', 'legacy-host'].includes(r.source) || typeof r.active !== 'boolean' || r.source === 'legacy-host' && !token(r.legacyBindingId) || r.source !== 'legacy-host' && r.legacyBindingId !== undefined || r.key !== checksum(r) || ids.has(r.bindingId) || r.active && active.has(r.workspaceId) || r.source !== 'local' && (!obj(r.remote) || !isAbsolute(r.remote.path) || !isAbsolute(r.remote.requestedPath) || !obj(r.remote.identity) || !obj(r.remote.entryIdentity) || !obj(r.remote.permissions) || !obj(r.host) || !token(r.host.host) || !token(r.host.username) || !Number.isSafeInteger(r.host.port) || !(/^[a-f0-9]{64}$/.test(r.identity))))
|
|
95
|
+
if (!obj(r) || !token(r.bindingId) || !token(r.workspaceId) || !isAbsolute(r.localPath) || !Number.isSafeInteger(r.localDev) || !Number.isSafeInteger(r.localIno) || !['local', 'host', 'legacy-host'].includes(r.source) || typeof r.active !== 'boolean' || r.source === 'legacy-host' && !token(r.legacyBindingId) || r.source !== 'legacy-host' && r.legacyBindingId !== undefined || r.revoked !== undefined && (r.source !== 'host' || !['HOST_DIRECTORY_CHANGED', 'HOST_DIRECTORY_UNREADABLE'].includes(r.revoked)) || r.key !== checksum(r) || ids.has(r.bindingId) || r.active && active.has(r.workspaceId) || r.source !== 'local' && (!obj(r.remote) || !isAbsolute(r.remote.path) || !isAbsolute(r.remote.requestedPath) || !obj(r.remote.identity) || !obj(r.remote.entryIdentity) || !obj(r.remote.permissions) || !obj(r.host) || !token(r.host.host) || !token(r.host.username) || !Number.isSafeInteger(r.host.port) || !(/^[a-f0-9]{64}$/.test(r.identity))))
|
|
82
96
|
reject('WORKSPACE_LOCATION_STORAGE_FAILED');
|
|
83
97
|
ids.add(r.bindingId);
|
|
84
98
|
if (r.active)
|
|
@@ -185,7 +199,32 @@ export function createWorkspaceLocations(o) {
|
|
|
185
199
|
reject('WORKSPACE_LOCATION_CONFLICT');
|
|
186
200
|
}
|
|
187
201
|
}
|
|
188
|
-
|
|
202
|
+
function bindingNeed(r) { const code = r.revoked ?? revokedBindings.get(r.bindingId) ?? (o.isHostBindingRevoked?.(r.bindingId) ? 'HOST_DIRECTORY_CHANGED' : undefined); if (code)
|
|
203
|
+
revokedBindings.set(r.bindingId, code); return code; }
|
|
204
|
+
function directoryChange(a, b) {
|
|
205
|
+
if (a.path !== b.path || a.requestedPath !== b.requestedPath || a.identity.device !== b.identity.device || a.identity.inode !== b.identity.inode || a.entryIdentity.device !== b.entryIdentity.device || a.entryIdentity.inode !== b.entryIdentity.inode || a.isSymlink !== b.isSymlink)
|
|
206
|
+
return 'HOST_DIRECTORY_CHANGED';
|
|
207
|
+
if (b.permissions.read === false || b.permissions.execute === false)
|
|
208
|
+
return 'HOST_DIRECTORY_UNREADABLE';
|
|
209
|
+
if (['read', 'write', 'execute'].some(k => typeof a.permissions[k] === 'boolean' && typeof b.permissions[k] === 'boolean' && a.permissions[k] !== b.permissions[k]))
|
|
210
|
+
return 'HOST_DIRECTORY_CHANGED';
|
|
211
|
+
}
|
|
212
|
+
async function invalidate(stored, r, code, c) {
|
|
213
|
+
// Confirmed observation cannot be forgotten if durable publication fails.
|
|
214
|
+
revokedBindings.set(r.bindingId, code);
|
|
215
|
+
r.revoked = code;
|
|
216
|
+
try {
|
|
217
|
+
await save(stored, async () => { check(c); if (!sameNative(r, await native(r.workspaceId)))
|
|
218
|
+
reject('WORKSPACE_LOCATION_INVALID'); }, c);
|
|
219
|
+
check(c);
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
if (exact(c))
|
|
223
|
+
publish(snapshot.items.map(i => i.bindingId === r.bindingId ? { ...i, status: 'invalid', need: need(code) } : i));
|
|
224
|
+
throw e;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function items(stored, legacy, inspectHost = false, c = connection()) {
|
|
189
228
|
const result = [];
|
|
190
229
|
for (const w of o.registry.list()) {
|
|
191
230
|
let n;
|
|
@@ -199,16 +238,37 @@ export function createWorkspaceLocations(o) {
|
|
|
199
238
|
const r = stored.find(r => r.active && r.workspaceId === w.id), old = legacy.find(r => r.workspaceId === w.id);
|
|
200
239
|
const base = { workspaceId: w.id, workspaceName: w.title || w.id, localPath: n.localPath, bindingId: r?.bindingId ?? old?.bindingId ?? null };
|
|
201
240
|
if (r) {
|
|
202
|
-
let valid = sameNative(r, n);
|
|
241
|
+
let valid = sameNative(r, n), error;
|
|
242
|
+
if (r.source === 'host')
|
|
243
|
+
error = bindingNeed(r);
|
|
203
244
|
if (valid && r.source !== 'local') {
|
|
204
245
|
try {
|
|
205
|
-
valid = (await target(
|
|
246
|
+
valid = (await target(c)).identity === r.identity;
|
|
247
|
+
if (valid && !error && inspectHost && r.source === 'host') {
|
|
248
|
+
const t = await target(c);
|
|
249
|
+
check(c);
|
|
250
|
+
const inspected = o.hostDirectories ? await remote(c, signal => o.hostDirectories.inspect(t.value, r.remote.requestedPath, signal)) : fail('DEPENDENCY_REQUIRED');
|
|
251
|
+
check(c);
|
|
252
|
+
if (!inspected.ok)
|
|
253
|
+
error = inspected.error.code;
|
|
254
|
+
else {
|
|
255
|
+
const changed = directoryChange(r.remote, inspected.value);
|
|
256
|
+
if (changed) {
|
|
257
|
+
await invalidate(stored, r, changed, c);
|
|
258
|
+
error = changed;
|
|
259
|
+
}
|
|
260
|
+
else if (Object.values(inspected.value.permissions).includes(null))
|
|
261
|
+
error = 'HOST_DIRECTORY_UNREADABLE';
|
|
262
|
+
}
|
|
263
|
+
}
|
|
206
264
|
}
|
|
207
|
-
catch {
|
|
265
|
+
catch (e) {
|
|
266
|
+
check(c);
|
|
208
267
|
valid = false;
|
|
268
|
+
error = e instanceof NeedError ? e.need.code : 'WORKSPACE_LOCATION_STORAGE_FAILED';
|
|
209
269
|
}
|
|
210
270
|
}
|
|
211
|
-
result.push({ ...base, source: r.source, status: valid ? 'selected' : 'invalid', execution: r.source === 'local' ? 'local-pending' : r.source === 'host' ? 'host-pending' : 'legacy-confirmed', ...(r.remote ? { remote: r.remote, host: r.host } : {}), ...(!valid ? { need: need('WORKSPACE_LOCATION_INVALID') } : {}) });
|
|
271
|
+
result.push({ ...base, source: r.source, status: valid && !error ? 'selected' : 'invalid', execution: r.source === 'local' ? 'local-pending' : r.source === 'host' ? 'host-pending' : 'legacy-confirmed', ...(r.remote ? { remote: r.remote, host: r.host } : {}), ...(!valid || error ? { need: need(error ?? 'WORKSPACE_LOCATION_INVALID') } : {}) });
|
|
212
272
|
}
|
|
213
273
|
else if (old) {
|
|
214
274
|
result.push({ ...base, source: 'legacy-host', status: 'legacy-confirmation-required', execution: 'not-selected', legacyPath: old.project.path, ...(!sameNative(old, n) ? { need: need('WORKSPACE_LOCATION_INVALID') } : {}) });
|
|
@@ -218,15 +278,19 @@ export function createWorkspaceLocations(o) {
|
|
|
218
278
|
}
|
|
219
279
|
return result;
|
|
220
280
|
}
|
|
221
|
-
async function refresh() {
|
|
281
|
+
async function refresh(c = connection()) {
|
|
222
282
|
try {
|
|
283
|
+
check(c);
|
|
223
284
|
await prepare();
|
|
224
285
|
const stored = await records(), legacy = await o.readLegacy();
|
|
225
|
-
|
|
286
|
+
const next = await items(stored, legacy, true, c);
|
|
287
|
+
check(c);
|
|
288
|
+
publish(next);
|
|
226
289
|
return ok(structuredClone(snapshot));
|
|
227
290
|
}
|
|
228
291
|
catch (e) {
|
|
229
|
-
|
|
292
|
+
if (exact(c))
|
|
293
|
+
publish(snapshot.items, e instanceof NeedError ? e.need.code : 'WORKSPACE_LOCATION_STORAGE_FAILED');
|
|
230
294
|
throw e;
|
|
231
295
|
}
|
|
232
296
|
}
|
|
@@ -302,7 +366,7 @@ export function createWorkspaceLocations(o) {
|
|
|
302
366
|
if (!sameNative(await native(c.workspaceId), x.n))
|
|
303
367
|
reject('WORKSPACE_LOCATION_CONFLICT');
|
|
304
368
|
check(c);
|
|
305
|
-
if (x.current && x.current.source === r.source && JSON.stringify(x.current.remote) === JSON.stringify(r.remote) && x.current.identity === r.identity)
|
|
369
|
+
if (x.current && !bindingNeed(x.current) && x.current.source === r.source && JSON.stringify(x.current.remote) === JSON.stringify(r.remote) && x.current.identity === r.identity)
|
|
306
370
|
return ok(structuredClone(snapshot));
|
|
307
371
|
for (const old of x.stored)
|
|
308
372
|
if (old.active && old.workspaceId === c.workspaceId)
|
|
@@ -405,7 +469,7 @@ export function createWorkspaceLocations(o) {
|
|
|
405
469
|
return ok(undefined);
|
|
406
470
|
}
|
|
407
471
|
// Same queue as selection: a successful callback cannot race a new source UUID.
|
|
408
|
-
function withHostBinding(input, run, finalize = () => { }) {
|
|
472
|
+
function withHostBinding(input, run, finalize = () => { }, inspectRemote = true) {
|
|
409
473
|
const c = structuredClone(input);
|
|
410
474
|
return serial(async () => {
|
|
411
475
|
strict(c, ['instanceId', 'epoch', 'workspaceId', 'expectedBindingId']);
|
|
@@ -414,6 +478,9 @@ export function createWorkspaceLocations(o) {
|
|
|
414
478
|
const x = await context(c), r = x.current;
|
|
415
479
|
if (!r || r.source !== 'host' || !r.remote)
|
|
416
480
|
reject('WORKSPACE_LOCATION_CONFLICT');
|
|
481
|
+
const invalid = bindingNeed(r);
|
|
482
|
+
if (invalid)
|
|
483
|
+
reject(invalid);
|
|
417
484
|
const t = await target(c);
|
|
418
485
|
check(c);
|
|
419
486
|
if (t.identity !== r.identity)
|
|
@@ -421,6 +488,9 @@ export function createWorkspaceLocations(o) {
|
|
|
421
488
|
const bytes = await readPrivate(file, o.metadataMaxBytes), registeredPath = registeredLocalPath(c.workspaceId);
|
|
422
489
|
const guard = () => {
|
|
423
490
|
check(c);
|
|
491
|
+
const invalid = bindingNeed(r);
|
|
492
|
+
if (invalid)
|
|
493
|
+
reject(invalid);
|
|
424
494
|
const now = o.api.getConnectionState();
|
|
425
495
|
if (now.phase !== 'connected')
|
|
426
496
|
reject('CONNECTION_LOST');
|
|
@@ -454,21 +524,24 @@ export function createWorkspaceLocations(o) {
|
|
|
454
524
|
if (!current.ok)
|
|
455
525
|
throw new NeedError(current.error);
|
|
456
526
|
const a = r.remote, b = current.value;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
527
|
+
const changed = directoryChange(a, b);
|
|
528
|
+
if (changed) {
|
|
529
|
+
await invalidate(x.stored, r, changed, c);
|
|
530
|
+
const next = await items(x.stored, x.legacy, false, c);
|
|
531
|
+
check(c);
|
|
532
|
+
publish(next);
|
|
533
|
+
reject(changed);
|
|
534
|
+
}
|
|
535
|
+
if (Object.values(b.permissions).includes(null))
|
|
460
536
|
reject('HOST_DIRECTORY_UNREADABLE');
|
|
461
|
-
if (['read', 'write', 'execute'].some(k => a.permissions[k] !== b.permissions[k]))
|
|
462
|
-
reject('HOST_DIRECTORY_CHANGED');
|
|
463
537
|
return b;
|
|
464
538
|
};
|
|
465
|
-
const directory = await inspect(), value = { directory, target: structuredClone(t.value), local: { path: x.n.localPath, device: x.n.localDev, inode: x.n.localIno }, revision: snapshot.revision };
|
|
539
|
+
const directory = inspectRemote ? await inspect() : structuredClone(r.remote), value = { directory, target: structuredClone(t.value), local: { path: x.n.localPath, device: x.n.localDev, inode: x.n.localIno }, revision: snapshot.revision };
|
|
466
540
|
const result = await run(value, guard);
|
|
467
541
|
guard();
|
|
468
542
|
if (!result.ok)
|
|
469
543
|
return result;
|
|
470
544
|
// Do not treat directory content timestamps as identity changes.
|
|
471
|
-
value.directory = await inspect();
|
|
472
545
|
guard();
|
|
473
546
|
finalize();
|
|
474
547
|
guard();
|
|
@@ -503,7 +576,7 @@ export function createWorkspaceLocations(o) {
|
|
|
503
576
|
return run({ path: x.n.localPath, device: x.n.localDev, inode: x.n.localIno }, guard);
|
|
504
577
|
});
|
|
505
578
|
}
|
|
506
|
-
return { withHostBinding, withLocalBinding, getLocalWorkspaceContext, getWorkspaceLocationState: () => ({ ...structuredClone(snapshot), host: currentHost() }), onWorkspaceLocationState(listener) { listeners.add(listener); return () => { listeners.delete(listener); }; }, refreshWorkspaceLocations: () => serial(refresh), browseWorkspaceHostDirectories: (c) => serial(() => browse(c)), selectWorkspaceLocation: (c) => serial(() => select(c)), guardLegacySession: (id) => serial(() => guard(id)), resolveLegacySession: (id, resolve) => serial(async () => {
|
|
579
|
+
return { withHostBinding, isHostBindingRevoked: (id) => revokedBindings.has(id) || !!o.isHostBindingRevoked?.(id), withLocalBinding, getLocalWorkspaceContext, getWorkspaceLocationState: () => ({ ...structuredClone(snapshot), host: currentHost() }), onWorkspaceLocationState(listener) { listeners.add(listener); return () => { listeners.delete(listener); }; }, refreshWorkspaceLocations: () => serial(refresh), browseWorkspaceHostDirectories: (c) => serial(() => browse(c)), selectWorkspaceLocation: (c) => serial(() => select(c)), guardLegacySession: (id) => serial(() => guard(id)), resolveLegacySession: (id, resolve) => serial(async () => {
|
|
507
580
|
const c = connection(), before = await guard(id);
|
|
508
581
|
if (!before.ok)
|
|
509
582
|
return before;
|
|
@@ -519,6 +592,10 @@ export function createWorkspaceLocations(o) {
|
|
|
519
592
|
for (const controller of controllers)
|
|
520
593
|
controller.abort();
|
|
521
594
|
publish(snapshot.items.map(i => i.source === 'host' || i.source === 'legacy-host' ? { ...i, status: i.status === 'legacy-confirmation-required' ? i.status : 'invalid', need: need('WORKSPACE_LOCATION_CONFLICT') } : i));
|
|
595
|
+
if (o.api.getConnectionState().phase === 'connected') {
|
|
596
|
+
const c = connection();
|
|
597
|
+
return serial(() => refresh(c));
|
|
598
|
+
}
|
|
522
599
|
}, dispose() {
|
|
523
600
|
disposed = true;
|
|
524
601
|
for (const controller of controllers)
|