machine-bridge-mcp 3.0.0-beta.201 → 3.0.0-beta.205
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 +14 -10
- package/README.md +5 -7
- package/SECURITY.md +5 -7
- package/bin/machine-mcp.mjs +11 -1
- package/browser-extension/manifest.json +1 -1
- package/cloudflare.config.ts +1 -0
- package/docs/AUDIT.md +8 -3
- package/docs/CLIENTS.md +5 -1
- package/docs/LOCAL_AUTHORIZATION.md +10 -13
- package/docs/LOGGING.md +2 -0
- package/docs/MULTI_ACCOUNT.md +7 -7
- package/docs/OPERATIONS.md +2 -0
- package/docs/POLICY_REFERENCE.md +8 -8
- package/docs/THREAT_MODEL.md +2 -2
- package/docs/TOOL_REFERENCE.md +49 -16
- package/docs/UPGRADING.md +3 -3
- package/package.json +6 -3
- package/scripts/github-push.mjs +4 -4
- package/scripts/github-release.mjs +4 -4
- package/scripts/network-retry.mjs +4 -1
- package/scripts/published-release.mjs +2 -0
- package/src/local/account-access.mjs +0 -2
- package/src/local/agent-context.mjs +27 -6
- package/src/local/agent-skill-discovery.mjs +14 -0
- package/src/local/agent-text-file.mjs +2 -0
- package/src/local/app-automation.mjs +17 -10
- package/src/local/authority-context.mjs +26 -5
- package/src/local/autostart-log-maintenance.mjs +1 -0
- package/src/local/bounded-output-helpers.mjs +29 -0
- package/src/local/bounded-output.mjs +35 -27
- package/src/local/browser-extension-path.mjs +2 -0
- package/src/local/browser-operation-service.mjs +1 -0
- package/src/local/cli-options.mjs +7 -2
- package/src/local/cli.mjs +9 -1
- package/src/local/computer-use-arguments.mjs +34 -4
- package/src/local/directory-metadata.mjs +7 -2
- package/src/local/errors.mjs +21 -5
- package/src/local/execution-routing.mjs +23 -4
- package/src/local/file-mutation-coordinator.mjs +6 -1
- package/src/local/git-content-service.mjs +83 -0
- package/src/local/git-sensitive-path-filter.mjs +63 -0
- package/src/local/git-service.mjs +11 -34
- package/src/local/managed-job-capacity-maintenance.mjs +24 -0
- package/src/local/managed-job-dependencies.mjs +16 -1
- package/src/local/managed-job-listing-records.mjs +45 -0
- package/src/local/managed-job-listing.mjs +3 -30
- package/src/local/managed-job-read-policy.mjs +7 -0
- package/src/local/managed-job-read-wait.mjs +14 -0
- package/src/local/managed-job-recovery-listing.mjs +3 -1
- package/src/local/managed-job-terminal-evidence-helpers.mjs +48 -0
- package/src/local/managed-job-terminal-evidence.mjs +71 -0
- package/src/local/managed-job-terminal-maintenance.mjs +20 -25
- package/src/local/managed-job-transient-recovery-capacity.mjs +1 -1
- package/src/local/managed-jobs.mjs +24 -17
- package/src/local/numbers.mjs +1 -21
- package/src/local/operation-authorization.mjs +61 -9
- package/src/local/operation-risk.mjs +10 -2
- package/src/local/process-fatal.mjs +40 -0
- package/src/local/process-output-stream.mjs +33 -7
- package/src/local/records.mjs +1 -9
- package/src/local/relay-peer-diagnostics.mjs +9 -3
- package/src/local/relay-tool-schema-extension.mjs +10 -2
- package/src/local/runtime-activity-projection.mjs +14 -6
- package/src/local/runtime-info-projection.mjs +5 -1
- package/src/local/runtime-info-relay-projection.mjs +18 -16
- package/src/local/runtime-tool-handlers.mjs +1 -1
- package/src/local/runtime.mjs +4 -4
- package/src/local/service.mjs +3 -0
- package/src/local/stdio.mjs +176 -16
- package/src/local/windows-launcher.mjs +3 -1
- package/src/local/workspace-file-rename-retry.mjs +32 -0
- package/src/local/workspace-file-service.mjs +54 -61
- package/src/local/workspace-file-transaction-helpers.mjs +73 -0
- package/src/local/workspace-file-transaction.mjs +35 -67
- package/src/local/workspace-profile-migration.mjs +55 -11
- package/src/local/workspace-search-service.mjs +212 -0
- package/src/local/workspace-search.mjs +18 -1
- package/src/shared/access-contract.json +9 -2
- package/src/shared/numbers.mjs +30 -0
- package/src/shared/project-overview-projection.mjs +10 -0
- package/src/shared/records.mjs +12 -0
- package/src/shared/result-projection.mjs +6 -4
- package/src/shared/server-metadata.json +3 -3
- package/src/shared/tool-call-capacity.mjs +4 -15
- package/src/shared/tool-catalog.json +49 -16
- package/src/worker/access.ts +0 -2
- package/src/worker/daemon-channel.ts +0 -8
- package/src/worker/index.ts +1 -1
- package/src/worker/mcp-http-contract.ts +7 -33
- package/src/worker/oauth-controller.ts +4 -1
- package/src/worker/oauth-refresh-exchange.ts +18 -15
- package/src/worker/oauth-refresh-retry.ts +34 -0
- package/src/worker/oauth-tokens.ts +5 -0
- package/src/worker/worker-entry.ts +7 -1
- package/tsconfig.local.json +41 -1
- package/wrangler.config.ts +1 -0
- package/wrangler.jsonc +1 -0
package/docs/TOOL_REFERENCE.md
CHANGED
|
@@ -137,7 +137,7 @@ Summarize the connected workspace, repository root, top-level entries, and proje
|
|
|
137
137
|
|
|
138
138
|
**Load session bootstrap**
|
|
139
139
|
|
|
140
|
-
Load built-in working agreements, bounded automatic project facts, authority-permitted user-global guidance, root workspace instructions, and capability refresh metadata. Delegated remote accounts do not read the daemon owner's home-scoped agent config unless their effective authority permits unrestricted paths. Clients call it explicitly when refreshed authority-scoped project context is needed;
|
|
140
|
+
Load built-in working agreements, bounded automatic project facts, authority-permitted user-global guidance, root workspace instructions, and capability refresh metadata. Delegated remote accounts do not read the daemon owner's home-scoped agent config unless their effective authority permits unrestricted paths. Clients call it explicitly when refreshed authority-scoped project context is needed; the optional stdio --compat handshake does not load session context.
|
|
141
141
|
|
|
142
142
|
| Contract field | Value |
|
|
143
143
|
|---|---|
|
|
@@ -1662,7 +1662,7 @@ Fill multiple fields and optionally submit a complex form. Sensitive values can
|
|
|
1662
1662
|
|
|
1663
1663
|
**Capture browser screenshot**
|
|
1664
1664
|
|
|
1665
|
-
Capture the visible area of the active or selected tab from the paired existing browser profile and return native MCP image content without focusing another window. Selecting an inactive tab may temporarily activate it. Immediately before activation, the extension revalidates that the same restore-baseline tab is still active in that window; a concurrent user tab switch fails definite pre-dispatch without activating anything. If the activation response is then lost, or if the resolved activation no longer verifies the same target tab in the restore-baseline window, the outcome is unknown, no capture or automatic rollback is attempted, and callers should inspect browser_list_tabs before retrying. Broker response loss after extension dispatch is attempted is also reported as unknown because the temporary activation/capture lifecycle may already have run. If the completed mutating extension result cannot be serialized or fit within the bounded response budget, that result settlement is likewise unknown because temporary tab activation/restoration may already have occurred. Fixed ambiguous browser settlements are returned as public, non-retryable MCP errors. Cancellation observed before temporary activation prevents activation; if it arrives after confirmed temporary activation but before capture, capture is skipped and the previous active tab is restored when safely verifiable. After confirmed temporary activation, later capture or verification failures restore the previous active tab when safe while preserving a concurrent user tab switch; restoration revalidates that the baseline tab still belongs to the capture window before activating it. Once the restore activation API is invoked, a rejected response, returned window mismatch, or failed post-restore verification is an unknown active-tab outcome and callers must inspect browser_list_tabs before retrying; no same screenshot is replayed automatically. Successful results use the verified post-capture active-tab observation for title/URL provenance and report tab_metadata_verified=true. Foreground execution is limited to 60 seconds; keep foreground interactions request-bounded and split longer workflows into independently terminal calls.
|
|
1665
|
+
Capture the visible area of the active or selected tab from the paired existing browser profile and return native MCP image content without focusing another window. Selecting an inactive tab may temporarily activate it; pass allow_tab_switch=false to refuse that activation, in which case an inactive target fails before capture and the active tab is never changed. Immediately before activation, the extension revalidates that the same restore-baseline tab is still active in that window; a concurrent user tab switch fails definite pre-dispatch without activating anything. If the activation response is then lost, or if the resolved activation no longer verifies the same target tab in the restore-baseline window, the outcome is unknown, no capture or automatic rollback is attempted, and callers should inspect browser_list_tabs before retrying. Broker response loss after extension dispatch is attempted is also reported as unknown because the temporary activation/capture lifecycle may already have run. If the completed mutating extension result cannot be serialized or fit within the bounded response budget, that result settlement is likewise unknown because temporary tab activation/restoration may already have occurred. Fixed ambiguous browser settlements are returned as public, non-retryable MCP errors. Cancellation observed before temporary activation prevents activation; if it arrives after confirmed temporary activation but before capture, capture is skipped and the previous active tab is restored when safely verifiable. After confirmed temporary activation, later capture or verification failures restore the previous active tab when safe while preserving a concurrent user tab switch; restoration revalidates that the baseline tab still belongs to the capture window before activating it. Once the restore activation API is invoked, a rejected response, returned window mismatch, or failed post-restore verification is an unknown active-tab outcome and callers must inspect browser_list_tabs before retrying; no same screenshot is replayed automatically. Successful results use the verified post-capture active-tab observation for title/URL provenance and report tab_metadata_verified=true. Foreground execution is limited to 60 seconds; keep foreground interactions request-bounded and split longer workflows into independently terminal calls.
|
|
1666
1666
|
|
|
1667
1667
|
| Contract field | Value |
|
|
1668
1668
|
|---|---|
|
|
@@ -1702,6 +1702,11 @@ Capture the visible area of the active or selected tab from the paired existing
|
|
|
1702
1702
|
"minimum": 1,
|
|
1703
1703
|
"maximum": 60,
|
|
1704
1704
|
"default": 30
|
|
1705
|
+
},
|
|
1706
|
+
"allow_tab_switch": {
|
|
1707
|
+
"type": "boolean",
|
|
1708
|
+
"default": true,
|
|
1709
|
+
"description": "When false, an inactive target tab fails before capture instead of being activated temporarily; the active tab is never changed."
|
|
1705
1710
|
}
|
|
1706
1711
|
}
|
|
1707
1712
|
}
|
|
@@ -1829,7 +1834,7 @@ Populate a browser file input from registered local resource files without retur
|
|
|
1829
1834
|
|
|
1830
1835
|
**Load agent context**
|
|
1831
1836
|
|
|
1832
|
-
Discover the instruction, skill, and registered-command inventory for a target path, including precedence and provenance. Use this when the caller needs the context itself; use resolve_task_capabilities when
|
|
1837
|
+
Discover the instruction, skill, and registered-command inventory for a target path, including precedence and provenance. Returns one consolidated effective_instructions body by default; set include_source_content=true to also return each source body. Set include_instruction_content=false to omit instruction bodies entirely. Use this when the caller needs the context itself; use resolve_task_capabilities when task-specific ranking and execution-route advice is needed.
|
|
1833
1838
|
|
|
1834
1839
|
| Contract field | Value |
|
|
1835
1840
|
|---|---|
|
|
@@ -1854,6 +1859,10 @@ Discover the instruction, skill, and registered-command inventory for a target p
|
|
|
1854
1859
|
"type": "boolean",
|
|
1855
1860
|
"default": true
|
|
1856
1861
|
},
|
|
1862
|
+
"include_source_content": {
|
|
1863
|
+
"type": "boolean",
|
|
1864
|
+
"default": false
|
|
1865
|
+
},
|
|
1857
1866
|
"max_skills": {
|
|
1858
1867
|
"type": "integer",
|
|
1859
1868
|
"minimum": 1,
|
|
@@ -1984,7 +1993,7 @@ List effective direct-argv commands from project manifests and safe automatic pa
|
|
|
1984
1993
|
|
|
1985
1994
|
**Run registered local command**
|
|
1986
1995
|
|
|
1987
|
-
Prefer this when the repository already defines the desired operation as a registered local command; a registered command may explicitly wrap a package-manager script. It runs the fixed argv/cwd/timeout contract without shell reinterpretation. A package script name is not implicitly registered: use run_process with the package manager argv when no registered command exists, or exec_command for ad hoc shell composition. Local
|
|
1996
|
+
Prefer this when the repository already defines the desired operation as a registered local command; a registered command may explicitly wrap a package-manager script. It runs the fixed argv/cwd/timeout contract without shell reinterpretation. A package script name is not implicitly registered: use run_process with the package manager argv when no registered command exists, or exec_command for ad hoc shell composition. Remote OAuth access is owner-only because arbitrary executables can read workspace credentials; delegated accounts use structured tools instead. Local stdio execution remains request-scoped. Remote execution is durable-first: the command is committed as a principal-bound one-step managed job and the response returns a job_id for read_job recovery across MCP disconnects or daemon replacement. Supply idempotency_key when retry-safe recovery of an ambiguous acceptance response is required. For a coherent workflow with several non-interactive commands, prefer a repository umbrella command or one multi-step start_job instead of issuing many one-step calls; this reduces host-visible event density without shortening execution.
|
|
1988
1997
|
|
|
1989
1998
|
| Contract field | Value |
|
|
1990
1999
|
|---|---|
|
|
@@ -2093,7 +2102,7 @@ List direct children of a workspace directory.
|
|
|
2093
2102
|
|
|
2094
2103
|
**List files**
|
|
2095
2104
|
|
|
2096
|
-
Recursively list files under a workspace path with bounded traversal and output.
|
|
2105
|
+
Recursively list files under a workspace path with bounded traversal and output. .git, node_modules, dist, build, coverage, .next, .turbo, .wrangler, Python cache directories, and virtual environments are ignored by default; set include_ignored=true to traverse them.
|
|
2097
2106
|
|
|
2098
2107
|
| Contract field | Value |
|
|
2099
2108
|
|---|---|
|
|
@@ -2118,6 +2127,10 @@ Recursively list files under a workspace path with bounded traversal and output.
|
|
|
2118
2127
|
"minimum": 1,
|
|
2119
2128
|
"maximum": 10000,
|
|
2120
2129
|
"default": 1000
|
|
2130
|
+
},
|
|
2131
|
+
"include_ignored": {
|
|
2132
|
+
"type": "boolean",
|
|
2133
|
+
"default": false
|
|
2121
2134
|
}
|
|
2122
2135
|
},
|
|
2123
2136
|
"additionalProperties": false
|
|
@@ -2128,7 +2141,7 @@ Recursively list files under a workspace path with bounded traversal and output.
|
|
|
2128
2141
|
|
|
2129
2142
|
**Read text file**
|
|
2130
2143
|
|
|
2131
|
-
Read a UTF-8 regular file or an inclusive 1-based line range.
|
|
2144
|
+
Read a UTF-8 regular file or an inclusive 1-based line range. Delegated remote roles are denied known credential-sensitive paths and protected control-plane roots; local/owner access follows its authority and operating-system permissions. Filename rules cannot detect secrets stored under arbitrary ordinary names.
|
|
2132
2145
|
|
|
2133
2146
|
| Contract field | Value |
|
|
2134
2147
|
|---|---|
|
|
@@ -2204,7 +2217,7 @@ Read a bounded PNG, JPEG, GIF, or WebP image from the workspace and return nativ
|
|
|
2204
2217
|
|
|
2205
2218
|
**Write text file**
|
|
2206
2219
|
|
|
2207
|
-
Atomically
|
|
2220
|
+
Atomically replace a UTF-8 file up to 5 MiB. Supports create-only and SHA-256 preconditions checked before replacement; the hash check is not a cross-process compare-and-swap. Expected state failures return typed conflict reasons without exposing file content or hashes.
|
|
2208
2221
|
|
|
2209
2222
|
| Contract field | Value |
|
|
2210
2223
|
|---|---|
|
|
@@ -2247,7 +2260,7 @@ Atomically write a UTF-8 file up to 5 MiB. Supports create-only and optimistic S
|
|
|
2247
2260
|
|
|
2248
2261
|
**Edit text file**
|
|
2249
2262
|
|
|
2250
|
-
Atomically replace an exact text fragment in one UTF-8 file. Missing text returns not_found; ambiguous text, stale
|
|
2263
|
+
Atomically replace an exact text fragment in one UTF-8 file while keeping the destination path visible through replacement. The SHA-256 precondition is checked before commit but is not a cross-process compare-and-swap. Missing text returns not_found; ambiguous text, stale preconditions, and unsupported targets return typed conflicts.
|
|
2251
2264
|
|
|
2252
2265
|
| Contract field | Value |
|
|
2253
2266
|
|---|---|
|
|
@@ -2328,7 +2341,7 @@ Apply a bounded Begin Patch/End Patch envelope containing add, update, move, or
|
|
|
2328
2341
|
|
|
2329
2342
|
**Search text**
|
|
2330
2343
|
|
|
2331
|
-
Search UTF-8 text files under a workspace path for a literal substring.
|
|
2344
|
+
Search UTF-8 text files under a workspace path for a literal substring. Supports a relative glob, case sensitivity, and bounded surrounding lines. Generated and dependency directories (.git, node_modules, dist, build, coverage, .next, .turbo, .wrangler, Python caches, and virtual environments) are ignored by default; set include_ignored=true to traverse them. Reports skipped_files and truncated=true when candidate files are skipped because of read limits, hard-link protection, unsafe file types, or delegated sensitive-path restrictions.
|
|
2332
2345
|
|
|
2333
2346
|
| Contract field | Value |
|
|
2334
2347
|
|---|---|
|
|
@@ -2346,7 +2359,8 @@ Search UTF-8 text files under a workspace path for a literal substring.
|
|
|
2346
2359
|
"properties": {
|
|
2347
2360
|
"query": {
|
|
2348
2361
|
"type": "string",
|
|
2349
|
-
"minLength": 1
|
|
2362
|
+
"minLength": 1,
|
|
2363
|
+
"maxLength": 4096
|
|
2350
2364
|
},
|
|
2351
2365
|
"path": {
|
|
2352
2366
|
"type": "string",
|
|
@@ -2363,6 +2377,25 @@ Search UTF-8 text files under a workspace path for a literal substring.
|
|
|
2363
2377
|
"minimum": 1,
|
|
2364
2378
|
"maximum": 100000,
|
|
2365
2379
|
"default": 10000
|
|
2380
|
+
},
|
|
2381
|
+
"glob": {
|
|
2382
|
+
"type": "string",
|
|
2383
|
+
"maxLength": 512,
|
|
2384
|
+
"description": "Optional relative glob used to filter paths, such as src/**/*.ts."
|
|
2385
|
+
},
|
|
2386
|
+
"case_sensitive": {
|
|
2387
|
+
"type": "boolean",
|
|
2388
|
+
"default": true
|
|
2389
|
+
},
|
|
2390
|
+
"context_lines": {
|
|
2391
|
+
"type": "integer",
|
|
2392
|
+
"minimum": 0,
|
|
2393
|
+
"maximum": 5,
|
|
2394
|
+
"default": 0
|
|
2395
|
+
},
|
|
2396
|
+
"include_ignored": {
|
|
2397
|
+
"type": "boolean",
|
|
2398
|
+
"default": false
|
|
2366
2399
|
}
|
|
2367
2400
|
},
|
|
2368
2401
|
"required": [
|
|
@@ -2565,7 +2598,7 @@ Create one local Git commit from the repository's existing staged index. This to
|
|
|
2565
2598
|
|
|
2566
2599
|
**Run process directly**
|
|
2567
2600
|
|
|
2568
|
-
Run an explicit executable plus argv when no shell syntax is needed and no registered command fits. This avoids quoting, globbing, pipelines, and redirection, but it is not a sandbox; use exec_command when Bash composition is the convenient choice. Local
|
|
2601
|
+
Run an explicit executable plus argv when no shell syntax is needed and no registered command fits. This avoids quoting, globbing, pipelines, and redirection, but it is not a sandbox; use exec_command when Bash composition is the convenient choice. Remote OAuth access is owner-only because arbitrary executables can read workspace credentials; delegated accounts use structured tools instead. Local stdio execution remains request-scoped. Remote execution is durable-first: the argv is committed as a principal-bound one-step managed job and the response returns a job_id for read_job recovery across MCP disconnects or daemon replacement. Supply idempotency_key when retry-safe recovery of an ambiguous acceptance response is required. For a coherent workflow with several non-interactive commands, prefer a repository umbrella command or one multi-step start_job instead of issuing many one-step calls; this reduces host-visible event density without shortening execution.
|
|
2569
2602
|
|
|
2570
2603
|
| Contract field | Value |
|
|
2571
2604
|
|---|---|
|
|
@@ -2615,7 +2648,7 @@ Run an explicit executable plus argv when no shell syntax is needed and no regis
|
|
|
2615
2648
|
|
|
2616
2649
|
**Start process session**
|
|
2617
2650
|
|
|
2618
|
-
Start a direct argv process without a shell and retain bounded stdout, stderr, and stdin state across MCP calls. Cancellation before spawn is definite. If cancellation or deadline arrives after the child has spawned but before the start result settles, the server requests termination and returns a public non-retryable unknown outcome with the allocated session_id; the retained session remains inspectable so callers can verify its state instead of starting the command again blindly. Process sessions are daemon-lifetime state: use start_job/read_job when work must survive a Machine Bridge daemon restart, service replacement, or MCP disconnect. For an authorized remote call on macOS, a successfully admitted session keeps an idle-sleep assertion for the child lifetime; this does not override explicit sleep or lid-close behavior.
|
|
2651
|
+
Start a direct argv process without a shell and retain bounded stdout, stderr, and stdin state across MCP calls. Cancellation before spawn is definite. If cancellation or deadline arrives after the child has spawned but before the start result settles, the server requests termination and returns a public non-retryable unknown outcome with the allocated session_id; the retained session remains inspectable so callers can verify its state instead of starting the command again blindly. Process sessions are daemon-lifetime state: use start_job/read_job when work must survive a Machine Bridge daemon restart, service replacement, or MCP disconnect. For an authorized remote call on macOS, a successfully admitted session keeps an idle-sleep assertion for the child lifetime; this does not override explicit sleep or lid-close behavior. Remote OAuth process-session access is owner-only because arbitrary executables can read workspace credentials.
|
|
2619
2652
|
|
|
2620
2653
|
| Contract field | Value |
|
|
2621
2654
|
|---|---|
|
|
@@ -2655,7 +2688,7 @@ Start a direct argv process without a shell and retain bounded stdout, stderr, a
|
|
|
2655
2688
|
|
|
2656
2689
|
**Read process session**
|
|
2657
2690
|
|
|
2658
|
-
Read bounded stdout and stderr deltas from a running process session or a recently completed one-shot command continuation, optionally waiting briefly for new output.
|
|
2691
|
+
Read bounded stdout and stderr deltas from a running process session or a recently completed one-shot command continuation, optionally waiting briefly for new output. Remote OAuth process-session access is owner-only.
|
|
2659
2692
|
|
|
2660
2693
|
| Contract field | Value |
|
|
2661
2694
|
|---|---|
|
|
@@ -2712,7 +2745,7 @@ Read bounded stdout and stderr deltas from a running process session or a recent
|
|
|
2712
2745
|
|
|
2713
2746
|
**Write process stdin**
|
|
2714
2747
|
|
|
2715
|
-
Write bounded UTF-8 data to a live process session and optionally close its stdin stream. Cancellation before any stdin mutation is definite. Once stdin.write or stdin.end has been invoked, callback/error/cancellation ambiguity is returned as a public non-retryable unknown outcome with the session_id; inspect the session before writing the same data again because the child may already have consumed it.
|
|
2748
|
+
Write bounded UTF-8 data to a live process session and optionally close its stdin stream. Cancellation before any stdin mutation is definite. Once stdin.write or stdin.end has been invoked, callback/error/cancellation ambiguity is returned as a public non-retryable unknown outcome with the session_id; inspect the session before writing the same data again because the child may already have consumed it. Remote OAuth process-session access is owner-only.
|
|
2716
2749
|
|
|
2717
2750
|
| Contract field | Value |
|
|
2718
2751
|
|---|---|
|
|
@@ -2751,7 +2784,7 @@ Write bounded UTF-8 data to a live process session and optionally close its stdi
|
|
|
2751
2784
|
|
|
2752
2785
|
**Terminate process session**
|
|
2753
2786
|
|
|
2754
|
-
Terminate a live server-managed process tree with graceful or forced termination.
|
|
2787
|
+
Terminate a live server-managed process tree with graceful or forced termination. Remote OAuth process-session access is owner-only.
|
|
2755
2788
|
|
|
2756
2789
|
| Contract field | Value |
|
|
2757
2790
|
|---|---|
|
|
@@ -3411,7 +3444,7 @@ Request cancellation of a detached managed job. The runner terminates the active
|
|
|
3411
3444
|
|
|
3412
3445
|
**Execute shell command**
|
|
3413
3446
|
|
|
3414
|
-
Run Bash-compatible shell composition in the workspace: pipelines, redirection, globbing, conditionals, or compact multi-command probes. This is the convenient general escape hatch, not a sandbox, and has the local user's operating-system authority. Prefer run_local_command for an existing fixed project command and run_process when no shell syntax is needed. Local
|
|
3447
|
+
Run Bash-compatible shell composition in the workspace: pipelines, redirection, globbing, conditionals, or compact multi-command probes. This is the convenient general escape hatch, not a sandbox, and has the local user's operating-system authority. Prefer run_local_command for an existing fixed project command and run_process when no shell syntax is needed. Remote OAuth access is owner-only because arbitrary executables can read workspace credentials; delegated accounts use structured tools instead. Local stdio execution remains request-scoped. Remote execution is durable-first: the shell argv is committed as a principal-bound one-step managed job and the response returns a job_id for read_job recovery across MCP disconnects or daemon replacement. Supply idempotency_key when retry-safe recovery of an ambiguous acceptance response is required. For a coherent workflow with several non-interactive commands, prefer one multi-step start_job or a repository umbrella command instead of a chain of one-step shell calls; this reduces host-visible event density without shortening execution.
|
|
3415
3448
|
|
|
3416
3449
|
| Contract field | Value |
|
|
3417
3450
|
|---|---|
|
package/docs/UPGRADING.md
CHANGED
|
@@ -6,7 +6,7 @@ This file defines the **currently supported upgrade path only**. Older version n
|
|
|
6
6
|
|
|
7
7
|
Machine Bridge supports direct upgrade from the immediately preceding published release. The repository may also need one bounded transition from the exact live owner-machine candidate named in the current changelog. Obsolete MCP transports, protocol sessions, replay stores, authorization workflows, and alternate runtime implementations are not retained as hidden compatibility paths.
|
|
8
8
|
|
|
9
|
-
Version 3 is a coordinated Worker, daemon, CLI, and browser-extension system. Components are expected to converge on the same exact package version before an upgrade is considered healthy. Mixed 2.x/3.x operation is unsupported. MCP `2026-07-28` is the only supported request-scoped protocol for both stdio and remote HTTP.
|
|
9
|
+
Version 3 is a coordinated Worker, daemon, CLI, and browser-extension system. Components are expected to converge on the same exact package version before an upgrade is considered healthy. Mixed 2.x/3.x operation is unsupported. MCP `2026-07-28` is the only supported request-scoped protocol for both stdio and remote HTTP. The default stdio path and remote HTTP reject obsolete initialization/session/replay behavior. The optional stdio `--compat` shim accepts only the initialization handshake and does not restore sessions, replay, or older protocol versions.
|
|
10
10
|
|
|
11
11
|
State migration is different from protocol compatibility. A bounded one-way reader may transform only the explicitly supported immediately preceding/live state for a subsystem without deleting credentials or creating split-brain ownership; ambiguous state fails closed and removed runtime behavior is not restored. Browser pairing uses schema 3, with one narrow beta.198-to-beta.199 transition: only the exact stable beta.198 schema-2 envelope with `pairingAuthVersion: 2` and `migrationPending: false` is accepted, and its two existing credentials plus port are preserved while the obsolete marker is removed. A beta.198 envelope with `migrationPending: true` remains blocked until beta.198 completes that earlier migration; older, extra-field, malformed, or coercible shapes remain unsupported. Security-audit persistence uses schema 3, with one deliberately narrow beta.198-to-beta.199 transition: the reader accepts only the exact beta.198 schema-1 envelope, validates its exact keys and native field types, verifies the existing hash chain, and preserves every prior event object and hash unchanged as an explicit legacy prefix before current events are appended. Schema 2 and unrelated older audit shapes remain unsupported. OAuth refresh persistence remains schema 3 with bounded consumed-token shards. Beta.198 already writes that current sharded OAuth shape; beta.199 no longer carries the older schema-1/schema-2 refresh upgrader or the pre-shard consumed-marker merger. An older runtime cannot safely read current state. Rollback must restore the complete pre-upgrade state root together with the prior package, Worker, service definition, and browser extension.
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ Existing browser pairing and OAuth state should be left in place. Beta.199 upgra
|
|
|
18
18
|
|
|
19
19
|
## MCP client transition
|
|
20
20
|
|
|
21
|
-
Machine Bridge uses MCP `2026-07-28` for both remote HTTP and stdio.
|
|
21
|
+
Machine Bridge uses MCP `2026-07-28` for both remote HTTP and stdio. Full initialization/session protocol compatibility is not retained. Stdio has one narrow, opt-in `--compat` handshake shim for hosts that require `initialize`; it creates no session or replay state and does not enable older protocol versions. See [client transport guidance](CLIENTS.md#current-protocol-requirements).
|
|
22
22
|
|
|
23
23
|
Current/native clients must:
|
|
24
24
|
|
|
@@ -31,7 +31,7 @@ Current/native clients must:
|
|
|
31
31
|
- treat `server/discover` instructions and `tools/list` as non-reusable across semantic upgrades: both current responses advertise `ttlMs=0`, every tool description carries `Tool schema generation N`, and the live generation/version plus `discovery_ttl_ms=0` / `tool_list_ttl_ms=0` can be compared with `server_info.tool_delivery`; `host_turn_deadline_observable=false` means Machine Bridge cannot predict an external assistant-turn cutoff, while `managed_jobs_detached_from_mcp_response=true` means that cutoff does not own an accepted durable job; a new daemon/Worker version does not prove that an external host discarded a stale instruction/tool snapshot;
|
|
32
32
|
- not use `Mcp-Session-Id`, recovery `GET /mcp`, SSE event IDs, `Last-Event-ID`, or protocol-session replay.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
With stdio compatibility disabled, any `initialize` request receives bounded rejection/upgrade guidance. With the opt-in shim enabled, only the handshake is accepted; subsequent requests still require current request-scoped metadata, and explicit retired/future versions are rejected. Removed session markers, replay markers, and other explicit retired protocol-session markers cannot reconstruct or dispatch old behavior. Remote `GET /mcp` is unsupported and returns 405; it is not a recovery channel.
|
|
35
35
|
|
|
36
36
|
Unknown/future protocol versions are also rejected. Machine Bridge does not guess that a newer client is wire-compatible with the current server.
|
|
37
37
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "machine-bridge-mcp",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.205",
|
|
4
4
|
"description": "Cross-client MCP bridge for local agent context, structured browser and application automation, files, Git, processes, resources, and durable jobs over stdio or OAuth relay.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"catalog:test": "node tests/catalog-test.mjs",
|
|
112
112
|
"tool-arguments:test": "node tests/tool-argument-validation-test.mjs",
|
|
113
113
|
"managed-job-output-redaction:test": "node tests/managed-job-output-redaction-test.mjs",
|
|
114
|
-
"managed-jobs:test": "node tests/managed-jobs-test.mjs",
|
|
114
|
+
"managed-jobs:test": "node tests/managed-jobs-test.mjs && node tests/managed-job-terminal-maintenance-test.mjs",
|
|
115
115
|
"ssh-key:test": "node tests/ssh-key-test.mjs",
|
|
116
116
|
"full-access:test": "node tests/full-access-test.mjs",
|
|
117
117
|
"atomic-fs:test": "node tests/atomic-fs-test.mjs",
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
"relay-http-fallback:test": "node tests/relay-http-fallback-test.mjs",
|
|
128
128
|
"install:test": "node tests/install-smoke-test.mjs",
|
|
129
129
|
"secure-file:test": "node tests/secure-file-test.mjs",
|
|
130
|
+
"workspace-search-security:test": "node tests/workspace-search-security-test.mjs",
|
|
130
131
|
"worker-secret-file:test": "node tests/worker-secret-file-test.mjs",
|
|
131
132
|
"architecture:test": "node tests/architecture-test.mjs",
|
|
132
133
|
"markdown:test": "node tests/markdown-test.mjs",
|
|
@@ -189,6 +190,7 @@
|
|
|
189
190
|
"oauth-browser:test": "node tests/oauth-browser-navigation-test.mjs",
|
|
190
191
|
"worker-deployment:test": "node tests/worker-deployment-test.mjs",
|
|
191
192
|
"typecheck:local": "tsc -p tsconfig.local.json --noEmit",
|
|
193
|
+
"local-typecheck-coverage:test": "node tests/local-typecheck-coverage-test.mjs",
|
|
192
194
|
"runtime-boundaries:test": "node tests/runtime-boundaries-test.mjs",
|
|
193
195
|
"git-commit:test": "node tests/git-commit-test.mjs",
|
|
194
196
|
"worker-oauth-controller:test": "node tests/worker-oauth-controller-test.mjs",
|
|
@@ -210,6 +212,7 @@
|
|
|
210
212
|
"full-verification-receipt:test": "node tests/full-verification-receipt-test.mjs",
|
|
211
213
|
"process-output:test": "node tests/process-output-continuation-test.mjs",
|
|
212
214
|
"process-nonreplayable:test": "node tests/process-nonreplayable-test.mjs",
|
|
215
|
+
"process-fatal:test": "node tests/process-fatal-test.mjs",
|
|
213
216
|
"github-backlog:test": "node tests/github-backlog-test.mjs",
|
|
214
217
|
"github:backlog": "node scripts/github-backlog.mjs",
|
|
215
218
|
"operation-authorization:test": "node tests/operation-authorization-test.mjs",
|
|
@@ -325,7 +328,7 @@
|
|
|
325
328
|
"packageManager": {
|
|
326
329
|
"name": "npm",
|
|
327
330
|
"version": ">=12.0.0",
|
|
328
|
-
"onFail": "
|
|
331
|
+
"onFail": "warn"
|
|
329
332
|
}
|
|
330
333
|
},
|
|
331
334
|
"overrides": {
|
package/scripts/github-push.mjs
CHANGED
|
@@ -24,7 +24,7 @@ try {
|
|
|
24
24
|
const branch = output(git, ["branch", "--show-current"]);
|
|
25
25
|
if (!branch) throw new Error("cannot push from a detached HEAD");
|
|
26
26
|
if (branch === "main") throw new Error("direct pushes to main are prohibited; push a reviewed branch and merge through a pull request");
|
|
27
|
-
runNetwork(git, ["fetch", "origin", "main", "--prune"]);
|
|
27
|
+
runNetwork(git, ["fetch", "origin", "main", "--prune"], { retryMode: "safe" });
|
|
28
28
|
const backlog = assertGitHubBacklogReady({ cwd: root, branch, git, gh, run: runBacklogCommand });
|
|
29
29
|
console.log(backlog.message);
|
|
30
30
|
|
|
@@ -84,8 +84,8 @@ function run(command, args, options = {}) {
|
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function runNetwork(command, args) {
|
|
88
|
-
const result = runNetworkCommand(command, args, { cwd: root, env: process.env, timeoutMs: 120_000 });
|
|
87
|
+
function runNetwork(command, args, options = {}) {
|
|
88
|
+
const result = runNetworkCommand(command, args, { cwd: root, env: process.env, timeoutMs: 120_000, retryMode: options.retryMode });
|
|
89
89
|
if (result.error || result.status !== 0) throw new Error(releaseCommandFailure(command, args, result));
|
|
90
90
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
91
91
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
@@ -93,7 +93,7 @@ function runNetwork(command, args) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function runBacklogCommand(command, args, cwd) {
|
|
96
|
-
const result = runNetworkCommand(command, args, { cwd, env: process.env, timeoutMs: 120_000 });
|
|
96
|
+
const result = runNetworkCommand(command, args, { cwd, env: process.env, timeoutMs: 120_000, retryMode: "safe" });
|
|
97
97
|
if (result.error || result.status !== 0) throw new Error(releaseCommandFailure(command, args, result));
|
|
98
98
|
return result;
|
|
99
99
|
}
|
|
@@ -56,7 +56,7 @@ function run(command, args, options = {}) {
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
function runNetwork(command, args, options = {}) {
|
|
59
|
-
const result = runNetworkCommand(command, args, { cwd: root, env: process.env });
|
|
59
|
+
const result = runNetworkCommand(command, args, { cwd: root, env: process.env, retryMode: options.retryMode });
|
|
60
60
|
if (!options.capture) {
|
|
61
61
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
62
62
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
@@ -67,7 +67,7 @@ function runNetwork(command, args, options = {}) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function outputNetwork(command, args, options = {}) {
|
|
70
|
-
const result = runNetwork(command, args, { ...options, capture: true });
|
|
70
|
+
const result = runNetwork(command, args, { ...options, capture: true, retryMode: options.retryMode || "safe" });
|
|
71
71
|
return (result.stdout ?? "").trim();
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -122,7 +122,7 @@ function ensureClean() {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function fetchRemote() {
|
|
125
|
-
runNetwork(git, ["fetch", "origin", "main", "--tags", "--prune"]);
|
|
125
|
+
runNetwork(git, ["fetch", "origin", "main", "--tags", "--prune"], { retryMode: "safe" });
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function localTagCommit(tag) {
|
|
@@ -184,7 +184,7 @@ async function waitForSuccessfulCi(head) {
|
|
|
184
184
|
}
|
|
185
185
|
function releaseInfo(tag) {
|
|
186
186
|
const args = ["api", githubReleaseByTagEndpoint(tag)];
|
|
187
|
-
const result = runNetwork(gh, args, { capture: true, allowFailure: true });
|
|
187
|
+
const result = runNetwork(gh, args, { capture: true, allowFailure: true, retryMode: "safe" });
|
|
188
188
|
if (result.status !== 0 || result.error) {
|
|
189
189
|
const detail = `${result.stdout ?? ""}${result.stderr ?? ""}${result.error?.message ?? ""}`.trim();
|
|
190
190
|
if (/\bHTTP 404\b|\bstatus 404\b|\b404 Not Found\b/i.test(detail)) return null;
|
|
@@ -4,7 +4,10 @@ const WAIT_BUFFER = new Int32Array(new SharedArrayBuffer(4));
|
|
|
4
4
|
const TRANSIENT_NETWORK_FAILURE = /(?:SSL_ERROR_SYSCALL|SSL_connect|TLS handshake timeout|Client network socket disconnected before secure TLS connection was established|unexpected EOF|unexpected eof while reading|\bEOF\b|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENETUNREACH|ECONNREFUSED|Could not resolve host|Failed to connect|connection (?:was )?reset|remote end hung up|unexpected disconnect|HTTP (?:429|5\d\d)|(?:502|503|504) (?:Bad Gateway|Service Unavailable|Gateway Timeout))/i;
|
|
5
5
|
|
|
6
6
|
export function runNetworkCommand(command, args, options = {}) {
|
|
7
|
-
|
|
7
|
+
// Replaying a timed-out mutation can duplicate a remote side effect. Retries are opt-in
|
|
8
|
+
// only for operations whose callers have classified as safe to repeat.
|
|
9
|
+
const retryMode = options.retryMode === "safe" ? "safe" : "never";
|
|
10
|
+
const attempts = retryMode === "safe" ? clampInteger(options.attempts, 3, 1, 5) : 1;
|
|
8
11
|
const baseDelayMs = clampInteger(options.baseDelayMs, 750, 0, 10_000);
|
|
9
12
|
const timeoutMs = clampInteger(options.timeoutMs, 120_000, 10, 600_000);
|
|
10
13
|
const actualArgs = networkCommandArgs(command, args);
|
|
@@ -108,6 +108,7 @@ function runNpmView(args, options = {}) {
|
|
|
108
108
|
const result = runNetworkCommand(process.execPath, [npmCli, "view", "--workspaces=false", "--global=false", ...args], {
|
|
109
109
|
env: nestedNpmEnvironment(options.env || process.env),
|
|
110
110
|
timeoutMs: options.timeoutMs,
|
|
111
|
+
retryMode: "safe",
|
|
111
112
|
});
|
|
112
113
|
if (result.error || result.status !== 0) {
|
|
113
114
|
const detail = String(result.stderr || result.stdout || result.error?.message || "");
|
|
@@ -126,6 +127,7 @@ function runGh(args) {
|
|
|
126
127
|
const result = runNetworkCommand(resolveTrustedGithubCli({ workspace: process.cwd() }), args, {
|
|
127
128
|
env: process.env,
|
|
128
129
|
timeoutMs: 120_000,
|
|
130
|
+
retryMode: "safe",
|
|
129
131
|
});
|
|
130
132
|
if (result.error || result.status !== 0) throw new Error(releaseCommandFailure("gh", args, result));
|
|
131
133
|
try { return JSON.parse(result.stdout); } catch { throw new Error("GitHub prerelease query returned invalid JSON"); }
|
|
@@ -3,13 +3,11 @@ import { BridgeError } from "./errors.mjs";
|
|
|
3
3
|
import { buildAuthorityContext } from "./authority-context.mjs";
|
|
4
4
|
import { policyProfile, toolNamesForPolicy, assertToolAllowed } from "./policy.mjs";
|
|
5
5
|
|
|
6
|
-
export const ACCOUNT_ACCESS_REVISION = Number(accessContract.revision);
|
|
7
6
|
const OWNER_ONLY_TOOLS = new Set((accessContract.ownerOnlyTools || []).map(String));
|
|
8
7
|
const ACCOUNT_ROLE_ENTRIES = Object.entries(accessContract.roles)
|
|
9
8
|
.map(([name, value]) => [name, Object.freeze({ ...value })]);
|
|
10
9
|
const ACCOUNT_ROLE_BY_NAME = new Map(ACCOUNT_ROLE_ENTRIES);
|
|
11
10
|
export const ACCOUNT_ROLES = Object.freeze(Object.fromEntries(ACCOUNT_ROLE_ENTRIES));
|
|
12
|
-
export const DEFAULT_ACCOUNT_ROLE = String(accessContract.defaultRole);
|
|
13
11
|
export const OWNER_ACCOUNT_ROLE = String(accessContract.ownerRole);
|
|
14
12
|
|
|
15
13
|
export function normalizeAccountRole(value) {
|
|
@@ -4,6 +4,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
4
4
|
import { createBuiltinInstruction, discoverAutomaticProjectInstruction } from "./default-instructions.mjs";
|
|
5
5
|
import { automaticPackageCommands, readProjectPackageMetadata } from "./project-package.mjs";
|
|
6
6
|
import { clampInteger } from "./numbers.mjs";
|
|
7
|
+
import { isSensitivePath } from "./operation-risk.mjs";
|
|
7
8
|
import {
|
|
8
9
|
discoverLocalSkills, listSkillFiles, MAX_SKILL_ENTRY_BYTES, MAX_SKILL_FILES, MAX_SKILL_RESULTS,
|
|
9
10
|
} from "./agent-skill-discovery.mjs";
|
|
@@ -47,7 +48,8 @@ export class AgentContextManager {
|
|
|
47
48
|
|
|
48
49
|
async agentContext(args = {}, context = {}) {
|
|
49
50
|
const state = await this.discoverState(args.path || ".", context);
|
|
50
|
-
const
|
|
51
|
+
const includeEffectiveContent = args.include_instruction_content !== false;
|
|
52
|
+
const includeSourceContent = args.include_source_content === true;
|
|
51
53
|
const skillLimit = clampInteger(args.max_skills, 100, 1, MAX_SKILL_RESULTS);
|
|
52
54
|
const discoveredSkills = await this.discoverSkills(state, { maxResults: MAX_SKILL_RESULTS }, context);
|
|
53
55
|
const contextSkills = contextSkillSummaries(discoveredSkills.skills, (value) => this.displayPath(value, context), skillLimit, MAX_CONTEXT_SKILL_SUMMARY_CHARS);
|
|
@@ -56,13 +58,13 @@ export class AgentContextManager {
|
|
|
56
58
|
scope_root: this.displayPath(state.scopeRoot, context),
|
|
57
59
|
precedence: "built-in defaults, automatic project facts, user-global guidance, then scope root to target directory; explicit files loaded later have higher precedence",
|
|
58
60
|
config_files: state.configFiles.map((file) => this.displayPath(file, context)),
|
|
59
|
-
builtin_instructions: publicVirtualInstruction(state.builtinInstructions,
|
|
60
|
-
automatic_project_context: publicVirtualInstruction(state.automaticProjectContext,
|
|
61
|
+
builtin_instructions: publicVirtualInstruction(state.builtinInstructions, includeSourceContent),
|
|
62
|
+
automatic_project_context: publicVirtualInstruction(state.automaticProjectContext, includeSourceContent),
|
|
61
63
|
model_instructions_file: state.modelInstructions ? {
|
|
62
64
|
path: this.displayPath(state.modelInstructions.path, context),
|
|
63
65
|
bytes: state.modelInstructions.bytes,
|
|
64
66
|
sha256: state.modelInstructions.sha256,
|
|
65
|
-
...(
|
|
67
|
+
...(includeSourceContent ? { content: state.modelInstructions.content } : {}),
|
|
66
68
|
} : null,
|
|
67
69
|
instruction_files: state.instructions.map((item) => ({
|
|
68
70
|
scope: item.scope,
|
|
@@ -70,11 +72,12 @@ export class AgentContextManager {
|
|
|
70
72
|
bytes: item.bytes,
|
|
71
73
|
sha256: item.sha256,
|
|
72
74
|
precedence: item.precedence,
|
|
73
|
-
...(
|
|
75
|
+
...(includeSourceContent ? { content: item.content } : {}),
|
|
74
76
|
})),
|
|
75
77
|
skills: contextSkills.skills,
|
|
76
78
|
skills_truncated: discoveredSkills.truncated || contextSkills.truncated,
|
|
77
79
|
skill_warnings: publicSkillWarnings(discoveredSkills.warnings, (value) => this.displayPath(value, context)),
|
|
80
|
+
instruction_warnings: state.instructionWarnings.map((message) => message),
|
|
78
81
|
instructions_truncated: state.instructionsTruncated,
|
|
79
82
|
commands: publicCommands(state.commands, (value) => this.displayPath(value, context)),
|
|
80
83
|
metadata_authority: METADATA_AUTHORITY,
|
|
@@ -85,7 +88,7 @@ export class AgentContextManager {
|
|
|
85
88
|
"Prefer run_local_command for registered repeatable commands. Use run_process or exec_command only when no registered command fits and policy permits it.",
|
|
86
89
|
],
|
|
87
90
|
};
|
|
88
|
-
if (
|
|
91
|
+
if (includeEffectiveContent) result.effective_instructions = renderEffectiveInstructions(effectiveInstructionItems(state), (value) => this.displayPath(value, context));
|
|
89
92
|
return result;
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -104,6 +107,7 @@ export class AgentContextManager {
|
|
|
104
107
|
skills_scanned: false,
|
|
105
108
|
generated_at: new Date().toISOString(),
|
|
106
109
|
},
|
|
110
|
+
instruction_warnings: state.instructionWarnings.map((message) => message),
|
|
107
111
|
guidance: [
|
|
108
112
|
"Built-in working agreements and bounded automatic project facts are present by default unless disabled in the user-global agent config.",
|
|
109
113
|
"Call resolve_task_capabilities only when skill, command, application/browser routing, or refreshed project instructions are needed; use direct file, Git, and execution tools for straightforward work.",
|
|
@@ -178,6 +182,7 @@ export class AgentContextManager {
|
|
|
178
182
|
recommended_tools: recommendedTools,
|
|
179
183
|
host_semantics: "Machine Bridge can discover, rank, and load project/user-provided capability context automatically. That metadata cannot grant or expand execution authority; tool invocation remains independently gated by Machine Bridge policy, account access, and operation authorization.",
|
|
180
184
|
warnings: publicSkillWarnings(discovered.warnings, (value) => this.displayPath(value, context)),
|
|
185
|
+
instruction_warnings: state.instructionWarnings.map((message) => message),
|
|
181
186
|
truncated: discovered.truncated,
|
|
182
187
|
};
|
|
183
188
|
}
|
|
@@ -185,6 +190,10 @@ export class AgentContextManager {
|
|
|
185
190
|
async collectModelInstructions(state, context) {
|
|
186
191
|
this.throwIfCancelled(context);
|
|
187
192
|
const path = state.modelInstructionsFile;
|
|
193
|
+
if (isDelegatedRelayContext(context) && isSensitivePath(path)) {
|
|
194
|
+
state.instructionWarnings.push("A sensitive model-instruction path was skipped for a delegated account.");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
188
197
|
const info = await lstat(path, { bigint: true }).catch((error) => error?.code === "ENOENT" ? null : Promise.reject(error));
|
|
189
198
|
if (!info) throw new Error(`model_instructions_file does not exist: ${path}`);
|
|
190
199
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`model_instructions_file must be a regular non-symbolic-link file: ${path}`);
|
|
@@ -312,6 +321,7 @@ export class AgentContextManager {
|
|
|
312
321
|
instructions: [],
|
|
313
322
|
instructionBytes: 0,
|
|
314
323
|
instructionsTruncated: false,
|
|
324
|
+
instructionWarnings: [],
|
|
315
325
|
};
|
|
316
326
|
|
|
317
327
|
const packageMetadata = await readProjectPackageMetadata(scopeRoot, () => this.throwIfCancelled(context));
|
|
@@ -410,6 +420,10 @@ export class AgentContextManager {
|
|
|
410
420
|
return;
|
|
411
421
|
}
|
|
412
422
|
const candidate = resolveInstructionPath(canonicalDirectory, configuredName);
|
|
423
|
+
if (isDelegatedRelayContext(context) && isSensitivePath(candidate)) {
|
|
424
|
+
state.instructionWarnings.push("A sensitive project instruction path was skipped for a delegated account.");
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
413
427
|
const info = await lstat(candidate).catch((error) => error?.code === "ENOENT" ? null : Promise.reject(error));
|
|
414
428
|
if (!info) continue;
|
|
415
429
|
if (info.isSymbolicLink()) throw new Error(`instruction file must not be a symbolic link: ${candidate}`);
|
|
@@ -452,6 +466,13 @@ export class AgentContextManager {
|
|
|
452
466
|
}
|
|
453
467
|
}
|
|
454
468
|
|
|
469
|
+
function isDelegatedRelayContext(context) {
|
|
470
|
+
const authority = context?.authority;
|
|
471
|
+
const principal = authority?.principal;
|
|
472
|
+
return context?.origin === "relay" && principal?.kind === "account"
|
|
473
|
+
&& principal.role !== "owner" && authority.owner !== true;
|
|
474
|
+
}
|
|
475
|
+
|
|
455
476
|
function sameArgv(left, right) {
|
|
456
477
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
457
478
|
}
|
|
@@ -4,6 +4,7 @@ import { dirname, join, relative, sep } from "node:path";
|
|
|
4
4
|
import { assertAllowedPath, MAX_SKILL_ROOTS } from "./agent-contract.mjs";
|
|
5
5
|
import { sha256 } from "./agent-context-projection.mjs";
|
|
6
6
|
import { readRegularUtf8 } from "./agent-text-file.mjs";
|
|
7
|
+
import { isSensitivePath } from "./operation-risk.mjs";
|
|
7
8
|
import { classifyOperationalError } from "./log.mjs";
|
|
8
9
|
|
|
9
10
|
export const MAX_SKILL_ENTRY_BYTES = 512 * 1024;
|
|
@@ -73,6 +74,10 @@ export async function discoverLocalSkills(options) {
|
|
|
73
74
|
if (entrypoint) {
|
|
74
75
|
const canonical = await realpath(entrypoint);
|
|
75
76
|
assertAllowedPath(canonical, options.workspace, options.unrestricted, "skill entrypoint");
|
|
77
|
+
if (isDelegatedRelayContext(options.context) && isSensitivePath(canonical)) {
|
|
78
|
+
if (warnings.length < 100) warnings.push({ entrypoint: canonical, message: "sensitive skill path skipped for delegated account" });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
76
81
|
if (!seenEntrypoints.has(canonical)) {
|
|
77
82
|
seenEntrypoints.add(canonical);
|
|
78
83
|
try {
|
|
@@ -128,6 +133,15 @@ export async function discoverLocalSkills(options) {
|
|
|
128
133
|
return { skills, warnings, truncated };
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
/** @param {unknown} context */
|
|
137
|
+
function isDelegatedRelayContext(context) {
|
|
138
|
+
const record = /** @type {Record<string, unknown>} */ (context !== null && typeof context === "object" ? context : {});
|
|
139
|
+
const authority = /** @type {Record<string, unknown>} */ (record.authority !== null && typeof record.authority === "object" ? record.authority : {});
|
|
140
|
+
const principal = /** @type {Record<string, unknown>} */ (authority.principal !== null && typeof authority.principal === "object" ? authority.principal : {});
|
|
141
|
+
return record.origin === "relay" && principal.kind === "account"
|
|
142
|
+
&& principal.role !== "owner" && authority.owner !== true;
|
|
143
|
+
}
|
|
144
|
+
|
|
131
145
|
/** @param {string} root @param {number} maxFiles @param {unknown} context @param {(context: unknown) => void} throwIfCancelled @param {string} [expectedRoot] */
|
|
132
146
|
export async function listSkillFiles(root, maxFiles, context, throwIfCancelled, expectedRoot) {
|
|
133
147
|
root = await realpath(root);
|
|
@@ -17,6 +17,7 @@ export async function readOptionalRegularUtf8(filePath, maxBytes, label, assertC
|
|
|
17
17
|
export async function readRegularUtf8(filePath, maxBytes, label, options = {}) {
|
|
18
18
|
const expected = options.expectedInfo || await lstat(filePath, { bigint: true });
|
|
19
19
|
if (!expected.isFile() || expected.isSymbolicLink()) throw new Error(`${label} is not a regular file: ${filePath}`);
|
|
20
|
+
if (expected.nlink > 1n) throw new Error(`${label} must not have multiple hard links: ${filePath}`);
|
|
20
21
|
const canonical = await realpath(filePath);
|
|
21
22
|
if (options.canonicalPath !== undefined && canonical !== options.canonicalPath) throw new Error(`${label} changed during read`);
|
|
22
23
|
const assertCurrent = async () => {
|
|
@@ -30,6 +31,7 @@ export async function readRegularUtf8(filePath, maxBytes, label, options = {}) {
|
|
|
30
31
|
try {
|
|
31
32
|
const info = await handle.stat({ bigint: true });
|
|
32
33
|
if (!sameRegularFile(info, expected)) throw new Error(`${label} changed during read`);
|
|
34
|
+
if (info.nlink > 1n) throw new Error(`${label} must not have multiple hard links: ${filePath}`);
|
|
33
35
|
await assertCurrent();
|
|
34
36
|
if (info.size > BigInt(maxBytes)) throw new Error(`${label} exceeds maximum size (${info.size} > ${maxBytes})`);
|
|
35
37
|
const buffer = Buffer.alloc(Number(info.size));
|
|
@@ -68,17 +68,8 @@ export class AppAutomationManager {
|
|
|
68
68
|
|
|
69
69
|
capabilities() {
|
|
70
70
|
return {
|
|
71
|
-
|
|
72
|
-
discovery: true,
|
|
73
|
-
open: true,
|
|
74
|
-
accessibility_inspection: this.platform === "darwin",
|
|
75
|
-
structured_accessibility_actions: this.platform === "darwin",
|
|
76
|
-
window_screenshot: this.platform === "darwin",
|
|
71
|
+
...desktopAutomationCapabilities(this.platform),
|
|
77
72
|
background_visual_point: this.visualPointCapability(),
|
|
78
|
-
arbitrary_script_execution: false,
|
|
79
|
-
permission_note: this.platform === "darwin"
|
|
80
|
-
? "UI inspection and actions require macOS Accessibility permission for the Machine Bridge runtime."
|
|
81
|
-
: "Structured UI inspection currently requires macOS; application discovery and opening remain cross-platform.",
|
|
82
73
|
};
|
|
83
74
|
}
|
|
84
75
|
|
|
@@ -1053,6 +1044,22 @@ function optionalString(value, label, maxLength) {
|
|
|
1053
1044
|
return value;
|
|
1054
1045
|
}
|
|
1055
1046
|
|
|
1047
|
+
export function desktopAutomationCapabilities(platform = process.platform) {
|
|
1048
|
+
const isDarwin = platform === "darwin";
|
|
1049
|
+
return {
|
|
1050
|
+
platform,
|
|
1051
|
+
discovery: true,
|
|
1052
|
+
open: true,
|
|
1053
|
+
accessibility_inspection: isDarwin,
|
|
1054
|
+
structured_accessibility_actions: isDarwin,
|
|
1055
|
+
window_screenshot: isDarwin,
|
|
1056
|
+
arbitrary_script_execution: false,
|
|
1057
|
+
permission_note: isDarwin
|
|
1058
|
+
? "UI inspection and actions require macOS Accessibility permission for the Machine Bridge runtime."
|
|
1059
|
+
: "Structured UI inspection currently requires macOS; application discovery and opening remain cross-platform.",
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1056
1063
|
function assertMacAccessibility(platform) {
|
|
1057
1064
|
if (platform !== "darwin") throw new Error("structured application UI automation currently requires macOS");
|
|
1058
1065
|
}
|