dsh-config-manager 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/README.zh-CN.md +10 -0
- package/lib/adapters/mcp.d.ts +9 -0
- package/lib/adapters/mcp.js +37 -0
- package/lib/adapters/plugins.js +10 -2
- package/lib/adapters/pnpm-workspace.js +1 -1
- package/lib/adapters/self.d.ts +2 -0
- package/lib/adapters/self.js +18 -2
- package/lib/adapters/workspaces.js +1 -1
- package/lib/cli/restore-resume.js +1 -1
- package/lib/cli/web/page.js +2 -2
- package/lib/client.d.ts +14 -41
- package/lib/client.js +794 -716
- package/lib/core/backup.d.ts +11 -0
- package/lib/core/backup.js +27 -0
- package/lib/core/env-lock-lifecycle.d.ts +17 -3
- package/lib/core/env-lock-lifecycle.js +38 -0
- package/lib/core/external-failure.d.ts +9 -0
- package/lib/core/external-failure.js +50 -0
- package/lib/core/local-plugin-host.d.ts +9 -7
- package/lib/core/local-plugin-host.js +109 -15
- package/lib/core/local-plugin-pack.d.ts +20 -0
- package/lib/core/local-plugin-pack.js +18 -3
- package/lib/core/mcp-connector-store.d.ts +13 -0
- package/lib/core/mcp-connector-store.js +16 -1
- package/lib/core/messages-core.d.ts +45 -0
- package/lib/core/messages-core.js +92 -0
- package/lib/core/messages.d.ts +1 -0
- package/lib/core/messages.js +6 -0
- package/lib/core/model-tool-plans.d.ts +66 -0
- package/lib/core/model-tool-plans.js +128 -0
- package/lib/core/model-tools.d.ts +96 -8
- package/lib/core/model-tools.js +568 -31
- package/lib/core/phase3-host.js +10 -2
- package/lib/core/plugin-data-registry.d.ts +1 -1
- package/lib/core/plugin-data-registry.js +1 -1
- package/lib/core/restore-plan-fingerprint.d.ts +2 -0
- package/lib/core/restore-plan-fingerprint.js +18 -0
- package/lib/core/restore-resume.d.ts +1 -1
- package/lib/core/restore-resume.js +1 -1
- package/lib/core/restore.d.ts +5 -0
- package/lib/core/restore.js +4 -1
- package/lib/core/types.d.ts +12 -0
- package/lib/foreign/claude-sessions.d.ts +1 -1
- package/lib/foreign/claude-sessions.js +1 -1
- package/lib/foreign/registry.js +1 -1
- package/lib/foreign/types.d.ts +1 -1
- package/lib/index.d.ts +15 -15
- package/lib/index.js +60 -67
- package/lib/market/git-file-writer.js +1 -1
- package/lib/market/github-repos.js +1 -1
- package/lib/market/market-config.js +1 -1
- package/lib/market/messages-market.js +1 -1
- package/lib/market/my-repo.js +1 -1
- package/lib/market/prepare.js +1 -1
- package/lib/market/reader.js +2 -2
- package/lib/market/repo-url.d.ts +1 -1
- package/lib/market/security.js +2 -2
- package/lib/market/star-cache.d.ts +1 -1
- package/lib/market/types.d.ts +1 -1
- package/lib/market/types.js +1 -1
- package/lib/market/url.js +1 -1
- package/lib/routes/backup.js +17 -9
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/kit.d.ts +2 -2
- package/lib/routes/market.d.ts +1 -1
- package/lib/routes/market.js +3 -60
- package/lib/routes/model-tools-deps.d.ts +41 -0
- package/lib/routes/model-tools-deps.js +18 -0
- package/lib/routes/recovery.js +5 -3
- package/lib/routes/route-support.d.ts +18 -26
- package/lib/routes/route-support.js +19 -32
- package/lib/routes/snapshots.d.ts +1 -1
- package/lib/routes/snapshots.js +4 -40
- package/lib/routes/sync.js +40 -28
- package/lib/schema/index.d.ts +2 -2
- package/lib/schema/index.js +2 -2
- package/lib/schema/section-registry.d.ts +5 -3
- package/lib/schema/section-registry.js +7 -3
- package/lib/security/secret-scanner.js +1 -1
- package/lib/sync/apply-bundle.d.ts +50 -0
- package/lib/sync/apply-bundle.js +60 -0
- package/lib/sync/autosync-scheduler.d.ts +9 -0
- package/lib/sync/autosync-scheduler.js +118 -89
- package/lib/sync/backup-scheduler.js +5 -4
- package/lib/sync/blob-store.d.ts +2 -2
- package/lib/sync/git/git-transport.d.ts +12 -0
- package/lib/sync/git/git-transport.js +50 -2
- package/lib/sync/merge.d.ts +2 -0
- package/lib/sync/merge.js +28 -0
- package/lib/sync/messages.d.ts +4 -0
- package/lib/sync/messages.js +9 -2
- package/lib/sync/s3/s3-transport.d.ts +1 -1
- package/lib/sync/s3/s3-transport.js +1 -1
- package/lib/sync/sync-engine.d.ts +4 -4
- package/lib/sync/sync-engine.js +25 -26
- package/lib/sync/sync-scope-boot.d.ts +34 -0
- package/lib/sync/sync-scope-boot.js +71 -0
- package/lib/sync/sync-scope.d.ts +103 -0
- package/lib/sync/sync-scope.js +229 -0
- package/lib/sync/sync-selection.d.ts +17 -4
- package/lib/sync/sync-selection.js +40 -14
- package/lib/sync/transport.d.ts +4 -1
- package/lib/sync/transport.js +6 -0
- package/lib/sync/webdav/webdav-transport.js +1 -1
- package/lib/sync/workspace-merge.d.ts +36 -0
- package/lib/sync/workspace-merge.js +152 -0
- package/lib/ui/backup-schedule.d.ts +13 -2
- package/lib/ui/backup-schedule.js +3 -0
- package/lib/ui/snapshots-view.d.ts +16 -0
- package/lib/ui/snapshots-view.js +21 -0
- package/lib/utils/env-lock.d.ts +96 -0
- package/lib/utils/env-lock.js +332 -111
- package/lib/utils/messages-utils.d.ts +6 -0
- package/lib/utils/messages-utils.js +17 -1
- package/lib/utils/patch-yaml.js +1 -1
- package/lib/utils/zip.js +1 -1
- package/package.json +3 -2
- package/src/adapters/mcp.test.ts +28 -0
- package/src/adapters/mcp.ts +33 -0
- package/src/adapters/plugins.test.ts +49 -0
- package/src/adapters/plugins.ts +9 -1
- package/src/adapters/pnpm-workspace.ts +1 -1
- package/src/adapters/self.test.ts +39 -1
- package/src/adapters/self.ts +20 -2
- package/src/adapters/workspaces.ts +1 -1
- package/src/cli/restore-resume.ts +1 -1
- package/src/cli/web/page.ts +2 -2
- package/src/client/about/AboutPanel.tsx +1 -1
- package/src/client/about/about-view.test.ts +1 -1
- package/src/client/about/about-view.ts +1 -1
- package/src/client/api.ts +1 -6
- package/src/client/chat/chat-entry-view.test.ts +1 -1
- package/src/client/chat/chat-slots.ts +1 -1
- package/src/client/chat/rollback-diff-tab.ts +1 -1
- package/src/client/client-types.ts +1 -1
- package/src/client/common/routes.ts +1 -5
- package/src/client/css-scale-guard.test.ts +1 -1
- package/src/client/home/HomePanel.tsx +3 -0
- package/src/client/library/ArtifactRow.tsx +14 -2
- package/src/client/library/LibraryPanel.tsx +44 -0
- package/src/client/locales/overview.ts +10 -2
- package/src/client/locales/sessions.ts +3 -0
- package/src/client/market/MyConfigsView.tsx +1 -1
- package/src/client/market/market-api.ts +2 -14
- package/src/client/market/market-locales.ts +1 -1
- package/src/client/market/market-view.ts +3 -3
- package/src/client/market/my-configs-api.ts +1 -1
- package/src/client/market/my-configs-view.ts +1 -1
- package/src/client/recovery/recovery-locales.test.ts +1 -1
- package/src/client/run-store.ts +1 -1
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -5
- package/src/client/sync/history-model.test.ts +28 -7
- package/src/client/sync/history-model.ts +6 -3
- package/src/client/sync/sync-locales.ts +10 -4
- package/src/client/sync/sync-view.ts +1 -1
- package/src/core/analyzer-cache.test.ts +1 -1
- package/src/core/backup.test.ts +45 -1
- package/src/core/backup.ts +25 -0
- package/src/core/disk-usage.test.ts +2 -0
- package/src/core/env-lock-lifecycle.ts +33 -3
- package/src/core/external-failure.test.ts +60 -0
- package/src/core/external-failure.ts +54 -0
- package/src/core/integrity-extra-entries.test.ts +1 -1
- package/src/core/local-plugin-host.test.ts +134 -0
- package/src/core/local-plugin-host.ts +122 -17
- package/src/core/local-plugin-pack.ts +39 -3
- package/src/core/mcp-connector-store.ts +26 -1
- package/src/core/messages-core.ts +94 -0
- package/src/core/messages.ts +6 -0
- package/src/core/model-tool-plans.test.ts +111 -0
- package/src/core/model-tool-plans.ts +170 -0
- package/src/core/model-tools.test.ts +212 -12
- package/src/core/model-tools.ts +710 -38
- package/src/core/phase3-host.ts +10 -2
- package/src/core/phase3-production-integration.test.ts +43 -0
- package/src/core/plugin-data-registry.ts +1 -1
- package/src/core/restore-plan-fingerprint.ts +19 -0
- package/src/core/restore-resume.ts +1 -1
- package/src/core/restore.ts +9 -1
- package/src/core/types.ts +12 -0
- package/src/foreign/claude-sessions.ts +3 -3
- package/src/foreign/registry.ts +1 -1
- package/src/foreign/types.ts +1 -1
- package/src/index.ts +91 -98
- package/src/market/git-file-writer.ts +1 -1
- package/src/market/github-repos.test.ts +1 -1
- package/src/market/github-repos.ts +1 -1
- package/src/market/market-config.ts +1 -1
- package/src/market/messages-market.ts +1 -1
- package/src/market/my-repo.test.ts +1 -1
- package/src/market/my-repo.ts +1 -1
- package/src/market/prepare.test.ts +1 -1
- package/src/market/prepare.ts +1 -1
- package/src/market/reader.ts +2 -2
- package/src/market/repo-url.ts +1 -1
- package/src/market/security.ts +2 -2
- package/src/market/star-cache.ts +1 -1
- package/src/market/types.ts +1 -1
- package/src/market/url.test.ts +1 -1
- package/src/market/url.ts +1 -1
- package/src/profiles/dsh-profile-copy-rollback.test.ts +1 -1
- package/src/routes/backup.ts +16 -9
- package/src/routes/index.ts +1 -1
- package/src/routes/kit.ts +2 -2
- package/src/routes/market.ts +2 -59
- package/src/routes/model-tools-deps.ts +56 -0
- package/src/routes/recovery.ts +5 -3
- package/src/routes/route-support.ts +49 -36
- package/src/routes/snapshots.ts +4 -40
- package/src/routes/sync.ts +39 -27
- package/src/schema/index.ts +2 -2
- package/src/schema/manifest-schema.test.ts +2 -2
- package/src/schema/registry.test.ts +1 -1
- package/src/schema/section-registry.ts +9 -4
- package/src/security/redaction.test.ts +1 -1
- package/src/security/secret-scanner.test.ts +2 -2
- package/src/security/secret-scanner.ts +1 -1
- package/src/sync/apply-bundle.ts +104 -0
- package/src/sync/autosync-scheduler.test.ts +180 -6
- package/src/sync/autosync-scheduler.ts +132 -92
- package/src/sync/backup-scheduler.test.ts +11 -4
- package/src/sync/backup-scheduler.ts +5 -4
- package/src/sync/blob-store.ts +2 -2
- package/src/sync/git/git-transport.test.ts +62 -0
- package/src/sync/git/git-transport.ts +54 -3
- package/src/sync/merge.ts +29 -0
- package/src/sync/messages.ts +9 -2
- package/src/sync/s3/s3-transport.ts +1 -1
- package/src/sync/sync-engine.test.ts +238 -2
- package/src/sync/sync-engine.ts +25 -26
- package/src/sync/sync-preview-push.test.ts +2 -1
- package/src/sync/sync-scope-boot.ts +87 -0
- package/src/sync/sync-scope.test.ts +154 -0
- package/src/sync/sync-scope.ts +256 -0
- package/src/sync/sync-selection.test.ts +76 -2
- package/src/sync/sync-selection.ts +40 -13
- package/src/sync/transport.test.ts +21 -1
- package/src/sync/transport.ts +12 -0
- package/src/sync/webdav/webdav-delete-index-unreadable.test.ts +2 -2
- package/src/sync/webdav/webdav-transport.ts +1 -1
- package/src/sync/workspace-merge.test.ts +110 -0
- package/src/sync/workspace-merge.ts +180 -0
- package/src/ui/backup-schedule.test.ts +5 -0
- package/src/ui/backup-schedule.ts +21 -2
- package/src/ui/session-issue-labels.ts +1 -1
- package/src/ui/snapshots-view.test.ts +32 -0
- package/src/ui/snapshots-view.ts +34 -0
- package/src/utils/env-lock.test.ts +242 -9
- package/src/utils/env-lock.ts +247 -13
- package/src/utils/messages-utils.ts +17 -1
- package/src/utils/patch-yaml.ts +1 -1
- package/src/utils/zip.ts +1 -1
- package/src/client/CLIENT_DEPENDENCIES.md +0 -94
|
@@ -257,6 +257,52 @@ export const zh = {
|
|
|
257
257
|
'core.modelTools.syncPullStrategyParam': '冲突全局策略;缺省 merge(冲突保留待决策)',
|
|
258
258
|
'core.modelTools.syncPullPasswordParam': '解密密码(加密快照需要;仅内存)',
|
|
259
259
|
'core.modelTools.syncPullOutputDesc': '差异报告(changes 列表 / needsReview)',
|
|
260
|
+
// ---------- model tools D2–D6:计划句柄、密码槽、导入 ----------
|
|
261
|
+
'core.modelTools.restorePlanIdParam': '预览返回的 planId;真实执行时必须带上(服务端会按当前磁盘重算计划并比对,变化即拒绝)',
|
|
262
|
+
'core.modelTools.syncPushPasswordDeprecatedParam': '已弃用:加密密码优先从 DSH credentials 的同通道槽位读取;确需临时密码才传(仅内存,不落盘/不回显)',
|
|
263
|
+
'core.modelTools.syncPushForceParam': '远端已被别的设备推进时仍覆盖(缺省 false = 前置检测到冲突即中止;会覆盖远端历史)',
|
|
264
|
+
'core.modelTools.syncPreviewToolDesc': '三方合并预览(只读):下载远端快照 + 对本机/远端/祖先分类,返回每个分区的结论与冲突位置。落地前必须先调它拿 planId。sessions 分区永不参与。',
|
|
265
|
+
'core.modelTools.syncPreviewSnapshotIdParam': '远端快照 id;缺省 = 最新',
|
|
266
|
+
'core.modelTools.syncPreviewPasswordParam': '解密密码;缺省优先取该通道已存的解密密码(仅内存)',
|
|
267
|
+
'core.modelTools.syncPreviewOutputDesc': '预览结果(planId / summary / 每个分区的 decision 与 conflicts)',
|
|
268
|
+
'core.modelTools.syncApplyToolDesc': '落地三方合并:必须带 config_sync_preview 的 planId。锁内重跑预览比对指纹,预览后有变化即拒绝(零写入)。写操作过 GLOBAL 锁并留回滚点。',
|
|
269
|
+
'core.modelTools.syncApplyPlanIdParam': 'config_sync_preview 返回的 planId',
|
|
270
|
+
'core.modelTools.syncApplyResolutionsParam': '逐分区裁决:id = 分区 id(或 分区id::冲突路径),action = keepLocal / useRemote / useMerged / skip',
|
|
271
|
+
'core.modelTools.syncApplyResolutionIdParam': '分区 id 或 分区id::冲突路径',
|
|
272
|
+
'core.modelTools.syncApplyResolutionActionParam': 'keepLocal 本机为准 / useRemote 远端为准 / useMerged 用自动合并结果 / skip 跳过该分区',
|
|
273
|
+
'core.modelTools.syncApplyPasswordParam': '解密密码;缺省优先取该通道已存的解密密码(仅内存)',
|
|
274
|
+
'core.modelTools.syncApplyOutputDesc': '落地报告(applied / restoreId / rolledBack / warnings / pendingConflicts / ignoredResolutions)',
|
|
275
|
+
'core.modelTools.importPlanToolDesc': '生成导入计划(只读):分析 ZIP + 合并冲突决策与路径映射,返回 planId 与计划摘要。加密归档直接拒绝(密码不进 agent 面,改走 GUI)。',
|
|
276
|
+
'core.modelTools.importPlanZipPathParam': '归档路径,必须落在受控目录内(exports 或临时目录)',
|
|
277
|
+
'core.modelTools.importPlanStrategyParam': '全局冲突策略:merge 保留冲突待裁决 / replace 覆盖 / skipExisting 跳过已存在',
|
|
278
|
+
'core.modelTools.importPlanResolutionsParam': '逐项裁决表:{ 计划项 id: keepCurrent | useImported | review }',
|
|
279
|
+
'core.modelTools.importPlanPathMappingsParam': '路径映射:把旧机器前缀换成本机前缀',
|
|
280
|
+
'core.modelTools.importPlanMappingOldParam': '归档里的旧路径前缀',
|
|
281
|
+
'core.modelTools.importPlanMappingNewParam': '本机的新路径前缀',
|
|
282
|
+
'core.modelTools.importPlanMappingAppliesToParam': '该映射作用的分区(workspaces / mcp / pluginConfig / skills)',
|
|
283
|
+
'core.modelTools.importPlanOutputDesc': '计划结果(planId / analysis 摘要 / plan 摘要;计划项最多回 50 条)',
|
|
284
|
+
'core.modelTools.importApplyToolDesc': '执行导入计划:必须带 config_import_plan 的 planId + confirm:true。执行前重算计划比对指纹,归档或盘面有变化即拒绝(零写入)。',
|
|
285
|
+
'core.modelTools.importApplyPlanIdParam': 'config_import_plan 返回的 planId',
|
|
286
|
+
'core.modelTools.importApplyConfirmParam': 'true 才真实执行(写盘 + 卸载/安装插件);缺省拒绝',
|
|
287
|
+
'core.modelTools.importApplyRollbackOnErrorParam': '任一项失败时是否整体回滚;缺省 = 引擎默认',
|
|
288
|
+
'core.modelTools.importApplyOutputDesc': '执行结果(executed / missingSecrets 数量 / warnings / rolledBack / rollbackFull)',
|
|
289
|
+
'core.modelTools.errPlanRequired': '真实执行前必须先预览并带上预览返回的 planId(缺省即拒绝写入,防止预览与执行不是同一份计划)',
|
|
290
|
+
'core.modelTools.errPlanChanged': '计划已变化:预览之后磁盘或远端又被改过。请重新预览并确认新的计划后再执行(本次零写入)',
|
|
291
|
+
'core.modelTools.errPlanExpired': 'planId 不存在或已过期(句柄只在本进程内存里存活 30 分钟)。请重新预览取得新的 planId',
|
|
292
|
+
'core.modelTools.errIncludeSecrets': '不允许 agent 触发 includeSecrets:真实凭据值只经 GUI 导出(本工具恒按 includeSecrets:false 执行)',
|
|
293
|
+
'core.modelTools.errSyncPasswordMissing': '通道 {channel} 需要加密密码,但没有可用密码(既未传入,也没在 DSH credentials 里存过)',
|
|
294
|
+
'core.modelTools.errInvalidResolution': '非法的冲突裁决动作「{action}」(可用:keepLocal / useRemote / useMerged / skip)',
|
|
295
|
+
'core.modelTools.errImportUnavailable': '导入引擎不可用:宿主没有注入导入器(该场景请走 GUI 导入)',
|
|
296
|
+
'core.modelTools.errPathNotControlled': 'ZIP 路径不在受控目录内:{path}(只接受 exports 或临时目录下的归档)',
|
|
297
|
+
'core.modelTools.errEncryptedArchive': '归档已加密:解密需要密码,而密码不进 agent 面。请让用户在 GUI 里执行加密导入',
|
|
298
|
+
'core.modelTools.errConfirmRequired': '执行前必须显式传 confirm:true(这是写盘操作,缺省即拒绝)',
|
|
299
|
+
'core.modelTools.nextRepreview': '重新调用预览工具取得新的 planId,再执行',
|
|
300
|
+
'core.modelTools.nextRetryWithoutSecrets': '去掉 includeSecrets 后重试(凭据值请让用户在 GUI 导出)',
|
|
301
|
+
'core.modelTools.nextSaveSyncPassword': '先在 GUI 的同步设置里保存该通道的加密密码,或由用户提供密码后再重试',
|
|
302
|
+
'core.modelTools.nextFixResolution': '把 action 改成 keepLocal / useRemote / useMerged / skip 之一后重试',
|
|
303
|
+
'core.modelTools.nextUseGuiImport': '该场景改走 GUI 导入(配置页 → 导入)',
|
|
304
|
+
'core.modelTools.nextPickControlledZip': '把归档放到 exports 或临时目录后重试,或让用户在 GUI 里选择文件',
|
|
305
|
+
'core.modelTools.nextPassConfirm': '确认计划无误后带 confirm:true 重试',
|
|
260
306
|
// ---------- backup ----------
|
|
261
307
|
'core.backup.fileSectionBaseMissing': '分区 {section} 是文件类分区,但 core/backup.ts 的 FILE_BASES 未给基准目录(拒绝静默退回 homeDir 根)',
|
|
262
308
|
'core.backup.secretsSectionNotSnapshotTarget': 'secrets 分区没有 adapter / 无分区载荷,不应作为快照目标(凭据值走独立加密容器,绝不进快照)',
|
|
@@ -554,6 +600,52 @@ export const en = {
|
|
|
554
600
|
'core.modelTools.syncPullStrategyParam': 'Global conflict strategy; default merge (conflicts are kept for a decision)',
|
|
555
601
|
'core.modelTools.syncPullPasswordParam': 'Decryption password (required for encrypted snapshots; memory only)',
|
|
556
602
|
'core.modelTools.syncPullOutputDesc': 'Diff report (changes list / needsReview)',
|
|
603
|
+
// ---------- model tools D2–D6: plan handles, password slot, import ----------
|
|
604
|
+
'core.modelTools.restorePlanIdParam': 'The planId returned by the preview; required to actually execute (the server recomputes the plan from the current disk and refuses on any change)',
|
|
605
|
+
'core.modelTools.syncPushPasswordDeprecatedParam': 'Deprecated: the encryption password is read from the DSH credentials slot for this channel first; pass one only for a one-off password (memory only, never written to disk or echoed back)',
|
|
606
|
+
'core.modelTools.syncPushForceParam': 'Overwrite even when another device has advanced the remote (default false = abort on the preflight conflict check; overwrites remote history)',
|
|
607
|
+
'core.modelTools.syncPreviewToolDesc': 'Three-way merge preview (read-only): download the remote snapshot and classify local/remote/ancestor, returning each section decision and conflict locations. Always call it first to obtain the planId. The sessions section never participates.',
|
|
608
|
+
'core.modelTools.syncPreviewSnapshotIdParam': 'Remote snapshot id; default = newest',
|
|
609
|
+
'core.modelTools.syncPreviewPasswordParam': 'Decryption password; the channel stored decryption password is preferred by default (memory only)',
|
|
610
|
+
'core.modelTools.syncPreviewOutputDesc': 'Preview result (planId / summary / decision and conflicts per section)',
|
|
611
|
+
'core.modelTools.syncApplyToolDesc': 'Apply the three-way merge: requires the planId from config_sync_preview. The preview is re-run inside the lock and the fingerprint compared; any change after the preview is refused (zero writes). Writes go through the GLOBAL lock and leave a rollback point.',
|
|
612
|
+
'core.modelTools.syncApplyPlanIdParam': 'The planId returned by config_sync_preview',
|
|
613
|
+
'core.modelTools.syncApplyResolutionsParam': 'Per-section decisions: id = section id (or sectionId::conflictPath), action = keepLocal / useRemote / useMerged / skip',
|
|
614
|
+
'core.modelTools.syncApplyResolutionIdParam': 'Section id or sectionId::conflictPath',
|
|
615
|
+
'core.modelTools.syncApplyResolutionActionParam': 'keepLocal local wins / useRemote remote wins / useMerged use the auto-merged result / skip skip this section',
|
|
616
|
+
'core.modelTools.syncApplyPasswordParam': 'Decryption password; the channel stored decryption password is preferred by default (memory only)',
|
|
617
|
+
'core.modelTools.syncApplyOutputDesc': 'Apply report (applied / restoreId / rolledBack / warnings / pendingConflicts / ignoredResolutions)',
|
|
618
|
+
'core.modelTools.importPlanToolDesc': 'Build an import plan (read-only): analyze the ZIP plus conflict decisions and path mappings, returning the planId and a plan summary. Encrypted archives are refused outright (passwords never enter the agent surface; use the GUI instead).',
|
|
619
|
+
'core.modelTools.importPlanZipPathParam': 'Archive path; must live inside a controlled directory (exports or a temporary directory)',
|
|
620
|
+
'core.modelTools.importPlanStrategyParam': 'Global conflict strategy: merge keeps conflicts for a decision / replace overwrites / skipExisting skips existing',
|
|
621
|
+
'core.modelTools.importPlanResolutionsParam': 'Per-item decisions: { plan item id: keepCurrent | useImported | review }',
|
|
622
|
+
'core.modelTools.importPlanPathMappingsParam': 'Path mappings: rewrite old-machine prefixes to local prefixes',
|
|
623
|
+
'core.modelTools.importPlanMappingOldParam': 'Old path prefix recorded in the archive',
|
|
624
|
+
'core.modelTools.importPlanMappingNewParam': 'New local path prefix',
|
|
625
|
+
'core.modelTools.importPlanMappingAppliesToParam': 'Sections this mapping applies to (workspaces / mcp / pluginConfig / skills)',
|
|
626
|
+
'core.modelTools.importPlanOutputDesc': 'Plan result (planId / analysis summary / plan summary; at most 50 plan items are returned)',
|
|
627
|
+
'core.modelTools.importApplyToolDesc': 'Execute an import plan: requires the planId from config_import_plan plus confirm:true. The plan is recomputed before execution and the fingerprint compared; a changed archive or disk state is refused (zero writes).',
|
|
628
|
+
'core.modelTools.importApplyPlanIdParam': 'The planId returned by config_import_plan',
|
|
629
|
+
'core.modelTools.importApplyConfirmParam': 'true actually executes (writes to disk and uninstalls/installs plugins); refused by default',
|
|
630
|
+
'core.modelTools.importApplyRollbackOnErrorParam': 'Whether to roll back everything when any item fails; default = the engine default',
|
|
631
|
+
'core.modelTools.importApplyOutputDesc': 'Execution result (executed / missingSecrets count / warnings / rolledBack / rollbackFull)',
|
|
632
|
+
'core.modelTools.errPlanRequired': 'Preview first and pass the planId it returned (writes are refused without it, so the executed plan is provably the previewed one)',
|
|
633
|
+
'core.modelTools.errPlanChanged': 'The plan changed: disk or remote was modified after the preview. Preview again, confirm the new plan, then execute (zero writes)',
|
|
634
|
+
'core.modelTools.errPlanExpired': 'The planId does not exist or has expired (handles live in process memory for 30 minutes only). Preview again for a new planId',
|
|
635
|
+
'core.modelTools.errIncludeSecrets': 'Agents may not trigger includeSecrets: real credential values are exported through the GUI only (this tool always runs with includeSecrets:false)',
|
|
636
|
+
'core.modelTools.errSyncPasswordMissing': 'Channel {channel} needs an encryption password but none is available (not passed and none stored in DSH credentials)',
|
|
637
|
+
'core.modelTools.errInvalidResolution': 'Invalid conflict resolution action "{action}" (allowed: keepLocal / useRemote / useMerged / skip)',
|
|
638
|
+
'core.modelTools.errImportUnavailable': 'The import engine is unavailable: the host injected no importer (use the GUI import instead)',
|
|
639
|
+
'core.modelTools.errPathNotControlled': 'The ZIP path is not inside a controlled directory: {path} (only archives under exports or a temporary directory are accepted)',
|
|
640
|
+
'core.modelTools.errEncryptedArchive': 'The archive is encrypted: decryption needs a password and passwords never enter the agent surface. Let the user run the encrypted import in the GUI',
|
|
641
|
+
'core.modelTools.errConfirmRequired': 'Pass confirm:true explicitly to execute (this writes to disk; the default refuses)',
|
|
642
|
+
'core.modelTools.nextRepreview': 'Call the preview tool again to obtain a new planId, then execute',
|
|
643
|
+
'core.modelTools.nextRetryWithoutSecrets': 'Retry without includeSecrets (let the user export credentials in the GUI)',
|
|
644
|
+
'core.modelTools.nextSaveSyncPassword': 'Save the encryption password for this channel in the GUI sync settings, or have the user provide a password, then retry',
|
|
645
|
+
'core.modelTools.nextFixResolution': 'Set action to one of keepLocal / useRemote / useMerged / skip and retry',
|
|
646
|
+
'core.modelTools.nextUseGuiImport': 'Use the GUI import for this case (configuration page → import)',
|
|
647
|
+
'core.modelTools.nextPickControlledZip': 'Move the archive under exports or a temporary directory and retry, or let the user pick the file in the GUI',
|
|
648
|
+
'core.modelTools.nextPassConfirm': 'Pass confirm:true once the plan looks right',
|
|
557
649
|
// ---------- backup ----------
|
|
558
650
|
'core.backup.fileSectionBaseMissing': 'Section {section} is a file section, but FILE_BASES in core/backup.ts has no base directory (refusing to silently fall back to the homeDir root)',
|
|
559
651
|
'core.backup.secretsSectionNotSnapshotTarget': 'the secrets section has no adapter / no section payload and must not be a snapshot target (credential values use the separate encrypted container and never enter a snapshot)',
|
package/lib/core/messages.d.ts
CHANGED
|
@@ -410,6 +410,7 @@ export declare const zh: {
|
|
|
410
410
|
readonly 'sync.git.adoptMergeConflict': '合并远端 {branch} 时发生冲突:已撤销这次合并(merge --abort),工作副本回到操作前的状态。请手工解决冲突后重试,或改用「重新克隆工作副本」。';
|
|
411
411
|
readonly 'sync.workdirModeInvalidFull': '重建工作副本的模式非法: {mode}(只允许 relink(重指向地址)、adopt(采纳远端历史)或 reclone(重新克隆))';
|
|
412
412
|
readonly 'sync.git.cmdFailed': 'git {args} 失败 (exit {code}): {err}';
|
|
413
|
+
readonly 'sync.git.identityMissing': 'git 在这台机器上没有可用的提交身份(user.name / user.email 未配置),本次操作被本机 git 拒绝(exit 128,与网络和远端无关)。插件会为同步工作副本自动补写仓库级身份;若仍失败,请在本机执行 git config --global user.name "<名字>" 与 git config --global user.email "<邮箱>" 后重试。原始错误:{err}';
|
|
413
414
|
readonly 'sync.git.pushTokenRequired': '推送需要访问令牌:远端是 http(s) 仓库,但本机没有可用的令牌(拉取公开仓库可以匿名完成,推送必须认证)。请在「同步 → 通道配置」里登录 GitHub 或填入访问令牌后重试。';
|
|
414
415
|
readonly 'sync.git.pushAuthFailed': '推送认证失败:{err}。请确认令牌有效且对该仓库有写权限(账号密码推送已被远端禁用);拉取成功不代表令牌可用 —— 公开仓库匿名即可拉取。可在「同步 → 通道配置」里重新登录或更换令牌。';
|
|
415
416
|
readonly 'sync.git.credentialHelperBlocked': 'git 在本机无法执行 credential helper(它需要 shell,而当前平台不允许从应用目录执行脚本/二进制),改用 HTTP 认证头重试也没成功。请确认 git 版本不低于 2.31(环境变量注入配置需要),或把仓库地址换成 ssh。原始错误:{err}';
|
package/lib/core/messages.js
CHANGED
|
@@ -408,6 +408,9 @@ export const zh = {
|
|
|
408
408
|
'sync.git.adoptMergeConflict': '合并远端 {branch} 时发生冲突:已撤销这次合并(merge --abort),工作副本回到操作前的状态。请手工解决冲突后重试,或改用「重新克隆工作副本」。',
|
|
409
409
|
'sync.workdirModeInvalidFull': '重建工作副本的模式非法: {mode}(只允许 relink(重指向地址)、adopt(采纳远端历史)或 reclone(重新克隆))',
|
|
410
410
|
'sync.git.cmdFailed': 'git {args} 失败 (exit {code}): {err}',
|
|
411
|
+
// 本机提交身份缺失(真机 issue:commit exit 128 ⇒ 交易 NEEDS_ATTENTION ⇒ 被误升 SAFE MODE)。
|
|
412
|
+
// 文案必须点名「本机配置」,并把「远端/网络/令牌」这三种常见误判方向明确排除。
|
|
413
|
+
'sync.git.identityMissing': 'git 在这台机器上没有可用的提交身份(user.name / user.email 未配置),本次操作被本机 git 拒绝(exit 128,与网络和远端无关)。插件会为同步工作副本自动补写仓库级身份;若仍失败,请在本机执行 git config --global user.name "<名字>" 与 git config --global user.email "<邮箱>" 后重试。原始错误:{err}',
|
|
411
414
|
// 推送认证(真机:公开仓库拉取可匿名成功、推送必失败,git 原文只说「Invalid username or token」)
|
|
412
415
|
'sync.git.pushTokenRequired': '推送需要访问令牌:远端是 http(s) 仓库,但本机没有可用的令牌(拉取公开仓库可以匿名完成,推送必须认证)。请在「同步 → 通道配置」里登录 GitHub 或填入访问令牌后重试。',
|
|
413
416
|
'sync.git.pushAuthFailed': '推送认证失败:{err}。请确认令牌有效且对该仓库有写权限(账号密码推送已被远端禁用);拉取成功不代表令牌可用 —— 公开仓库匿名即可拉取。可在「同步 → 通道配置」里重新登录或更换令牌。',
|
|
@@ -904,6 +907,9 @@ export const en = {
|
|
|
904
907
|
'sync.git.adoptMergeConflict': 'Merging remote {branch} produced conflicts: the merge was aborted (merge --abort) and the working copy is back to its previous state. Resolve the conflicts manually and retry, or use "clone the working copy again".',
|
|
905
908
|
'sync.workdirModeInvalidFull': 'Invalid working-copy rebuild mode: {mode} (only relink (re-point the address), adopt (merge the remote history) or reclone (clone again) are allowed).',
|
|
906
909
|
'sync.git.cmdFailed': 'git {args} failed (exit {code}): {err}',
|
|
910
|
+
// Missing local commit identity (real-world issue: commit exit 128 → NEEDS_ATTENTION → wrongly escalated to SAFE MODE).
|
|
911
|
+
// Name the local config and rule out the three usual suspects (remote, network, token).
|
|
912
|
+
'sync.git.identityMissing': 'git has no usable commit identity on this machine (user.name / user.email is unset), so local git refused the operation (exit 128 — unrelated to the network or the remote). The plugin writes a repository-level identity into the sync working copy automatically; if that still fails, run git config --global user.name "<name>" and git config --global user.email "<email>" on this machine and retry. Original error: {err}',
|
|
907
913
|
'sync.git.pushTokenRequired': 'Push requires an access token, but none is available on this machine (public repositories can be fetched anonymously; pushing always needs authentication). Sign in to GitHub or paste an access token under Sync → Channel configuration, then retry.',
|
|
908
914
|
'sync.git.pushAuthFailed': 'Push authentication failed: {err}. Check that the token is valid and has write access to this repository (password authentication is disabled by the remote); a successful pull does not prove the token works — public repositories can be fetched anonymously. Sign in again or replace the token under Sync → Channel configuration.',
|
|
909
915
|
'sync.git.credentialHelperBlocked': 'git cannot run the credential helper on this machine (it needs a shell, and this platform does not allow executing scripts/binaries from the app directory), and retrying with an HTTP authorization header did not work either. Make sure git is 2.31 or newer (injecting config through environment variables needs it) or switch the repository address to ssh. Original error: {err}',
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ImportDecisions, ImportPlan } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* 指纹只消费三方合并预览的这几个字段 —— 这里用结构化最小类型声明,
|
|
4
|
+
* 而不是 import `../sync/sync-engine.ts` 的 MergePreview:
|
|
5
|
+
* core 不得反向依赖 sync 层(架构边界),且指纹只需要「结论 + 冲突位置」。
|
|
6
|
+
*/
|
|
7
|
+
interface MergePreviewShape {
|
|
8
|
+
readonly ok: boolean;
|
|
9
|
+
readonly snapshotId?: string | null;
|
|
10
|
+
readonly hasAncestor?: boolean;
|
|
11
|
+
readonly sections: readonly {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly decision: string;
|
|
14
|
+
readonly autoMerged?: number;
|
|
15
|
+
readonly conflicts: readonly {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly kind: string;
|
|
18
|
+
readonly reason?: string | null;
|
|
19
|
+
}[];
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export type ModelPlanKind = 'restore' | 'sync-merge' | 'import';
|
|
23
|
+
export interface ModelPlanRecord {
|
|
24
|
+
/** planId = 指纹本身(同一计划重复预览得到同一个 id,天然幂等) */
|
|
25
|
+
id: string;
|
|
26
|
+
kind: ModelPlanKind;
|
|
27
|
+
fingerprint: string;
|
|
28
|
+
/** 重放材料:只放 id / 路径 / 决策,绝不放密码或凭据值 */
|
|
29
|
+
payload: Record<string, string>;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
}
|
|
33
|
+
/** 计划句柄存活时长(与同步会话的 30 分钟同档)。 */
|
|
34
|
+
export declare const MODEL_PLAN_TTL_MS: number;
|
|
35
|
+
/** 同时在册的计划上限(超出淘汰最旧的一条)。 */
|
|
36
|
+
export declare const MODEL_PLAN_MAX = 8;
|
|
37
|
+
export declare class ModelPlanStore {
|
|
38
|
+
private readonly records;
|
|
39
|
+
private readonly now;
|
|
40
|
+
constructor(now?: () => number);
|
|
41
|
+
/** 登记一份预览过的计划;返回 planId(= fingerprint)。同一指纹重复登记只刷新时间。 */
|
|
42
|
+
set(kind: ModelPlanKind, fingerprint: string, payload: Record<string, string>): string;
|
|
43
|
+
get(id: string): ModelPlanRecord | undefined;
|
|
44
|
+
delete(id: string): void;
|
|
45
|
+
get size(): number;
|
|
46
|
+
/** 惰性清理过期项 + 按插入序淘汰最旧(不做定时器:无人调用时不需要清理)。 */
|
|
47
|
+
private evict;
|
|
48
|
+
}
|
|
49
|
+
/** 稳定序列化:对象键按字典序,保证同一份材料在任何构造顺序下得到同一个指纹。 */
|
|
50
|
+
export declare function stableStringify(value: unknown): string;
|
|
51
|
+
/**
|
|
52
|
+
* 同步合并计划的指纹:只取「分区 id + 结论 + 冲突位置」。
|
|
53
|
+
*
|
|
54
|
+
* **刻意不含三侧预览文本**(localPreview / remotePreview / ancestorPreview):那是给人看的,
|
|
55
|
+
* 同一份计划在不同时刻被截断/脱敏的方式可能变,纳入指纹会让「什么都没变的计划」被误判成变化。
|
|
56
|
+
* 反过来,冲突多出一处路径 = 远端或本机真的动了,必须重新确认。
|
|
57
|
+
*/
|
|
58
|
+
export declare function syncMergeFingerprint(preview: MergePreviewShape): string;
|
|
59
|
+
/**
|
|
60
|
+
* 导入计划的指纹:取「每条 item 的身份 + 结论」与用户决策。
|
|
61
|
+
*
|
|
62
|
+
* 不含 description / detail 文案(改文案不该让预览失效),但含 target.ref 与 kind ——
|
|
63
|
+
* 计划项从 Create 变成 Conflict、或目标路径变了,都是用户需要重新看一眼的变化。
|
|
64
|
+
*/
|
|
65
|
+
export declare function importPlanFingerprint(plan: ImportPlan, decisions: ImportDecisions): string;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent 工具面的「计划句柄」表(planId → 预览时算出的指纹与重放材料)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么 agent 侧需要这张表,而不能只让模型把整个计划回传:
|
|
5
|
+
* - 计划正文可能很大(导入计划动辄上百条 item),塞进模型上下文既贵又容易被截断/改写;
|
|
6
|
+
* - 模型改写过的计划不构成「用户确认过的计划」,服务端必须能从**当前磁盘**重算同一份计划。
|
|
7
|
+
* 于是:预览时返回 planId(= 计划指纹),执行时只带 planId,服务端重算 → 比对指纹 →
|
|
8
|
+
* 不一致就拒绝(plan-changed)并且零写入。等价于 GUI 恢复路由的 409。
|
|
9
|
+
*
|
|
10
|
+
* 存放纪律(安全不变量):
|
|
11
|
+
* - 只在进程内存,绝不落盘、绝不进响应、绝不进日志;
|
|
12
|
+
* - payload 只放「重放所需的最小材料」(快照 id / 通道 / ZIP 路径 / 决策 JSON),
|
|
13
|
+
* **绝不存密码、凭据值、解密明文**;
|
|
14
|
+
* - TTL 30 分钟、上限 8 条:模型隔了很久才执行时应当重新预览,而不是拿到一份
|
|
15
|
+
* 早已过期的确认去写盘。
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
/** 计划句柄存活时长(与同步会话的 30 分钟同档)。 */
|
|
19
|
+
export const MODEL_PLAN_TTL_MS = 30 * 60 * 1000;
|
|
20
|
+
/** 同时在册的计划上限(超出淘汰最旧的一条)。 */
|
|
21
|
+
export const MODEL_PLAN_MAX = 8;
|
|
22
|
+
export class ModelPlanStore {
|
|
23
|
+
records = new Map();
|
|
24
|
+
now;
|
|
25
|
+
constructor(now = () => Date.now()) {
|
|
26
|
+
this.now = now;
|
|
27
|
+
}
|
|
28
|
+
/** 登记一份预览过的计划;返回 planId(= fingerprint)。同一指纹重复登记只刷新时间。 */
|
|
29
|
+
set(kind, fingerprint, payload) {
|
|
30
|
+
const ts = this.now();
|
|
31
|
+
// Map 的迭代序 = 插入序;先删再插让「刚预览的」排到最新,淘汰时才不会把刚发的 id 挤掉。
|
|
32
|
+
this.records.delete(fingerprint);
|
|
33
|
+
this.records.set(fingerprint, {
|
|
34
|
+
id: fingerprint,
|
|
35
|
+
kind,
|
|
36
|
+
fingerprint,
|
|
37
|
+
payload,
|
|
38
|
+
createdAt: ts,
|
|
39
|
+
expiresAt: ts + MODEL_PLAN_TTL_MS,
|
|
40
|
+
});
|
|
41
|
+
this.evict(ts);
|
|
42
|
+
return fingerprint;
|
|
43
|
+
}
|
|
44
|
+
get(id) {
|
|
45
|
+
const record = this.records.get(id);
|
|
46
|
+
if (record === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
if (record.expiresAt <= this.now()) {
|
|
49
|
+
this.records.delete(id);
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return record;
|
|
53
|
+
}
|
|
54
|
+
delete(id) {
|
|
55
|
+
this.records.delete(id);
|
|
56
|
+
}
|
|
57
|
+
get size() {
|
|
58
|
+
return this.records.size;
|
|
59
|
+
}
|
|
60
|
+
/** 惰性清理过期项 + 按插入序淘汰最旧(不做定时器:无人调用时不需要清理)。 */
|
|
61
|
+
evict(ts) {
|
|
62
|
+
for (const [id, record] of this.records) {
|
|
63
|
+
if (record.expiresAt <= ts)
|
|
64
|
+
this.records.delete(id);
|
|
65
|
+
}
|
|
66
|
+
while (this.records.size > MODEL_PLAN_MAX) {
|
|
67
|
+
const oldest = this.records.keys().next();
|
|
68
|
+
if (oldest.done === true)
|
|
69
|
+
break;
|
|
70
|
+
this.records.delete(oldest.value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/* ------------------------------------------------------------ 指纹 */
|
|
75
|
+
/** 稳定序列化:对象键按字典序,保证同一份材料在任何构造顺序下得到同一个指纹。 */
|
|
76
|
+
export function stableStringify(value) {
|
|
77
|
+
if (value === null || typeof value !== 'object')
|
|
78
|
+
return JSON.stringify(value) ?? 'null';
|
|
79
|
+
if (Array.isArray(value))
|
|
80
|
+
return `[${value.map(stableStringify).join(',')}]`;
|
|
81
|
+
const record = value;
|
|
82
|
+
const keys = Object.keys(record).sort();
|
|
83
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(',')}}`;
|
|
84
|
+
}
|
|
85
|
+
function digest(kind, material) {
|
|
86
|
+
return createHash('sha256').update(kind).update('\n').update(stableStringify(material)).digest('hex');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 同步合并计划的指纹:只取「分区 id + 结论 + 冲突位置」。
|
|
90
|
+
*
|
|
91
|
+
* **刻意不含三侧预览文本**(localPreview / remotePreview / ancestorPreview):那是给人看的,
|
|
92
|
+
* 同一份计划在不同时刻被截断/脱敏的方式可能变,纳入指纹会让「什么都没变的计划」被误判成变化。
|
|
93
|
+
* 反过来,冲突多出一处路径 = 远端或本机真的动了,必须重新确认。
|
|
94
|
+
*/
|
|
95
|
+
export function syncMergeFingerprint(preview) {
|
|
96
|
+
return digest('sync-merge', {
|
|
97
|
+
ok: preview.ok,
|
|
98
|
+
snapshotId: preview.snapshotId,
|
|
99
|
+
hasAncestor: preview.hasAncestor,
|
|
100
|
+
sections: preview.sections.map((section) => ({
|
|
101
|
+
id: section.id,
|
|
102
|
+
decision: section.decision,
|
|
103
|
+
autoMerged: section.autoMerged ?? 0,
|
|
104
|
+
conflicts: section.conflicts.map((conflict) => [conflict.path, conflict.kind, conflict.reason ?? '']),
|
|
105
|
+
})),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 导入计划的指纹:取「每条 item 的身份 + 结论」与用户决策。
|
|
110
|
+
*
|
|
111
|
+
* 不含 description / detail 文案(改文案不该让预览失效),但含 target.ref 与 kind ——
|
|
112
|
+
* 计划项从 Create 变成 Conflict、或目标路径变了,都是用户需要重新看一眼的变化。
|
|
113
|
+
*/
|
|
114
|
+
export function importPlanFingerprint(plan, decisions) {
|
|
115
|
+
return digest('import', {
|
|
116
|
+
strategy: decisions.strategy,
|
|
117
|
+
pathMappings: decisions.pathMappings.map((mapping) => [mapping.oldPrefix, mapping.newPrefix, mapping.appliesTo.join(',')]),
|
|
118
|
+
items: plan.items.map((item) => [
|
|
119
|
+
item.id,
|
|
120
|
+
item.kind,
|
|
121
|
+
item.adapter,
|
|
122
|
+
item.target?.ref ?? '',
|
|
123
|
+
item.target?.file ?? '',
|
|
124
|
+
]),
|
|
125
|
+
missingSecrets: plan.missingSecrets.map((secret) => secret.ref),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=model-tool-plans.js.map
|
|
@@ -4,6 +4,8 @@ import type { SyncEngine } from '../sync/sync-engine.ts';
|
|
|
4
4
|
import type { SectionId } from '../schema/types.ts';
|
|
5
5
|
import type { SyncConfig, SyncTransportType } from '../sync/sync-config.ts';
|
|
6
6
|
import type { ConfigAdapter, HostContext, SecretScanner } from './types.ts';
|
|
7
|
+
import type { Importer } from './importer.ts';
|
|
8
|
+
import { ModelPlanStore } from './model-tool-plans.ts';
|
|
7
9
|
/** 模型工具所需依赖(与 host 路由同一来源闭包)。 */
|
|
8
10
|
export interface ModelToolsDeps {
|
|
9
11
|
/** HostContext 门面(homeDir / profile / msg / log) */
|
|
@@ -16,8 +18,14 @@ export interface ModelToolsDeps {
|
|
|
16
18
|
snapshotsDir: string;
|
|
17
19
|
/** 同步状态目录($DSH_HOME/dsh-config-manager/sync) */
|
|
18
20
|
syncDir: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* SyncEngine 工厂(git/webdav 按配置分支构造传输;与 host 路由同一来源)。
|
|
23
|
+
* D5:agent 侧按工具决定 optInSections(仅合并类工具带用户放行的可选分区),
|
|
24
|
+
* 推送/拉取仍走缺省(= 只 portable),与改动前的工具行为逐字节一致。
|
|
25
|
+
*/
|
|
26
|
+
makeSyncEngine: (cfg: SyncConfig, opts?: {
|
|
27
|
+
optInSections?: readonly SectionId[];
|
|
28
|
+
}) => SyncEngine;
|
|
21
29
|
/** 插件版本(manifest.exporter.version) */
|
|
22
30
|
exporterVersion?: string;
|
|
23
31
|
/**
|
|
@@ -27,8 +35,38 @@ export interface ModelToolsDeps {
|
|
|
27
35
|
* 可选:缺省落回 Exporter 的 defaultSecretScanner()(无 scanText → 文件类分区不扫描,与修复前一致)。
|
|
28
36
|
*/
|
|
29
37
|
scanner?: SecretScanner;
|
|
38
|
+
/**
|
|
39
|
+
* D3:按 DSH credentials 槽位读同步密码(ENCRYPT / DECRYPT + 通道)。
|
|
40
|
+
* 值只在宿主内存里交给引擎,绝不进工具返回 / render / 日志。缺省 = 未接凭据服务。
|
|
41
|
+
*/
|
|
42
|
+
syncPassword?: (kind: 'ENCRYPT' | 'DECRYPT', channel: SyncTransportType) => Promise<string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* D5:用户逐分区放行的可选分区(宿主 = selectionOptInSections(channel, true) 的 'auto' 档)。
|
|
45
|
+
* 缺省 = 空集;agent 侧永远再剔除 sessions(会话内容不受工具调用摆布)。
|
|
46
|
+
*/
|
|
47
|
+
optInSections?: (channel: SyncTransportType) => readonly SectionId[];
|
|
48
|
+
/** D6:导入引擎工厂(与 HTTP 导入路由同一来源)。缺省 = 导入类工具返回 import-unavailable。 */
|
|
49
|
+
makeImporter?: () => Importer;
|
|
50
|
+
/**
|
|
51
|
+
* D6:受控路径根(导入 ZIP 必须落在其中;与 /analyze、/plan 同一判据 isControlledPath)。
|
|
52
|
+
* 缺省 = 一律拒绝(fail-closed:宁可让用户走 GUI,也不让 agent 把任意路径交给解析器)。
|
|
53
|
+
*/
|
|
54
|
+
roots?: readonly string[];
|
|
55
|
+
/** 计划句柄表(单测可注入假时钟;缺省每次 createModelTools 新建一个进程内表)。 */
|
|
56
|
+
planStore?: ModelPlanStore;
|
|
30
57
|
}
|
|
31
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* 工具失败的统一形状:模型据此判断「能不能重试、下一步做什么」,不需要解析自然语言。
|
|
60
|
+
* 成功路径保留各自业务字段(含 ok:true)。
|
|
61
|
+
*/
|
|
62
|
+
export interface ModelToolFailure extends Record<string, JsonValue> {
|
|
63
|
+
ok: false;
|
|
64
|
+
code: string;
|
|
65
|
+
message: string;
|
|
66
|
+
retryable: boolean;
|
|
67
|
+
nextAction: string;
|
|
68
|
+
}
|
|
69
|
+
/** 9 个工具的纯编排实现(可独立测试,不依赖 Cordis ctx)。所有返回均为 JsonValue(可序列化、无 undefined)。 */
|
|
32
70
|
export declare function createModelTools(deps: ModelToolsDeps): {
|
|
33
71
|
/** 全量备份到 exports 目录(默认不含 secret;password 可选加密,仅内存)。 */
|
|
34
72
|
backup(input: {
|
|
@@ -38,28 +76,78 @@ export declare function createModelTools(deps: ModelToolsDeps): {
|
|
|
38
76
|
/** 列出本地回滚快照(非敏感 meta,按 createdAt 倒序)。 */
|
|
39
77
|
listSnapshots(): Promise<JsonValue>;
|
|
40
78
|
/**
|
|
41
|
-
* 恢复到指定快照。缺省只 planRestore
|
|
42
|
-
* confirm:true
|
|
79
|
+
* 恢复到指定快照。缺省只 planRestore(零写入)预览并**返回 planId**;
|
|
80
|
+
* 真实执行必须 confirm:true 且带回预览给的 planId —— 计划在预览后变了就拒绝(零写入)。
|
|
43
81
|
*/
|
|
44
82
|
restore(input: {
|
|
45
83
|
snapshotId: string;
|
|
84
|
+
planId?: string;
|
|
46
85
|
confirm?: boolean;
|
|
47
86
|
}): Promise<JsonValue>;
|
|
48
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* 手动推送同步(写远端)。密钥绝不明文进通道:
|
|
89
|
+
* D4 起 includeSecrets 恒 false —— agent 传 true 直接拒绝(模型无权让凭据值上行)。
|
|
90
|
+
*/
|
|
49
91
|
syncPush(input: {
|
|
50
92
|
channel?: SyncTransportType;
|
|
51
93
|
sections?: SectionId[];
|
|
52
94
|
encrypt?: boolean;
|
|
53
95
|
includeSecrets?: boolean;
|
|
54
96
|
password?: string;
|
|
97
|
+
force?: boolean;
|
|
55
98
|
}): Promise<JsonValue>;
|
|
56
|
-
/** 拉取差异预览(零写入:只下载 + analyze + plan
|
|
99
|
+
/** 拉取差异预览(零写入:只下载 + analyze + plan 出差异报告)。解密密码同样优先取已存槽位(D3)。 */
|
|
57
100
|
syncPull(input: {
|
|
58
101
|
channel?: SyncTransportType;
|
|
59
102
|
snapshotId?: string;
|
|
60
103
|
strategy?: 'merge' | 'replace' | 'skipExisting';
|
|
61
104
|
password?: string;
|
|
62
105
|
}): Promise<JsonValue>;
|
|
106
|
+
/**
|
|
107
|
+
* 三方合并预览(只读):下载远端快照 + 分类 + 出裁决清单,零写入。
|
|
108
|
+
* 返回的 planId 是这份预览的指纹:config_sync_apply 必须带回来,落地前在锁内重跑预览比对。
|
|
109
|
+
* 刻意不下发 localPreview / remotePreview / ancestorPreview —— 那是 GUI 逐键对比用的分段文本。
|
|
110
|
+
*/
|
|
111
|
+
syncPreview(input: {
|
|
112
|
+
channel?: SyncTransportType;
|
|
113
|
+
snapshotId?: string;
|
|
114
|
+
password?: string;
|
|
115
|
+
}): Promise<JsonValue>;
|
|
116
|
+
/**
|
|
117
|
+
* 落地三方合并:必须带 config_sync_preview 返回的 planId(缺失/过期 → plan-*,零写入)。
|
|
118
|
+
* 锁内重跑预览比对指纹 —— 预览后远端或本机变了就拒绝,不把旧裁决硬套到新盘面。
|
|
119
|
+
*/
|
|
120
|
+
syncApply(input: {
|
|
121
|
+
planId: string;
|
|
122
|
+
resolutions: {
|
|
123
|
+
id: string;
|
|
124
|
+
action: string;
|
|
125
|
+
}[];
|
|
126
|
+
password?: string;
|
|
127
|
+
}): Promise<JsonValue>;
|
|
128
|
+
/**
|
|
129
|
+
* 生成导入计划(只读):分析归档 + 合并冲突决策 / 路径映射,零写入。
|
|
130
|
+
* 加密归档直接拒绝 —— 解密需要密码,而密码不进 agent 面(该场景走 GUI 导入)。
|
|
131
|
+
*/
|
|
132
|
+
importPlan(input: {
|
|
133
|
+
zipPath: string;
|
|
134
|
+
strategy?: 'merge' | 'replace' | 'skipExisting';
|
|
135
|
+
resolutions?: Record<string, JsonValue>;
|
|
136
|
+
pathMappings?: readonly {
|
|
137
|
+
oldPrefix: string;
|
|
138
|
+
newPrefix: string;
|
|
139
|
+
appliesTo?: readonly string[];
|
|
140
|
+
}[];
|
|
141
|
+
}): Promise<JsonValue>;
|
|
142
|
+
/**
|
|
143
|
+
* 执行导入计划:必须带 config_import_plan 返回的 planId + confirm:true。
|
|
144
|
+
* 执行前按存档决策重算计划比对指纹(归档被换 / 本机状态变了 → 拒绝,零写入)。
|
|
145
|
+
*/
|
|
146
|
+
importApply(input: {
|
|
147
|
+
planId: string;
|
|
148
|
+
confirm?: boolean;
|
|
149
|
+
rollbackOnError?: boolean;
|
|
150
|
+
}): Promise<JsonValue>;
|
|
63
151
|
};
|
|
64
|
-
/** 把
|
|
152
|
+
/** 把 9 个模型工具注册进 ctx.tools;tools 服务未组合时静默跳过(不崩溃)。 */
|
|
65
153
|
export declare function registerModelTools(ctx: Context, deps: ModelToolsDeps): void;
|