@ai-workbench/connect 0.7.20 → 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 +21 -3
- package/client/index.cjs +4 -4
- package/lib/conversation-details.js +87 -34
- package/lib/host-directories.js +2 -2
- package/lib/host-session-projects.d.ts +2 -1
- package/lib/host-session-projects.js +2 -6
- package/lib/local-user-turn-acceptance.d.ts +1 -1
- 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
|
|
|
@@ -125,3 +125,21 @@ payload 仅有七个必填字段:phase 固定 `workspace-source-admission`;s
|
|
|
125
125
|
## 0.7.19 本地首轮会话核验修复
|
|
126
126
|
|
|
127
127
|
官方 rc.2 JSONL 会将新会话省略的 delegationDepth 写为 0。接纳与本地技术详情历史核验现在只将这两种官方表示视为同一身份,避免新建 Claude/Codex 会话误报 REMOTE_DETAIL_SCOPE_INVALID;其他完整 header 身份、实际员工输入、品牌、目录与连接代次检查保持严格。不会重写原始 header/旧关系摘要或恢复旧轮写权限,无新增 Config、权限或自动重试。X 的输入核验和错误文案须随统一 0.8.13 修复;leo 真实组合复验另行进行,本包不安装现场、不 publish。
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## 0.7.20 已选主机目录
|
|
131
|
+
|
|
132
|
+
已选主机文件夹经真实会话/品牌/工作区关系和目录身份/权限复核后,可返回主机执行目录;远程提供方须消费hostWorkspaceResolution及resolveSessionProject的主机位置CAS增量。原projectRoot不改,同会话不能换来源/目录,变更后明确“文件来源已改,请新建会话继续”,原技术详情历史只读。运行前核目录身份和权限是正确性要求,不可关闭;实际写入仍由主机系统权限决定。当前可信主机标识不依赖先浏览;设置页短暂HTTP/SSE异常保留最后快照并标“正在重新确认”。两插件组合与leo产品验收由编排安排。
|
|
133
|
+
|
|
134
|
+
## 0.7.21 技术详情增量读取
|
|
135
|
+
|
|
136
|
+
写入技术详情使用紧凑内存索引,避免每条都重读整个域的JSON及重复打开相同接纳关系;正文仍保存在原私有文件中,按页读取全部原始字段。每次核文件身份/权限及变更元数据,新增或变化文件重验完整schema与摘要;作用域证明仅在本次操作内按完整归属合并,返回正文前重核原记录关系,不能借同会话另一关系读取悬空记录。跨会话eventId幂等、全历史序号、原子写和文件/目录fsync、未知结果只读核实保持。
|
|
137
|
+
|
|
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;}
|
|
@@ -48,6 +48,7 @@ export function validRemoteConversationDetail(v) {
|
|
|
48
48
|
return false;
|
|
49
49
|
return v.version === 1 && text(v.eventId) && text(v.instanceId) && integer(v.epoch) && text(v.sessionId) && brand(v.provider) && integer(v.sequence) && [v.turn, v.step].every(x => x === null || text(x) || integer(x)) && text(v.kind) && ['info', 'warning', 'action-required'].includes(v.severity) && text(v.code) && typeof v.summary === 'string' && (v.method === undefined || text(v.method));
|
|
50
50
|
}
|
|
51
|
+
const header = (d) => ({ eventId: d.eventId, instanceId: d.instanceId, epoch: d.epoch, sessionId: d.sessionId, provider: d.provider, sequence: d.sequence, kind: d.kind, severity: d.severity });
|
|
51
52
|
const counts = (items, knownKinds = ['extensions', 'commands', 'tools', 'usage', 'action-required']) => ({ total: items.length, unknownCount: items.filter(d => !knownKinds.includes(d.kind)).length, actionRequiredCount: items.filter(d => d.severity === 'action-required' || d.kind === 'action-required').length });
|
|
52
53
|
export function createConversationDetails(options) {
|
|
53
54
|
const parent = join(options.profileDir, 'ai-workbench-connect'), root = join(parent, options.storageName ?? 'conversation-details');
|
|
@@ -60,6 +61,9 @@ export function createConversationDetails(options) {
|
|
|
60
61
|
let snapshotGuards = [];
|
|
61
62
|
let snapshot = { ...connectionIds(), revision, phase: 'unavailable', sessions: [] };
|
|
62
63
|
const listeners = new Set();
|
|
64
|
+
// Only compact, validated metadata is retained: event bodies remain on disk.
|
|
65
|
+
const indexed = new Map(), storedDigests = new WeakMap();
|
|
66
|
+
const operationScopes = new Map();
|
|
63
67
|
function connectionIds() { const c = options.getConnectionState(); return { instanceId: c.instanceId, epoch: c.epoch }; }
|
|
64
68
|
function check(before) { const c = options.getConnectionState(); if (disposed || c.phase === 'disposed')
|
|
65
69
|
throw new NeedError(need('DISPOSED')); if (c.phase !== 'connected' || c.instanceId !== before.instanceId || c.epoch !== before.epoch)
|
|
@@ -83,6 +87,7 @@ export function createConversationDetails(options) {
|
|
|
83
87
|
return { ...connectionIds(), revision, phase: 'unavailable', sessions: [], need: need(e instanceof NeedError ? e.need.code : 'REMOTE_DETAIL_STORAGE_FAILED') };
|
|
84
88
|
} return structuredClone(snapshot); }
|
|
85
89
|
function error(e) { const code = e instanceof NeedError ? e.need.code : 'REMOTE_DETAIL_STORAGE_FAILED'; if (code === 'REMOTE_DETAIL_STORAGE_FAILED') {
|
|
90
|
+
indexed.clear();
|
|
86
91
|
uncertain = true;
|
|
87
92
|
publish('failed', [], code);
|
|
88
93
|
}
|
|
@@ -92,6 +97,7 @@ export function createConversationDetails(options) {
|
|
|
92
97
|
publish('unavailable', [], code); return fail(code); }
|
|
93
98
|
function serial(run) {
|
|
94
99
|
const pending = (queues.get(root) ?? Promise.resolve()).then(async () => { try {
|
|
100
|
+
operationScopes.clear();
|
|
95
101
|
return await run();
|
|
96
102
|
}
|
|
97
103
|
catch (e) {
|
|
@@ -224,36 +230,74 @@ export function createConversationDetails(options) {
|
|
|
224
230
|
return Object.keys(raw).sort().join(',') === 'detail,digest,hostBindingRef,scopeDigest,version' && text(raw.hostBindingRef) && raw.scopeDigest === digest(canonical(['host', raw.hostBindingRef, raw.detail]));
|
|
225
231
|
return raw.version === 2 && Object.keys(raw).sort().join(',') === 'detail,digest,localAcceptanceId,scopeDigest,version' && text(raw.localAcceptanceId) && raw.scopeDigest === digest(canonical([raw.localAcceptanceId, raw.detail]));
|
|
226
232
|
}
|
|
233
|
+
function metadata(st) {
|
|
234
|
+
if (!st.isFile() || st.isSymbolicLink() || st.uid !== BigInt(process.getuid()) || st.nlink !== 1n || (st.mode & 511n) !== 384n)
|
|
235
|
+
throw Error('DETAIL_RECORD_INVALID');
|
|
236
|
+
return [st.dev, st.ino, st.size, st.mtimeNs, st.ctimeNs, st.mode, st.uid, st.gid, st.nlink].join(':');
|
|
237
|
+
}
|
|
238
|
+
function recordScope(d, identity, before) {
|
|
239
|
+
const host = hostRefs.get(d), local = localRefs.get(d), ref = host ?? local;
|
|
240
|
+
if (!ref)
|
|
241
|
+
throw Error('DETAIL_CONTEXT_REQUIRED');
|
|
242
|
+
const id = canonical([identity, host ? 'host' : 'local', ref, d.sessionId, d.provider, d.instanceId, d.epoch]), cached = operationScopes.get(id);
|
|
243
|
+
if (cached)
|
|
244
|
+
return cached;
|
|
245
|
+
const admission = host ? options.hostAcceptance : options.localAcceptance;
|
|
246
|
+
if (!admission)
|
|
247
|
+
throw Error('DETAIL_CONTEXT_REQUIRED');
|
|
248
|
+
return checked(admission.readScope(d.sessionId, d.provider, ref, d, identity), before).then(r => { operationScopes.set(id, r); return r; });
|
|
249
|
+
}
|
|
227
250
|
async function rows(domain, before) {
|
|
228
|
-
const items = [], ids = new Set(), sequences = new Set();
|
|
229
|
-
|
|
251
|
+
const items = [], ids = new Set(), sequences = new Set(), previous = indexed.get(domain), next = new Map();
|
|
252
|
+
const names = await checked(readdir(domain), before);
|
|
253
|
+
for (const name of names)
|
|
230
254
|
if (!/^[a-f0-9]{64}\.json$/.test(name))
|
|
231
255
|
throw Error('DETAIL_RECORD_INVALID');
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
241
|
-
throw
|
|
256
|
+
// Batch independent metadata reads under one post-await admission check. Never
|
|
257
|
+
// treat an unchanged directory mtime as evidence that file contents are intact.
|
|
258
|
+
const fingerprints = await checked(Promise.all(names.map(async (name) => metadata(await lstat(join(domain, name), { bigint: true })))), before);
|
|
259
|
+
for (let n = 0; n < names.length; n++) {
|
|
260
|
+
const name = names[n], fingerprint = fingerprints[n];
|
|
261
|
+
let entry = previous?.get(name);
|
|
262
|
+
if (!entry || entry.fingerprint !== fingerprint) {
|
|
263
|
+
const raw = JSON.parse(await privateRead(join(domain, name), before));
|
|
264
|
+
if (!validStored(raw) || name !== digest(raw.detail.eventId) + '.json' || metadata(await checked(lstat(join(domain, name), { bigint: true }), before)) !== fingerprint)
|
|
265
|
+
throw Error('DETAIL_RECORD_INVALID');
|
|
266
|
+
const d = header(raw.detail);
|
|
267
|
+
if (raw.version === 2)
|
|
268
|
+
localRefs.set(d, raw.localAcceptanceId);
|
|
269
|
+
if (raw.version === 3)
|
|
270
|
+
hostRefs.set(d, raw.hostBindingRef);
|
|
271
|
+
entry = { fingerprint, row: d, digest: raw.digest };
|
|
272
|
+
storedDigests.set(d, raw.digest);
|
|
242
273
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const
|
|
274
|
+
const d = entry.row;
|
|
275
|
+
if (ids.has(d.eventId) || sequences.has(canonical([d.sessionId, d.provider, d.sequence])))
|
|
276
|
+
throw Error('DETAIL_RECORD_INVALID');
|
|
277
|
+
if (localRefs.has(d) || hostRefs.has(d)) {
|
|
278
|
+
const proof = recordScope(d, basename(domain), before), r = proof instanceof Promise ? await proof : proof;
|
|
248
279
|
if (!r.ok && r.error.code !== 'REMOTE_DETAIL_SCOPE_INVALID')
|
|
249
280
|
throw new NeedError(r.error);
|
|
250
281
|
}
|
|
251
282
|
ids.add(d.eventId);
|
|
252
283
|
sequences.add(canonical([d.sessionId, d.provider, d.sequence]));
|
|
253
284
|
items.push(d);
|
|
285
|
+
next.set(name, entry);
|
|
254
286
|
}
|
|
287
|
+
indexed.set(domain, next);
|
|
255
288
|
return items;
|
|
256
289
|
}
|
|
290
|
+
async function loadDetail(domain, row, before) {
|
|
291
|
+
const raw = JSON.parse(await privateRead(join(domain, digest(row.eventId) + '.json'), before));
|
|
292
|
+
if (!validStored(raw) || canonical(header(raw.detail)) !== canonical(row) || raw.digest !== storedDigests.get(row) || (raw.localAcceptanceId ?? undefined) !== localRefs.get(row) || (raw.hostBindingRef ?? undefined) !== hostRefs.get(row))
|
|
293
|
+
throw Error('DETAIL_RECORD_INVALID');
|
|
294
|
+
const d = raw.detail;
|
|
295
|
+
if (localRefs.has(row))
|
|
296
|
+
localRefs.set(d, localRefs.get(row));
|
|
297
|
+
if (hostRefs.has(row))
|
|
298
|
+
hostRefs.set(d, hostRefs.get(row));
|
|
299
|
+
return d;
|
|
300
|
+
}
|
|
257
301
|
async function scope(sessionId, provider, before) {
|
|
258
302
|
if (!text(sessionId) || !brand(provider))
|
|
259
303
|
throw new NeedError(need('REMOTE_DETAIL_SCOPE_INVALID'));
|
|
@@ -291,7 +335,7 @@ export function createConversationDetails(options) {
|
|
|
291
335
|
for (const d of selected) {
|
|
292
336
|
const hostRef = hostRefs.get(d);
|
|
293
337
|
if (hostRef) {
|
|
294
|
-
const
|
|
338
|
+
const proof = recordScope(d, identity, before), r = proof instanceof Promise ? await proof : proof;
|
|
295
339
|
if (r.ok && r.value.identity === identity) {
|
|
296
340
|
recordGuards.set(d, { guard: r.value.guard, cacheGuard: r.value.cacheGuard });
|
|
297
341
|
result.push(d);
|
|
@@ -302,7 +346,7 @@ export function createConversationDetails(options) {
|
|
|
302
346
|
}
|
|
303
347
|
const ref = localRefs.get(d);
|
|
304
348
|
if (ref) {
|
|
305
|
-
const
|
|
349
|
+
const proof = recordScope(d, identity, before), r = proof instanceof Promise ? await proof : proof;
|
|
306
350
|
if (r.ok && r.value.identity === identity) {
|
|
307
351
|
recordGuards.set(d, { guard: r.value.guard, cacheGuard: r.value.cacheGuard });
|
|
308
352
|
result.push(d);
|
|
@@ -315,6 +359,11 @@ export function createConversationDetails(options) {
|
|
|
315
359
|
}
|
|
316
360
|
return result;
|
|
317
361
|
}
|
|
362
|
+
function guardRecords(items) {
|
|
363
|
+
const guards = new Set(items.flatMap(d => { const proof = recordGuards.get(d); return proof ? [proof.guard] : []; }));
|
|
364
|
+
for (const guard of guards)
|
|
365
|
+
guard();
|
|
366
|
+
}
|
|
318
367
|
async function stateRows(items, identity, before) {
|
|
319
368
|
const publicationRevision = options.publicationRevision?.(), publicationCurrent = () => !options.publicationRevision || options.publicationRevision() === publicationRevision, publicationGuard = () => { if (!publicationCurrent())
|
|
320
369
|
throw new NeedError(need('REMOTE_DETAIL_SCOPE_INVALID')); };
|
|
@@ -340,11 +389,11 @@ export function createConversationDetails(options) {
|
|
|
340
389
|
sessions.push({ sessionId: d.sessionId, provider: d.provider, ...counts(accessible, options.knownKinds) });
|
|
341
390
|
}
|
|
342
391
|
check(before);
|
|
343
|
-
for (const guard of guards)
|
|
392
|
+
for (const guard of new Set(guards))
|
|
344
393
|
guard();
|
|
345
394
|
if (!publicationCurrent())
|
|
346
395
|
return;
|
|
347
|
-
snapshotGuards = [...cacheGuards, ...(options.cacheContext ? [() => options.cacheContext(identity)] : []), ...(options.publicationRevision ? [publicationGuard] : [])];
|
|
396
|
+
snapshotGuards = [...new Set(cacheGuards), ...(options.cacheContext ? [() => options.cacheContext(identity)] : []), ...(options.publicationRevision ? [publicationGuard] : [])];
|
|
348
397
|
publish('ready', sessions, excluded ? 'REMOTE_DETAIL_SCOPE_INVALID' : undefined);
|
|
349
398
|
}
|
|
350
399
|
function cursor(value, secret) { const payload = Buffer.from(canonical(value)).toString('base64url'); return payload + '.' + createHmac('sha256', secret).update(payload).digest('hex'); }
|
|
@@ -390,7 +439,7 @@ export function createConversationDetails(options) {
|
|
|
390
439
|
if (!Number.isSafeInteger(options.maxEventBytes) || options.maxEventBytes < 1)
|
|
391
440
|
return fail('SETTINGS_REQUIRED');
|
|
392
441
|
const identity = proof?.identity ?? await scope(detail.sessionId, detail.provider, before), domain = (await prepare(identity, before, true)), items = await rows(domain, before), existing = items.find(d => d.eventId === detail.eventId);
|
|
393
|
-
if (existing && (
|
|
442
|
+
if (existing && (storedDigests.get(existing) !== digest(canonical(detail)) || localRefs.get(existing) !== localId || hostRefs.get(existing) !== proof?.hostBindingRef))
|
|
394
443
|
return fail('REMOTE_DETAIL_CONFLICT');
|
|
395
444
|
if (!existing && Buffer.byteLength(JSON.stringify(detail), 'utf8') > options.maxEventBytes)
|
|
396
445
|
return fail('REMOTE_DETAIL_TOO_LARGE');
|
|
@@ -411,15 +460,11 @@ export function createConversationDetails(options) {
|
|
|
411
460
|
items.push(detail);
|
|
412
461
|
}
|
|
413
462
|
else {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
finally {
|
|
420
|
-
await h.close();
|
|
421
|
-
}
|
|
422
|
-
await syncDir(domain, before);
|
|
463
|
+
if (localId)
|
|
464
|
+
localRefs.set(detail, localId);
|
|
465
|
+
if (proof?.hostBindingRef)
|
|
466
|
+
hostRefs.set(detail, proof.hostBindingRef);
|
|
467
|
+
await verifyReceipt(domain, detail, before);
|
|
423
468
|
}
|
|
424
469
|
await stateRows(items, identity, before);
|
|
425
470
|
if (!proof && await scope(detail.sessionId, detail.provider, before) !== identity)
|
|
@@ -463,7 +508,8 @@ export function createConversationDetails(options) {
|
|
|
463
508
|
const before = start();
|
|
464
509
|
if (!q || !text(q.eventId) || Object.keys(q).sort().join(',') !== 'eventId,provider,sessionId')
|
|
465
510
|
return fail('REMOTE_DETAIL_INVALID');
|
|
466
|
-
const identity = await readScope(q.sessionId, q.provider, before), domain = await prepare(identity, before), items = domain ? await rows(domain, before) : [],
|
|
511
|
+
const identity = await readScope(q.sessionId, q.provider, before), domain = await prepare(identity, before), items = domain ? await rows(domain, before) : [], row = items.find(r => r.eventId === q.eventId);
|
|
512
|
+
const d = row ? await loadDetail(domain, row, before) : undefined;
|
|
467
513
|
if (d && (d.sessionId !== q.sessionId || d.provider !== q.provider || !(await authorized([d], identity, q.sessionId, q.provider, before)).length))
|
|
468
514
|
return fail('REMOTE_DETAIL_SCOPE_INVALID');
|
|
469
515
|
if (d)
|
|
@@ -474,6 +520,8 @@ export function createConversationDetails(options) {
|
|
|
474
520
|
return fail('REMOTE_DETAIL_SCOPE_INVALID');
|
|
475
521
|
if (d)
|
|
476
522
|
uncertain = false;
|
|
523
|
+
if (d)
|
|
524
|
+
guardRecords([d]);
|
|
477
525
|
finalReadGuard?.();
|
|
478
526
|
check(before);
|
|
479
527
|
return ok(d ? { eventId: q.eventId, recorded: true, detail: structuredClone(d) } : { eventId: q.eventId, recorded: false });
|
|
@@ -517,7 +565,11 @@ export function createConversationDetails(options) {
|
|
|
517
565
|
await stateRows(items, identity, before);
|
|
518
566
|
if (await readScope(q.sessionId, q.provider, before) !== identity)
|
|
519
567
|
return fail('REMOTE_DETAIL_SCOPE_INVALID');
|
|
520
|
-
const
|
|
568
|
+
const bodies = await Promise.all(page.map(d => loadDetail(domain, d, before)));
|
|
569
|
+
if (await readScope(q.sessionId, q.provider, before) !== identity)
|
|
570
|
+
return fail('REMOTE_DETAIL_SCOPE_INVALID');
|
|
571
|
+
const value = { items: structuredClone(bodies), ...counts(bounded, options.knownKinds), ...(page.length < remaining.length ? { nextCursor: cursor({ version: 1, identity, sessionId: q.sessionId, provider: q.provider, upper, after: page.at(-1).sequence, authorization: digest(canonical(bounded.map(d => [d.eventId, reference(d)]))) }, secret) } : {}) };
|
|
572
|
+
guardRecords(bounded);
|
|
521
573
|
finalReadGuard?.();
|
|
522
574
|
check(before);
|
|
523
575
|
return ok(value);
|
|
@@ -528,11 +580,12 @@ export function createConversationDetails(options) {
|
|
|
528
580
|
};
|
|
529
581
|
return { ...api, observeConnection(c) { if (disposed)
|
|
530
582
|
return; if (c.phase !== 'connected') {
|
|
583
|
+
indexed.clear();
|
|
531
584
|
publish(c.phase === 'disposed' ? 'disposed' : 'unavailable', [], c.phase === 'disposed' ? 'DISPOSED' : 'CONNECTION_LOST');
|
|
532
585
|
return;
|
|
533
586
|
} if (uncertain) {
|
|
534
587
|
publish('failed', [], 'REMOTE_DETAIL_STORAGE_FAILED');
|
|
535
588
|
return;
|
|
536
589
|
} publish('loading'); void serial(async () => { const before = start(), context = await checked(options.context(), before); if (!context.ok)
|
|
537
|
-
throw new NeedError(context.error); const identity = context.value.identity, domain = await prepare(identity, before); await stateRows(domain ? await rows(domain, before) : [], identity, before); return ok(undefined); }); }, async dispose() { disposed = true; await tail; publish('disposed', [], 'DISPOSED'); listeners.clear(); } };
|
|
590
|
+
throw new NeedError(context.error); const identity = context.value.identity, domain = await prepare(identity, before); await stateRows(domain ? await rows(domain, before) : [], identity, before); return ok(undefined); }); }, async dispose() { disposed = true; indexed.clear(); await tail; publish('disposed', [], 'DISPOSED'); listeners.clear(); } };
|
|
538
591
|
}
|
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;
|
|
@@ -53,7 +54,7 @@ export declare function createHostSessionProjects(o: Options): {
|
|
|
53
54
|
observeLocations: (state: WorkspaceLocationState) => void;
|
|
54
55
|
observeSessionDisposed: (session: Session) => void;
|
|
55
56
|
resolve: (id: string, use: WorkspaceUse, input: HostWorkspaceResolveContext) => Promise<Result<HostSessionProjectTarget>>;
|
|
56
|
-
readScope: (sessionId: string, provider: Provider, ref?: string, detail?: RemoteConversationDetail, expectedIdentity?: string) => Promise<Result<{
|
|
57
|
+
readScope: (sessionId: string, provider: Provider, ref?: string, detail?: Pick<RemoteConversationDetail, "sessionId" | "provider" | "instanceId" | "epoch">, expectedIdentity?: string) => Promise<Result<{
|
|
57
58
|
identity: string;
|
|
58
59
|
guard: () => void;
|
|
59
60
|
cacheGuard: () => void;
|
|
@@ -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())
|
|
@@ -59,7 +59,7 @@ export declare function createLocalUserTurnAcceptance(o: Options): {
|
|
|
59
59
|
observe: (session: Session, event: SessionEvent) => void;
|
|
60
60
|
observeLocations: (state: WorkspaceLocationState) => void;
|
|
61
61
|
observeSessionDisposed: (session: Session) => void;
|
|
62
|
-
readScope: (sessionId: string, provider: Provider, acceptanceId?: string, detail?: RemoteConversationDetail, expectedIdentity?: string) => Promise<Result<{
|
|
62
|
+
readScope: (sessionId: string, provider: Provider, acceptanceId?: string, detail?: Pick<RemoteConversationDetail, "sessionId" | "provider" | "instanceId" | "epoch">, expectedIdentity?: string) => Promise<Result<{
|
|
63
63
|
identity: string;
|
|
64
64
|
guard: () => void;
|
|
65
65
|
cacheGuard: () => void;
|
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)
|