@ai-workbench/connect 0.7.40 → 0.7.42

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 CHANGED
@@ -122,3 +122,11 @@ Codex保持官方设备码登录,设备码在本设置行显示,网页用系
122
122
  “远程主机连接”跟随 DSH 当前界面语言,显示连接资料、公司主机连接、Codex、Claude四项真实状态及剩余步骤。已导入后显示员工标识,不再要求重复领取资料;检查中不显示可以开始使用。目录选择器、工作区文件来源和技术详情收在默认折叠的“高级”中。
123
123
 
124
124
  登录区内联显示完整可选中/复制的公开链接;系统打开默认浏览器较慢或失败时,仍可复制链接自行打开,也可点打开按钮。Codex显示官方CLI提供的一次性设备码和复制按钮;没有verification_uri_complete时只用CLI原基础链接,不拼接附码URL。Claude粘贴框为等宽文本、适应可用宽度,不限制授权码长度,粘贴去首尾空白,空值不能提交。授权码仍只经受保护POST正文和主机CLI stdin交接,不写日志/状态/argv。成功自动收起;本次失败说明原因并可重新发起。不新增设置、检查、轮询、重试或时限。
125
+
126
+ ### Claude 状态只读检查(0.7.41)
127
+
128
+ 需要主机先部署 host 0.8.5 的 `lib/claude-auth-state.cjs`。连接与登录前后状态检查不再启动 `claude auth status`,只由员工本人读取自己的主机订阅存储,读取失败明确报未知,不自动重登。主机模型目录在官方五分钟续期窗口内暂不可用;正常 Claude 会话完成续期、离开窗口后重新打开模型菜单。登录取消、登出及正常会话回收不在本轮修复范围。
129
+
130
+ ### DSH 子代理子会话的主机目录归属(0.7.42)
131
+
132
+ DSH 自带子代理(subagent/subagent_fork/workflow 等)创建的子会话不是工作区成员。主机目录核对员工归属时,L 沿 live 的 `parentSession` 找到最近一个登记在工作区里的祖先会话,按它的归属判断:新员工父会话派出的子会话可用,旧员工父会话的子会话照旧拒绝;祖先不在 live 会话中时保持原来的路径拒绝规则。不新增设置、限制或错误码;层数和并发由 DSH 自己的子代理设置决定。
@@ -1,9 +1,20 @@
1
- // Only official CLI status. Codex exit 1 alone also means a check error; require its fixed official not-signed-in response. No credential files or OAuth.
1
+ // Claude 状态只复用主机只读判断器;Codex 与显式登出仍走原 CLI 路径。
2
2
  const {spawn}=require('node:child_process');const {StringDecoder}=require('node:string_decoder');const decoder=new StringDecoder('utf8'),errorDecoder=new StringDecoder('utf8');
3
3
  const [provider,budgetText,action='status',...extra]=process.argv.slice(1),budget=Number(budgetText);
4
4
  if(!['codex','claude'].includes(provider)||!Number.isSafeInteger(budget)||budget<1||!['status','logout'].includes(action)||extra.length)process.exit(2);
5
+ if(provider==='claude'&&action==='status'){
6
+ try{
7
+ const {readClaudeAuthState}=require('/usr/local/aw-host/lib/claude-auth-state.cjs');
8
+ const state=readClaudeAuthState({maxOutputBytes:budget});
9
+ if(!state||Object.keys(state).sort().join(',')!=='loggedIn,refreshDue'||typeof state.loggedIn!=='boolean'||typeof state.refreshDue!=='boolean')throw Error();
10
+ const exitCode=state.loggedIn?0:1;
11
+ process.stdout.write(JSON.stringify({protocolVersion:1,provider,exitCode,loggedIn:state.loggedIn})+'\n');process.exitCode=exitCode;
12
+ }catch{
13
+ process.stderr.write('EXECUTION_FAILED: 主机无法只读确认 Claude 登录状态;请管理员检查主机工具、员工凭据存储及钥匙串。\n');process.exitCode=2;
14
+ }
15
+ }else{
5
16
  let stdout='',stderr='',size=0,invalid=false,finished=false;
6
- const child=spawn(provider,action==='logout'?(provider==='codex'?['logout']:['auth','logout']):provider==='codex'?['login','status']:['auth','status'],{stdio:['ignore','pipe','pipe']});
17
+ const child=spawn(provider,action==='logout'?(provider==='codex'?['logout']:['auth','logout']):['login','status'],{stdio:['ignore','pipe','pipe']});
7
18
  const stop=()=>{invalid=true;child.kill('SIGKILL');};
8
19
  process.on('SIGHUP',stop);process.on('SIGTERM',stop);process.stdout.on('error',stop);child.once('error',()=>{invalid=true;});
9
20
  for(const [stream,channel] of [[child.stdout,'out'],[child.stderr,'err']])stream.on('data',b=>{size+=b.length;if(size>budget){stop();return;}if(channel==='out')stdout+=decoder.write(b);else if(provider==='codex')stderr+=errorDecoder.write(b);});
@@ -12,8 +23,9 @@ function finish(exitCode){
12
23
  stdout+=decoder.end();stderr+=errorDecoder.end();let loggedIn=null;
13
24
  if(action==='logout'){process.exitCode=!invalid&&Number.isInteger(exitCode)&&exitCode>=0&&exitCode<=255?exitCode:1;return;}
14
25
  if(!invalid&&provider==='codex'){if(exitCode===0)loggedIn=true;else if(exitCode===1&&stdout.trim()===''&&stderr.trim()==='Not logged in')loggedIn=false;}
15
- if(!invalid&&provider==='claude')try{const v=JSON.parse(stdout);if(v&&typeof v==='object'&&!Array.isArray(v)&&typeof v.loggedIn==='boolean')loggedIn=v.loggedIn;}catch(error){process.stderr.write("AUTH_STATUS_JSON_INVALID:"+(error instanceof SyntaxError?"SyntaxError":"ParseError")+"\n");}
16
26
  const code=Number.isInteger(exitCode)&&exitCode>=0&&exitCode<=255?exitCode:1;
17
27
  process.stdout.write(JSON.stringify({protocolVersion:1,provider,exitCode,loggedIn})+'\n',()=>process.exit(code));
18
28
  }
19
29
  child.once('exit',code=>{if(invalid)finish(code);});child.once('close',finish);
30
+
31
+ }
package/lib/needs.js CHANGED
@@ -42,7 +42,7 @@ const entries = {
42
42
  CONNECTION_LOST: { layer: 'network', message: '连接中断,正在等待网络恢复信号,恢复后将重新连接。', requires: '网络恢复', actor: 'plugin', action: { id: 'await-network', label: '等待网络恢复', available: false } },
43
43
  DEPENDENCY_REQUIRED: { layer: 'integration', message: '远程主机连接的连接组件没有装好,请联系管理员。', requires: '提供方契约与适配器', actor: 'administrator', action: { id: 'supply-dependency', label: '提供集成前置条件', available: false } },
44
44
  SETTINGS_REQUIRED: { layer: 'settings', message: '远程主机连接设置暂不可用,请查看技术详情。', requires: '已确认的连接设置', actor: 'administrator', action: { id: 'configure-settings', label: '确认具名设置', available: false } },
45
- AUTH_STATUS_INVALID: { layer: 'auth', message: '暂时无法确认登录状态,可检查本机网络后重新检查。', requires: '有效的官方 CLI 登录状态', actor: 'administrator', action: { id: 'inspect-auth-status', label: '检查官方 CLI', available: false } },
45
+ AUTH_STATUS_INVALID: { layer: 'auth', message: '暂时无法读取主机上的登录状态,请联系管理员检查认证存储、钥匙串或连接。', requires: '可读取的主机登录状态', actor: 'administrator', action: { id: 'inspect-auth-status', label: '检查主机登录状态', available: false } },
46
46
  LOGOUT_FAILED: { layer: 'auth', message: '主机账号登出未完成或结果无法确认,请重新检查;不会自动重试登出。', requires: '官方退出成功且同一主机员工状态为未登录', actor: 'employee', action: { id: 'check-login', label: '重新检查', available: true } },
47
47
  LOGIN_FAILED: { layer: 'auth', message: '登录未完成,可以立即重新发起登录。', requires: '完成 AI 授权', actor: 'employee', action: { id: 'open-login', label: '重新授权', available: true } },
48
48
  HOST_TRUST_REQUIRED: { layer: 'ssh', message: '远程主机连接还缺少可信的连接信息,请联系管理员。', requires: 'host.knownHosts', actor: 'administrator', action: { id: 'supply-host-trust', label: '提供主机信任材料', available: false } },
@@ -92,7 +92,7 @@ function attachScopedProfileRuntime(ctx, api, ports, config, network, autoStart
92
92
  ctx.inject(['profileContext', 'workspaceRegistry', 'sessions'], native => {
93
93
  const registry = native.get('workspaceRegistry');
94
94
  let picker;
95
- const currentLocations = createWorkspaceLocations({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, pageSize: config.workspaceLocations?.pageSize ?? WORKSPACE_LOCATION_DEFAULTS.pageSize, isWorkspacePending: id => picker?.isPending(id) ?? false, nextRevision: () => ++locationRevision, api, registry, hostDirectories: ports.hostDirectories, onState: state => ctx.emit('ai-workbench/workspace-location-state', state) });
95
+ const currentLocations = createWorkspaceLocations({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, pageSize: config.workspaceLocations?.pageSize ?? WORKSPACE_LOCATION_DEFAULTS.pageSize, isWorkspacePending: id => picker?.isPending(id) ?? false, nextRevision: () => ++locationRevision, api, registry, sessions: native.get('sessions'), hostDirectories: ports.hostDirectories, onState: state => ctx.emit('ai-workbench/workspace-location-state', state) });
96
96
  locations = currentLocations;
97
97
  const location = currentLocations;
98
98
  const pickerRegistry = registry;
@@ -10,6 +10,13 @@ interface Options {
10
10
  pageSize: number;
11
11
  api: Pick<ConnectApi, 'getConnectionState' | 'getModelCatalogTarget'>;
12
12
  registry: NativeWorkspaceRegistry;
13
+ sessions?: {
14
+ get(id: string): {
15
+ header: {
16
+ parentSession?: string;
17
+ };
18
+ } | undefined;
19
+ };
13
20
  hostDirectories?: ReturnType<typeof createHostDirectories>;
14
21
  onState?: (s: WorkspaceLocationState) => void;
15
22
  nextRevision?: () => number;
@@ -406,6 +406,15 @@ export function createWorkspaceLocations(o) {
406
406
  async function guardEmployee(sessionId, target, source) {
407
407
  if (disposed)
408
408
  reject('DISPOSED');
409
+ // DSH子代理子会话不是workspace成员:沿live parentSession取最近的登记祖先,按它的归属核对。
410
+ const member = (id) => o.registry.list().some(w => w.sessionIds.includes(id)), seen = new Set();
411
+ while (!member(sessionId)) {
412
+ seen.add(sessionId);
413
+ const parent = o.sessions?.get(sessionId)?.header.parentSession;
414
+ if (!parent || seen.has(parent) || !o.sessions?.get(parent))
415
+ break;
416
+ sessionId = parent;
417
+ }
409
418
  const ids = new Set(o.registry.list().filter(w => w.sessionIds.includes(sessionId)).map(w => w.id));
410
419
  // Missing historical registry information keeps the original source-path refusal.
411
420
  const stored = await records();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-workbench/connect",
3
- "version": "0.7.40",
3
+ "version": "0.7.42",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24.13.1",