@ai-workbench/connect 0.7.41 → 0.7.43
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 +8 -0
- package/lib/connect.js +31 -18
- package/lib/profile-runtime.js +1 -1
- package/lib/workspace-locations.d.ts +7 -0
- package/lib/workspace-locations.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,3 +126,11 @@ Codex保持官方设备码登录,设备码在本设置行显示,网页用系
|
|
|
126
126
|
### Claude 状态只读检查(0.7.41)
|
|
127
127
|
|
|
128
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 自己的子代理设置决定。
|
|
133
|
+
|
|
134
|
+
### 同品牌并行轮的登录就绪核对(0.7.43)
|
|
135
|
+
|
|
136
|
+
DSH workflow/subagent 并行派出的多个子会话(以及同一员工同时进行的多个会话)每一轮开始前都要经 `ensureReady` 核对主机登录状态。旧实现每次调用各发一条主机状态命令,并按“最新一次为准”作废同品牌较早的检查,于是 N 路并行只有最后发起的一路成功,其余报 `AUTH_STATUS_INVALID`(`STATUS_SUPERSEDED`),DSH workflow 把它们记为 null。现在同品牌并发的 `ensureReady` 共用同一次进行中的核对,结果一致;结束后下一次调用照常重新核对。不新增设置、限制或错误码,不改登录、登出与授权流程。
|
package/lib/connect.js
CHANGED
|
@@ -57,6 +57,7 @@ export function createConnect(ports, emit, options = {}) {
|
|
|
57
57
|
let controller = new AbortController();
|
|
58
58
|
const loginFlights = new Map();
|
|
59
59
|
const logoutFlights = new Map();
|
|
60
|
+
const readyFlights = new Map();
|
|
60
61
|
const statusFlights = new Map();
|
|
61
62
|
let forgetFlight, quiesced = false;
|
|
62
63
|
const pending = new Set();
|
|
@@ -417,24 +418,36 @@ export function createConnect(ports, emit, options = {}) {
|
|
|
417
418
|
refreshLoginPrompts: async () => { await startup.check(); const s = startup.getState(); return s.phase === 'disposed' ? fail('DISPOSED') : s.phase === 'blocked' ? fail(s.technicalDetails.code ?? 'AUTH_STATUS_INVALID') : ok(s); },
|
|
418
419
|
login: async (provider) => { const request = await startup.request(provider, 'automatic'); if (!request.ok)
|
|
419
420
|
return request; return request.value.logins[provider] === true ? ok({ provider, loggedIn: true }) : fail('LOGIN_REQUIRED'); },
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
421
|
+
// Concurrent turns of one brand (DSH workflow/subagent fan-out) share one readiness flight:
|
|
422
|
+
// separate same-brand checks supersede each other and all but the newest would fail.
|
|
423
|
+
ensureReady: provider => {
|
|
424
|
+
const prior = readyFlights.get(provider);
|
|
425
|
+
if (prior)
|
|
426
|
+
return prior;
|
|
427
|
+
const promise = track((async () => {
|
|
428
|
+
const checking = checkLogin(provider), g = generation;
|
|
429
|
+
const r = await checking;
|
|
430
|
+
const stale = invalid(g);
|
|
431
|
+
if (stale)
|
|
432
|
+
return stale;
|
|
433
|
+
if (!r.ok)
|
|
434
|
+
return r;
|
|
435
|
+
if (!r.value.loggedIn) {
|
|
436
|
+
const request = await startup.request(provider, 'automatic');
|
|
437
|
+
return invalid(g) ?? (!request.ok ? request : fail('LOGIN_REQUIRED'));
|
|
438
|
+
}
|
|
439
|
+
if (logoutFlights.has(provider))
|
|
440
|
+
return fail('ACTIVATION_CONFLICT');
|
|
441
|
+
const owner = startup.captureCheck(provider);
|
|
442
|
+
const connected = await connect(), current = startup.getState();
|
|
443
|
+
return invalid(g) ?? (logoutFlights.has(provider) || !startup.currentTicket(owner) || current.logins[provider] !== true || current.checkingProviders.includes(provider) || current.providerNeeds[provider] ? fail('AUTH_STATUS_INVALID') : connected);
|
|
444
|
+
})());
|
|
445
|
+
readyFlights.set(provider, promise);
|
|
446
|
+
const clear = () => { if (readyFlights.get(provider) === promise)
|
|
447
|
+
readyFlights.delete(provider); };
|
|
448
|
+
void promise.then(clear, clear);
|
|
449
|
+
return promise;
|
|
450
|
+
},
|
|
438
451
|
dispose: () => { if (disposal)
|
|
439
452
|
return disposal; let done; disposal = new Promise(resolve => done = resolve); disposed = true; generation++; startup.stop(); controller.abort(); const paused = ports.enrollment?.pause?.(); unsubscribe?.(); publish({ phase: 'disposed' }); setConnection('disposed'); connectionListeners.clear(); void Promise.allSettled([...pending, paused]).then(() => startup.dispose()).then(done); return disposal; },
|
|
440
453
|
};
|
package/lib/profile-runtime.js
CHANGED
|
@@ -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();
|