@ai-workbench/connect 0.7.22 → 0.7.26

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.
Files changed (62) hide show
  1. package/README.md +20 -67
  2. package/client/index.cjs +93 -65
  3. package/helper/host-directories.cjs +8 -1
  4. package/lib/api.d.ts +21 -163
  5. package/lib/component-download.d.ts +1 -1
  6. package/lib/component-download.js +1 -1
  7. package/lib/component-source.d.ts +6 -27
  8. package/lib/component-source.js +10 -138
  9. package/lib/components.d.ts +1 -1
  10. package/lib/components.js +86 -98
  11. package/lib/connect.d.ts +0 -3
  12. package/lib/connect.js +15 -62
  13. package/lib/connection-messages.d.ts +2 -3
  14. package/lib/connection-messages.js +5 -4
  15. package/lib/conversation-log.d.ts +9 -0
  16. package/lib/conversation-log.js +44 -0
  17. package/lib/cordis.d.ts +1 -4
  18. package/lib/defaults.d.ts +0 -7
  19. package/lib/defaults.js +0 -2
  20. package/lib/enrollment.js +1 -8
  21. package/lib/host-directories.d.ts +6 -4
  22. package/lib/host-directories.js +4 -4
  23. package/lib/host-session-projects.d.ts +8 -58
  24. package/lib/host-session-projects.js +45 -270
  25. package/lib/index.d.ts +2 -11
  26. package/lib/index.js +11 -23
  27. package/lib/integration.d.ts +2 -2
  28. package/lib/integration.js +0 -2
  29. package/lib/native-workspace.d.ts +10 -0
  30. package/lib/needs.js +13 -25
  31. package/lib/ports.d.ts +1 -6
  32. package/lib/profile-runtime.js +59 -152
  33. package/lib/profile-settings.d.ts +6 -1
  34. package/lib/profile-settings.js +3 -5
  35. package/lib/startup.js +2 -2
  36. package/lib/workspace-directory-picker-types.d.ts +44 -0
  37. package/lib/workspace-directory-picker-types.js +1 -0
  38. package/lib/workspace-directory-picker.d.ts +30 -0
  39. package/lib/workspace-directory-picker.js +394 -0
  40. package/lib/workspace-location-types.d.ts +3 -7
  41. package/lib/workspace-locations.d.ts +6 -30
  42. package/lib/workspace-locations.js +83 -177
  43. package/package.json +3 -2
  44. package/helper/projects.cjs +0 -57
  45. package/lib/conversation-detail-settings.d.ts +0 -32
  46. package/lib/conversation-detail-settings.js +0 -119
  47. package/lib/conversation-details.d.ts +0 -30
  48. package/lib/conversation-details.js +0 -591
  49. package/lib/host-session-store.d.ts +0 -27
  50. package/lib/host-session-store.js +0 -130
  51. package/lib/local-acceptance-store.d.ts +0 -18
  52. package/lib/local-acceptance-store.js +0 -133
  53. package/lib/local-user-turn-acceptance.d.ts +0 -76
  54. package/lib/local-user-turn-acceptance.js +0 -289
  55. package/lib/local-user-turn-types.d.ts +0 -40
  56. package/lib/login-diagnostics.d.ts +0 -28
  57. package/lib/login-diagnostics.js +0 -57
  58. package/lib/projects.d.ts +0 -4
  59. package/lib/projects.js +0 -41
  60. package/lib/workspace-bindings.d.ts +0 -64
  61. package/lib/workspace-bindings.js +0 -379
  62. /package/lib/{local-user-turn-types.js → native-workspace.js} +0 -0
package/lib/needs.js CHANGED
@@ -1,24 +1,21 @@
1
1
  const entries = {
2
- LOCAL_USER_TURN_CHANGED: { layer: 'integration', message: '本次输入在核实期间发生变化,本轮已停止。', requires: '下一次真实员工输入与当前会话关系', actor: 'plugin', action: { id: 'inspect-local-user-turn', label: '查看技术详情', available: false } },
2
+ WORKSPACE_PICKER_INVALID: { layer: 'projects', message: '目录选择请求已失效或格式无效,请重新打开目录选择器。', requires: '本次选择器的有效目录与令牌', actor: 'employee', action: { id: 'open-workspace-directory-picker', label: '重新选择目录', available: true } },
3
+ WORKSPACE_PICKER_STORAGE_FAILED: { layer: 'projects', message: '本次未能读取或保存目录位置,可重新打开选择器再选。', requires: '本次可读写的目录选择记录', actor: 'employee', action: { id: 'open-workspace-directory-picker', label: '重新选择目录', available: true } },
4
+ WORKSPACE_PICKER_ROLLBACK_FAILED: { layer: 'projects', message: '本次添加未完成;若工作区列表有残留条目,可在 DSH 原生工作区管理中删除,再重新选择。', requires: '重新选择目录', actor: 'employee', action: { id: 'manage-native-workspaces', label: '在原生工作区管理中删除残留条目', available: true } },
3
5
  LOCAL_WORKSPACE_CONTEXT_UNSUPPORTED: { layer: 'integration', message: '当前平台尚未接入本地工作区进程环境交接。', requires: '已接入平台的本机后端上下文', actor: 'plugin', action: { id: 'inspect-local-workspace-context', label: '查看技术详情', available: false } },
4
6
  LOCAL_WORKSPACE_CONTEXT_UNAVAILABLE: { layer: 'integration', message: '本机进程环境无法确认,已停止交接;根因未查明。', requires: '当前进程的真实操作系统账户与环境', actor: 'plugin', action: { id: 'inspect-local-workspace-context', label: '查看技术详情', available: false } },
7
+ HOST_DIRECTORY_EXISTS: { layer: 'projects', message: '文件夹已存在,请换个名称。', requires: '尚未使用的文件夹名称', actor: 'employee', action: { id: 'create-workspace-directory', label: '更改文件夹名称', available: true } },
5
8
  HOST_DIRECTORY_INVALID: { layer: 'projects', message: '目录不存在或不是文件夹,请重新选择。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
6
9
  HOST_DIRECTORY_UNREADABLE: { layer: 'projects', message: '主机目录无法列出,请查看目录权限或连接状态。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
7
10
  HOST_DIRECTORY_CHANGED: { layer: 'projects', message: '目录内容或位置已变化,请重新浏览后选择。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
8
- HOST_DIRECTORY_PAGE_TOO_LARGE: { layer: 'projects', message: '本页目录元数据超过 commandOutputMaxBytes,请减小每页条数或联系管理员调整。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
9
- WORKSPACE_LOCATION_REQUIRED: { layer: 'projects', message: '请先在远程主机连接设置中选择此工作区的文件来源;旧关联需要确认。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
11
+ HOST_DIRECTORY_PAGE_TOO_LARGE: { layer: 'projects', message: '本页目录信息过多,请减小每页条数后重新浏览。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
12
+ WORKSPACE_LOCATION_REQUIRED: { layer: 'projects', message: '请先为此工作区选择文件来源。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
10
13
  WORKSPACE_LOCATION_INVALID: { layer: 'projects', message: '工作区位置与当前目录或主机身份不符,请重新选择。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
11
14
  WORKSPACE_LOCATION_CONFLICT: { layer: 'projects', message: '工作区或连接已变化,请刷新位置。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
12
15
  WORKSPACE_LOCATION_PROVIDER_REQUIRED: { layer: 'projects', message: '主机文件夹已记录,等待远程提供方接入位置合同后才能执行。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
13
16
  WORKSPACE_EXECUTION_UNAVAILABLE: { layer: 'projects', message: '本地文件夹已记录,按需远程文件与命令执行尚未接通。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
14
- WORKSPACE_LOCATION_STORAGE_FAILED: { layer: 'projects', message: '工作区位置记录无法读取或保存,已停止操作,请联系管理员。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
15
- REMOTE_DETAIL_INVALID: { layer: 'integration', message: '诊断内容格式无效或含未脱敏认证材料,已拒绝保存。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
16
- REMOTE_DETAIL_SCOPE_INVALID: { layer: 'integration', message: '诊断内容与当前连接、原生会话或已核验品牌关联不符,已拒绝保存。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
17
- REMOTE_DETAIL_STORAGE_FAILED: { layer: 'integration', message: '诊断记录无法持久保存或读取,结果无法确认,请联系管理员。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
18
- REMOTE_DETAIL_TOO_LARGE: { layer: 'integration', message: '诊断事件超过 conversationDetails.maxEventBytes,已拒绝保存,未裁剪。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
19
- REMOTE_DETAIL_SEQUENCE_INVALID: { layer: 'integration', message: '诊断事件序号没有严格递增,已拒绝保存。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
20
- REMOTE_DETAIL_CONFLICT: { layer: 'integration', message: '此诊断事件编号已有不同内容,已拒绝保存。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
21
- REMOTE_DETAIL_CURSOR_INVALID: { layer: 'integration', message: '详情分页位置与当前主机用户、会话、品牌或快照不符,请刷新详情。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
17
+ WORKSPACE_LOCATION_STORAGE_FAILED: { layer: 'projects', message: '本次无法读取或保存工作区位置,可重新打开目录选择器再选。', requires: '当前工作区位置与连接合同', actor: 'employee', action: { id: 'select-workspace-location', label: '查看工作区位置', available: true } },
18
+ REMOTE_DETAIL_STORAGE_FAILED: { layer: 'integration', message: '本地日志暂时无法读取,可稍后重新展开查看。', requires: '可读取的本机日志', actor: 'employee', action: { id: 'read-conversation-log', label: '重新展开查看', available: true } },
22
19
  MODEL_CATALOG_CONTEXT_INVALID: { layer: 'integration', message: '模型目录查询的品牌无效。', requires: '有效且已脱敏的诊断与可信连接', actor: 'plugin', action: { id: 'inspect-remote-details', label: '查看技术详情', available: false } },
23
20
  ACTIVATION_CONFLICT: { layer: 'network', message: '已有另一项开通正在进行,已停止重复开通,请联系管理员。', requires: '唯一的开通请求', actor: 'administrator', action: { id: 'inspect-network-enrollment', label: '联系管理员', available: false } },
24
21
  ACTIVATION_CANCELLED: { layer: 'network', message: '本次网络开通已取消。', requires: '完成明确的开通操作', actor: 'plugin', action: { id: 'inspect-network-enrollment', label: '联系管理员', available: false } },
@@ -36,30 +33,21 @@ const entries = {
36
33
  ENROLLMENT_REQUIRED: { layer: 'enrollment', message: '我需要开通链接,请联系管理员发放。', requires: '开通文件', actor: 'administrator', action: { id: 'request-enrollment', label: '联系管理员开通', available: false } },
37
34
  ENROLLMENT_INVALID: { layer: 'enrollment', message: '开通文件无效,我需要管理员重新发放。', requires: '有效开通文件', actor: 'administrator', action: { id: 'request-enrollment', label: '重新开通', available: false } },
38
35
  NETWORK_KEY_INVALID: { layer: 'network', message: '员工开通已失效,请联系管理员重新发放开通链接。', requires: '新的开通链接', actor: 'administrator', action: { id: 'request-enrollment', label: '联系管理员', available: false } },
39
- HOST_OFFLINE: { layer: 'network', message: '主机离线,请联系管理员;最后在线时间未提供时为未知。', requires: '在线的公司主机', actor: 'administrator', action: { id: 'contact-administrator', label: '联系管理员', available: false } },
36
+ HOST_OFFLINE: { layer: 'network', message: '暂时无法连接主机,最后在线时间未提供时为未知;可先检查本机网络。', requires: '在线的公司主机', actor: 'administrator', action: { id: 'contact-administrator', label: '联系管理员', available: false } },
40
37
  EMPLOYEE_MISSING: { layer: 'ssh', message: '主机上没有你的员工账号,需要管理员运行开通。', requires: '员工主机账号', actor: 'administrator', action: { id: 'provision-employee', label: '管理员开通账号', available: false } },
41
- SSH_FAILED: { layer: 'ssh', message: '远程主机连接暂时连不上,请联系管理员。', requires: '可用且身份匹配的员工 SSH 连接', actor: 'administrator', action: { id: 'inspect-ssh', label: '检查主机连接', available: false } },
38
+ SSH_FAILED: { layer: 'ssh', message: '与主机暂时连不上,可先检查本机网络。', requires: '可用且身份匹配的员工 SSH 连接', actor: 'administrator', action: { id: 'inspect-ssh', label: '检查主机连接', available: false } },
42
39
  LOGIN_PROMPT_INVALID: { layer: 'auth', message: '这个登录询问已经更新,请使用当前提示。', requires: '当前登录询问', actor: 'employee', action: { id: 'current-login-prompt', label: '查看当前提示', available: false } },
43
40
  LOGIN_REQUIRED: { layer: 'auth', message: '需要登录,请到设置 → 远程主机连接 点登录', requires: 'AI 账号授权', actor: 'employee', action: { id: 'open-login', label: '前往远程主机连接设置', available: true } },
44
41
  POLICY_DENIED: { layer: 'auth', message: '公司的 AI 席位设置不允许此操作,需要 AI 账号管理员开启。', requires: '允许此操作的 AI 席位设置', actor: 'ai-administrator', action: { id: 'contact-ai-administrator', label: '联系 AI 账号管理员', available: false } },
45
42
  CONNECTION_LOST: { layer: 'network', message: '连接中断,正在等待网络恢复信号,恢复后将重新连接。', requires: '网络恢复', actor: 'plugin', action: { id: 'await-network', label: '等待网络恢复', available: false } },
46
43
  DEPENDENCY_REQUIRED: { layer: 'integration', message: '远程主机连接的连接组件没有装好,请联系管理员。', requires: '提供方契约与适配器', actor: 'administrator', action: { id: 'supply-dependency', label: '提供集成前置条件', available: false } },
47
44
  SETTINGS_REQUIRED: { layer: 'settings', message: '远程主机连接还没有设置好,请联系管理员。', requires: '已确认的连接设置', actor: 'administrator', action: { id: 'configure-settings', label: '确认具名设置', available: false } },
48
- 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: '有效的官方 CLI 登录状态', actor: 'administrator', action: { id: 'inspect-auth-status', label: '检查官方 CLI', available: false } },
49
46
  LOGIN_FAILED: { layer: 'auth', message: '登录未完成,窗口已关闭或助手失败,可以重新授权。', requires: '完成 AI 授权', actor: 'employee', action: { id: 'open-login', label: '重新授权', available: true } },
50
47
  HOST_TRUST_REQUIRED: { layer: 'ssh', message: '远程主机连接还缺少可信的连接信息,请联系管理员。', requires: 'host.knownHosts', actor: 'administrator', action: { id: 'supply-host-trust', label: '提供主机信任材料', available: false } },
51
48
  HOST_KEY_MISMATCH: { layer: 'ssh', message: '主机身份与已开通的信任材料不符,需要管理员检查。', requires: '匹配的主机公钥', actor: 'administrator', action: { id: 'verify-host-trust', label: '检查主机身份', available: false } },
52
- PROJECT_NAME_INVALID: { layer: 'projects', message: '工作区名必须是单个目录名称,不能是路径、点目录或控制字符。', requires: '有效工作区名', actor: 'employee', action: { id: 'rename-project', label: '修改工作区名', available: true } },
53
- PROJECT_ROOT_INVALID: { layer: 'projects', message: '工作区暂时无法打开,请联系管理员。', requires: 'S 开通的 700 工作区根目录', actor: 'administrator', action: { id: 'check-project-root', label: '检查开通目录', available: false } },
54
- PROJECT_EXISTS: { layer: 'projects', message: '同名工作区或文件已经存在,请换一个工作区名。', requires: '未被占用的工作区名', actor: 'employee', action: { id: 'rename-project', label: '修改工作区名', available: true } },
55
- PROJECT_INIT_FAILED: { layer: 'projects', message: '工作区创建没有完成,已保留现有文件,请联系管理员。', requires: '可用的主机 Git 与目录检查', actor: 'administrator', action: { id: 'inspect-project-init', label: '检查 Git 初始化', available: false } },
56
- PROJECT_CREATE_FAILED: { layer: 'projects', message: '工作区创建没有完成,请联系管理员。', requires: '可用的工作区目录与 Git', actor: 'administrator', action: { id: 'inspect-project-create', label: '检查新建工作区', available: false } },
57
- PROJECT_LIST_FAILED: { layer: 'projects', message: '工作区列表暂时打不开,请联系管理员。', requires: '可读的工作区目录与 Git', actor: 'administrator', action: { id: 'inspect-project-list', label: '检查工作区目录', available: false } },
58
- PROJECT_PROTOCOL_INVALID: { layer: 'projects', message: '工作区暂时无法打开,已停止操作,请联系管理员。', requires: '匹配版本的工作区服务', actor: 'administrator', action: { id: 'inspect-project-protocol', label: '检查工作区接口', available: false } },
59
- PROJECT_BINDING_INVALID: { layer: 'projects', message: '工作区关联与当前目录或主机身份不符,已停止操作,请联系管理员。', requires: '原工作区与可信主机身份', actor: 'administrator', action: { id: 'check-workspace-binding', label: '联系管理员', available: false } },
60
- PROJECT_BINDING_BUSY: { layer: 'projects', message: '此工作区正在关联或说明正在投递,请联系管理员核实。', requires: '完成当前关联或投递', actor: 'administrator', action: { id: 'check-workspace-binding', label: '联系管理员', available: false } },
61
- PROJECT_CREATE_UNKNOWN: { layer: 'projects', message: '远程工作区创建结果无法确认,已保留现场,请联系管理员。', requires: '核实上次远程工作区创建结果', actor: 'administrator', action: { id: 'check-workspace-create', label: '联系管理员', available: false } },
62
- PROJECT_NOTICE_DELIVERY_UNKNOWN: { layer: 'projects', message: '工作区说明的投递结果无法确认,已停止远程派发,请联系管理员核实。', requires: '官方会话回复的持久投递证据', actor: 'administrator', action: { id: 'check-workspace-notice', label: '联系管理员', available: false } },
49
+ PROJECT_PROTOCOL_INVALID: { layer: 'projects', message: '本次未能读取工作区位置,可重新打开目录选择器再选。', requires: '匹配版本的工作区服务', actor: 'administrator', action: { id: 'inspect-project-protocol', label: '检查工作区接口', available: false } },
50
+ PROJECT_BINDING_INVALID: { layer: 'projects', message: '会话的文件来源已变化,请新建会话继续。', requires: '新会话与当前文件来源', actor: 'employee', action: { id: 'new-session', label: '新建会话', available: true } },
63
51
  PROJECT_BINDING_REQUIRED: { layer: 'projects', message: '请在会话中选择已关联的远程工作区。', requires: '当前会话的可信远程工作区关联', actor: 'employee', action: { id: 'select-workspace', label: '选择工作区', available: true } },
64
52
  DISPOSED: { layer: 'integration', message: '连接插件已卸载,需要重新启用插件。', requires: '已启用的连接插件', actor: 'employee', action: { id: 'enable-plugin', label: '启用插件', available: false } },
65
53
  };
package/lib/ports.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import type { Provider, Result, SshTarget, SessionTarget, HostContext, Project, ProjectList } from './api.ts';
1
+ import type { Provider, Result, SshTarget, SessionTarget } from './api.ts';
2
2
  import type { createHostDirectories } from './host-directories.ts';
3
3
  export interface Enrollment {
4
4
  authKeyFile?: string;
5
- hostContext?: HostContext;
6
5
  host: string;
7
6
  username: string;
8
7
  port: number;
@@ -35,10 +34,6 @@ export interface Ports {
35
34
  verify(target: SshTarget, signal: AbortSignal): Promise<Result<void>>;
36
35
  status(target: SshTarget, provider: Provider, signal: AbortSignal): Promise<Result<CommandResult>>;
37
36
  };
38
- projects?: {
39
- list(t: SshTarget, s: AbortSignal): Promise<Result<ProjectList>>;
40
- create(t: SshTarget, name: string, s: AbortSignal): Promise<Result<Project>>;
41
- };
42
37
  login?: {
43
38
  run(target: SshTarget, provider: Provider, signal: AbortSignal): Promise<Result<void>>;
44
39
  };
@@ -1,22 +1,17 @@
1
- import { WORKSPACE_LOCATION_DEFAULTS } from "./defaults.js";
2
- import { createWorkspaceLocations } from "./workspace-locations.js";
3
1
  import { mapNetworkNeed } from "./provider.js";
4
2
  import { createProfileEnrollment } from "./profile-enrollment.js";
5
- import { createWorkspaceBindings } from "./workspace-bindings.js";
6
- import { NeedError, need, fail } from "./needs.js";
7
- import { createNativeImportPicker } from "./native-import-picker.js";
8
- import { createHash } from 'node:crypto';
9
- import { readPrivate, readPrivateSync } from "./private-files.js";
10
- import { hostProjectStore } from "./host-session-store.js";
11
- import { acceptanceStore, sameSessionHeader } from "./local-acceptance-store.js";
12
- import { createHostSessionProjects, changedSessionBinding } from "./host-session-projects.js";
13
- import { createLocalUserTurnAcceptance } from "./local-user-turn-acceptance.js";
14
- import { createConversationDetails } from "./conversation-details.js";
15
- import { createLoginDiagnostics } from "./login-diagnostics.js";
16
- import { CONVERSATION_DETAIL_DEFAULTS, L_DEFAULTS } from "./defaults.js";
17
3
  import { createProfileActivation } from "./profile-activation.js";
18
- // Composition only: consume official services; never provide replacements or alter default entries.
4
+ import { createNativeImportPicker } from "./native-import-picker.js";
5
+ import { createWorkspaceLocations } from "./workspace-locations.js";
6
+ import { createWorkspaceDirectoryPicker } from "./workspace-directory-picker.js";
7
+ import { createHostSessionProjects } from "./host-session-projects.js";
8
+ import { createConversationLog } from "./conversation-log.js";
9
+ import { L_DEFAULTS, WORKSPACE_LOCATION_DEFAULTS } from "./defaults.js";
10
+ import { fail } from "./needs.js";
19
11
  export function attachProfileRuntime(ctx, api, ports, config, network) {
12
+ ctx.inject(['profileContext'], scope => attachScopedProfileRuntime(scope, api, ports, config, network));
13
+ }
14
+ function attachScopedProfileRuntime(ctx, api, ports, config, network) {
20
15
  const profile = ctx.get('profileContext');
21
16
  if (!profile || typeof profile.dir !== 'string')
22
17
  return;
@@ -31,34 +26,54 @@ export function attachProfileRuntime(ctx, api, ports, config, network) {
31
26
  api.importEnrollment = async () => { const result = await manager.importEnrollment(); if (result.ok && result.value.outcome === 'imported')
32
27
  await api.refreshLoginPrompts(); return result; };
33
28
  ctx.effect(() => () => manager.dispose());
29
+ const beforeAppend = api.appendRemoteConversationDetail, beforeRead = api.readConversationLog;
30
+ const log = createConversationLog({ profileDir: profile.dir });
31
+ api.appendRemoteConversationDetail = log.append;
32
+ const readLogs = async () => {
33
+ const local = await log.read(), parts = [];
34
+ if (local.ok && local.value)
35
+ parts.push(local.value);
36
+ const reader = ctx.get('aiWorkbenchRemoteDiagnostics');
37
+ const registry = ctx.get('workspaceRegistry');
38
+ if (reader && registry) {
39
+ const ids = new Set(registry.list().flatMap(w => w.sessionIds));
40
+ for (const sessionId of ids)
41
+ for (const provider of ['claude', 'codex']) {
42
+ try {
43
+ const rows = await reader.read({ sessionId, provider });
44
+ for (const row of rows)
45
+ parts.push(JSON.stringify(row) + '\n');
46
+ }
47
+ catch {
48
+ console.warn('会话技术日志暂时无法读取;运行不受影响。');
49
+ }
50
+ }
51
+ }
52
+ return parts.length ? { ok: true, value: parts.join('\n') } : local;
53
+ };
54
+ api.readConversationLog = readLogs;
55
+ const beforeContract = api.getContractInfo;
56
+ const currentContract = () => api.getConnectionState().phase === 'disposed' ? beforeContract() : ({ ...beforeContract(), conversationLog: 1, ...(api.getWorkspaceLocationState ? { workspaceLocations: 1 } : {}), ...(api.getLocalWorkspaceContext ? { localWorkspaceContext: 1 } : {}), ...(api.getWorkspaceDirectoryPickerSettings ? { workspaceDirectoryPicker: 1 } : {}), ...(api.resolveSessionProject !== unavailableHost ? { hostWorkspaceResolution: 1 } : {}) });
57
+ api.getContractInfo = currentContract;
58
+ ctx.effect(() => () => { if (api.getContractInfo === currentContract)
59
+ api.getContractInfo = beforeContract; if (api.appendRemoteConversationDetail === log.append)
60
+ api.appendRemoteConversationDetail = beforeAppend; if (api.readConversationLog === readLogs)
61
+ api.readConversationLog = beforeRead; });
62
+ const unavailableHost = async () => fail('DEPENDENCY_REQUIRED');
63
+ api.resolveSessionProject = unavailableHost;
34
64
  let locationRevision = 0;
35
- let workspaceRevision = 0;
36
- let lastWorkspaceError;
37
- ctx.provide('aiWorkbenchWorkspaceDiagnostics', { getLatest: () => lastWorkspaceError });
38
- ctx.inject(['profileContext', 'workspaceRegistry', 'sessions', 'sessionPersistence'], native => {
39
- const profile = native.get('profileContext');
40
- if (!profile || typeof profile.dir !== 'string')
41
- return;
42
- // Invalidate diagnostic snapshots before any of our lifecycle handlers can emit SSE.
43
- let diagnosticSessionRevision = 0;
44
- const advanceDiagnosticSessions = () => { diagnosticSessionRevision++; };
45
- native.on('session/created', advanceDiagnosticSessions);
46
- native.on('session/disposed', advanceDiagnosticSessions);
65
+ ctx.inject(['profileContext', 'workspaceRegistry', 'sessions'], native => {
47
66
  const registry = native.get('workspaceRegistry');
48
- const readHeader = async (id) => {
49
- const live = native.get('sessions');
50
- const session = live?.get(id);
51
- if (session)
52
- return session.header;
53
- const persistence = native.get('sessionPersistence');
54
- if (!persistence)
55
- throw new NeedError(need('DEPENDENCY_REQUIRED'));
56
- return (await persistence.list()).find(s => s.header.id === id)?.header;
57
- };
58
- const bindings = createWorkspaceBindings({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, api, registry,
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 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) });
67
+ let picker;
68
+ const locations = 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) });
69
+ const pickerRegistry = registry;
70
+ if (typeof pickerRegistry.create === 'function') {
71
+ picker = createWorkspaceDirectoryPicker({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, pageSize: config.workspaceLocations?.pageSize ?? WORKSPACE_LOCATION_DEFAULTS.pageSize, slotPriority: config.workspaceLocations?.pickerSlotPriority ?? -10, api, registry: pickerRegistry, hostDirectories: ports.hostDirectories, locations });
72
+ api.getWorkspaceDirectoryPickerSettings = picker.getWorkspaceDirectoryPickerSettings;
73
+ api.browseWorkspaceDirectories = picker.browseWorkspaceDirectories;
74
+ api.createWorkspaceDirectory = picker.createWorkspaceDirectory;
75
+ api.selectWorkspaceDirectory = picker.selectWorkspaceDirectory;
76
+ }
62
77
  if (process.platform === 'darwin')
63
78
  api.getLocalWorkspaceContext = locations.getLocalWorkspaceContext;
64
79
  api.getWorkspaceLocationState = locations.getWorkspaceLocationState;
@@ -66,117 +81,9 @@ export function attachProfileRuntime(ctx, api, ports, config, network) {
66
81
  api.refreshWorkspaceLocations = locations.refreshWorkspaceLocations;
67
82
  api.browseWorkspaceHostDirectories = locations.browseWorkspaceHostDirectories;
68
83
  api.selectWorkspaceLocation = locations.selectWorkspaceLocation;
84
+ const host = createHostSessionProjects({ api, registry, services: () => ({ sessions: native.get('sessions') }), withHostBinding: locations.withHostBinding });
85
+ api.resolveSessionProject = host.resolve;
69
86
  native.effect(() => { void locations.refreshWorkspaceLocations(); return api.onConnectionState(() => locations.observeConnection()); });
70
- native.effect(() => () => { if (api.getLocalWorkspaceContext === locations.getLocalWorkspaceContext)
71
- delete api.getLocalWorkspaceContext; delete api.getWorkspaceLocationState; delete api.onWorkspaceLocationState; delete api.refreshWorkspaceLocations; delete api.browseWorkspaceHostDirectories; delete api.selectWorkspaceLocation; return locations.dispose(); });
72
- const settings = ctx.get('aiWorkbenchConversationDetailSettings');
73
- const identityOf = (target, trust) => createHash('sha256').update(JSON.stringify([target.host, target.username, target.port, trust])).digest('hex');
74
- const context = async () => {
75
- const current = api.getModelCatalogTarget('codex');
76
- if (!current.ok)
77
- return current;
78
- const t = current.value.target, budget = config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes;
79
- try {
80
- const trust = await readPrivate(t.knownHostsFile, budget), identity = identityOf(t, trust);
81
- const guard = () => { const latest = api.getModelCatalogTarget('codex'); if (!latest.ok)
82
- throw new NeedError(latest.error); try {
83
- if (identityOf(latest.value.target, readPrivateSync(latest.value.target.knownHostsFile, budget)) !== identity)
84
- throw Error('TRUST_CHANGED');
85
- }
86
- catch (e) {
87
- if (e instanceof NeedError)
88
- throw e;
89
- throw new NeedError(need('REMOTE_DETAIL_SCOPE_INVALID'));
90
- } };
91
- guard();
92
- return { ok: true, value: { identity, guard } };
93
- }
94
- catch (e) {
95
- return e instanceof NeedError ? { ok: false, error: e.need } : fail('REMOTE_DETAIL_SCOPE_INVALID');
96
- }
97
- };
98
- const nativeSessions = native.get('sessions'), nativePersistence = native.get('sessionPersistence');
99
- const localLedger = acceptanceStore(profile.dir, config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes);
100
- const assertHostBinding = (id, header) => { if (hostLedger.read().some(r => r.sessionId === id && sameSessionHeader(r.header, header)))
101
- changedSessionBinding(); };
102
- const officialServices = () => ({ sessions: native.get('sessions'), persistence: native.get('sessionPersistence') });
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;
104
- if (hostAcceptance) {
105
- native.on('session/event', (session, event) => hostAcceptance.observe(session, event));
106
- native.on('session/disposed', (session) => hostAcceptance.observeSessionDisposed(session));
107
- native.effect(() => locations.onWorkspaceLocationState(hostAcceptance.observeLocations));
108
- native.effect(() => () => hostAcceptance.dispose());
109
- }
110
- const localAcceptance = process.platform === 'darwin' && typeof nativeSessions?.flush === 'function' && typeof nativePersistence?.open === 'function' && typeof nativePersistence?.identity === 'symbol' ? createLocalUserTurnAcceptance({ profileDir: profile.dir, metadataMaxBytes: config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes, registry, getConnectionState: api.getConnectionState, readHeader, context, assertSessionBinding: assertHostBinding, assertPriorBinding: async (id) => { if ((await bindings.readLegacyLocations()).some(r => r.sessionIds.includes(id)))
111
- changedSessionBinding(); }, withLocalBinding: locations.withLocalBinding,
112
- // SessionStore proxies are not instance IDs. Check the exact live Session and
113
- // SessionPersistence's public stable identity, plus the injected lifetime.
114
- services: () => ({ sessions: native.get('sessions'), persistence: native.get('sessionPersistence') }) }) : undefined;
115
- if (localAcceptance) {
116
- api.acceptLocalWorkspaceUserTurn = localAcceptance.acceptLocalWorkspaceUserTurn;
117
- native.on('session/event', (session, event) => localAcceptance.observe(session, event));
118
- native.on('session/disposed', (session) => localAcceptance.observeSessionDisposed(session));
119
- native.effect(() => locations.onWorkspaceLocationState(localAcceptance.observeLocations));
120
- native.effect(() => () => { localAcceptance.dispose(); if (api.acceptLocalWorkspaceUserTurn === localAcceptance.acceptLocalWorkspaceUserTurn)
121
- delete api.acceptLocalWorkspaceUserTurn; });
122
- }
123
- const details = createConversationDetails({ profileDir: profile.dir, get maxEventBytes() { return settings ? settings.values()?.maxEventBytes ?? 0 : config.conversationDetails?.maxEventBytes ?? CONVERSATION_DETAIL_DEFAULTS.maxEventBytes; }, get pageSize() { return settings ? settings.values()?.pageSize ?? 0 : config.conversationDetails?.pageSize ?? CONVERSATION_DETAIL_DEFAULTS.pageSize; }, getConnectionState: api.getConnectionState,
124
- context, localAcceptance, hostAcceptance,
125
- scope: async (sessionId, provider) => { const current = api.getModelCatalogTarget(provider); if (!current.ok)
126
- return current; return bindings.verifyRemoteConversationScope(sessionId, provider, current.value.target); },
127
- onState: state => ctx.emit('ai-workbench/remote-conversation-detail-state', state) });
128
- native.on('session/created', () => details.observeConnection(api.getConnectionState()));
129
- native.on('session/disposed', () => details.observeConnection(api.getConnectionState()));
130
- api.appendRemoteConversationDetail = details.appendRemoteConversationDetail;
131
- api.getRemoteConversationDetailReceipt = details.getRemoteConversationDetailReceipt;
132
- api.getRemoteConversationDetailState = details.getRemoteConversationDetailState;
133
- api.onRemoteConversationDetailState = details.onRemoteConversationDetailState;
134
- api.listRemoteConversationDetails = details.listRemoteConversationDetails;
135
- const loginDiagnostics = createLoginDiagnostics({ profileDir: profile.dir, get maxEventBytes() { return settings ? settings.values()?.maxEventBytes ?? 0 : config.conversationDetails?.maxEventBytes ?? CONVERSATION_DETAIL_DEFAULTS.maxEventBytes; }, get pageSize() { return settings ? settings.values()?.pageSize ?? 0 : config.conversationDetails?.pageSize ?? CONVERSATION_DETAIL_DEFAULTS.pageSize; }, getConnectionState: api.getConnectionState, context,
136
- publicationRevision: () => diagnosticSessionRevision,
137
- cacheContext: identity => { const current = api.getModelCatalogTarget('codex'); if (!current.ok)
138
- throw new NeedError(current.error); const t = current.value.target; try {
139
- if (identityOf(t, readPrivateSync(t.knownHostsFile, config.enrollmentMetadataMaxBytes ?? L_DEFAULTS.enrollmentMetadataMaxBytes)) !== identity)
140
- throw new NeedError(need('REMOTE_DETAIL_SCOPE_INVALID'));
141
- }
142
- catch (e) {
143
- if (e instanceof NeedError)
144
- throw e;
145
- throw new NeedError(need('REMOTE_DETAIL_SCOPE_INVALID'));
146
- } },
147
- scope: async (sessionId, provider) => { const current = api.getModelCatalogTarget(provider); if (!current.ok)
148
- return current; const header = await readHeader(sessionId); if (!header || header.id !== sessionId)
149
- return fail('REMOTE_DETAIL_SCOPE_INVALID'); return context(); },
150
- onState: state => ctx.emit('ai-workbench/login-diagnostic-state', state) });
151
- const refreshDiagnosticSessions = () => loginDiagnostics.observeConnection(api.getConnectionState());
152
- native.on('session/created', refreshDiagnosticSessions);
153
- native.on('session/disposed', refreshDiagnosticSessions);
154
- api.appendLoginDiagnostic = loginDiagnostics.appendLoginDiagnostic;
155
- api.getLoginDiagnosticReceipt = loginDiagnostics.getLoginDiagnosticReceipt;
156
- api.listLoginDiagnostics = loginDiagnostics.listLoginDiagnostics;
157
- api.getLoginDiagnosticState = loginDiagnostics.getLoginDiagnosticState;
158
- api.onLoginDiagnosticState = loginDiagnostics.onLoginDiagnosticState;
159
- const previousContractInfo = api.getContractInfo, detailContractInfo = () => ({ ...previousContractInfo(), remoteConversationDetails: 1, loginDiagnostics: 1, workspaceLocations: 1, ...(hostAcceptance?.active() && api.getConnectionState().phase !== 'disposed' ? { hostWorkspaceResolution: 1 } : {}), ...(api.getConnectionState().phase !== 'disposed' ? { preflightDiagnostics: 1 } : {}), ...(process.platform === 'darwin' && api.getConnectionState().phase !== 'disposed' ? { localWorkspaceContext: 1, ...(localAcceptance?.active() ? { localUserTurnAcceptance: 1 } : {}) } : {}) });
160
- api.getContractInfo = detailContractInfo;
161
- native.effect(() => { details.observeConnection(api.getConnectionState()); return api.onConnectionState(details.observeConnection); });
162
- native.effect(() => { loginDiagnostics.observeConnection(api.getConnectionState()); return api.onConnectionState(loginDiagnostics.observeConnection); });
163
- native.effect(() => () => { if (api.getContractInfo === detailContractInfo)
164
- api.getContractInfo = previousContractInfo; return Promise.all([details.dispose(), loginDiagnostics.dispose()]); });
165
- native.effect(() => api.onConnectionState(bindings.observeConnection));
166
- api.getWorkspaceBindingState = bindings.getWorkspaceBindingState;
167
- api.onWorkspaceBindingState = bindings.onWorkspaceBindingState;
168
- api.acknowledgeWorkspaceNotice = bindings.acknowledgeWorkspaceNotice;
169
- api.resolveSessionProject = (sessionId, use, location) => { if (location !== undefined)
170
- return hostAcceptance ? hostAcceptance.resolve(sessionId, use, location) : Promise.resolve(fail('DEPENDENCY_REQUIRED')); return locations.resolveLegacySession(sessionId, async () => { try {
171
- const header = await readHeader(sessionId);
172
- assertHostBinding(sessionId, header);
173
- if (localLedger.read().some(r => r.acceptance.sessionId === sessionId && sameSessionHeader(r.header, header)))
174
- changedSessionBinding();
175
- return bindings.resolveSessionProject(sessionId, use);
176
- }
177
- catch (e) {
178
- return e instanceof NeedError ? { ok: false, error: e.need } : fail('REMOTE_DETAIL_STORAGE_FAILED');
179
- } }); };
180
- native.effect(() => () => { api.resolveSessionProject = async () => fail('DEPENDENCY_REQUIRED'); api.acknowledgeWorkspaceNotice = async () => fail('DEPENDENCY_REQUIRED'); return bindings.dispose(); });
87
+ native.effect(() => () => { api.resolveSessionProject = unavailableHost; delete api.getLocalWorkspaceContext; delete api.getWorkspaceLocationState; delete api.onWorkspaceLocationState; delete api.refreshWorkspaceLocations; delete api.browseWorkspaceHostDirectories; delete api.selectWorkspaceLocation; delete api.getWorkspaceDirectoryPickerSettings; delete api.browseWorkspaceDirectories; delete api.createWorkspaceDirectory; delete api.selectWorkspaceDirectory; host.dispose(); return Promise.all([locations.dispose(), picker?.dispose()]); });
181
88
  });
182
89
  }
@@ -1,2 +1,7 @@
1
1
  import type { Config } from './index.ts';
2
- export declare function profileSettings(config: Config, profileDir?: string, platform?: string, arch?: string): Config;
2
+ export type RuntimeConfig = Config & {
3
+ helper?: NonNullable<Config['helper']> & {
4
+ source?: string;
5
+ };
6
+ };
7
+ export declare function profileSettings(config: Config, profileDir?: string, platform?: string, arch?: string): RuntimeConfig;
@@ -1,13 +1,11 @@
1
1
  import { isAbsolute, join } from 'node:path';
2
- import { COMPONENT_SOURCES, preset } from "./component-source.js";
3
- import { L_DEFAULTS, ELECTRON_PIN, CONVERSATION_DETAIL_DEFAULTS } from "./defaults.js";
2
+ import { COMPONENT_SOURCES } from "./component-source.js";
3
+ import { L_DEFAULTS, ELECTRON_PIN } from "./defaults.js";
4
4
  // Owner approved technical values, 2026-10-20 settings decision, part two.
5
5
  // 组件直接下载;Claude网页遵循员工系统网络,Codex暂保留N主机代理。
6
6
  export function profileSettings(config, profileDir, platform = process.platform, arch = process.arch) {
7
7
  if (typeof profileDir !== 'string' || !isAbsolute(profileDir))
8
8
  return config;
9
9
  const runtime = platform === 'darwin' && arch === 'arm64' ? { ...ELECTRON_PIN, source: COMPONENT_SOURCES.npmmirror.source } : {};
10
- const chosen = config.helper?.componentDownloadSource;
11
- const selected = chosen === undefined ? {} : { source: preset(chosen) ? COMPONENT_SOURCES[chosen].source : '' };
12
- return { ...config, conversationDetails: { ...CONVERSATION_DETAIL_DEFAULTS, ...config.conversationDetails }, commandOutputMaxBytes: config.commandOutputMaxBytes === undefined ? L_DEFAULTS.commandOutputMaxBytes : config.commandOutputMaxBytes, helper: { ...runtime, componentDownloadMaxRedirects: L_DEFAULTS.componentDownloadMaxRedirects, componentObservationIntervalMs: L_DEFAULTS.componentObservationIntervalMs, maxDownloadBytes: L_DEFAULTS.maxDownloadBytes, maxExtractedBytes: L_DEFAULTS.maxExtractedBytes, loginOutputMaxBytes: L_DEFAULTS.loginOutputMaxBytes, ipcMaxBytes: L_DEFAULTS.ipcMaxBytes, remoteKillGraceMs: L_DEFAULTS.remoteKillGraceMs, ...config.helper, ...selected, cacheDir: config.helper?.cacheDir === undefined ? join(profileDir, 'ai-workbench-connect', 'login-component-cache') : config.helper.cacheDir } };
10
+ return { ...config, commandOutputMaxBytes: config.commandOutputMaxBytes === undefined ? L_DEFAULTS.commandOutputMaxBytes : config.commandOutputMaxBytes, helper: { ...runtime, componentDownloadMaxRedirects: L_DEFAULTS.componentDownloadMaxRedirects, componentObservationIntervalMs: L_DEFAULTS.componentObservationIntervalMs, maxDownloadBytes: L_DEFAULTS.maxDownloadBytes, maxExtractedBytes: L_DEFAULTS.maxExtractedBytes, loginOutputMaxBytes: L_DEFAULTS.loginOutputMaxBytes, ipcMaxBytes: L_DEFAULTS.ipcMaxBytes, remoteKillGraceMs: L_DEFAULTS.remoteKillGraceMs, ...config.helper, ...(platform === 'darwin' && arch === 'arm64' ? { source: COMPONENT_SOURCES.npmmirror.source } : {}), cacheDir: config.helper?.cacheDir === undefined ? join(profileDir, 'ai-workbench-connect', 'login-component-cache') : config.helper.cacheDir } };
13
11
  }
package/lib/startup.js CHANGED
@@ -145,7 +145,7 @@ export function createStartup(api, providers, emit = () => { }, result = () => {
145
145
  }
146
146
  }
147
147
  }
148
- publish({ ...state, queuedProviders: [], technicalDetails: connected.value.hostContext ? { hostContext: structuredClone(connected.value.hostContext) } : {} });
148
+ publish({ ...state, queuedProviders: [], technicalDetails: {} });
149
149
  ask();
150
150
  }
151
151
  catch {
@@ -293,7 +293,7 @@ export function createStartup(api, providers, emit = () => { }, result = () => {
293
293
  publish({ phase: 'checking', message: '正在连接远程主机…', logins: {}, queuedProviders: [], checkingProviders: [], providerNeeds: {}, technicalDetails: {} });
294
294
  }
295
295
  if (!changed && prior === next.phase && next.recovery && previousRecovery !== next.recovery.phase) {
296
- publish({ ...state, message: next.recovery.message });
296
+ publish({ ...state, message: connectionEmployeeMessage(next) ?? state.message });
297
297
  return;
298
298
  }
299
299
  if (next.phase === 'unavailable' || next.phase === 'disposed') {
@@ -0,0 +1,44 @@
1
+ import type { Result } from './api.ts';
2
+ export type WorkspacePickerTarget = 'local' | 'host';
3
+ export interface WorkspacePickerRequest {
4
+ target?: WorkspacePickerTarget;
5
+ path?: string;
6
+ cursor?: string;
7
+ }
8
+ export interface WorkspacePickerEntry {
9
+ name: string;
10
+ path: string;
11
+ available: boolean;
12
+ isSymlink: boolean;
13
+ }
14
+ export interface WorkspacePickerPage {
15
+ target: WorkspacePickerTarget;
16
+ path: string;
17
+ parentPath: string | null;
18
+ entries: WorkspacePickerEntry[];
19
+ selectionToken: string;
20
+ nextCursor?: string;
21
+ notice?: string;
22
+ }
23
+ export interface WorkspacePickerSelection {
24
+ path: string;
25
+ workspaceId: string;
26
+ source: WorkspacePickerTarget;
27
+ }
28
+ export interface WorkspacePickerSettings {
29
+ slotPriority: number;
30
+ mappingRoot: string;
31
+ pageSize: number;
32
+ metadataMaxBytes: number;
33
+ }
34
+ export interface WorkspaceDirectoryPickerApi {
35
+ getWorkspaceDirectoryPickerSettings(): WorkspacePickerSettings;
36
+ browseWorkspaceDirectories(request: WorkspacePickerRequest): Promise<Result<WorkspacePickerPage>>;
37
+ createWorkspaceDirectory(request: {
38
+ selectionToken: string;
39
+ name: string;
40
+ }): Promise<Result<WorkspacePickerPage>>;
41
+ selectWorkspaceDirectory(request: {
42
+ selectionToken: string;
43
+ }): Promise<Result<WorkspacePickerSelection>>;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { ConnectApi, Result } from './api.ts';
2
+ import type { NativeWorkspace, NativeWorkspaceRegistry } from './native-workspace.ts';
3
+ import type { WorkspaceLocationState, WorkspaceBrowseRequest, WorkspaceBrowsePage, WorkspaceSelectRequest } from './workspace-location-types.ts';
4
+ import type { createHostDirectories } from './host-directories.ts';
5
+ import type { WorkspaceDirectoryPickerApi } from './workspace-directory-picker-types.ts';
6
+ interface Options {
7
+ profileDir: string;
8
+ metadataMaxBytes: number;
9
+ pageSize: number;
10
+ slotPriority: number;
11
+ api: Pick<ConnectApi, 'getConnectionState' | 'getModelCatalogTarget'> & Partial<Pick<ConnectApi, 'onConnectionState'>>;
12
+ registry: NativeWorkspaceRegistry & {
13
+ create(path: string, title?: string): Promise<NativeWorkspace & {
14
+ setTitle?: (title: string) => Promise<void>;
15
+ }>;
16
+ };
17
+ hostDirectories?: ReturnType<typeof createHostDirectories>;
18
+ locations: {
19
+ getWorkspaceLocationState(): WorkspaceLocationState;
20
+ refreshWorkspaceLocations(): Promise<Result<WorkspaceLocationState>>;
21
+ browseWorkspaceHostDirectories(c: WorkspaceBrowseRequest): Promise<Result<WorkspaceBrowsePage>>;
22
+ selectWorkspaceLocation(c: WorkspaceSelectRequest): Promise<Result<WorkspaceLocationState>>;
23
+ captureWorkspacePickerGuard(workspaceId: string, expectedBindingId: string): () => void;
24
+ };
25
+ }
26
+ export declare function createWorkspaceDirectoryPicker(o: Options): WorkspaceDirectoryPickerApi & {
27
+ isPending(workspaceId: string): boolean;
28
+ dispose(): Promise<void>;
29
+ };
30
+ export {};