@openclaw/matrix 2026.10.5-beta.4 → 2026.10.10-beta.1
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/dist/.setup/{approval-handler.runtime-rxLn8CbP.mjs → approval-handler.runtime-CsqMdj7h.mjs} +9 -9
- package/dist/.setup/{approval-reactions-DhB6gNPU.mjs → approval-reactions-D2pEUrFS.mjs} +1 -1
- package/dist/.setup/{channel-BcwGspPw.mjs → channel-Dw4_imdd.mjs} +132 -111
- package/dist/.setup/{channel.runtime-CUc6rbu1.mjs → channel.runtime-2EEtIlyu.mjs} +6 -6
- package/dist/.setup/{channel.setup-CwuYD_CT.mjs → channel.setup-Be8TYKMA.mjs} +8 -3
- package/dist/.setup/{cli-mbL9jCro.mjs → cli-CEmWh7wh.mjs} +99 -37
- package/dist/.setup/{cli-metadata-6MOGuyHq.mjs → cli-metadata-CBLGwJT6.mjs} +1 -1
- package/dist/.setup/{client-BlTvpEWC.mjs → client-BKiiI29H.mjs} +3 -3
- package/dist/.setup/{client-vPPbaxNp.mjs → client-C4Gibhzl.mjs} +94 -120
- package/dist/.setup/{client-bootstrap-D05xy1HB.mjs → client-bootstrap-kOIDV4z_.mjs} +3 -3
- package/dist/.setup/{create-client-CroC4BVc.mjs → create-client-BS8UYx6N.mjs} +23 -15
- package/dist/.setup/{credentials-Bf9PQ7xs.mjs → credentials-CPnJZaZB.mjs} +3 -5
- package/dist/.setup/{credentials-read-CqRiEAQa.mjs → credentials-read-D2ULV55A.mjs} +12 -4
- package/dist/.setup/{crypto-runtime-CpJ0b7vY.mjs → crypto-runtime-D8yY7kjD.mjs} +168 -290
- package/dist/.setup/crypto-state-store-D4wrCvFs.mjs +185 -0
- package/dist/.setup/crypto-store-ownership-Z_Y5WRKr.mjs +174 -0
- package/dist/.setup/crypto-unsafe-state-doctor-C8szCYmf.mjs +54 -0
- package/dist/.setup/{directory-live-B1WbfSHo.mjs → directory-live-BpSz-FQB.mjs} +1 -1
- package/dist/.setup/{draft-stream-Bdrh7dRt.mjs → draft-stream-DYf0th1n.mjs} +1 -1
- package/dist/.setup/{exec-approvals-BgNWWJg1.mjs → exec-approvals-DaM-5OA5.mjs} +33 -43
- package/dist/.setup/{file-sync-store-BdKx_gMi.mjs → file-sync-store-CUH8EAJq.mjs} +3 -3
- package/dist/.setup/idb-persistence-BHTYPRe_.mjs +233 -0
- package/dist/.setup/idb-persistence-lock-Bh3ZLIsE.mjs +14 -0
- package/dist/.setup/{messages-B1CZqU8u.mjs → messages-_XHVg3do.mjs} +3 -18
- package/dist/.setup/{monitor-Dk_fQL1k.mjs → monitor-DRUSJ_Ev.mjs} +31 -39
- package/dist/.setup/{onboarding-CrSexor_.mjs → onboarding-CK9Ksgio.mjs} +3 -3
- package/dist/.setup/{outbound-LR3SqPIq.mjs → outbound-D5Z_4FBg.mjs} +28 -36
- package/dist/.setup/{profile-update-C7bjaGR6.mjs → profile-update--Pf3jCXD.mjs} +2 -2
- package/dist/.setup/{reaction-events-CTSvOlXO.mjs → reaction-events-BG9spedG.mjs} +6 -6
- package/dist/.setup/{resolve-targets-BVVbbvP6.mjs → resolve-targets-BJ5sIKeM.mjs} +1 -1
- package/dist/.setup/{retired-state-DW5pLH05.mjs → retired-state-DOCruzWd.mjs} +10 -10
- package/dist/.setup/{room-info-9Uqlpt1V.mjs → room-info-BE7bbX_c.mjs} +3 -3
- package/dist/.setup/runtime-setter-api-i2MOXoT3.mjs +2 -0
- package/dist/.setup/{sdk-Cfc6m7fY.mjs → sdk-ByU8So5S.mjs} +242 -139
- package/dist/.setup/secret-contract-DxyzKSzf.mjs +90 -0
- package/dist/.setup/secret-contract-api-Dukgvike.mjs +2 -0
- package/dist/.setup/{send-LCOuTVc1.mjs → send-BprM-Wmx.mjs} +19 -42
- package/dist/.setup/{setup-bootstrap-CV-hHBXu.mjs → setup-bootstrap-DmznRqYe.mjs} +2 -6
- package/dist/.setup/{setup-core-CKnNTfgD.mjs → setup-core-DcCk1_Tv.mjs} +4 -7
- package/dist/.setup/setup-plugin-api-BU6UGksW.mjs +2 -0
- package/dist/.setup/{startup-verification-CgfUb4yJ.mjs → startup-verification-UU8DUvi4.mjs} +5 -13
- package/dist/.setup/state-layout-walk-BQMgMykU.mjs +27 -0
- package/dist/.setup/{storage-DkC6bHgA.mjs → storage-l8V0XsGM.mjs} +7 -166
- package/dist/.setup/{subagent-hooks-D8jyeQsO.mjs → subagent-hooks-CSY4iwa_.mjs} +7 -6
- package/dist/.setup/{sync-cache-state-D4G-fi3t.mjs → sync-cache-state-Cnm4TCEI.mjs} +1 -1
- package/dist/.setup/thread-bindings-rrwQAS6R.mjs +620 -0
- package/dist/.setup/{thread-bindings-shared-CbsFNbAY.mjs → thread-bindings-shared-CPjUA0Ib.mjs} +26 -5
- package/dist/.setup/{tool-actions-DAp6_XSJ.mjs → tool-actions-DBrk6Yei.mjs} +9 -11
- package/dist/.setup/{verification-B3VswneT.mjs → verification--qUbmRd-.mjs} +2 -2
- package/dist/api.js +6 -6
- package/dist/auth-presence.js +16 -2
- package/dist/channel-plugin-api.js +1 -2
- package/dist/cli-metadata.js +1 -2
- package/dist/contract-api.js +2 -2
- package/dist/doctor-contract-api.js +20 -27
- package/dist/index.js +38 -12
- package/dist/plugin-entry.handlers.runtime.js +32 -5
- package/dist/runtime-api.js +3 -3
- package/dist/runtime-setter-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -3
- package/dist/setup-plugin-api.js +1 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -2
- package/dist/thread-bindings-runtime.js +1 -2
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +148 -0
- package/node_modules/@openclaw/fs-safe/README.md +20 -4
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +9 -2
- package/node_modules/@openclaw/fs-safe/dist/clone-metadata.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +2 -1
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/config.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +3 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +8 -7
- package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-link.js +170 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +11 -2
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +2 -4
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
- package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
- package/node_modules/@openclaw/fs-safe/dist/create.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/creation-boundary.js +7 -4
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +7 -4
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +20 -5
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
- package/node_modules/@openclaw/fs-safe/dist/directory-receipt.d.ts +7 -7
- package/node_modules/@openclaw/fs-safe/dist/directory-receipt.js +9 -4
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/exact-identity.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/exact-identity.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/file-hash.js +11 -9
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +7 -1
- package/node_modules/@openclaw/fs-safe/dist/file-identity.js +27 -5
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -2
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +22 -15
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/index.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
- package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +24 -13
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +85 -18
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.js +11 -0
- package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +6 -4
- package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js +26 -2
- package/node_modules/@openclaw/fs-safe/dist/native-guidance.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-guidance.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +8 -6
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +44 -4
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +85 -15
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +3 -3
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +33 -6
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +22 -3
- package/node_modules/@openclaw/fs-safe/dist/native-policy-directory-observation.js +4 -3
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +16 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +15 -5
- package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/native-status.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/native-status.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts +31 -4
- package/node_modules/@openclaw/fs-safe/dist/native.js +107 -9
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl-batch.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +83 -47
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +8 -3
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +10 -8
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +7 -5
- package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +3 -2
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +38 -10
- package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +5 -3
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +26 -20
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +3 -4
- package/node_modules/@openclaw/fs-safe/dist/realpath.js +32 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.js +11 -15
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +3 -2
- package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +8 -13
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +252 -27
- package/node_modules/@openclaw/fs-safe/dist/root-directory-creation.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +11 -8
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +35 -13
- package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +108 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.js +15 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +154 -175
- package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +239 -0
- package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +37 -15
- package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js +56 -0
- package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-public-types.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +95 -16
- package/node_modules/@openclaw/fs-safe/dist/root-remove.js +6 -4
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +23 -19
- package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -6
- package/node_modules/@openclaw/fs-safe/dist/root-write-publication.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/secure-file-windows.js +3 -1
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.js +10 -4
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +5 -3
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +13 -2
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +71 -3
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js +39 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +25 -36
- package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +24 -5
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
- package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +12 -10
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +2 -1
- package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
- package/node_modules/@openclaw/fs-safe/docs/config.md +71 -1
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +45 -5
- package/node_modules/@openclaw/fs-safe/docs/copy.md +45 -5
- package/node_modules/@openclaw/fs-safe/docs/durability.md +34 -7
- package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
- package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/install.md +47 -27
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -6
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +79 -6
- package/node_modules/@openclaw/fs-safe/docs/native.md +279 -8
- package/node_modules/@openclaw/fs-safe/docs/permissions.md +64 -15
- package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
- package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
- package/node_modules/@openclaw/fs-safe/docs/public-api.md +10 -0
- package/node_modules/@openclaw/fs-safe/docs/queue-link-free-design.md +237 -0
- package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
- package/node_modules/@openclaw/fs-safe/docs/reading.md +56 -2
- package/node_modules/@openclaw/fs-safe/docs/regular-file.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
- package/node_modules/@openclaw/fs-safe/docs/secure-file.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/security-model.md +35 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
- package/node_modules/@openclaw/fs-safe/docs/staged-file.md +18 -0
- package/node_modules/@openclaw/fs-safe/docs/store.md +15 -0
- package/node_modules/@openclaw/fs-safe/docs/temp.md +39 -0
- package/node_modules/@openclaw/fs-safe/docs/testing.md +13 -0
- package/node_modules/@openclaw/fs-safe/docs/types.md +51 -81
- package/node_modules/@openclaw/fs-safe/docs/walk.md +4 -1
- package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
- package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
- package/node_modules/@openclaw/fs-safe/package.json +21 -12
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +3 -0
- package/package.json +7 -6
- package/dist/.setup/runtime-setter-api-DtxDAM-x.mjs +0 -3
- package/dist/.setup/secret-contract-DSBRvhdZ.mjs +0 -95
- package/dist/.setup/secret-contract-api-DzEJ-X7n.mjs +0 -3
- package/dist/.setup/setup-plugin-api-BDAYk1a5.mjs +0 -3
- package/dist/.setup/thread-bindings-CT4P-OSZ.mjs +0 -365
- package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +0 -336
- package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.ps1 +0 -90
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
|
|
2
|
-
import { a as listBindingsForAccount, c as setBindingRecord, f as toSessionBindingRecord, o as removeBindingRecord, r as getMatrixThreadBindingManagerEntry, s as resolveBindingKey, t as deleteMatrixThreadBindingManagerEntry, u as setMatrixThreadBindingManagerEntry } from "./thread-bindings-shared-CbsFNbAY.mjs";
|
|
3
|
-
import { o as resolveMatrixSqliteStateEnv, r as assertMatrixSupportedStateFile, s as resolveMatrixSqliteStateKey } from "./retired-state-DW5pLH05.mjs";
|
|
4
|
-
import { a as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-DkC6bHgA.mjs";
|
|
5
|
-
import { r as sendMessageMatrix } from "./send-LCOuTVc1.mjs";
|
|
6
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
-
import { createHash } from "node:crypto";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
10
|
-
import { registerSessionBindingAdapter, resolveThreadBindingFarewellText, resolveThreadBindingLifecycle, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
11
|
-
import { resolveSessionAgentIdStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
12
|
-
import { resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
|
|
13
|
-
//#region extensions/matrix/src/matrix/thread-bindings.ts
|
|
14
|
-
const THREAD_BINDINGS_NAMESPACE = "thread-bindings";
|
|
15
|
-
const THREAD_BINDINGS_MAX_ENTRIES = 1e4;
|
|
16
|
-
const THREAD_BINDINGS_SWEEP_INTERVAL_MS = 6e4;
|
|
17
|
-
const TOUCH_PERSIST_DELAY_MS = 3e4;
|
|
18
|
-
function createThreadBindingStore(params) {
|
|
19
|
-
return getMatrixRuntime().state.openKeyedStore({
|
|
20
|
-
namespace: THREAD_BINDINGS_NAMESPACE,
|
|
21
|
-
maxEntries: THREAD_BINDINGS_MAX_ENTRIES,
|
|
22
|
-
env: resolveMatrixSqliteStateEnv(params)
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function buildThreadBindingStoreKey(record) {
|
|
26
|
-
const digest = createHash("sha256").update(record.accountId).update("\0").update(record.parentConversationId ?? "").update("\0").update(record.conversationId).digest("hex");
|
|
27
|
-
return `${record.accountId}:${digest}`;
|
|
28
|
-
}
|
|
29
|
-
function normalizeBindingRecord(entry, accountId) {
|
|
30
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return null;
|
|
31
|
-
const record = entry;
|
|
32
|
-
if (record.accountId && record.accountId !== accountId) return null;
|
|
33
|
-
const conversationId = normalizeOptionalString(record.conversationId);
|
|
34
|
-
const parentConversationId = normalizeOptionalString(record.parentConversationId);
|
|
35
|
-
const targetSessionKey = normalizeOptionalString(record.targetSessionKey) ?? "";
|
|
36
|
-
if (!conversationId || !targetSessionKey) return null;
|
|
37
|
-
const boundAt = resolveOptionalIntegerOption(record.boundAt) ?? Date.now();
|
|
38
|
-
const lastActivityAt = resolveOptionalIntegerOption(record.lastActivityAt) ?? boundAt;
|
|
39
|
-
return {
|
|
40
|
-
accountId,
|
|
41
|
-
conversationId,
|
|
42
|
-
...parentConversationId ? { parentConversationId } : {},
|
|
43
|
-
targetKind: record.targetKind === "subagent" ? "subagent" : "acp",
|
|
44
|
-
targetSessionKey,
|
|
45
|
-
agentId: normalizeOptionalString(record.agentId) || void 0,
|
|
46
|
-
label: normalizeOptionalString(record.label) || void 0,
|
|
47
|
-
boundBy: normalizeOptionalString(record.boundBy) || void 0,
|
|
48
|
-
boundAt,
|
|
49
|
-
lastActivityAt: Math.max(lastActivityAt, boundAt),
|
|
50
|
-
idleTimeoutMs: resolveOptionalIntegerOption(record.idleTimeoutMs, { min: 0 }),
|
|
51
|
-
maxAgeMs: resolveOptionalIntegerOption(record.maxAgeMs, { min: 0 })
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async function loadBindingsFromPluginState(params) {
|
|
55
|
-
const store = createThreadBindingStore(params);
|
|
56
|
-
const loaded = [];
|
|
57
|
-
for (const entry of await store.entries()) {
|
|
58
|
-
const record = normalizeBindingRecord(entry.value, params.accountId);
|
|
59
|
-
if (record) loaded.push(record);
|
|
60
|
-
}
|
|
61
|
-
return loaded;
|
|
62
|
-
}
|
|
63
|
-
function toPluginJsonValue(value) {
|
|
64
|
-
const serialized = JSON.stringify(value);
|
|
65
|
-
return JSON.parse(serialized);
|
|
66
|
-
}
|
|
67
|
-
async function persistBindingsSnapshot(params) {
|
|
68
|
-
const store = createThreadBindingStore(params);
|
|
69
|
-
const liveKeys = new Set(params.bindings.map((record) => buildThreadBindingStoreKey(record)));
|
|
70
|
-
for (const entry of await store.entries()) if (normalizeBindingRecord(entry.value, params.accountId) && !liveKeys.has(entry.key)) await store.delete(entry.key);
|
|
71
|
-
for (const record of params.bindings) await store.register(buildThreadBindingStoreKey(record), toPluginJsonValue(record));
|
|
72
|
-
}
|
|
73
|
-
function buildMatrixBindingIntroText(params) {
|
|
74
|
-
const introText = normalizeOptionalString(params.metadata?.introText);
|
|
75
|
-
if (introText) return introText;
|
|
76
|
-
const label = normalizeOptionalString(params.metadata?.label);
|
|
77
|
-
const agentId = normalizeOptionalString(params.metadata?.agentId) || resolveAgentIdFromSessionKey(params.targetSessionKey);
|
|
78
|
-
return `⚙️ ${label || agentId || "session"} session active. Messages here go directly to this session.`;
|
|
79
|
-
}
|
|
80
|
-
async function sendBindingMessage(params) {
|
|
81
|
-
const trimmed = params.text.trim();
|
|
82
|
-
if (!trimmed) return null;
|
|
83
|
-
return (await sendMessageMatrix(`room:${params.roomId}`, trimmed, {
|
|
84
|
-
cfg: params.cfg,
|
|
85
|
-
client: params.client,
|
|
86
|
-
accountId: params.accountId,
|
|
87
|
-
...params.threadId ? { threadId: params.threadId } : {}
|
|
88
|
-
})).messageId || null;
|
|
89
|
-
}
|
|
90
|
-
async function sendFarewellMessage(params) {
|
|
91
|
-
const roomId = params.record.parentConversationId ?? params.record.conversationId;
|
|
92
|
-
const idleTimeoutMs = typeof params.record.idleTimeoutMs === "number" ? params.record.idleTimeoutMs : params.defaultIdleTimeoutMs;
|
|
93
|
-
const maxAgeMs = typeof params.record.maxAgeMs === "number" ? params.record.maxAgeMs : params.defaultMaxAgeMs;
|
|
94
|
-
const farewellText = resolveThreadBindingFarewellText({
|
|
95
|
-
reason: params.reason,
|
|
96
|
-
idleTimeoutMs,
|
|
97
|
-
maxAgeMs
|
|
98
|
-
});
|
|
99
|
-
await sendBindingMessage({
|
|
100
|
-
cfg: params.cfg,
|
|
101
|
-
client: params.client,
|
|
102
|
-
accountId: params.accountId,
|
|
103
|
-
roomId,
|
|
104
|
-
threadId: params.record.parentConversationId && params.record.parentConversationId !== params.record.conversationId ? params.record.conversationId : void 0,
|
|
105
|
-
text: farewellText
|
|
106
|
-
}).catch(() => {});
|
|
107
|
-
}
|
|
108
|
-
async function createMatrixThreadBindingManager(params) {
|
|
109
|
-
if (params.auth.accountId !== params.accountId) throw new Error(`Matrix thread binding account mismatch: requested ${params.accountId}, auth resolved ${params.auth.accountId}`);
|
|
110
|
-
const legacyFilePath = await resolveMatrixStateFilePath({
|
|
111
|
-
filename: "thread-bindings.json",
|
|
112
|
-
auth: params.auth,
|
|
113
|
-
accountId: params.accountId,
|
|
114
|
-
env: params.env,
|
|
115
|
-
stateDir: params.stateDir
|
|
116
|
-
});
|
|
117
|
-
await assertMatrixSupportedStateFile(legacyFilePath);
|
|
118
|
-
const sqliteStateDir = path.dirname(legacyFilePath);
|
|
119
|
-
const storageKey = resolveMatrixSqliteStateKey({
|
|
120
|
-
env: params.env,
|
|
121
|
-
stateDir: sqliteStateDir
|
|
122
|
-
});
|
|
123
|
-
const existingEntry = getMatrixThreadBindingManagerEntry(params.accountId);
|
|
124
|
-
if (existingEntry) {
|
|
125
|
-
if (existingEntry.storageKey === storageKey) return existingEntry.manager;
|
|
126
|
-
await existingEntry.manager.stop();
|
|
127
|
-
}
|
|
128
|
-
const loaded = await loadBindingsFromPluginState({
|
|
129
|
-
accountId: params.accountId,
|
|
130
|
-
env: params.env,
|
|
131
|
-
stateDir: sqliteStateDir
|
|
132
|
-
});
|
|
133
|
-
for (const record of loaded) setBindingRecord(record);
|
|
134
|
-
let persistQueue = Promise.resolve();
|
|
135
|
-
const enqueuePersist = (bindings) => {
|
|
136
|
-
const snapshot = bindings ?? listBindingsForAccount(params.accountId);
|
|
137
|
-
const next = persistQueue.catch(() => {}).then(async () => {
|
|
138
|
-
await persistBindingsSnapshot({
|
|
139
|
-
accountId: params.accountId,
|
|
140
|
-
bindings: snapshot,
|
|
141
|
-
env: params.env,
|
|
142
|
-
stateDir: sqliteStateDir
|
|
143
|
-
});
|
|
144
|
-
await claimCurrentTokenStorageState({ rootDir: sqliteStateDir });
|
|
145
|
-
});
|
|
146
|
-
persistQueue = next;
|
|
147
|
-
return next;
|
|
148
|
-
};
|
|
149
|
-
const persist = async () => await enqueuePersist();
|
|
150
|
-
const persistSafely = (reason, bindings) => {
|
|
151
|
-
enqueuePersist(bindings).catch((err) => {
|
|
152
|
-
params.logVerboseMessage?.(`matrix: failed persisting thread bindings account=${params.accountId} action=${reason}: ${String(err)}`);
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
const defaults = {
|
|
156
|
-
idleTimeoutMs: params.idleTimeoutMs,
|
|
157
|
-
maxAgeMs: params.maxAgeMs
|
|
158
|
-
};
|
|
159
|
-
let persistTimer = null;
|
|
160
|
-
const schedulePersist = (delayMs) => {
|
|
161
|
-
if (persistTimer) return;
|
|
162
|
-
persistTimer = setTimeout(() => {
|
|
163
|
-
persistTimer = null;
|
|
164
|
-
persistSafely("delayed-touch");
|
|
165
|
-
}, delayMs);
|
|
166
|
-
persistTimer.unref?.();
|
|
167
|
-
};
|
|
168
|
-
const updateBindingsBySessionKey = (input) => {
|
|
169
|
-
const targetSessionKey = input.targetSessionKey.trim();
|
|
170
|
-
if (!targetSessionKey) return [];
|
|
171
|
-
const now = Date.now();
|
|
172
|
-
const nextBindings = listBindingsForAccount(params.accountId).filter((entry) => entry.targetSessionKey === targetSessionKey).map((entry) => Object.assign({}, entry, {
|
|
173
|
-
[input.field]: Math.max(0, Math.floor(input.value)),
|
|
174
|
-
lastActivityAt: now
|
|
175
|
-
}));
|
|
176
|
-
if (nextBindings.length === 0) return [];
|
|
177
|
-
for (const entry of nextBindings) setBindingRecord(entry);
|
|
178
|
-
persistSafely(input.persistReason);
|
|
179
|
-
return nextBindings;
|
|
180
|
-
};
|
|
181
|
-
const manager = {
|
|
182
|
-
accountId: params.accountId,
|
|
183
|
-
getIdleTimeoutMs: () => defaults.idleTimeoutMs,
|
|
184
|
-
getMaxAgeMs: () => defaults.maxAgeMs,
|
|
185
|
-
persist,
|
|
186
|
-
getByConversation: ({ conversationId, parentConversationId }) => listBindingsForAccount(params.accountId).find((entry) => {
|
|
187
|
-
if (entry.conversationId !== conversationId.trim()) return false;
|
|
188
|
-
if (!parentConversationId) return true;
|
|
189
|
-
return (entry.parentConversationId ?? "") === parentConversationId.trim();
|
|
190
|
-
}),
|
|
191
|
-
listBySessionKey: (targetSessionKey) => listBindingsForAccount(params.accountId).filter((entry) => entry.targetSessionKey === targetSessionKey.trim()),
|
|
192
|
-
listBindings: () => listBindingsForAccount(params.accountId),
|
|
193
|
-
touchBinding: (bindingId, at) => {
|
|
194
|
-
const record = listBindingsForAccount(params.accountId).find((entry) => resolveBindingKey(entry) === bindingId.trim());
|
|
195
|
-
if (!record) return null;
|
|
196
|
-
const nextRecord = {
|
|
197
|
-
...record,
|
|
198
|
-
lastActivityAt: typeof at === "number" && Number.isFinite(at) ? Math.max(record.lastActivityAt, Math.floor(at)) : Date.now()
|
|
199
|
-
};
|
|
200
|
-
setBindingRecord(nextRecord);
|
|
201
|
-
schedulePersist(TOUCH_PERSIST_DELAY_MS);
|
|
202
|
-
return nextRecord;
|
|
203
|
-
},
|
|
204
|
-
setIdleTimeoutBySessionKey: ({ targetSessionKey, idleTimeoutMs }) => updateBindingsBySessionKey({
|
|
205
|
-
targetSessionKey,
|
|
206
|
-
field: "idleTimeoutMs",
|
|
207
|
-
value: idleTimeoutMs,
|
|
208
|
-
persistReason: "idle-timeout-update"
|
|
209
|
-
}),
|
|
210
|
-
setMaxAgeBySessionKey: ({ targetSessionKey, maxAgeMs }) => updateBindingsBySessionKey({
|
|
211
|
-
targetSessionKey,
|
|
212
|
-
field: "maxAgeMs",
|
|
213
|
-
value: maxAgeMs,
|
|
214
|
-
persistReason: "max-age-update"
|
|
215
|
-
}),
|
|
216
|
-
stop: async () => {
|
|
217
|
-
if (sweepTimer) clearInterval(sweepTimer);
|
|
218
|
-
let finalPersist = persistQueue;
|
|
219
|
-
if (persistTimer) {
|
|
220
|
-
clearTimeout(persistTimer);
|
|
221
|
-
persistTimer = null;
|
|
222
|
-
finalPersist = enqueuePersist();
|
|
223
|
-
}
|
|
224
|
-
unregisterSessionBindingAdapter({
|
|
225
|
-
channel: "matrix",
|
|
226
|
-
accountId: params.accountId,
|
|
227
|
-
adapter: sessionBindingAdapter
|
|
228
|
-
});
|
|
229
|
-
if (getMatrixThreadBindingManagerEntry(params.accountId)?.manager === manager) {
|
|
230
|
-
deleteMatrixThreadBindingManagerEntry(params.accountId);
|
|
231
|
-
for (const record of listBindingsForAccount(params.accountId)) removeBindingRecord(record);
|
|
232
|
-
}
|
|
233
|
-
await finalPersist;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
let sweepTimer = null;
|
|
237
|
-
const unbindRecords = async (records, reason, onRemoved) => {
|
|
238
|
-
const removed = records.map((record) => removeBindingRecord(record)).filter((record) => Boolean(record));
|
|
239
|
-
if (removed.length === 0) return [];
|
|
240
|
-
removed.forEach((record) => onRemoved?.(record));
|
|
241
|
-
await persist();
|
|
242
|
-
await Promise.all(removed.map((record) => sendFarewellMessage({
|
|
243
|
-
cfg: params.cfg,
|
|
244
|
-
client: params.client,
|
|
245
|
-
accountId: params.accountId,
|
|
246
|
-
record,
|
|
247
|
-
defaultIdleTimeoutMs: defaults.idleTimeoutMs,
|
|
248
|
-
defaultMaxAgeMs: defaults.maxAgeMs,
|
|
249
|
-
reason: typeof reason === "function" ? reason(record) : reason
|
|
250
|
-
})));
|
|
251
|
-
return removed.map((record) => toSessionBindingRecord(record, defaults));
|
|
252
|
-
};
|
|
253
|
-
const sessionBindingAdapter = {
|
|
254
|
-
channel: "matrix",
|
|
255
|
-
accountId: params.accountId,
|
|
256
|
-
capabilities: {
|
|
257
|
-
placements: ["current", "child"],
|
|
258
|
-
bindSupported: true,
|
|
259
|
-
unbindSupported: true
|
|
260
|
-
},
|
|
261
|
-
bind: async (input) => {
|
|
262
|
-
const conversationId = input.conversation.conversationId.trim();
|
|
263
|
-
const parentConversationId = normalizeOptionalString(input.conversation.parentConversationId);
|
|
264
|
-
const targetSessionKey = input.targetSessionKey.trim();
|
|
265
|
-
if (!conversationId || !targetSessionKey) return null;
|
|
266
|
-
let boundConversationId = conversationId;
|
|
267
|
-
let boundParentConversationId = parentConversationId;
|
|
268
|
-
const introText = buildMatrixBindingIntroText({
|
|
269
|
-
metadata: input.metadata,
|
|
270
|
-
targetSessionKey
|
|
271
|
-
});
|
|
272
|
-
if (input.placement === "child") {
|
|
273
|
-
const roomId = parentConversationId || conversationId;
|
|
274
|
-
const rootEventId = await sendBindingMessage({
|
|
275
|
-
cfg: params.cfg,
|
|
276
|
-
client: params.client,
|
|
277
|
-
accountId: params.accountId,
|
|
278
|
-
roomId,
|
|
279
|
-
text: introText
|
|
280
|
-
});
|
|
281
|
-
if (!rootEventId) return null;
|
|
282
|
-
boundConversationId = rootEventId;
|
|
283
|
-
boundParentConversationId = roomId;
|
|
284
|
-
}
|
|
285
|
-
const now = Date.now();
|
|
286
|
-
const record = {
|
|
287
|
-
accountId: params.accountId,
|
|
288
|
-
conversationId: boundConversationId,
|
|
289
|
-
...boundParentConversationId ? { parentConversationId: boundParentConversationId } : {},
|
|
290
|
-
targetKind: input.targetKind === "subagent" ? "subagent" : "acp",
|
|
291
|
-
targetSessionKey,
|
|
292
|
-
agentId: normalizeOptionalString(input.metadata?.agentId) ?? resolveSessionAgentIdStrict({
|
|
293
|
-
config: params.cfg,
|
|
294
|
-
sessionKey: targetSessionKey
|
|
295
|
-
}),
|
|
296
|
-
label: normalizeOptionalString(input.metadata?.label) || void 0,
|
|
297
|
-
boundBy: normalizeOptionalString(input.metadata?.boundBy) || "system",
|
|
298
|
-
boundAt: now,
|
|
299
|
-
lastActivityAt: now,
|
|
300
|
-
idleTimeoutMs: defaults.idleTimeoutMs,
|
|
301
|
-
maxAgeMs: defaults.maxAgeMs
|
|
302
|
-
};
|
|
303
|
-
setBindingRecord(record);
|
|
304
|
-
await persist();
|
|
305
|
-
if (input.placement === "current" && introText) {
|
|
306
|
-
const roomId = boundParentConversationId || boundConversationId;
|
|
307
|
-
const threadId = boundParentConversationId && boundParentConversationId !== boundConversationId ? boundConversationId : void 0;
|
|
308
|
-
await sendBindingMessage({
|
|
309
|
-
cfg: params.cfg,
|
|
310
|
-
client: params.client,
|
|
311
|
-
accountId: params.accountId,
|
|
312
|
-
roomId,
|
|
313
|
-
threadId,
|
|
314
|
-
text: introText
|
|
315
|
-
}).catch(() => {});
|
|
316
|
-
}
|
|
317
|
-
return toSessionBindingRecord(record, defaults);
|
|
318
|
-
},
|
|
319
|
-
listBySession: (targetSessionKey) => manager.listBySessionKey(targetSessionKey).map((record) => toSessionBindingRecord(record, defaults)),
|
|
320
|
-
resolveByConversation: (ref) => {
|
|
321
|
-
const record = manager.getByConversation(ref);
|
|
322
|
-
return record ? toSessionBindingRecord(record, defaults) : null;
|
|
323
|
-
},
|
|
324
|
-
touch: (bindingId, at) => {
|
|
325
|
-
manager.touchBinding(bindingId, at);
|
|
326
|
-
},
|
|
327
|
-
unbind: async (input) => {
|
|
328
|
-
return unbindRecords(listBindingsForAccount(params.accountId).filter((record) => {
|
|
329
|
-
if (input.bindingId?.trim()) return resolveBindingKey(record) === input.bindingId.trim();
|
|
330
|
-
if (input.targetSessionKey?.trim()) return record.targetSessionKey === input.targetSessionKey.trim();
|
|
331
|
-
return false;
|
|
332
|
-
}), input.reason);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
registerSessionBindingAdapter(sessionBindingAdapter);
|
|
336
|
-
if (params.enableSweeper !== false) {
|
|
337
|
-
sweepTimer = setInterval(() => {
|
|
338
|
-
const now = Date.now();
|
|
339
|
-
const expired = listBindingsForAccount(params.accountId).map((record) => ({
|
|
340
|
-
record,
|
|
341
|
-
lifecycle: resolveThreadBindingLifecycle({
|
|
342
|
-
record,
|
|
343
|
-
defaultIdleTimeoutMs: defaults.idleTimeoutMs,
|
|
344
|
-
defaultMaxAgeMs: defaults.maxAgeMs
|
|
345
|
-
})
|
|
346
|
-
})).filter((entry) => typeof entry.lifecycle.expiresAt === "number" && entry.lifecycle.expiresAt <= now && Boolean(entry.lifecycle.reason));
|
|
347
|
-
if (expired.length === 0) return;
|
|
348
|
-
const reasonByBindingKey = new Map(expired.map(({ record, lifecycle }) => [resolveBindingKey(record), lifecycle.reason]));
|
|
349
|
-
unbindRecords(expired.map(({ record }) => record), (record) => reasonByBindingKey.get(resolveBindingKey(record)), (record) => {
|
|
350
|
-
const reason = reasonByBindingKey.get(resolveBindingKey(record));
|
|
351
|
-
params.logVerboseMessage?.(`matrix: auto-unbinding ${record.conversationId} due to ${reason}`);
|
|
352
|
-
}).catch((err) => {
|
|
353
|
-
params.logVerboseMessage?.(`matrix: failed auto-unbinding expired bindings account=${params.accountId}: ${String(err)}`);
|
|
354
|
-
});
|
|
355
|
-
}, THREAD_BINDINGS_SWEEP_INTERVAL_MS);
|
|
356
|
-
sweepTimer.unref?.();
|
|
357
|
-
}
|
|
358
|
-
setMatrixThreadBindingManagerEntry(params.accountId, {
|
|
359
|
-
storageKey,
|
|
360
|
-
manager
|
|
361
|
-
});
|
|
362
|
-
return manager;
|
|
363
|
-
}
|
|
364
|
-
//#endregion
|
|
365
|
-
export { createMatrixThreadBindingManager as t };
|