machine-bridge-mcp 3.0.0-beta.20 → 3.0.0-beta.201
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/CHANGELOG.md +12 -1089
- package/README.md +93 -31
- package/SECURITY.md +39 -16
- package/SUPPORT.md +3 -1
- package/bin/machine-mcp.mjs +2 -1
- package/browser-extension/broker-auth.js +85 -0
- package/browser-extension/broker-liveness.js +35 -0
- package/browser-extension/browser-error-boundary.js +51 -0
- package/browser-extension/browser-operation-contract.js +92 -0
- package/browser-extension/browser-operations.js +1386 -106
- package/browser-extension/devtools-input.js +195 -34
- package/browser-extension/devtools-observation.js +429 -0
- package/browser-extension/devtools-session.js +48 -0
- package/browser-extension/manifest.json +2 -3
- package/browser-extension/page-automation.js +614 -132
- package/browser-extension/pairing-bootstrap.js +41 -0
- package/browser-extension/pairing.js +38 -12
- package/browser-extension/service-worker.js +93 -97
- package/cloudflare.config.ts +23 -0
- package/docs/AGENT_CONTEXT.md +27 -28
- package/docs/AUDIT.md +37 -542
- package/docs/CLIENTS.md +19 -15
- package/docs/COMPUTER_USE.md +297 -0
- package/docs/GETTING_STARTED.md +12 -24
- package/docs/LOCAL_AUTHORIZATION.md +4 -4
- package/docs/LOCAL_AUTOMATION.md +33 -23
- package/docs/LOGGING.md +47 -27
- package/docs/MANAGED_JOBS.md +60 -14
- package/docs/MULTI_ACCOUNT.md +12 -10
- package/docs/OPERATIONS.md +175 -66
- package/docs/OVERVIEW.md +12 -8
- package/docs/POLICY_REFERENCE.md +71 -3
- package/docs/PRIVACY.md +60 -6
- package/docs/THREAT_MODEL.md +46 -16
- package/docs/TOOL_REFERENCE.md +682 -63
- package/docs/UPGRADING.md +64 -96
- package/mbm.cmd +3 -3
- package/native/macos/MachineBridgeBackgroundInput.swift +1051 -0
- package/native/macos/MachineBridgeBackgroundInputSmokeFixture.swift +295 -0
- package/native/macos/MachineBridgeTrustBroker.swift +52 -8
- package/package.json +135 -28
- package/scripts/accepted-candidate-tarball.mjs +115 -0
- package/scripts/candidate-runtime-store.mjs +64 -9
- package/scripts/consumer-package-security.mjs +322 -0
- package/scripts/coverage-generation.mjs +41 -0
- package/scripts/foreground-daemon-recovery.mjs +88 -0
- package/scripts/github-backlog.mjs +43 -12
- package/scripts/github-push.mjs +58 -23
- package/scripts/github-release-asset.mjs +58 -0
- package/scripts/github-release.mjs +272 -165
- package/scripts/global-package-installation.mjs +68 -0
- package/scripts/hardened-npm-session.mjs +44 -0
- package/scripts/install-published-prerelease.mjs +109 -77
- package/scripts/local-release-acceptance.mjs +89 -42
- package/scripts/network-retry.mjs +10 -1
- package/scripts/npm-global-prefix.mjs +27 -0
- package/scripts/npm-publication-policy.mjs +2 -1
- package/scripts/persistent-activation-process.mjs +82 -0
- package/scripts/prerelease-activation.mjs +117 -23
- package/scripts/privacy-check.mjs +120 -21
- package/scripts/promotion-digest.mjs +21 -10
- package/scripts/publish-npm.mjs +314 -22
- package/scripts/published-release.mjs +65 -20
- package/scripts/release-acceptance.mjs +53 -70
- package/scripts/release-browser-extension-store.mjs +172 -0
- package/scripts/release-candidate-manifest.mjs +24 -9
- package/scripts/release-channel.mjs +1 -1
- package/scripts/release-ci.mjs +88 -9
- package/scripts/release-diagnostic.mjs +41 -0
- package/scripts/release-impact-check.mjs +2 -1
- package/scripts/release-oauth-canary-core.mjs +332 -0
- package/scripts/release-oauth-canary-evidence.mjs +102 -0
- package/scripts/release-oauth-canary.mjs +127 -0
- package/scripts/release-publication-guard.mjs +50 -0
- package/scripts/release-soak.mjs +81 -31
- package/scripts/release-state.mjs +1 -1
- package/scripts/sbom-check.mjs +106 -0
- package/scripts/source-dependency-tree.mjs +21 -0
- package/scripts/start-release-candidate.mjs +199 -83
- package/scripts/verification-state.mjs +109 -0
- package/src/local/account-access.mjs +9 -2
- package/src/local/account-admin-response.mjs +92 -0
- package/src/local/account-admin.mjs +42 -84
- package/src/local/agent-context-projection.mjs +37 -8
- package/src/local/agent-context.mjs +92 -20
- package/src/local/agent-contract.mjs +21 -1
- package/src/local/agent-skill-discovery.mjs +49 -14
- package/src/local/agent-text-file.mjs +38 -13
- package/src/local/app-automation-macos-jxa.mjs +350 -0
- package/src/local/app-automation.mjs +790 -154
- package/src/local/application-capability-match.mjs +15 -0
- package/src/local/application-capability-projection.mjs +24 -0
- package/src/local/atomic-fs.mjs +31 -3
- package/src/local/authority-context.mjs +10 -6
- package/src/local/autostart-log-maintenance.mjs +36 -0
- package/src/local/bounded-output.mjs +11 -14
- package/src/local/browser-bridge-http.mjs +1 -2
- package/src/local/browser-bridge.mjs +94 -27
- package/src/local/browser-broker-auth-http.mjs +67 -0
- package/src/local/browser-broker-auth.mjs +99 -0
- package/src/local/browser-broker-routes.mjs +60 -21
- package/src/local/browser-broker-server.mjs +27 -8
- package/src/local/browser-command.mjs +81 -30
- package/src/local/browser-computer-observation-service.mjs +209 -0
- package/src/local/browser-extension-identity.mjs +5 -3
- package/src/local/browser-extension-path.mjs +22 -0
- package/src/local/browser-extension-protocol.mjs +43 -9
- package/src/local/browser-operation-service.mjs +138 -123
- package/src/local/browser-pairing-grant.mjs +109 -0
- package/src/local/browser-pairing-http.mjs +4 -4
- package/src/local/browser-pairing-launch.mjs +58 -0
- package/src/local/browser-pairing-store.mjs +81 -56
- package/src/local/browser-request-registry.mjs +40 -14
- package/src/local/browser-request-settlement.mjs +78 -0
- package/src/local/browser-resource-input.mjs +74 -0
- package/src/local/browser-trusted-input-health.mjs +63 -0
- package/src/local/call-authority.mjs +30 -0
- package/src/local/call-capacity.mjs +45 -0
- package/src/local/call-registry-drain.mjs +54 -0
- package/src/local/call-registry.mjs +30 -15
- package/src/local/capability-observer.mjs +5 -0
- package/src/local/capability-ranking.mjs +3 -2
- package/src/local/cf-authentication.mjs +58 -0
- package/src/local/cf-network-integrity.mjs +68 -0
- package/src/local/cf-project.mjs +108 -0
- package/src/local/child-process-settlement.mjs +132 -0
- package/src/local/cli-account-admin.mjs +3 -4
- package/src/local/cli-activate.mjs +88 -12
- package/src/local/cli-idle-sleep.mjs +15 -0
- package/src/local/cli-local-admin.mjs +64 -43
- package/src/local/cli-options.mjs +10 -9
- package/src/local/cli-policy.mjs +1 -1
- package/src/local/cli-ready-output.mjs +52 -0
- package/src/local/cli-service.mjs +59 -7
- package/src/local/cli.mjs +174 -182
- package/src/local/computer-use-application-observation.mjs +224 -0
- package/src/local/computer-use-arguments.mjs +266 -0
- package/src/local/computer-use-deadline.mjs +50 -0
- package/src/local/computer-use-dispatch-settlement.mjs +40 -0
- package/src/local/computer-use-expectation.mjs +171 -0
- package/src/local/computer-use-observation-contract.mjs +129 -0
- package/src/local/computer-use-observation.mjs +779 -0
- package/src/local/computer-use-recovery.mjs +82 -0
- package/src/local/computer-use-result-budget.mjs +145 -0
- package/src/local/computer-use-snapshot-store.mjs +67 -0
- package/src/local/computer-use.mjs +2163 -0
- package/src/local/daemon-http-relay-auth.mjs +26 -0
- package/src/local/daemon-http-relay-connection.mjs +406 -0
- package/src/local/daemon-http-relay-request.mjs +74 -0
- package/src/local/daemon-http-relay-sequence.mjs +51 -0
- package/src/local/daemon-http-retry-policy.mjs +23 -0
- package/src/local/daemon-process.mjs +54 -16
- package/src/local/default-instructions.mjs +11 -0
- package/src/local/delegated-process-sandbox.mjs +31 -8
- package/src/local/device-identity.mjs +45 -32
- package/src/local/device-root-provider.mjs +7 -7
- package/src/local/directory-metadata.mjs +47 -0
- package/src/local/doctor-reporting.mjs +23 -0
- package/src/local/durable-process-initial-settlement.mjs +40 -0
- package/src/local/durable-process-spec.mjs +76 -0
- package/src/local/errors.mjs +0 -12
- package/src/local/exclusive-file.mjs +82 -29
- package/src/local/exclusive-publication-recovery.mjs +113 -0
- package/src/local/execution-limits.mjs +9 -0
- package/src/local/execution-routing-intent.mjs +108 -0
- package/src/local/execution-routing.mjs +266 -0
- package/src/local/execution-surface.mjs +23 -0
- package/src/local/file-mutation-coordinator.mjs +47 -0
- package/src/local/file-snapshot-preservation.mjs +24 -0
- package/src/local/filesystem-identity.mjs +54 -0
- package/src/local/fixed-process-environment.mjs +21 -0
- package/src/local/full-access-test.mjs +49 -20
- package/src/local/git-commit.mjs +69 -0
- package/src/local/git-config-safety.mjs +55 -0
- package/src/local/git-log-parser.mjs +41 -0
- package/src/local/git-metadata-boundary.mjs +77 -0
- package/src/local/git-metadata-tree-safety.mjs +59 -0
- package/src/local/git-operation-state.mjs +19 -0
- package/src/local/git-service.mjs +155 -21
- package/src/local/git-version.mjs +11 -0
- package/src/local/hardened-npm-download-timeout.mjs +46 -0
- package/src/local/hardened-npm-download.mjs +109 -0
- package/src/local/hardened-npm-extract.mjs +20 -0
- package/src/local/hardened-npm-launcher.mjs +48 -0
- package/src/local/hardened-npm-verification.mjs +104 -0
- package/src/local/hardened-npm.mjs +202 -0
- package/src/local/hosted-file-read-budget.mjs +53 -0
- package/src/local/idle-sleep-mode.mjs +9 -0
- package/src/local/job-runner.mjs +325 -164
- package/src/local/lifecycle.mjs +6 -0
- package/src/local/log.mjs +5 -6
- package/src/local/loopback-health.mjs +5 -0
- package/src/local/macos-background-input.mjs +398 -0
- package/src/local/macos-idle-sleep-assertion.mjs +79 -0
- package/src/local/macos-idle-sleep-recovery.mjs +52 -0
- package/src/local/macos-trust-broker.mjs +141 -52
- package/src/local/managed-job-acceptance.mjs +30 -0
- package/src/local/managed-job-active-child.mjs +154 -0
- package/src/local/managed-job-activity.mjs +27 -0
- package/src/local/managed-job-cancellation.mjs +42 -0
- package/src/local/managed-job-capacity.mjs +17 -0
- package/src/local/managed-job-dependencies.mjs +180 -0
- package/src/local/managed-job-dependency-admission.mjs +44 -0
- package/src/local/managed-job-dependency-metadata.mjs +16 -0
- package/src/local/managed-job-dependency-retention.mjs +38 -0
- package/src/local/managed-job-directory-generation.mjs +60 -0
- package/src/local/managed-job-directory.mjs +77 -0
- package/src/local/managed-job-durable-process.mjs +50 -0
- package/src/local/managed-job-hosted-reconcile.mjs +16 -0
- package/src/local/managed-job-hosted-status.mjs +35 -0
- package/src/local/managed-job-idempotency.mjs +29 -0
- package/src/local/managed-job-listing.mjs +57 -0
- package/src/local/managed-job-lock.mjs +46 -27
- package/src/local/managed-job-output-redaction.mjs +163 -0
- package/src/local/managed-job-plan-integrity.mjs +13 -0
- package/src/local/managed-job-plan.mjs +70 -15
- package/src/local/managed-job-projection.mjs +36 -20
- package/src/local/managed-job-read-policy.mjs +39 -0
- package/src/local/managed-job-read-wait.mjs +65 -0
- package/src/local/managed-job-recovery-history.mjs +49 -0
- package/src/local/managed-job-recovery-listing.mjs +27 -0
- package/src/local/managed-job-relaunch.mjs +53 -0
- package/src/local/managed-job-resource-context.mjs +17 -0
- package/src/local/managed-job-retention-policy.mjs +54 -0
- package/src/local/managed-job-retention.mjs +125 -0
- package/src/local/managed-job-runner-claim.mjs +107 -0
- package/src/local/managed-job-runner-exit-recovery.mjs +48 -0
- package/src/local/managed-job-runner-liveness.mjs +44 -0
- package/src/local/managed-job-runner.mjs +56 -43
- package/src/local/managed-job-state-validation.mjs +28 -0
- package/src/local/managed-job-storage.mjs +20 -5
- package/src/local/managed-job-terminal-maintenance.mjs +48 -0
- package/src/local/managed-job-terminal.mjs +17 -3
- package/src/local/managed-job-transient-recovery-capacity.mjs +141 -0
- package/src/local/managed-job-transient-recovery.mjs +30 -0
- package/src/local/managed-jobs.mjs +448 -367
- package/src/local/network-proxy.mjs +64 -4
- package/src/local/npm-audit-report.mjs +21 -0
- package/src/local/npm-cli.mjs +42 -0
- package/src/local/npm-environment.mjs +31 -0
- package/src/local/numbers.mjs +6 -0
- package/src/local/observability.mjs +4 -7
- package/src/local/operation-authorization.mjs +38 -130
- package/src/local/operation-risk.mjs +37 -6
- package/src/local/owner-state-lock.mjs +43 -18
- package/src/local/package-identity.mjs +9 -0
- package/src/local/patch.mjs +20 -18
- package/src/local/private-toolchain-integrity.mjs +54 -0
- package/src/local/process-contract.mjs +9 -0
- package/src/local/process-error-message.mjs +6 -0
- package/src/local/process-execution.mjs +89 -89
- package/src/local/process-foreground-timeout.mjs +50 -0
- package/src/local/process-identity.mjs +118 -11
- package/src/local/process-lock-read-retry.mjs +15 -0
- package/src/local/process-nonreplayable-settlement.mjs +50 -0
- package/src/local/process-output-stream.mjs +5 -7
- package/src/local/process-result-projection.mjs +22 -0
- package/src/local/process-session-events.mjs +42 -0
- package/src/local/process-session-read.mjs +65 -0
- package/src/local/process-session-remote-activity.mjs +10 -0
- package/src/local/process-session-remote-poll.mjs +37 -0
- package/src/local/process-session-termination.mjs +73 -0
- package/src/local/process-sessions.mjs +137 -125
- package/src/local/process-tracker.mjs +128 -13
- package/src/local/process-tree-force-settlement.mjs +44 -0
- package/src/local/process-tree-ownership-types.d.ts +37 -0
- package/src/local/process-tree-ownership.mjs +39 -41
- package/src/local/process-tree-signal.mjs +34 -0
- package/src/local/process-tree-snapshot.mjs +77 -0
- package/src/local/process-tree-supervisor.mjs +69 -0
- package/src/local/process-tree.mjs +9 -54
- package/src/local/project-metadata.mjs +19 -6
- package/src/local/relay-call-recovery.mjs +75 -57
- package/src/local/relay-connect-timing.mjs +66 -0
- package/src/local/relay-connection-classification.mjs +142 -0
- package/src/local/relay-connection-support.mjs +101 -0
- package/src/local/relay-connection.mjs +199 -291
- package/src/local/relay-diagnostics.mjs +94 -6
- package/src/local/relay-heartbeat-options.mjs +16 -0
- package/src/local/relay-heartbeat-stall.mjs +47 -0
- package/src/local/relay-heartbeat-transport-state.mjs +30 -0
- package/src/local/relay-heartbeat.mjs +115 -0
- package/src/local/relay-inbound-state.mjs +41 -0
- package/src/local/relay-liveness-actions.mjs +66 -0
- package/src/local/relay-liveness.mjs +107 -0
- package/src/local/relay-peer-diagnostics.mjs +145 -0
- package/src/local/relay-probe-deadline.mjs +44 -0
- package/src/local/relay-probe-dispatch-metrics.mjs +22 -0
- package/src/local/relay-probe-dispatch.mjs +38 -0
- package/src/local/relay-reconnect.mjs +40 -0
- package/src/local/relay-recovery-admission.mjs +19 -0
- package/src/local/relay-recovery-capacity.mjs +29 -0
- package/src/local/relay-recovery-diagnostics.mjs +28 -0
- package/src/local/relay-redelivery-safety.mjs +43 -0
- package/src/local/relay-result-retention.mjs +66 -0
- package/src/local/relay-tool-schema-extension.mjs +31 -0
- package/src/local/relay-transport-confirmation.mjs +79 -0
- package/src/local/relay-transport-error-state.mjs +48 -0
- package/src/local/relay-transport-probe-send.mjs +27 -0
- package/src/local/relay-transport-probe.mjs +26 -0
- package/src/local/release-runtime-lock.mjs +18 -0
- package/src/local/remote-activity-idle-sleep-guard.mjs +79 -0
- package/src/local/remote-activity-idle-sleep-timeline.mjs +33 -0
- package/src/local/remote-configuration.mjs +6 -4
- package/src/local/remote-idle-sleep-assertions.mjs +41 -0
- package/src/local/resilient-relay-connection.mjs +332 -0
- package/src/local/resource-admission-diagnostic-error.mjs +21 -0
- package/src/local/resource-admission-diagnostics.mjs +50 -0
- package/src/local/resource-admission-policy.mjs +115 -0
- package/src/local/resource-admission.mjs +339 -0
- package/src/local/resource-build-root.mjs +83 -0
- package/src/local/resource-cargo-concurrency.mjs +38 -0
- package/src/local/resource-cmake-concurrency.mjs +42 -0
- package/src/local/resource-command-concurrency.mjs +37 -0
- package/src/local/resource-command-profile.mjs +176 -0
- package/src/local/resource-coordinator-accounting.mjs +21 -0
- package/src/local/resource-cpu-window.mjs +20 -0
- package/src/local/resource-disk-headroom.mjs +13 -0
- package/src/local/resource-elastic-memory.mjs +19 -0
- package/src/local/resource-elastic-request.mjs +36 -0
- package/src/local/resource-foreground-wait.mjs +29 -0
- package/src/local/resource-go-concurrency.mjs +43 -0
- package/src/local/resource-gradle-concurrency.mjs +57 -0
- package/src/local/resource-host-cache.mjs +39 -0
- package/src/local/resource-host-darwin.mjs +44 -0
- package/src/local/resource-host-linux.mjs +35 -0
- package/src/local/resource-host-sample-file.mjs +7 -0
- package/src/local/resource-host-snapshot.mjs +81 -0
- package/src/local/resource-lease-accounting.mjs +119 -0
- package/src/local/resource-lease-liveness.mjs +31 -0
- package/src/local/resource-light-command.mjs +19 -0
- package/src/local/resource-make-concurrency.mjs +42 -0
- package/src/local/resource-maven-concurrency.mjs +38 -0
- package/src/local/resource-ninja-command-concurrency.mjs +20 -0
- package/src/local/resource-ninja-concurrency.mjs +28 -0
- package/src/local/resource-operations.mjs +8 -21
- package/src/local/resource-pressure.mjs +86 -0
- package/src/local/resource-probe-command.mjs +27 -0
- package/src/local/resource-process-admission.mjs +59 -0
- package/src/local/resource-process-ancestry-cache.mjs +34 -0
- package/src/local/resource-process-ancestry.mjs +26 -0
- package/src/local/resource-process-priority.mjs +15 -0
- package/src/local/resource-project-key.mjs +53 -0
- package/src/local/resource-pytest-concurrency.mjs +33 -0
- package/src/local/resource-release-control-classification.mjs +14 -0
- package/src/local/resource-release-control-executable.mjs +70 -0
- package/src/local/resource-release-control-workspace.mjs +41 -0
- package/src/local/resource-request-contract.mjs +31 -0
- package/src/local/resource-script-classification.mjs +44 -0
- package/src/local/resource-shell-analysis.mjs +58 -0
- package/src/local/resource-staging-recovery.mjs +90 -0
- package/src/local/resource-state-file.mjs +22 -0
- package/src/local/resource-swift-concurrency.mjs +31 -0
- package/src/local/resource-transaction-lock.mjs +117 -0
- package/src/local/resource-wait.mjs +48 -0
- package/src/local/resource-waiter-diagnostics.mjs +42 -0
- package/src/local/resource-waiters.mjs +138 -0
- package/src/local/resource-xcode-command.mjs +7 -0
- package/src/local/resource-xcode-concurrency.mjs +34 -0
- package/src/local/resource-xcode-non-build.mjs +19 -0
- package/src/local/runtime-activation.mjs +599 -33
- package/src/local/runtime-activity-projection.mjs +48 -0
- package/src/local/runtime-application-automation.mjs +26 -0
- package/src/local/runtime-capabilities.mjs +38 -22
- package/src/local/runtime-device-session.mjs +111 -0
- package/src/local/runtime-diagnostic-projection.mjs +44 -0
- package/src/local/runtime-diagnostic-state.mjs +34 -0
- package/src/local/runtime-diagnostics.mjs +35 -34
- package/src/local/runtime-info-projection.mjs +65 -0
- package/src/local/runtime-info-relay-projection.mjs +23 -0
- package/src/local/runtime-node-executable.mjs +84 -0
- package/src/local/runtime-package-identity.mjs +62 -0
- package/src/local/runtime-paths.mjs +2 -1
- package/src/local/runtime-process-routing.mjs +51 -0
- package/src/local/runtime-relay-acknowledgements.mjs +17 -0
- package/src/local/runtime-relay-connection-options.mjs +53 -0
- package/src/local/runtime-relay-control.mjs +203 -0
- package/src/local/runtime-relay-shutdown-drain.mjs +53 -0
- package/src/local/runtime-relay.mjs +26 -48
- package/src/local/runtime-reporting.mjs +39 -22
- package/src/local/runtime-resource-service.mjs +3 -3
- package/src/local/runtime-tool-handlers.mjs +19 -5
- package/src/local/runtime.mjs +183 -151
- package/src/local/secure-file.mjs +74 -25
- package/src/local/security-audit-activity.mjs +87 -0
- package/src/local/security-audit-beta198-migration.mjs +50 -0
- package/src/local/security-audit-dispatch.mjs +47 -0
- package/src/local/security-audit-gate.mjs +38 -0
- package/src/local/security-audit-log.mjs +186 -171
- package/src/local/security-audit-state.mjs +176 -0
- package/src/local/security-audit-storage.mjs +146 -0
- package/src/local/security-audit-warning.mjs +31 -0
- package/src/local/security-audit-worker.mjs +87 -0
- package/src/local/service-convergence.mjs +29 -4
- package/src/local/service-definition.mjs +24 -0
- package/src/local/service-environment.mjs +24 -14
- package/src/local/service-owner.mjs +146 -0
- package/src/local/service-ownership.mjs +1 -1
- package/src/local/service-restart-handoff.mjs +22 -8
- package/src/local/service-restartability.mjs +20 -0
- package/src/local/service-runtime-convergence.mjs +52 -0
- package/src/local/service-runtime.mjs +105 -0
- package/src/local/service-status.mjs +21 -8
- package/src/local/service.mjs +298 -87
- package/src/local/shell.mjs +115 -36
- package/src/local/short-identifiers.mjs +4 -0
- package/src/local/ssh-key.mjs +157 -45
- package/src/local/state-inventory.mjs +36 -28
- package/src/local/state-owner-lock-inventory.mjs +23 -0
- package/src/local/state-root-owned-namespaces.mjs +72 -0
- package/src/local/state-root-retirement.mjs +89 -0
- package/src/local/state.mjs +274 -116
- package/src/local/stdio.mjs +94 -69
- package/src/local/support-state-projection.mjs +30 -0
- package/src/local/system-network-route.mjs +76 -0
- package/src/local/system-sleep-diagnostics.mjs +190 -0
- package/src/local/systemd-removal.mjs +20 -0
- package/src/local/tool-executor.mjs +72 -40
- package/src/local/toolchain-operation-lock.mjs +41 -0
- package/src/local/tools.mjs +6 -5
- package/src/local/windows-service-convergence.mjs +49 -0
- package/src/local/windows-service.mjs +57 -64
- package/src/local/worker-deployment-fingerprint.mjs +146 -0
- package/src/local/worker-deployment.mjs +85 -80
- package/src/local/worker-health.mjs +33 -10
- package/src/local/worker-identity-contract.mjs +14 -0
- package/src/local/worker-secret-file.mjs +53 -21
- package/src/local/workspace-file-service.mjs +130 -235
- package/src/local/workspace-file-transaction.mjs +189 -0
- package/src/local/workspace-profile-migration.mjs +570 -0
- package/src/local/workspace-search.mjs +55 -0
- package/src/local/wrangler-toolchain/package-lock.json +1563 -0
- package/src/local/wrangler-toolchain/package.json +25 -0
- package/src/local/wrangler-toolchain-installed-tree.mjs +43 -0
- package/src/local/wrangler-toolchain-verification.mjs +121 -0
- package/src/local/wrangler-toolchain.mjs +206 -0
- package/src/shared/access-contract.json +7 -1
- package/src/shared/activation-recovery.mjs +49 -0
- package/src/shared/admin-auth.mjs +6 -7
- package/src/shared/authority-revocation.d.mts +9 -0
- package/src/shared/authority-revocation.mjs +29 -0
- package/src/shared/daemon-auth.d.mts +11 -0
- package/src/shared/daemon-auth.mjs +23 -7
- package/src/shared/device-session-auth.mjs +8 -7
- package/src/shared/foreground-timeout.d.mts +15 -0
- package/src/shared/foreground-timeout.mjs +70 -0
- package/src/shared/log-redaction.d.mts +2 -0
- package/src/shared/log-redaction.mjs +43 -14
- package/src/shared/mcp-protocol.d.mts +29 -0
- package/src/shared/mcp-protocol.mjs +300 -0
- package/src/shared/project-overview-projection.d.mts +4 -0
- package/src/shared/project-overview-projection.mjs +96 -0
- package/src/shared/relay-contract.json +47 -7
- package/src/shared/result-projection.d.mts +2 -1
- package/src/shared/result-projection.mjs +13 -2
- package/src/shared/sensitive-value-patterns.mjs +21 -0
- package/src/shared/server-metadata.json +16 -10
- package/src/shared/tool-argument-validation.d.mts +17 -0
- package/src/shared/tool-argument-validation.mjs +325 -0
- package/src/shared/tool-call-capacity.d.mts +41 -0
- package/src/shared/tool-call-capacity.mjs +59 -0
- package/src/shared/tool-catalog.json +655 -60
- package/src/worker/access.ts +14 -1
- package/src/worker/account-admin.ts +39 -14
- package/src/worker/authority-revocations.ts +208 -0
- package/src/worker/authority.ts +29 -2
- package/src/worker/daemon-auth.ts +13 -9
- package/src/worker/daemon-channel.ts +36 -0
- package/src/worker/daemon-http-auth.ts +63 -0
- package/src/worker/daemon-http-channel.ts +129 -0
- package/src/worker/daemon-http-controller.ts +185 -0
- package/src/worker/daemon-http-protocol.ts +67 -0
- package/src/worker/daemon-http-registry.ts +82 -0
- package/src/worker/daemon-last-observation.ts +30 -0
- package/src/worker/daemon-liveness.ts +16 -8
- package/src/worker/daemon-planned-drain.ts +28 -0
- package/src/worker/daemon-ready-dispatch.ts +25 -0
- package/src/worker/daemon-ready-messages.ts +78 -0
- package/src/worker/daemon-ready-waiter-policy.ts +55 -0
- package/src/worker/daemon-ready-waiter-state.ts +53 -0
- package/src/worker/daemon-ready-waiters.ts +62 -0
- package/src/worker/daemon-recovery-budget.ts +29 -0
- package/src/worker/daemon-registry.ts +69 -0
- package/src/worker/daemon-relay-diagnostics.ts +342 -0
- package/src/worker/daemon-resume-reconciliation.ts +43 -0
- package/src/worker/daemon-socket-attachment.ts +57 -0
- package/src/worker/daemon-sockets.ts +56 -52
- package/src/worker/daemon-status.ts +38 -0
- package/src/worker/daemon-tool-redelivery.ts +14 -0
- package/src/worker/device-session-verifier.ts +11 -7
- package/src/worker/dpop.ts +22 -11
- package/src/worker/durable-process-timeout.ts +29 -0
- package/src/worker/errors.ts +67 -0
- package/src/worker/hosted-browser-target-schema.ts +31 -0
- package/src/worker/hosted-result-budget.ts +28 -0
- package/src/worker/http.ts +71 -34
- package/src/worker/index.ts +440 -413
- package/src/worker/managed-job-capability.ts +61 -0
- package/src/worker/managed-job-hosted-authority.ts +129 -0
- package/src/worker/managed-job-hosted-schema.ts +64 -0
- package/src/worker/managed-job-read-timeout.ts +37 -0
- package/src/worker/mcp-access.ts +13 -2
- package/src/worker/mcp-controller.ts +219 -0
- package/src/worker/mcp-http-accept.ts +11 -0
- package/src/worker/mcp-http-contract.ts +322 -0
- package/src/worker/mcp-job-monitor-claims.ts +94 -0
- package/src/worker/mcp-job-monitor-status.ts +28 -0
- package/src/worker/mcp-job-monitor-store.ts +149 -0
- package/src/worker/mcp-job-monitor-tools.ts +89 -0
- package/src/worker/mcp-job-monitor-ui.ts +129 -0
- package/src/worker/mcp-jsonrpc.ts +11 -29
- package/src/worker/mcp-removed-protocol.ts +17 -0
- package/src/worker/mcp-request-cancellation.ts +112 -0
- package/src/worker/mcp-response-cancel.ts +25 -0
- package/src/worker/mcp-response-proxy.ts +130 -0
- package/src/worker/mcp-response-stream.ts +49 -0
- package/src/worker/mcp-stale-schema-guidance.ts +129 -0
- package/src/worker/mcp-stream-proxy-contract.ts +48 -0
- package/src/worker/mcp-streamed-tool-response.ts +19 -0
- package/src/worker/mcp-subscription-capacity.ts +47 -0
- package/src/worker/mcp-subscription-contract.ts +6 -0
- package/src/worker/mcp-subscription-registry.ts +122 -0
- package/src/worker/mcp-subscription-stream.ts +69 -0
- package/src/worker/mcp-tool-call-input.ts +23 -0
- package/src/worker/nonce-store.ts +32 -30
- package/src/worker/oauth-authorization-page.ts +21 -1
- package/src/worker/oauth-client-admin.ts +13 -8
- package/src/worker/oauth-client-contract.ts +37 -0
- package/src/worker/oauth-controller.ts +72 -91
- package/src/worker/oauth-field-contract.ts +31 -0
- package/src/worker/oauth-record-contract.ts +7 -0
- package/src/worker/oauth-refresh-authority.ts +27 -0
- package/src/worker/oauth-refresh-exchange.ts +37 -15
- package/src/worker/oauth-refresh-families.ts +68 -10
- package/src/worker/oauth-refresh-persistence.ts +105 -0
- package/src/worker/oauth-state.ts +26 -52
- package/src/worker/oauth-store-validation.ts +135 -0
- package/src/worker/oauth-token-issuance.ts +27 -17
- package/src/worker/oauth-tokens.ts +84 -27
- package/src/worker/observability.ts +39 -43
- package/src/worker/pending-call-capacity.ts +122 -0
- package/src/worker/pending-call-contract.ts +32 -9
- package/src/worker/pending-call-deadlines.ts +8 -4
- package/src/worker/pending-call-reconnect-settlement.ts +13 -0
- package/src/worker/pending-call-registration.ts +43 -0
- package/src/worker/pending-calls.ts +69 -70
- package/src/worker/runtime-alarm-storage.ts +37 -0
- package/src/worker/runtime-alarm.ts +77 -80
- package/src/worker/server-info-activity.ts +36 -0
- package/src/worker/server-info-tool-delivery.ts +54 -0
- package/src/worker/server-info.ts +169 -0
- package/src/worker/tool-call-recovery.ts +29 -0
- package/src/worker/tool-catalog.ts +70 -4
- package/src/worker/tool-timeout.ts +73 -15
- package/src/worker/websocket-protocol.ts +18 -0
- package/src/worker/worker-continuity-evidence.ts +121 -0
- package/src/worker/worker-edge-guard.ts +10 -1
- package/src/worker/worker-edge-log.ts +11 -8
- package/src/worker/worker-entry.ts +52 -0
- package/src/worker/worker-mcp-config.ts +28 -0
- package/src/worker/worker-metadata.ts +7 -2
- package/src/worker/worker-rate-limit-key.ts +30 -0
- package/src/worker/worker-runtime-config.ts +20 -0
- package/src/worker/worker-socket-disconnect-evidence.ts +58 -0
- package/src/worker/worker-static-routes.ts +8 -2
- package/src/worker/worker-task-lifetime.ts +18 -0
- package/src/worker/worker-tool-authority.ts +31 -0
- package/tsconfig.local.json +17 -1
- package/wrangler.config.ts +5 -0
- package/wrangler.jsonc +5 -0
- package/CODE_OF_CONDUCT.md +0 -24
- package/CONTRIBUTING.md +0 -68
- package/GOVERNANCE.md +0 -50
- package/docs/ARCHITECTURE.md +0 -314
- package/docs/ENGINEERING.md +0 -210
- package/docs/PROJECT_STANDARDS.md +0 -153
- package/docs/RELEASING.md +0 -231
- package/docs/TESTING.md +0 -164
- package/scripts/check-plan.mjs +0 -116
- package/scripts/check-runner.mjs +0 -78
- package/scripts/commit-message-check.mjs +0 -66
- package/scripts/coverage-check.mjs +0 -206
- package/scripts/generate-policy-reference.mjs +0 -92
- package/scripts/generate-tool-reference.mjs +0 -87
- package/scripts/generate-worker-types.mjs +0 -19
- package/scripts/markdown.mjs +0 -9
- package/scripts/prepare-pinned-npm.mjs +0 -97
- package/scripts/run-checks.mjs +0 -19
- package/scripts/sarif-security-gate.mjs +0 -148
- package/scripts/syntax-check.mjs +0 -52
- package/src/local/cli-approval.mjs +0 -73
- package/src/local/operation-state-lock.mjs +0 -13
- package/src/worker/mcp-resumption-config.ts +0 -46
- package/src/worker/mcp-resumption-http.ts +0 -43
- package/src/worker/mcp-resumption-records.ts +0 -167
- package/src/worker/mcp-resumption.ts +0 -239
- package/src/worker/mcp-session.ts +0 -72
- package/src/worker/mcp-stream-channel.ts +0 -125
- package/src/worker/mcp-stream-dispatch.ts +0 -186
- package/src/worker/mcp-stream-proxy.ts +0 -114
- package/src/worker/mcp-stream-subscription.ts +0 -98
- package/src/worker/mcp-stream.ts +0 -129
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
| Understand components and authority | [System overview](docs/OVERVIEW.md) |
|
|
15
15
|
| Review security assumptions | [Threat model](docs/THREAT_MODEL.md) and [security policy](SECURITY.md) |
|
|
16
16
|
| Operate or troubleshoot a deployment | [Operations](docs/OPERATIONS.md) |
|
|
17
|
-
| Contribute code |
|
|
17
|
+
| Contribute code | Use the contribution guide in the source repository |
|
|
18
18
|
|
|
19
|
-
Support boundaries are defined in [SUPPORT.md](SUPPORT.md).
|
|
19
|
+
Support boundaries are defined in [SUPPORT.md](SUPPORT.md). Contribution, conduct, governance, architecture, and test-design material is maintained in the source repository and is intentionally not part of the consumer package.
|
|
20
20
|
|
|
21
21
|
## What it provides
|
|
22
22
|
|
|
@@ -25,16 +25,19 @@ Support boundaries are defined in [SUPPORT.md](SUPPORT.md). Repository participa
|
|
|
25
25
|
- bounded file, patch, Git, process, diagnostic, application, browser, and managed-job tools;
|
|
26
26
|
- account roles whose authority is intersected with the connected daemon policy;
|
|
27
27
|
- root-certified ephemeral daemon sessions, trusted OAuth client binding, refresh-family ownership, and non-escalatable account roles;
|
|
28
|
-
- structured, privacy-conscious lifecycle events and stable error codes;
|
|
28
|
+
- structured, privacy-conscious lifecycle events, a worker-thread-isolated self-verifying audit hash chain with documented same-user rewrite limits, and stable error codes;
|
|
29
|
+
- control-plane resilience through end-to-end reserved diagnostic capacity, event-loop-aware relay liveness, and explicit draining-process accounting;
|
|
29
30
|
- fail-closed state, lock, release, package, and supply-chain checks.
|
|
30
31
|
|
|
31
32
|
The remote Worker authenticates and relays requests. It cannot directly read local files or start local processes. Local-user authority remains in the daemon process.
|
|
32
33
|
|
|
34
|
+
Expected file-state failures are machine-readable. File mutations return stable codes such as `conflict`, `not_found`, `invalid_request`, and `limit_exceeded`, with bounded `details.reason` tokens where useful. Conflict responses should trigger a fresh read and reconciliation rather than a blind retry; public errors do not include file contents, compared hashes, or hidden paths.
|
|
35
|
+
|
|
33
36
|
```text
|
|
34
37
|
Hosted MCP client
|
|
35
38
|
-> HTTPS + OAuth 2.1 / PKCE
|
|
36
39
|
-> Cloudflare Worker + Durable Object
|
|
37
|
-
-> root-certified ephemeral P-256 WebSocket
|
|
40
|
+
-> root-certified ephemeral P-256 daemon channel (WebSocket primary; signed HTTPS fallback)
|
|
38
41
|
-> request-level effective authority and object ownership
|
|
39
42
|
-> local runtime
|
|
40
43
|
|
|
@@ -45,6 +48,20 @@ Local MCP client
|
|
|
45
48
|
|
|
46
49
|
The complete component and trust-boundary diagram is in [docs/OVERVIEW.md](docs/OVERVIEW.md).
|
|
47
50
|
|
|
51
|
+
## MCP protocol model
|
|
52
|
+
|
|
53
|
+
Machine Bridge uses MCP `2026-07-28` for both stdio and remote HTTP. There is no successful initialization-era adapter: every supported request is current and request-scoped.
|
|
54
|
+
|
|
55
|
+
- **Native current requests are self-describing.** Protocol version and client capabilities travel in `_meta`; HTTP requests also mirror the version, method, and applicable name/parameter values into validated headers. Current `2026-07-28` clients use `server/discover` and do not create an MCP protocol session.
|
|
56
|
+
- **Removed protocol requests fail closed.** `initialize`, `Mcp-Session-Id`, `Last-Event-ID`, and other explicit removed session/replay markers do not dispatch tool work and receive bounded upgrade guidance. Remote `/mcp` is POST-only; GET remains a 405 method rejection. Obsolete clients must reconnect with MCP `2026-07-28`.
|
|
57
|
+
- **HTTP streams are request-scoped and non-resumable.** Closing the response stream cancels that request. There is no recovery GET, SSE event-ID replay, or session-bound delivery store.
|
|
58
|
+
- **Removed session/replay semantics never execute.** Unsupported protocol dates and requests for the retired session/recovery model receive bounded rejection or upgrade guidance rather than legacy state or replay behavior.
|
|
59
|
+
- **Transport identity is not conversation identity.** Stdio and HTTP processes/connections may interleave unrelated requests; state that spans calls must use an explicit tool, job, process-session, or resource identifier.
|
|
60
|
+
|
|
61
|
+
The Worker validates the actual `/mcp` Origin, mirrored headers, role-filtered tool visibility, and raw arguments before routing or daemon dispatch. Tool arguments use one bounded JSON Schema 2020-12 contract in both Worker and local runtime; validation has fixed schema and runtime-work budgets and never echoes rejected values. Request-stream cancellation uses a private random capability stripped from public requests and forwards no OAuth/DPoP credential.
|
|
62
|
+
|
|
63
|
+
`resolve_task_capabilities` provides bounded, set-level route advice across registered commands, direct Bash/argv, process sessions, managed jobs, files/Git, browser, applications, resources, and diagnostics. It does not hide or disable tools: Bash through `exec_command` remains the first-class general escape hatch under a shell-capable effective policy. The versioned result is filtered by the authenticated account's effective authority, reports routing ambiguity and fallbacks, and accepts the previous `refresh.fingerprint` to omit unchanged static instructions while still recomputing task-specific matches. Route scores are deterministic relative ranks within one response, not probabilities or cross-version metrics.
|
|
64
|
+
|
|
48
65
|
## Requirements
|
|
49
66
|
|
|
50
67
|
- Node.js 26 or newer
|
|
@@ -62,8 +79,8 @@ macOS/Linux:
|
|
|
62
79
|
install_dir="$(mktemp -d)"
|
|
63
80
|
(
|
|
64
81
|
cd "$install_dir"
|
|
65
|
-
npx --yes npm@12.0.
|
|
66
|
-
npx --yes npm@12.0.
|
|
82
|
+
npx --yes npm@12.0.2 install --global npm@12.0.2
|
|
83
|
+
npx --yes npm@12.0.2 install --global --omit=optional --allow-scripts=esbuild,workerd,sharp,fsevents machine-bridge-mcp@latest
|
|
67
84
|
)
|
|
68
85
|
rm -rf "$install_dir"
|
|
69
86
|
npm --version
|
|
@@ -76,8 +93,8 @@ Windows Command Prompt:
|
|
|
76
93
|
set "MBM_INSTALL_DIR=%TEMP%\machine-bridge-mcp-install-%RANDOM%-%RANDOM%"
|
|
77
94
|
mkdir "%MBM_INSTALL_DIR%"
|
|
78
95
|
pushd "%MBM_INSTALL_DIR%"
|
|
79
|
-
npx --yes npm@12.0.
|
|
80
|
-
npx --yes npm@12.0.
|
|
96
|
+
npx --yes npm@12.0.2 install --global npm@12.0.2
|
|
97
|
+
npx --yes npm@12.0.2 install --global --omit=optional --allow-scripts=esbuild,workerd,sharp,fsevents machine-bridge-mcp@latest
|
|
81
98
|
popd
|
|
82
99
|
rmdir /s /q "%MBM_INSTALL_DIR%"
|
|
83
100
|
npm --version
|
|
@@ -86,6 +103,8 @@ machine-mcp doctor
|
|
|
86
103
|
|
|
87
104
|
`Unknown cli config "--allow-scripts"` means the package installation ran under npm 11 or older. `Invalid property "node"` or `Invalid property "devEngines.node"` means an older npm parser inspected incompatible nearby project metadata. Repeat the empty-directory procedure and reopen the terminal if `npm --version` still resolves to an older executable.
|
|
88
105
|
|
|
106
|
+
The consumer runtime has three direct dependencies. Deployment tooling is installed and audited separately; its upstream cf bundle is verified without rewriting third-party code.
|
|
107
|
+
|
|
89
108
|
For a source checkout:
|
|
90
109
|
|
|
91
110
|
```sh
|
|
@@ -102,7 +121,9 @@ Run the CLI in the workspace to expose:
|
|
|
102
121
|
machine-mcp --workspace /path/to/project
|
|
103
122
|
```
|
|
104
123
|
|
|
105
|
-
On first remote start, Machine Bridge creates workspace-scoped state, signs in
|
|
124
|
+
On first remote start, Machine Bridge creates workspace-scoped state, signs in with `cf auth login --scopes account-settings.read user-details.read workers-scripts.read workers-scripts.write workers-scripts.bind workers-routes.read workers-routes.write workers-observability.read workers-observability.write offline` when needed, builds and deploys one stable Worker through `cf`, creates the initial `owner` account, installs user-level autostart unless disabled, starts the outbound daemon connection, and prints the MCP URL and one-time owner password.
|
|
125
|
+
|
|
126
|
+
Machine Bridge, including Worker deployment, requires Node.js 26 or later. `cf` has its own login, separate from Wrangler. Before unattended activation, complete `cf auth login` in an ordinary owner terminal; for multiple Cloudflare accounts, set `CLOUDFLARE_ACCOUNT_ID` to the existing Worker's account. The pinned deployment tools stay in Machine Bridge's private toolchain, outside the consumer runtime dependencies. Native `cloudflare.config.ts` controls deployment; the retained `wrangler.jsonc` is used for deterministic runtime type generation and legacy maintenance commands.
|
|
106
127
|
|
|
107
128
|
Use the printed endpoint in the hosted client:
|
|
108
129
|
|
|
@@ -110,7 +131,9 @@ Use the printed endpoint in the hosted client:
|
|
|
110
131
|
https://<worker>.<account>.workers.dev/mcp
|
|
111
132
|
```
|
|
112
133
|
|
|
113
|
-
Remote readiness is end-to-end. A daemon becomes available only after a Worker probe traverses the same authenticated local dispatch and
|
|
134
|
+
Remote readiness is end-to-end. A daemon becomes available only after a Worker probe traverses the same authenticated local dispatch and result-delivery path used by real tool calls. A replacement daemon is verified before it displaces a healthy incumbent.
|
|
135
|
+
|
|
136
|
+
When the relay must use a proxy but should not inherit an operating-system VPN/TUN path, set `MBM_RELAY_PROXY` to a dedicated HTTP(S) proxy endpoint. By default it takes precedence over `HTTPS_PROXY`/`HTTP_PROXY` and `NO_PROXY` for both the preferred WebSocket relay and signed HTTP fallback; a configured proxy failure never silently retries the same transport directly. Deployments that need the HTTPS fallback in a different application-layer fault domain may also set `MBM_RELAY_FALLBACK_PROXY`: a non-empty value selects an explicit fallback-only HTTP(S) proxy, while an explicitly empty value restores standard `HTTPS_PROXY`/`HTTP_PROXY`/`NO_PROXY` resolution for the fallback without changing the WebSocket route. A common primary deployment is a loopback-only sidecar whose own upstream socket is pinned to the intended physical/network interface. Machine Bridge does not itself bind either route below the application layer, so a `system-network-stack` fallback may still be intercepted by an operating-system VPN/TUN. See [docs/OPERATIONS.md](docs/OPERATIONS.md).
|
|
114
137
|
|
|
115
138
|
For account roles, OAuth lifecycle, supported callback behavior, and tenancy limits, read [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) and [docs/MULTI_ACCOUNT.md](docs/MULTI_ACCOUNT.md).
|
|
116
139
|
|
|
@@ -153,7 +176,15 @@ The default is intentionally `full` for owner-operated local automation. This is
|
|
|
153
176
|
|
|
154
177
|
The shared source of truth is `src/shared/policy-contract.json`. The generated matrix is in [docs/POLICY_REFERENCE.md](docs/POLICY_REFERENCE.md).
|
|
155
178
|
|
|
156
|
-
For remote calls, `server_info.authorization.effective_policy` and `effective_tools` are authoritative. Daemon policy and tools describe only the local capability ceiling before account-role and host-side filtering.
|
|
179
|
+
For routine remote health checks, prefer `server_info` with `detail: "summary"`; the empty/default call remains full diagnostics and, for owner/full callers, includes a privacy-bounded durable continuity summary that survives Worker isolate replacement without retaining identities, call IDs, tool arguments, results, endpoints, or close reasons. For routine workspace inventory, `project_overview` also accepts `detail: "summary"`; it preserves policy/tool counts and top-level names/types without repeating exact tool arrays, account identity, routing fingerprints, or per-entry paths/sizes. Its empty/default call likewise remains full for compatibility. For remote calls, `server_info.authorization.effective_policy` and, when exact membership is needed, the full projection's `effective_tools` are authoritative. Daemon policy and tools describe only the local capability ceiling before account-role and host-side filtering.
|
|
180
|
+
|
|
181
|
+
`tools/list` is the authenticated account's discovery catalog. Both `server/discover` and `tools/list` advertise `ttlMs=0`, and every host-visible tool description carries `Tool schema generation N`. Remote discovery supports `tools.listChanged=true`: `subscriptions/listen` acknowledges `toolsListChanged`, emits a level-trigger `notifications/tools/list_changed`, and stays open until cancellation or its bounded lease expires. Clients re-fetch the catalog; the server cannot prove which generation a host cached. Discovery does not grant authority: calls still require the current account/ready-daemon intersection.
|
|
182
|
+
|
|
183
|
+
WebSocket is preferred. An actually dispatched Ping has a ten-second Pong deadline, followed by one independent fifteen-second application-confirmation window. A protocol Pong or explicit application `pong` during that second stage preserves WSS. Local event-loop stalls use a separate recovery path. WSS connect attempts have a thirty-second outer budget. Healthy WSS keeps signed HTTPS fallback stopped; suspicion permits standby prewarming, and actual loss permits takeover of that exact generation. The daemon sends `resume_calls_ack.missing_ids` only after replacement readiness and only with fail-closed proof that absent ownership means non-execution. A possibly executed call is never automatically replayed. See [architecture](https://github.com/YuLeiFuYun/machine-bridge-mcp/blob/main/docs/ARCHITECTURE.md#daemon-reconnect-and-replacement) for transport sequencing, deadlines, and diagnostics.
|
|
184
|
+
|
|
185
|
+
Planned shutdown sends `daemon_draining` before relay close. An interrupted `read_job` returns `recovery.mode=read_same_job`; preserve its `job_id` and `recovery_key` and read that same job after reconnect. Replacement does not transfer ordinary executing calls to a new daemon.
|
|
186
|
+
|
|
187
|
+
Hosted synchronous calls otherwise retain their ordinary 20-second execution plus separate five-second Worker settlement margin. Configurable browser/application tools use 20-second defaults; compound `computer_observe` / `computer_act` retain 30-second defaults, with a 45-second explicit maximum. Durable process acceptance and continuation have separate budgets below. These limits do not establish external host receipt or a whole-assistant-turn deadline.
|
|
157
188
|
|
|
158
189
|
`full` is the daemon capability ceiling. An authenticated owner may exercise it without per-operation approval IDs. Delegated reviewer, editor, and operator accounts remain inside immutable role ceilings; out-of-role operations are denied rather than converted into a temporary elevation workflow. Process sessions, retained output, and managed jobs are additionally bound to account, client, and refresh-token family. See [local authorization](docs/LOCAL_AUTHORIZATION.md).
|
|
159
190
|
|
|
@@ -168,13 +199,31 @@ machine-mcp browser status
|
|
|
168
199
|
|
|
169
200
|
Load the printed unpacked-extension directory into the intended Chromium profile. Reload the extension after every Machine Bridge upgrade. The broker validates a versioned capability handshake, keeps pairing state local and owner-only, and does not return the pairing token through MCP.
|
|
170
201
|
|
|
171
|
-
Machine Bridge does not launch or identify a separate browser profile. It controls whichever profile contains the extension, including that profile's tabs and login state. Read [docs/LOCAL_AUTOMATION.md](docs/LOCAL_AUTOMATION.md) before enabling it.
|
|
202
|
+
Machine Bridge does not launch or identify a separate browser profile. It controls whichever profile contains the extension, including that profile's tabs and login state. Because browser focus is shared machine state rather than hosted conversation identity, hosted browser content/action tools require an explicit `tab_id` from `browser_list_tabs`, and hosted browser `computer_observe` requires the same explicit target before snapshot creation. Read [docs/LOCAL_AUTOMATION.md](docs/LOCAL_AUTOMATION.md) before enabling it.
|
|
203
|
+
|
|
204
|
+
For stateful GUI trajectories, owner/full callers can use the higher-level `computer_observe` / `computer_act` pair. `computer_observe` creates one bounded browser or application snapshot with semantic evidence and native MCP image content when available; `computer_act` consumes the exact snapshot as one-shot mutation authority, dispatches at most once, observes post-state, and reports dispatch/effect settlement separately so ambiguous mutations are not automatically replayed. Their `timeout_seconds` value is one end-to-end budget for the compound operation rather than a fresh timeout for each internal screenshot, Accessibility/DOM preflight, dispatch, verification, or post-observation stage. See [docs/COMPUTER_USE.md](docs/COMPUTER_USE.md).
|
|
172
205
|
|
|
173
206
|
## Durable work and local resources
|
|
174
207
|
|
|
175
|
-
|
|
208
|
+
Remote `exec_command`, `run_process`, and `run_local_command` require a caller-held `idempotency_key` and become principal-bound one-step jobs before execution. Their acceptance envelope is ten seconds; child execution is independently bounded to 1–600 seconds after resource admission. Use `start_job` for a continuous command needing more time: main/finally steps default to 600 seconds and may request up to 21,600 seconds (six hours). Batch coherent non-interactive work into one plan or repository umbrella command. Process sessions serve interactive stdin/incremental output and retain daemon-lifetime ownership; hosted `read_process` reports `status_polling_mode=paced_followup`, with a one-second actual blocking cap and a fifteen-second would-block cooldown.
|
|
209
|
+
|
|
210
|
+
Preserve `job_id`, `recovery_key`, and `control_key` from acceptance. Reads/dependencies require the recovery capability; cancellation requires the control capability. A bare ID is not hosted authority. When terminal state is needed, continue bounded same-response `read_job` follow-up: active reads report `status_polling_mode=bounded_followup` and `host_turn_handoff_recommended=false`. The default long-poll is 40 seconds, terminal checks are bounded to five-second intervals, and nonterminal progress is coalesced for at least 30 seconds; step-name changes alone do not wake a hosted read. Explicit `wait_ms=0` requests a checkpoint and the public maximum is 60 seconds. Do not busy-loop or substitute diagnostic calls for known-job reads. Elapsed minutes do not justify handoff; after an actual host/tool boundary, recover the same job instead of repeating its side effect.
|
|
211
|
+
|
|
212
|
+
An active `start_job` may offer a Job Monitor on an MCP Apps-capable host. Polling ownership is separate from task ownership: if remaining work needs the result, keep following `read_job`. Otherwise render once with the accepted `job_id`, `recovery_key`, and `ui_monitor_id`, then read with those same values to verify the View claim. A claimed ordinary job reports `status_polling_mode=ui_monitor`, `follow_up_read_required=false`, and `host_turn_handoff_recommended=false`. Only an explicit `continuation_mode=task_supervisor` plan that already owns all remaining noninteractive work may recommend handoff; completeness remains an owner/caller semantic assertion. Monitor failures never resubmit execution.
|
|
213
|
+
|
|
214
|
+
The retained-state cap is 512. A hosted helper awaiting its promised terminal response is non-evictable during the fixed 24-hour undelivered-result grace; a store with no removable slot rejects new work with retryable `limit_exceeded`. After terminal delivery, helpers have a bounded newest-16/thirty-minute reserve and lower eviction priority than explicit durable history. Delegated one-step pending recovery is capped at 16 records per account ID plus account version across all OAuth clients and refresh families, checked before new state or process launch; a valid same-key replay adds no slot, while a statusless directory must pass admission again. Local CLI/stdio retains detailed inventory; hosted `list_jobs` exposes aggregates, so lost capabilities require local administration. A retained-record `not_found` does not prove non-execution.
|
|
215
|
+
|
|
216
|
+
Jobs can declare `depends_on`: the dependent remains `queued/dependency_wait` before main execution, upstream failure yields `dependency_failed`, and active/staged dependencies protect referenced results. Register secrets as local resource aliases and put idempotent cleanup in `finally_steps`. Timeout or cancellation alone does not prove process-tree settlement. See [managed jobs](docs/MANAGED_JOBS.md) for examples, retention, recovery, and privacy boundaries.
|
|
176
217
|
|
|
177
|
-
|
|
218
|
+
The repository-tracked `workflow-bundle.json` is the project-native lifecycle authority for local readiness. Its `project-native:npm:check:fast` and `project-native:npm:check:full` stages must remain `sandbox: required`; a machine-local or untracked lifecycle file must not silently lower high-risk containment. Release architecture checks enforce both Git tracking and those required Seatbelt modes, so the job-local continuation contract above is validated under the same repository-owned verification authority used for the candidate.
|
|
219
|
+
|
|
220
|
+
The Job Monitor is deliberately a status surface, not a duplicate result viewer. Its app-only reads expose only bounded lifecycle state; command output, command text, paths, nested step results, and recovery/control capabilities remain on the normal managed-job result path. The `recovery_key` is present in the render input only because it is the View's read authority and is cleared from View memory on teardown. If optional monitor coordination storage is unavailable after `start_job` or `read_job` has already succeeded, Machine Bridge keeps the durable job result authoritative and falls back to normal model-side continuation rather than reporting a new job failure.
|
|
221
|
+
|
|
222
|
+
On macOS, authorized remote activity uses a bounded idle-sleep assertion so ordinary system Idle Sleep does not suspend an active remote workflow. Relay handlers share the assertion for their execution lifetime plus a fixed thirty-minute rolling inactivity grace; each new authorized remote activity cancels a pending release and restarts the full grace after the last concurrent handler settles. An admitted remote process session extends daemon-side ownership until its child settles, and an account-backed managed-job runner owns a runner-bound assertion from confirmed claim through terminal persistence. Local managed jobs do not acquire the remote-continuity assertion. These protections do not override explicit sleep or lid-close behavior.
|
|
223
|
+
|
|
224
|
+
When `run_process` or `exec_command` returns a child exit code and bounded stdout/stderr, the local process did run. For nested tools such as `ssh`, a remote forced-command usage message or command allowlist is therefore evidence from the target-side authorization layer, not evidence that Machine Bridge blocked process execution. Diagnose and change the narrowest failing layer instead of widening the `full` profile, which already removes Machine Bridge's own shell and path restrictions.
|
|
225
|
+
|
|
226
|
+
Credentials and files can be registered by alias so the injection operation does not place their contents in MCP arguments or echo them in its result:
|
|
178
227
|
|
|
179
228
|
```sh
|
|
180
229
|
machine-mcp resource add maintenance-key ~/.ssh/example_maintenance_ed25519
|
|
@@ -183,6 +232,7 @@ machine-mcp job submit plan.json
|
|
|
183
232
|
```
|
|
184
233
|
|
|
185
234
|
See [docs/MANAGED_JOBS.md](docs/MANAGED_JOBS.md) for integrity checks, recovery, redaction, cleanup, and residual risks.
|
|
235
|
+
For browser or application injection, the destination receives the content by design and can copy, render, or transmit it; later observations of that destination can therefore expose content it now holds.
|
|
186
236
|
|
|
187
237
|
## Operations
|
|
188
238
|
|
|
@@ -193,10 +243,10 @@ machine-mcp
|
|
|
193
243
|
machine-mcp status
|
|
194
244
|
machine-mcp doctor
|
|
195
245
|
machine-mcp workspace show|set|reset
|
|
246
|
+
machine-mcp idle-sleep show|set MODE
|
|
196
247
|
machine-mcp service status|install|start|stop|uninstall
|
|
197
248
|
machine-mcp account list|clients|revoke-client|add|role|enable|disable|rotate-password|remove
|
|
198
|
-
machine-mcp
|
|
199
|
-
machine-mcp browser status|setup|pair|path
|
|
249
|
+
machine-mcp browser status|setup|pair|reset|path
|
|
200
250
|
machine-mcp resource add|list|check|remove
|
|
201
251
|
machine-mcp job submit|inspect|list|read|cancel
|
|
202
252
|
machine-mcp rotate-secrets
|
|
@@ -212,11 +262,11 @@ The exact tool set depends on the effective policy and account role. Both transp
|
|
|
212
262
|
Major groups include:
|
|
213
263
|
|
|
214
264
|
- workspace reads, writes, exact edits, and transactional patches;
|
|
215
|
-
- Git status, diff, log, and show with helper suppression and privacy bounds
|
|
265
|
+
- Git status, diff, log, and show with helper suppression and privacy bounds, plus structured staged-only `git_commit`;
|
|
216
266
|
- direct argv execution, shell execution, and interactive process sessions;
|
|
217
267
|
- runtime diagnostics and structured project/capability discovery;
|
|
218
268
|
- managed jobs and registered local resources;
|
|
219
|
-
- supported application and
|
|
269
|
+
- supported application/browser operations and snapshot-bound Computer Use.
|
|
220
270
|
|
|
221
271
|
## Development and verification
|
|
222
272
|
|
|
@@ -230,9 +280,9 @@ npm audit --omit=dev --audit-level=high
|
|
|
230
280
|
npm pack --dry-run
|
|
231
281
|
```
|
|
232
282
|
|
|
233
|
-
|
|
283
|
+
In a source checkout, the repository check plan defines the fast, full, and platform verification waves. macOS and Windows CI run the platform plan plus the installed-package smoke test. Linux CI runs the complete plan, including coverage, browser broker, package/install, stdio, Worker/OAuth, and real-browser navigation tests. Package audit, CodeQL, dependency review, governance, and OpenSSF Scorecard remain separate fail-closed jobs.
|
|
234
284
|
|
|
235
|
-
|
|
285
|
+
Detailed test design and engineering invariants are source-repository maintenance material; they are not installed with the consumer package.
|
|
236
286
|
|
|
237
287
|
## Release boundary
|
|
238
288
|
|
|
@@ -240,35 +290,47 @@ Version 3 and later use a mandatory prerelease and soak path. Package work start
|
|
|
240
290
|
|
|
241
291
|
```sh
|
|
242
292
|
npm run release:candidate
|
|
243
|
-
# The
|
|
293
|
+
# The coding agent rechecks source/package identity and disposable installability before live activation:
|
|
294
|
+
node scripts/start-release-candidate.mjs --install-only
|
|
295
|
+
# Repository automation then runs the exact persistent activation command without another conversational approval:
|
|
244
296
|
npm run release:candidate:activate -- --allow-worker-deploy
|
|
245
|
-
#
|
|
297
|
+
# Activation requires device-authenticated relay readiness. One explicit authentication rejection may
|
|
298
|
+
# redeploy the same Worker once with the unchanged selected identity; it never rotates credentials.
|
|
299
|
+
# The login service is accepted only after a committed machine owner and the matching daemon
|
|
300
|
+
# publish the post-authentication, post-relay-probe readiness checkpoint.
|
|
301
|
+
# After the coding agent verifies the live Worker/daemon and records acceptance,
|
|
302
|
+
# GitHub source publication proceeds automatically once release-integrity gates pass:
|
|
246
303
|
npm run prerelease:release
|
|
247
|
-
#
|
|
248
|
-
npm run prerelease:publish
|
|
304
|
+
# npm publication is the sole explicit authorization boundary:
|
|
305
|
+
npm run prerelease:publish -- --owner-confirm
|
|
306
|
+
# Registry-verified installation/activation then proceeds automatically:
|
|
249
307
|
npm run prerelease:install -- --allow-worker-deploy
|
|
250
308
|
```
|
|
251
309
|
|
|
310
|
+
The full release gate starts with a real source-tree SBOM check. The GitHub and npm publication commands also rebuild ignored `node_modules` from the committed lockfile through the integrity-pinned hardened npm before their release verification, so publication does not rely on a stale ambient dependency tree.
|
|
311
|
+
|
|
252
312
|
Formal soak begins only after the exact published prerelease is installed and activated. Minimum soak is seven days for a major release, three days for a minor release, and one day for a patch. Every blocking fix creates a new prerelease and restarts the clock.
|
|
253
313
|
|
|
254
|
-
Stable promotion must retain the soaked package's functional digest. After the owner reports successful soak, the agent records the soak result
|
|
314
|
+
Stable promotion must retain the soaked package's functional digest. After the owner reports successful soak, the agent records the soak result and prepares and verifies the stable candidate. Final GitHub tag/Release publication uses `npm run release` automatically once its gates pass; npm stable publication is the sole separately authorized operation and uses `npm run stable:publish -- --owner-confirm`.
|
|
255
315
|
|
|
256
|
-
|
|
316
|
+
Detailed release-governance instructions are source-repository maintenance material; the installed package retains only the release helpers required by the supported release and activation workflows.
|
|
257
317
|
|
|
258
318
|
## Documentation
|
|
259
319
|
|
|
260
320
|
- [System overview](docs/OVERVIEW.md)
|
|
261
|
-
- [Architecture](docs/ARCHITECTURE.md)
|
|
262
321
|
- [Threat model](docs/THREAT_MODEL.md)
|
|
263
322
|
- [Security policy](SECURITY.md)
|
|
264
323
|
- [Getting started](docs/GETTING_STARTED.md)
|
|
324
|
+
- [Client integration](docs/CLIENTS.md)
|
|
265
325
|
- [Operations](docs/OPERATIONS.md)
|
|
266
|
-
- [
|
|
267
|
-
- [
|
|
268
|
-
- [
|
|
269
|
-
- [Audit
|
|
326
|
+
- [Upgrading](docs/UPGRADING.md)
|
|
327
|
+
- [Computer use](docs/COMPUTER_USE.md)
|
|
328
|
+
- [Managed jobs](docs/MANAGED_JOBS.md)
|
|
329
|
+
- [Audit status](docs/AUDIT.md)
|
|
270
330
|
- [Privacy hygiene](docs/PRIVACY.md)
|
|
271
331
|
|
|
332
|
+
Architecture, engineering, testing, project-standard, release-governance, contribution, conduct, and governance documents remain available in the source repository but are not part of the npm consumer payload.
|
|
333
|
+
|
|
272
334
|
## Uninstall
|
|
273
335
|
|
|
274
336
|
```sh
|
package/SECURITY.md
CHANGED
|
@@ -46,6 +46,12 @@ Trusted components are:
|
|
|
46
46
|
|
|
47
47
|
The Worker authenticates and filters remote requests. The local runtime owns filesystem, process, browser, application, resource, and job authority. Stdio bypasses the Worker and relies on local process and configuration trust.
|
|
48
48
|
|
|
49
|
+
The repository Workflow Policy Gate independently validates the complete GitHub workflow set: approved triggers, least-privilege permissions, bounded jobs, workflow/ref concurrency, immutable reviewed Actions, disabled checkout credentials, and safe event-data handling. Release creation requires its successful push run for the exact commit.
|
|
50
|
+
|
|
51
|
+
The final published consumer tree is audited separately from the source workspace. Deployment-only Wrangler/Miniflare packages are installed from a package-owned lock into an owner-only private toolchain, not shipped as runtime dependencies. Before use, that toolchain must match exact patched versions, pass a zero-vulnerability audit, and pass registry-signature verification. Installation and release mutation use a separately integrity-pinned hardened npm CLI rather than the ambient global npm bundle. Critical npm commands remove inherited execution modes case-insensitively and explicitly disable dry-run/workspace behavior. GitHub and npm publication upload private staged copies of the exact accepted tarball; after every irreversible command, bounded remote reconciliation requires GitHub REST SHA-256 or npm version/SHA-1/SRI/dist-tag evidence before success is reported. An unresolved outcome is explicitly ambiguous and must not be blindly retried. Release Git/gh operations use trusted absolute executables outside workspace/state/home roots and retain bounded network deadlines. Private toolchain reconstruction is limited to positively identified integrity corruption; permission, I/O, quota, memory, retry, stale-handle, storage, and timeout failures preserve existing state and fail closed. A root npm override in the source checkout is not considered consumer security evidence.
|
|
52
|
+
|
|
53
|
+
Candidate activation treats Worker deployment and local service replacement as separate evidence boundaries. Authorization is checked before candidate downloads or installation, rollback evidence is captured before temporary npm disposal, and inactive runtime cleanup may touch only canonical real directories contained below the state root. One explicit current-version device-authentication rejection permits one same-name, unchanged-identity repair deployment and bounded fresh-session convergence; other ambiguous failures do not authorize a repeated remote write. Worker deployment fingerprints use length-framed normalized paths and bounded no-follow file reads; missing, inaccessible, symlinked, hard-linked, special, or changing source paths stop before deployment. After the Worker advances, compatible-service recovery is successful only when the exact service daemon completes authenticated relay readiness and matches the Worker. Provider-active state alone is insufficient, and incomplete compensation preserves both the primary failure and recovery error.
|
|
54
|
+
|
|
49
55
|
## Effective remote authority
|
|
50
56
|
|
|
51
57
|
Remote authority is an intersection:
|
|
@@ -65,9 +71,9 @@ The roles are:
|
|
|
65
71
|
- `operator`: workspace-confined mutation and direct process execution;
|
|
66
72
|
- `owner`: complete bridge authority within the daemon policy ceiling.
|
|
67
73
|
|
|
68
|
-
No approval ID, refresh token, reconnect, client registration
|
|
74
|
+
No approval ID, refresh token, reconnect, or client registration can expand a role. Out-of-role operations fail with `authorization_denied`.
|
|
69
75
|
|
|
70
|
-
The Worker filters the
|
|
76
|
+
The Worker filters the stable discovery catalog by account role. Discovery is not authorization: each call is separately intersected with the current end-to-end-ready daemon capability ceiling, and the local runtime independently recomputes the role and policy boundary before dispatch. Account disablement, role change, password rotation, account removal, client revocation, token-version rotation, and refresh-family replay invalidate the appropriate credentials.
|
|
71
77
|
|
|
72
78
|
An OAuth client is bound to one account, account version, and role after successful authorization. It cannot silently switch accounts. Use `machine-mcp account clients` to inspect clients and `machine-mcp account revoke-client CLIENT_ID` to revoke one client and its credentials.
|
|
73
79
|
|
|
@@ -81,6 +87,7 @@ The default `full` profile prioritizes owner automation over least privilege.
|
|
|
81
87
|
- `review` exposes read-only workspace, Git, and image tools.
|
|
82
88
|
|
|
83
89
|
A stored `full` label is canonical. Per-capability narrowing is represented as `custom`, not as a partially restricted `full`.
|
|
90
|
+
Whether a process receives the complete parent environment is derived from that effective policy (or an already accepted managed-job plan). Ambient process variables cannot promote an isolated execution environment to full inheritance. Optional owner runtime settings such as the macOS trust broker and experimental native visual backend are separate configuration inputs, not execution-authority overrides.
|
|
84
91
|
|
|
85
92
|
`run_process` avoids shell parsing but an invoked interpreter, package manager, compiler, test runner, or repository script can execute arbitrary code. `exec_command` additionally enables shell expansion.
|
|
86
93
|
|
|
@@ -106,7 +113,7 @@ Remote daemon authentication uses a long-term device root and a root-certified e
|
|
|
106
113
|
|
|
107
114
|
The default provider on every platform, including macOS, is an owner-only portable P-256 root. Its private JWK is exportable by the daemon OS user and is reported as such in `server_info`. The root signs a 24-hour ephemeral session certificate at daemon startup; the ephemeral private key remains in memory and signs WebSocket preflight, Worker challenge, reconnect, and account-administration requests. Portable startup does not access Keychain and does not request user presence.
|
|
108
115
|
|
|
109
|
-
macOS can opt into a non-exportable Secure Enclave root only through `MBM_MACOS_TRUST_BROKER`. The configured executable must be an app-like broker signed by an Apple development or distribution identity with provisioning-profile-validated data-protection Keychain entitlements. Machine Bridge validates its canonical path, file mutability, strict code signature, signing identifier, Team ID, protocol responses, and a real create/delete Secure Enclave key probe before enrollment. The broker identity remains bound to the root and is revalidated before later use.
|
|
116
|
+
macOS can opt into a non-exportable Secure Enclave root only through `MBM_MACOS_TRUST_BROKER`. The configured executable must be an app-like broker signed by an Apple development or distribution identity with provisioning-profile-validated data-protection Keychain entitlements. Machine Bridge validates its canonical path, file mutability, strict code signature, signing identifier, Team ID, protocol responses, and a real create/delete Secure Enclave key probe before enrollment. The broker identity remains bound to the root and is revalidated before later use. The native broker verifies the returned key's Secure Enclave token, private-key class, EC type, and 256-bit size before use or export. Only an explicit key-not-found result permits creation; other lookup failures preserve existing state. Deletion binds the validated key reference, and signing input is bounded before Keychain access.
|
|
110
117
|
|
|
111
118
|
The prompt frequency is therefore:
|
|
112
119
|
|
|
@@ -119,7 +126,7 @@ The prompt frequency is therefore:
|
|
|
119
126
|
|
|
120
127
|
The packaged Swift source and ad-hoc build are development/protocol fixtures. The production validator deliberately rejects them because ad-hoc code has no provisioning-profile-validated data-protection Keychain access group.
|
|
121
128
|
|
|
122
|
-
The broker path, signing identifier, Team ID, and capability are revalidated before use, but those checks cannot distinguish a malicious replacement signed by the same trusted Apple team and identifier. Install production brokers in a root-owned or otherwise daemon-user-non-writable location and protect the signing identity and update channel.
|
|
129
|
+
The optional source-built development broker is cached only when a versioned marker matches both source and compiled-binary SHA-256 and the executable remains regular, single-link, owner-only, and executable. The broker path, signing identifier, Team ID, and capability are revalidated before use, but those checks cannot distinguish a malicious replacement signed by the same trusted Apple team and identifier. Install production brokers in a root-owned or otherwise daemon-user-non-writable location and protect the signing identity and update channel.
|
|
123
130
|
|
|
124
131
|
## Account administration
|
|
125
132
|
|
|
@@ -178,13 +185,23 @@ The extension independently caps active operations at 32. Its public error bound
|
|
|
178
185
|
|
|
179
186
|
After trusted input dispatch begins, an ambiguous failure is reported as unknown outcome and is not automatically replayed.
|
|
180
187
|
|
|
181
|
-
|
|
188
|
+
`computer_observe` / `computer_act` add snapshot binding, not new authority. Browser targets are tied to the observed tab/document/frame/semantic identity and optional screenshot; macOS application targets are tied to the exact process generation and, when available, owner-window evidence. A snapshot is one-shot mutation authority and is consumed before backend mutation handoff. Raw backend-node IDs, arbitrary CDP calls, unbound screen coordinates, or caller-provided JXA/native code are not accepted. If a browser transport or fixed local UI helper may already have started a mutation, the result is explicitly non-retryable and the caller must inspect post-state before any new action.
|
|
189
|
+
|
|
190
|
+
Computer Use screenshots share the ordinary MCP result-size boundary. When an image would make an observation result too large, the image is omitted before the snapshot ID is published and pixel-action authority is disabled. When a post-action image would overflow the same boundary, it is removed from the returned/stored post snapshot while the already-established mutation settlement and bounded continuation handle are preserved; the result never turns that dispatched action into a generic retryable size failure. Semantic state may still be returned. The experimental macOS background visual backend is disabled unless explicitly configured and successfully probed; Accessibility, Automation, Screen Recording, and the operating system remain independent enforcement boundaries.
|
|
191
|
+
|
|
192
|
+
Local resources may be injected without placing their bytes in the mutating MCP arguments or echoing them in that mutation result, but the destination page or application still receives them. Once delivered, the destination can copy, render, or transmit the value; a later explicit value inspection, screenshot, page source read, or other observation may therefore expose content the destination now holds. In particular, raw serialized HTML may contain hidden bootstrap/session/account/authentication values that are not visible in the rendered page; `browser_get_source` therefore should be used only when raw markup is required, and `browser_inspect_page` should normally keep `include_values=false`.
|
|
193
|
+
|
|
194
|
+
## Network egress boundaries
|
|
195
|
+
|
|
196
|
+
Machine Bridge can select application-layer HTTP(S) proxy routes for relay traffic. A non-empty `MBM_RELAY_PROXY` takes precedence over standard proxy/`NO_PROXY` resolution for the WebSocket relay and, unless separately overridden, the signed HTTP fallback. `MBM_RELAY_FALLBACK_PROXY` may explicitly select a different fallback-only HTTP(S) proxy; when that key is present with an empty value, only the fallback returns to standard `HTTPS_PROXY`/`HTTP_PROXY`/`NO_PROXY` resolution. A failed selected route is never silently rewritten into an unconfigured direct retry. Proxy URLs and credentials are not returned through runtime diagnostics or operational logs.
|
|
197
|
+
|
|
198
|
+
This is not an operating-system network-isolation boundary. Machine Bridge does not bind proxy upstream sockets to physical interfaces, implement an independent routing table, or prevent a system VPN/TUN from intercepting traffic to a remotely addressed proxy or a fallback using the system network stack. When relay traffic must be isolated from such a tunnel, use a loopback-only sidecar whose own outbound socket and DNS path are explicitly routed outside that tunnel. Separate application-layer routes reduce shared failure coupling but do not by themselves prove independent operating-system failure domains. The sidecar and upstream proxy remain separate trusted network components.
|
|
182
199
|
|
|
183
200
|
## Filesystem and mutation integrity
|
|
184
201
|
|
|
185
202
|
Workspace-confined profiles canonicalize existing paths and write ancestors. Final symbolic-link writes are rejected. Patch add, update, delete, and move destinations are classified before mutation.
|
|
186
203
|
|
|
187
|
-
Writes use bounded same-directory staging and atomic replacement. Expected hashes and exact edits reduce stale overwrites. Patch transactions prevalidate all operations, serialize mutation, maintain backups, and roll back ordinary commit errors.
|
|
204
|
+
Writes use bounded same-directory staging and atomic replacement. Expected hashes and exact edits reduce stale overwrites. Patch transactions prevalidate all operations, serialize mutation, maintain backups, and roll back ordinary commit errors. If rollback of an already-committed user-file step itself fails, Machine Bridge returns a public non-retryable `patch_recovery_incomplete` settlement directing the caller to inspect affected paths instead of hiding the potentially partial mutation behind a generic internal error.
|
|
188
205
|
|
|
189
206
|
On systems without descriptor-relative traversal, a malicious same-user process can still race parent-directory replacement between validation and open. Machine Bridge does not claim protection from a hostile process with equivalent OS-user authority.
|
|
190
207
|
|
|
@@ -194,7 +211,7 @@ Sensitive and persistence targets are owner-only. Generic remote file tools cann
|
|
|
194
211
|
|
|
195
212
|
Direct processes use argv without shell parsing. Shell expansion is available only through the explicit shell tool.
|
|
196
213
|
|
|
197
|
-
Process counts, stdin, output, timeouts, retained sessions, and tool-call concurrency are bounded. Timeout, explicit cancellation, reconnect-grace expiry, runtime shutdown, and non-recoverable daemon replacement use process-tree termination with bounded graceful and forced phases. A transient relay or HTTP/SSE disconnect is not cancellation.
|
|
214
|
+
Process counts, stdin, output, timeouts, retained sessions, and tool-call concurrency are bounded. Timeout, explicit cancellation, reconnect-grace expiry, runtime shutdown, and non-recoverable daemon replacement use process-tree termination with bounded graceful and forced phases. A transient relay or HTTP/SSE disconnect is not cancellation. After a same-daemon relay interruption, the Worker may keep only the in-memory result-settlement owner alive for up to fifteen additional seconds beyond its original settlement deadline, capped by the existing tool settlement maximum; this does not extend execution/redelivery authority, weaken cancellation, authorize replay, or persist a terminal result. Streamed-call ownership and deadlines survive Durable Object hibernation, while a random per-WebSocket generation prevents an obsolete socket from settling or detaching a rebound call.
|
|
198
215
|
|
|
199
216
|
Interactive process sessions die when their owning runtime stops or is replaced; an ordinary same-process relay reconnect does not itself destroy them. Retained output sessions and process control are bound to account, account version, OAuth client, and refresh family.
|
|
200
217
|
|
|
@@ -206,7 +223,13 @@ Registered resources store canonical paths and bounded metadata, not file conten
|
|
|
206
223
|
|
|
207
224
|
At job acceptance, referenced resources are reopened, bounded, hashed, and copied into a private runtime area. Changed or unavailable resources fail closed. Environment injection may be visible to same-user process inspection; private file-path substitution or stdin is generally safer.
|
|
208
225
|
|
|
209
|
-
Managed jobs are durability, not sandboxing. Only `owner` may create remote persistent plans. Long-lived jobs bind to account, account version, OAuth client, and refresh family.
|
|
226
|
+
Managed jobs are durability, not sandboxing. Only `owner` may create remote persistent plans. Long-lived jobs bind to account, account version, OAuth client, and refresh family. The local owner role is intentionally a global object administrator, so daemon-local owner/CLI inspection is not a conversation-isolation boundary.
|
|
227
|
+
|
|
228
|
+
Hosted managed-job recovery adds a separate Worker capability boundary. `start_job`, `stage_job`, and durable one-step process acceptance return deterministic HMAC-SHA256 `recovery_key` and `control_key` values bound to account version, OAuth client, refresh family, role, job ID, and purpose. Hosted `read_job` and dependency references require the read capability; hosted `cancel_job` requires the control capability. The Worker verifies them before daemon dispatch and strips them from daemon arguments. Capability values are derived with domain separation from the existing Worker OAuth identity key, are not persisted in local job state, are not mirrored into MCP parameter headers, and are covered by ordinary log/privacy redaction. Rotating the OAuth identity key invalidates outstanding hosted capabilities. Hosted `list_jobs` returns aggregate state only, while local CLI/stdio remains the global administration surface. This prevents Machine Bridge inventory from turning one hosted conversation into another conversation's job-discovery authority, but it cannot identify host-side conversation misrouting if the host itself supplies the other conversation's still-valid capability.
|
|
229
|
+
|
|
230
|
+
Delegated `operator` accounts still cannot call `start_job` or `stage_job`, but remote `exec_command`, `run_process`, and `run_local_command` use internal `transient_process` managed-job carriers so an accepted one-step operation remains recoverable after a host boundary. Those carriers share the profile-wide 512-state job store. To keep the 24-hour hard undelivered-result promise from becoming a cross-principal capacity claim, one relay non-owner account version may hold at most 16 unresolved `transient_recovery_pending` carriers across all of its OAuth clients and refresh families. The fairness key is account ID plus account version; changing client or refresh-family identity does not reset it. The check runs inside the existing root `capacity.lock` before new durable status publication or runner launch and derives its count from persisted job truth rather than a second quota ledger. A securely readable valid persisted same-key job remains recoverable at quota because replay adds no reservation; deterministic-directory existence by itself is not replay, and a statusless partial publication must pass the account quota again. Present but unreadable, malformed, or integrity-invalid retained status fails closed. Already accepted pending results remain non-evictable for their full 24-hour grace, while hosted terminal delivery or terminal grace expiry releases the account quota. Owner/local work remains governed only by the existing global capacity contract. Quota errors expose only a bounded maximum and coarse capacity scope, not account/client/family/job identifiers, paths, command text, output, or recovery capabilities.
|
|
231
|
+
|
|
232
|
+
Job directories must remain canonical real children of the owner-only job root. Cancellation markers are atomically replaced owner-only timestamp files; unreadable, malformed, symlinked, or hard-linked markers fail closed instead of being treated as no cancellation.
|
|
210
233
|
|
|
211
234
|
`stage_job` is non-executing and cannot be promoted by a terminal approval command. `machine-mcp job approve` was removed. Execution requires trusted `start_job` authority or an explicit local `machine-mcp job submit PLAN.json` action.
|
|
212
235
|
|
|
@@ -224,17 +247,17 @@ Destructive state removal validates marker files, selected workspace, known layo
|
|
|
224
247
|
|
|
225
248
|
## Relay and denial of service
|
|
226
249
|
|
|
227
|
-
Only one verified daemon is active. Candidates have preflight, hello, readiness, and liveness deadlines. A candidate
|
|
250
|
+
Only one verified daemon is active. Candidates have preflight, hello, readiness, and liveness deadlines. Ordinary replacement requires authentication and end-to-end readiness. A signed same-instance HTTPS takeover naming the exact incumbent connection generation may retire a zombie WebSocket after candidate preconditions pass; the replacement still cannot dispatch ordinary calls until end-to-end readiness is verified.
|
|
228
251
|
|
|
229
|
-
Pending calls are bounded, socket-bound, request-bound, timed out, cancellable, and recoverable only for the same verified daemon instance during the documented reconnect grace period.
|
|
252
|
+
Pending calls are bounded, socket-generation-bound, request-bound, timed out, cancellable, and recoverable only for the same verified daemon instance during the documented reconnect grace period. Worker transport/liveness invalidation is retryable and cannot by itself stop the daemon process; unknown protocol messages, authentication rejection, and identity/version mismatch remain fatal.
|
|
230
253
|
|
|
231
254
|
Request bodies, messages, traversals, files, output, OAuth stores, nonce stores, sessions, and failure identities are bounded. These controls do not replace Cloudflare MFA, WAF/rate limits, billing alerts, or external cost controls.
|
|
232
255
|
|
|
233
256
|
## Logs, audit, and privacy
|
|
234
257
|
|
|
235
|
-
Operational logs omit tool arguments, command text, stdin, file/patch contents, form values, and outputs. Known credential forms, private-key material, embedded-credential URLs, user-home paths, email addresses, and control characters are recursively redacted as defense in depth.
|
|
258
|
+
Operational logs omit tool arguments, command text, stdin, file/patch contents, form values, and outputs. Known credential forms, private-key material, embedded-credential URLs, user-home paths, email addresses, and control characters are recursively redacted as defense in depth. Runtime log sanitization and repository privacy scanning share the same common credential-pattern source; token alphabets that allow hyphen, underscore, or padding use explicit alphabet-aware termination rather than a generic word boundary, including current Machine Bridge account-password/OAuth/managed-job capability formats.
|
|
236
259
|
|
|
237
|
-
The local security audit is a bounded SHA-256 hash chain. It records operation type, risk category, outcome, duration, byte counts, target
|
|
260
|
+
The local security audit is a bounded SHA-256 hash chain. It records operation type, risk category, outcome, duration, byte counts, and pseudonymous target/principal references. Risky target correlation and account/client/family identity are HMAC-keyed with fresh per-daemon runtime keys before persistent audit state applies its existing per-file salt, so the public salt stored beside the chain is not sufficient to recompute references from guessed paths, short commands, or account identifiers. Those references are intentionally not stable cross-restart identities. The audit does not record commands, paths, contents, fields, or results.
|
|
238
261
|
|
|
239
262
|
No logging policy prevents data from being returned to an authorized client that explicitly invokes an enabled tool. Remote arguments and results necessarily traverse the user's Worker and MCP host.
|
|
240
263
|
|
|
@@ -258,9 +281,9 @@ No logging policy prevents data from being returned to an authorized client that
|
|
|
258
281
|
|
|
259
282
|
Machine Bridge cannot make arbitrary local executables safe, identify all sensitive data, guarantee cleanup across every power/storage/security failure, override MCP-host or endpoint-security policy, neutralize prompt injection, protect against root or a fully compromised same-user account, or manufacture production signing and governance controls.
|
|
260
283
|
|
|
261
|
-
See [docs/AUDIT.md](docs/AUDIT.md) for
|
|
262
|
-
##
|
|
284
|
+
See [docs/AUDIT.md](docs/AUDIT.md) for current audit conclusions and residual limitations.
|
|
285
|
+
## Request-scoped Streamable HTTP delivery
|
|
263
286
|
|
|
264
|
-
|
|
287
|
+
MCP `2026-07-28` response streams are request-scoped and non-resumable. SSE frames carry no event IDs, `GET /mcp` is not a recovery channel, and `Mcp-Session-Id` / `Last-Event-ID` do not create protocol-session or replay state. Closing the public response stream cancels that request through a random internal capability that carries neither Authorization nor DPoP credentials.
|
|
265
288
|
|
|
266
|
-
|
|
289
|
+
A brief relay interruption may rebind an already-dispatched pending call only to the same verified daemon instance within the bounded reconnect grace period. That continuity is in memory and remains owned by the initiating HTTP response; it does not persist a terminal result, create client-visible replay state, or authorize retry after the response has ended. Both remote HTTP and stdio reject removed initialization and older protocol dates before tool dispatch; neither transport has an initialization compatibility adapter. Transport recovery does not restore the removed session model.
|
package/SUPPORT.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
The supported runtime is the pinned Node.js 26 and npm 12 baseline on current GitHub-hosted Linux, macOS, and Windows environments. Older Node/npm releases and obsolete MCP protocol versions are not compatibility targets.
|
|
6
6
|
|
|
7
|
+
Source-release privacy tooling requires Git 2.50 or later. The reachable-history scanner intentionally relies on the machine-parsable NUL-delimited `git rev-list` object format introduced in Git 2.50 and does not carry an older-output compatibility parser.
|
|
8
|
+
|
|
7
9
|
The project supports the current package version and a direct upgrade from the immediately preceding published version when both use the current local state and policy schemas. See [Upgrading](docs/UPGRADING.md).
|
|
8
10
|
|
|
9
11
|
## Where to ask
|
|
@@ -21,7 +23,7 @@ A useful report includes:
|
|
|
21
23
|
- whether the transport is remote OAuth relay or local stdio;
|
|
22
24
|
- the active policy profile;
|
|
23
25
|
- the exact command or MCP operation that failed;
|
|
24
|
-
-
|
|
26
|
+
- output from `machine-mcp doctor` (which uses the support-safe state projection) and, when available, a reviewed/sanitized `diagnose_runtime` result;
|
|
25
27
|
- a minimal reproduction and whether the failure persists in a fresh disposable workspace.
|
|
26
28
|
|
|
27
29
|
Never include passwords, bearer tokens, private keys, browser pairing material, raw state files, real home/workspace paths, or unredacted logs. Replace them with synthetic values before posting.
|
package/bin/machine-mcp.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { main } from "../src/local/cli.mjs";
|
|
3
|
+
import { sanitizeLogText } from "../src/local/log.mjs";
|
|
3
4
|
|
|
4
5
|
main().catch(error => {
|
|
5
6
|
const message = process.env.MBM_DEBUG === "1"
|
|
6
7
|
? (error?.stack || error?.message || String(error))
|
|
7
8
|
: (error?.message || String(error));
|
|
8
|
-
console.error(`Error: ${message}`);
|
|
9
|
+
console.error(`Error: ${sanitizeLogText(message)}`);
|
|
9
10
|
process.exitCode = 1;
|
|
10
11
|
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const TOKEN = /^[A-Za-z0-9_-]{32,100}$/;
|
|
3
|
+
const NONCE = /^[A-Za-z0-9_-]{32}$/;
|
|
4
|
+
const PROOF = /^[A-Za-z0-9_-]{43}$/;
|
|
5
|
+
const BROKER_AUTH_REQUEST_HEADER = "x-machine-bridge-broker-auth";
|
|
6
|
+
const BROKER_AUTH_REQUEST_VALUE = "machine-bridge-browser-v2";
|
|
7
|
+
|
|
8
|
+
async function extensionProtocol(endpoint, token) {
|
|
9
|
+
if (typeof token !== "string" || !TOKEN.test(token)) throw new Error("browser pairing token is invalid");
|
|
10
|
+
const parsed = parseEndpoint(endpoint);
|
|
11
|
+
if (!parsed) throw new Error("browser broker endpoint is invalid");
|
|
12
|
+
const clientChallenge = randomBase64Url(24);
|
|
13
|
+
const authUrl = new URL(endpoint);
|
|
14
|
+
authUrl.protocol = "http:";
|
|
15
|
+
authUrl.pathname = "/extension-auth";
|
|
16
|
+
const initProof = await hmac(token, `machine-bridge-browser-extension-init-v2\0${clientChallenge}`);
|
|
17
|
+
authUrl.search = `?challenge=${encodeURIComponent(clientChallenge)}&init=${encodeURIComponent(initProof)}`;
|
|
18
|
+
const response = await brokerFetch(authUrl, "GET");
|
|
19
|
+
if (response.status !== 204) throw new Error("browser broker authentication failed");
|
|
20
|
+
const serverNonce = String(response.headers.get("x-machine-bridge-broker-nonce") || "");
|
|
21
|
+
const serverProof = String(response.headers.get("x-machine-bridge-broker-proof") || "");
|
|
22
|
+
if (!NONCE.test(serverNonce) || !PROOF.test(serverProof)) throw new Error("browser broker authentication failed");
|
|
23
|
+
const expected = await hmac(token, `machine-bridge-browser-extension-server-v2\0${clientChallenge}\0${serverNonce}`);
|
|
24
|
+
if (!fixedEqual(expected, serverProof)) throw new Error("browser broker authentication failed");
|
|
25
|
+
const clientProof = await hmac(token, `machine-bridge-browser-extension-client-v2\0${clientChallenge}\0${serverNonce}`);
|
|
26
|
+
return `mbm-extension-v2.${clientChallenge}.${serverNonce}.${clientProof}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseEndpoint(value) {
|
|
30
|
+
if (typeof value !== "string") return null;
|
|
31
|
+
let parsed;
|
|
32
|
+
try { parsed = new URL(value); } catch { return null; }
|
|
33
|
+
const port = Number(parsed.port);
|
|
34
|
+
if (parsed.protocol !== "ws:" || parsed.hostname !== "127.0.0.1" || parsed.pathname !== "/extension"
|
|
35
|
+
|| parsed.username || parsed.password || parsed.search || parsed.hash
|
|
36
|
+
|| !Number.isInteger(port) || port < 1024 || port > 65535) return null;
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
function pairingUrlFromEndpoint(endpoint) {
|
|
40
|
+
const parsed = parseEndpoint(endpoint);
|
|
41
|
+
return parsed ? `http://127.0.0.1:${parsed.port}/pair` : "";
|
|
42
|
+
}
|
|
43
|
+
function parsePairingPage(value) {
|
|
44
|
+
if (typeof value !== "string") return null;
|
|
45
|
+
let parsed;
|
|
46
|
+
try { parsed = new URL(value); } catch { return null; }
|
|
47
|
+
const port = Number(parsed.port);
|
|
48
|
+
if (parsed.protocol !== "http:" || parsed.hostname !== "127.0.0.1" || parsed.pathname !== "/pair"
|
|
49
|
+
|| parsed.username || parsed.password || parsed.search || parsed.hash
|
|
50
|
+
|| !Number.isInteger(port) || port < 1024 || port > 65535) return null;
|
|
51
|
+
return parsed;
|
|
52
|
+
}
|
|
53
|
+
async function brokerFetch(url, method) {
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const timer = setTimeout(() => controller.abort(), 1500);
|
|
56
|
+
try {
|
|
57
|
+
return await fetch(url, {
|
|
58
|
+
method, redirect: "error", cache: "no-store", signal: controller.signal,
|
|
59
|
+
headers: { [BROKER_AUTH_REQUEST_HEADER]: BROKER_AUTH_REQUEST_VALUE },
|
|
60
|
+
});
|
|
61
|
+
} finally { clearTimeout(timer); }
|
|
62
|
+
}
|
|
63
|
+
async function hmac(token, message) {
|
|
64
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(token), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
65
|
+
return base64Url(new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(message))));
|
|
66
|
+
}
|
|
67
|
+
function randomBase64Url(size) {
|
|
68
|
+
const bytes = new Uint8Array(size); crypto.getRandomValues(bytes); return base64Url(bytes);
|
|
69
|
+
}
|
|
70
|
+
function base64Url(bytes) {
|
|
71
|
+
let binary = ""; for (const value of bytes) binary += String.fromCharCode(value);
|
|
72
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
73
|
+
}
|
|
74
|
+
function fixedEqual(left, right) {
|
|
75
|
+
if (left.length !== right.length) return false;
|
|
76
|
+
let difference = 0;
|
|
77
|
+
for (let index = 0; index < left.length; index += 1) difference |= left.charCodeAt(index) ^ right.charCodeAt(index);
|
|
78
|
+
return difference === 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
globalThis.__machineBridgeBrokerAuth = Object.freeze({
|
|
82
|
+
extensionProtocol, pairingUrlFromEndpoint, parseBrokerEndpoint: parseEndpoint, parsePairingPage,
|
|
83
|
+
internal: Object.freeze({ brokerFetch, fixedEqual, hmac, randomBase64Url, tokenPattern: TOKEN, noncePattern: NONCE, proofPattern: PROOF }),
|
|
84
|
+
});
|
|
85
|
+
})();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
globalThis.__machineBridgeBrokerLiveness = (() => {
|
|
2
|
+
const PONG_TIMEOUT_MS = 10000;
|
|
3
|
+
function initialize(socket) {
|
|
4
|
+
socket.pongTimer = null;
|
|
5
|
+
socket.pongWatchdog = false;
|
|
6
|
+
socket.pingSequence = 0;
|
|
7
|
+
}
|
|
8
|
+
function clear(socket) {
|
|
9
|
+
clearTimeout(socket?.pongTimer);
|
|
10
|
+
if (socket) socket.pongTimer = null;
|
|
11
|
+
}
|
|
12
|
+
function negotiate(socket, enabled) { socket.pongWatchdog = enabled === true; }
|
|
13
|
+
function keepalive(socket, current, send, close) {
|
|
14
|
+
if (!current || !socket.bridgeReady || socket.readyState !== WebSocket.OPEN) return;
|
|
15
|
+
const seq = socket.pongWatchdog ? ++socket.pingSequence : 0;
|
|
16
|
+
if (!send(socket, JSON.stringify({ type: "ping", ...(seq ? { seq } : {}) }))) {
|
|
17
|
+
close(socket, 1011, "browser extension keepalive failed");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!seq) return;
|
|
21
|
+
clear(socket);
|
|
22
|
+
socket.pongTimer = setTimeout(() => {
|
|
23
|
+
if (socket.bridgeReady && socket.pingSequence === seq) close(socket, 1012, "browser broker pong timed out");
|
|
24
|
+
}, PONG_TIMEOUT_MS);
|
|
25
|
+
}
|
|
26
|
+
function handlePong(socket, message, close) {
|
|
27
|
+
if (!socket.pongWatchdog) return;
|
|
28
|
+
if (!Number.isSafeInteger(message.seq) || message.seq !== socket.pingSequence) {
|
|
29
|
+
close(socket, 1002, "invalid browser broker pong");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
clear(socket);
|
|
33
|
+
}
|
|
34
|
+
return Object.freeze({ initialize, clear, negotiate, keepalive, handlePong });
|
|
35
|
+
})();
|