machine-bridge-mcp 1.0.7 → 1.0.8
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 +8 -0
- package/README.md +2 -0
- package/browser-extension/manifest.json +2 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLIENTS.md +1 -1
- package/docs/MULTI_ACCOUNT.md +2 -0
- package/docs/OPERATIONS.md +2 -1
- package/docs/TESTING.md +1 -1
- package/docs/TOOL_REFERENCE.md +2 -2
- package/package.json +1 -1
- package/src/shared/server-metadata.json +2 -2
- package/src/shared/tool-catalog.json +2 -2
- package/src/worker/authority.ts +146 -0
- package/src/worker/index.ts +20 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.8 - 2026-07-14
|
|
4
|
+
|
|
5
|
+
### Effective account authority reporting
|
|
6
|
+
|
|
7
|
+
- Separate the authenticated account authority from the local daemon capability ceiling in remote diagnostics. `server_info.authorization.effective_policy` and `effective_tools` are now the authoritative account fields, while `daemon.policy` and `daemon.tools` are explicitly scoped as pre-role ceilings. The response also includes a deterministic authority summary and scope labels so clients cannot reasonably equate an `editor` account with a `full` daemon.
|
|
8
|
+
- Make remote `project_overview` return the role-intersected policy and tools at its existing top-level fields, while preserving the daemon values separately as `daemonPolicy` and `daemonTools`. Add a Worker integration regression that authorizes an `editor` account against a canonical `full` daemon and proves shell/browser tools remain excluded at both reporting surfaces and at relay enforcement.
|
|
9
|
+
- Update MCP initialization guidance, tool descriptions, operations diagnostics, architecture, client, account, testing, and generated tool-reference documentation to use the effective-account fields when diagnosing permissions.
|
|
10
|
+
|
|
3
11
|
## 1.0.7 - 2026-07-14
|
|
4
12
|
|
|
5
13
|
### Browser-complete OAuth callback navigation
|
package/README.md
CHANGED
|
@@ -144,6 +144,8 @@ The Worker grants browser CORS response access to the exact first-party origins
|
|
|
144
144
|
|
|
145
145
|
One Worker supports several named accounts and OAuth clients. Accounts have independent passwords, roles, active state, versions, codes, and tokens. The roles are `reviewer`, `editor`, `operator`, and `owner`; their effective authority is intersected with the connected daemon policy and enforced in both the Worker and local runtime. Role changes, suspension, password rotation, and removal revoke only the affected account.
|
|
146
146
|
|
|
147
|
+
For remote connections, `server_info.authorization.effective_policy` and `server_info.authorization.effective_tools` are the authoritative account-permission fields. `server_info.daemon.policy` and `server_info.daemon.tools` describe only the local daemon capability ceiling before account-role filtering. Remote `project_overview` likewise places the effective account policy/tools in `policy` and `tools`, while preserving the daemon ceiling separately as `daemonPolicy` and `daemonTools`.
|
|
148
|
+
|
|
147
149
|
This is application-level authorization, not kernel or browser-profile isolation. All accounts reach one daemon running as one OS user. Use separate Workers and preferably separate low-privilege OS accounts, containers, or VMs for mutually untrusted users or hard tenant isolation. See [Multi-account authorization and tenancy](docs/MULTI_ACCOUNT.md).
|
|
148
150
|
|
|
149
151
|
## Optional local stdio MCP
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Machine Bridge Browser",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"description": "Connects the current Chromium browser profile to the local Machine Bridge runtime for user-authorized automation.",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"tabs",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"action": {
|
|
31
31
|
"default_title": "Machine Bridge Browser"
|
|
32
32
|
},
|
|
33
|
-
"version_name": "1.0.
|
|
33
|
+
"version_name": "1.0.8"
|
|
34
34
|
}
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -239,7 +239,7 @@ Browser-origin handling separates CORS response sharing from protocol authentica
|
|
|
239
239
|
|
|
240
240
|
## Observability
|
|
241
241
|
|
|
242
|
-
Public health exposes only server identity and version. Authenticated `server_info` exposes bounded runtime status,
|
|
242
|
+
Public health exposes only server identity and version. Authenticated `server_info` exposes bounded runtime status, managed-job counts, resource alias names without paths or values, relay route state without endpoint details, and privacy-preserving capability-routing evidence. It separates the daemon capability ceiling from the authenticated account authority: `daemon.policy`/`daemon.tools` retain the pre-role ceiling, while `authorization.effective_policy`/`authorization.effective_tools` and the top-level `tools` report the role-intersected authority before any host-side filtering. It explicitly reports that the host-exposed subset is unknown to the server. `diagnose_runtime` runs fixed local probes and explicitly reports that its own request reached the daemon.
|
|
243
243
|
|
|
244
244
|
Foreground logging defaults to `info`; autostart uses `warn`. Authenticated readiness, persistent degradation, and recovery are user-visible state transitions. Brief relay interruptions, raw transport close details, retry timing, and all per-tool starts/successes/failures/cancellations/durations are debug-only. Unexpected local and Worker infrastructure errors are reduced to classes. Messages, strings, arrays, object depth/key counts, and serialized fields are bounded.
|
|
245
245
|
|
package/docs/CLIENTS.md
CHANGED
|
@@ -149,7 +149,7 @@ For SSH automation, prefer `generate_ssh_key_resource` under canonical full, or
|
|
|
149
149
|
|
|
150
150
|
The local `full` profile controls Machine Bridge's own tool catalog, path resolver, path display, process environment, and shell availability. It does not control the MCP host's model policy, approval UI, connector gateway, or platform execution filters.
|
|
151
151
|
|
|
152
|
-
Machine Bridge itself does not block files because their names look sensitive.
|
|
152
|
+
Machine Bridge itself does not block files because their names look sensitive. In remote mode, first inspect `server_info.authorization.effective_policy` and `effective_tools`; `daemon.policy` is only the local ceiling. If the effective profile is `full` and the effective tool is present but a direct call is still rejected before a structured result, the host/connector may have blocked delivery. If `diagnose_runtime` responds but its fixed process or shell probe fails, the likely source is local OS policy, endpoint-security software, permissions, or shell configuration. Changing `--profile`, `--unrestricted-paths`, or `--absolute-paths` cannot override either layer.
|
|
153
153
|
|
|
154
154
|
Do not attempt to evade a host refusal by renaming, encoding, or switching to another arbitrary execution tool. Instead:
|
|
155
155
|
|
package/docs/MULTI_ACCOUNT.md
CHANGED
|
@@ -25,6 +25,8 @@ The effective tool set is the intersection of:
|
|
|
25
25
|
|
|
26
26
|
The Worker filters `tools/list` and rejects unauthorized calls before relay. Every accepted relay call also carries `account_id`, `account_version`, and `role`; the local runtime validates the role again before dispatch. The shared policy contract remains the single source of capability semantics.
|
|
27
27
|
|
|
28
|
+
Authenticated `server_info` deliberately reports both layers. `authorization.effective_policy` and `authorization.effective_tools` are authoritative for the current account. The nested `daemon.policy` and `daemon.tools` fields are only the local capability ceiling before account-role filtering; a `full` daemon does not make an `editor` account full. Remote `project_overview` uses the effective values at top-level `policy` and `tools` and preserves the daemon values as `daemonPolicy` and `daemonTools`.
|
|
29
|
+
|
|
28
30
|
## Account lifecycle
|
|
29
31
|
|
|
30
32
|
List accounts:
|
package/docs/OPERATIONS.md
CHANGED
|
@@ -14,7 +14,8 @@ machine-mcp service status
|
|
|
14
14
|
|
|
15
15
|
| Result | Interpretation |
|
|
16
16
|
|---|---|
|
|
17
|
-
| `
|
|
17
|
+
| `authorization.effective_policy.profile` is `full` and the tool is in `authorization.effective_tools`, but the current session UI exposes fewer tools | Host/connector post-relay filtering; Machine Bridge cannot enumerate or override that subset |
|
|
18
|
+
| `daemon.policy.profile` is `full` but `authorization.effective_policy.profile` is `review`, `edit`, or `agent` | Expected account-role narrowing; the daemon field is only a capability ceiling and must not be reported as the account permission |
|
|
18
19
|
| `capability_routing.bootstrap_observed` is false | The current local runtime has not received `session_bootstrap`; reconnect or inspect host initialization handling |
|
|
19
20
|
| `task_resolution_observed` is false after a substantive task | The host/model did not call `resolve_task_capabilities`; server-side discovery cannot force that host decision |
|
|
20
21
|
| Task resolution ran but all match counts are zero | The resolver ran successfully but found no sufficiently relevant local skill, command, or application |
|
package/docs/TESTING.md
CHANGED
|
@@ -53,7 +53,7 @@ The suite includes:
|
|
|
53
53
|
- deterministic property tests over hostile browser-protocol byte strings, canonical/custom policy combinations, argv bounds/NULs, and a real direct process proving shell metacharacters remain literal argv;
|
|
54
54
|
- CLI parsing, policy profiles, and client configuration boundaries;
|
|
55
55
|
- live stdio MCP initialization with session instructions, capability resolution, discovery, calls, rich content, sessions, cancellation, managed-job acceptance, and a detached job/finally phase that survives stdio shutdown;
|
|
56
|
-
- live local Worker OAuth registration, consent, URL-constructed `303` callbacks including the ChatGPT redirect URI and encoded state, PKCE, token replay rejection, throttling, exact built-in ChatGPT/Grok browser origins, additive custom origins, unrelated-origin preflight rejection, no CORS response sharing for unrelated or opaque origins, opaque-origin authorization-form routing, exact per-request redirect-origin CSP, accessible credential-error rendering, protocol negotiation, HMAC-bound MCP session issuance, two-session same-id concurrency, sessionless same-id independence, session-scoped cancellation isolation, same-session duplicate rejection, daemon-backed session bootstrap, dynamic tool advertisement, rich content, daemon replacement, cancellation, malformed daemon JSON/non-object rejection, duplicate hello rejection, and unknown-message closure.
|
|
56
|
+
- live local Worker OAuth registration, consent, URL-constructed `303` callbacks including the ChatGPT redirect URI and encoded state, PKCE, token replay rejection, throttling, exact built-in ChatGPT/Grok browser origins, additive custom origins, unrelated-origin preflight rejection, no CORS response sharing for unrelated or opaque origins, opaque-origin authorization-form routing, exact per-request redirect-origin CSP, accessible credential-error rendering, protocol negotiation, HMAC-bound MCP session issuance, two-session same-id concurrency, sessionless same-id independence, session-scoped cancellation isolation, same-session duplicate rejection, daemon-backed session bootstrap, dynamic tool advertisement, rich content, daemon replacement, cancellation, malformed daemon JSON/non-object rejection, duplicate hello rejection, and unknown-message closure. The same integration runs an `editor` account against a canonical `full` daemon and proves that `server_info` and remote `project_overview` report effective `edit` authority while retaining the full daemon ceiling only in explicitly scoped fields.
|
|
57
57
|
- local runtime proof that one blocked tool handler does not serialize an independent handler, plus relay fault injection proving an undeliverable terminal result interrupts the ambiguous socket and enters reconnect backoff.
|
|
58
58
|
- a real headless-Chrome OAuth navigation regression with a negative control showing that `form-action 'self'` blocks a cross-origin `303`, followed by the production policy shape proving the exact callback origin receives `code` and `state`. Linux CI fails if Chrome is unavailable; other environments skip only this browser executable check while retaining the Worker CSP assertions.
|
|
59
59
|
|
package/docs/TOOL_REFERENCE.md
CHANGED
|
@@ -66,7 +66,7 @@ Tool count: **51**.
|
|
|
66
66
|
|
|
67
67
|
**Server information**
|
|
68
68
|
|
|
69
|
-
Return
|
|
69
|
+
Return authenticated account authority, effective policy/tools, daemon capability ceiling, runtime metadata, and protocol status. Treat authorization.effective_policy and authorization.effective_tools as authoritative; daemon.policy is only a ceiling.
|
|
70
70
|
|
|
71
71
|
| Contract field | Value |
|
|
72
72
|
|---|---|
|
|
@@ -89,7 +89,7 @@ Return bridge/runtime metadata, active policy, protocol versions, and available
|
|
|
89
89
|
|
|
90
90
|
**Project overview**
|
|
91
91
|
|
|
92
|
-
Summarize the connected workspace
|
|
92
|
+
Summarize the connected workspace and repository. Remote responses report the authenticated account effective policy/tools at policy and tools, with the daemon capability ceiling preserved separately as daemonPolicy and daemonTools.
|
|
93
93
|
|
|
94
94
|
| Contract field | Value |
|
|
95
95
|
|---|---|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "machine-bridge-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"For existing-browser work, use the paired Machine Bridge browser extension. It operates the user current Chromium profile and tabs, can inspect DOM/source, fill complex forms, and inject sensitive text from registered local resources without returning those values.",
|
|
13
13
|
"For local application work, use structured application discovery and Accessibility actions. Arbitrary caller-supplied AppleScript or JavaScript is intentionally not accepted.",
|
|
14
14
|
"Remote mode uses a Cloudflare relay; stdio mode runs on the local machine. File and command operations execute on the user's local runtime, not in the Worker.",
|
|
15
|
-
"
|
|
15
|
+
"In remote multi-account mode, account authority is the intersection of the authenticated account role and the daemon capability ceiling. Only authorization.effective_policy and authorization.effective_tools describe that account authority; daemon.policy is not the account permission.",
|
|
16
16
|
"Filename sensitivity is not classified by this server; the MCP host, connector gateway, local OS, or endpoint-security software may enforce additional independent rules.",
|
|
17
17
|
"A named full profile is canonical: it always enables writes, shell execution, unrestricted paths, the full parent environment, absolute paths, and the complete tool catalog. Any explicit narrowing is stored as custom.",
|
|
18
|
-
"The full catalog
|
|
18
|
+
"The local daemon may advertise the full catalog as its capability ceiling. In remote mode, the Worker relays only the intersection allowed by the authenticated account role; a connector host may then expose an even smaller subset that Machine Bridge cannot observe or override.",
|
|
19
19
|
"Use diagnose_runtime to distinguish a request that reached the daemon from local filesystem, process-spawn, shell, managed-job-storage, and resource failures. A tool call blocked before any response cannot be diagnosed by the server.",
|
|
20
20
|
"Never request or return secret-file contents when a local resource alias can be used. Resources are registered through the local machine-mcp CLI; under canonical full policy, generate_ssh_key_resource can generate and register an Ed25519 key without returning private content and may be injected by path, stdin, or environment without entering MCP arguments.",
|
|
21
21
|
"If execution-class tools are unavailable but write access remains, use stage_job to persist a reviewed plan without running it; the operator can launch it locally with machine-mcp job approve JOB_ID.",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{
|
|
3
3
|
"name": "server_info",
|
|
4
4
|
"title": "Server information",
|
|
5
|
-
"description": "Return
|
|
5
|
+
"description": "Return authenticated account authority, effective policy/tools, daemon capability ceiling, runtime metadata, and protocol status. Treat authorization.effective_policy and authorization.effective_tools as authoritative; daemon.policy is only a ceiling.",
|
|
6
6
|
"availability": "always",
|
|
7
7
|
"annotations": {
|
|
8
8
|
"readOnlyHint": true,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
{
|
|
19
19
|
"name": "project_overview",
|
|
20
20
|
"title": "Project overview",
|
|
21
|
-
"description": "Summarize the connected workspace
|
|
21
|
+
"description": "Summarize the connected workspace and repository. Remote responses report the authenticated account effective policy/tools at policy and tools, with the daemon capability ceiling preserved separately as daemonPolicy and daemonTools.",
|
|
22
22
|
"availability": "always",
|
|
23
23
|
"annotations": {
|
|
24
24
|
"readOnlyHint": true,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import policyContract from "../shared/policy-contract.json";
|
|
2
|
+
import { accountRolePolicy, accountRoleToolNames, type AccountRole } from "./access";
|
|
3
|
+
import type { DaemonPolicy } from "./policy";
|
|
4
|
+
|
|
5
|
+
type EffectivePolicy = {
|
|
6
|
+
scope: "authenticated_account_effective_authority";
|
|
7
|
+
derived_from: ["account_role_policy", "daemon_capability_ceiling"];
|
|
8
|
+
profile: string;
|
|
9
|
+
revision: number;
|
|
10
|
+
allowWrite: boolean;
|
|
11
|
+
allowExec: boolean;
|
|
12
|
+
execMode: DaemonPolicy["execMode"];
|
|
13
|
+
unrestrictedPaths: boolean;
|
|
14
|
+
minimalEnv: boolean;
|
|
15
|
+
exposeAbsolutePaths: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type AccountIdentity = { accountId: string; accountVersion: number; role: AccountRole };
|
|
19
|
+
|
|
20
|
+
type AccountAuthority = {
|
|
21
|
+
account: { account_id: string; role: AccountRole; version: number };
|
|
22
|
+
account_policy: DaemonPolicy & { scope: "account_role_capability_ceiling" };
|
|
23
|
+
daemon_policy_ceiling: DaemonPolicy | null;
|
|
24
|
+
effective_policy: EffectivePolicy | null;
|
|
25
|
+
effective_tools: string[];
|
|
26
|
+
effective_tool_count: number;
|
|
27
|
+
account_role_is_owner: boolean;
|
|
28
|
+
effective_profile_is_full: boolean;
|
|
29
|
+
interpretation: {
|
|
30
|
+
authoritative_permission_fields: ["effective_policy", "effective_tools"];
|
|
31
|
+
daemon_policy: string;
|
|
32
|
+
host_filtering: string;
|
|
33
|
+
};
|
|
34
|
+
summary: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type DaemonCeilingStatus = Record<string, unknown> & {
|
|
38
|
+
policy: DaemonPolicy | null;
|
|
39
|
+
tools: string[];
|
|
40
|
+
policy_scope: "daemon_capability_ceiling_not_account_authority";
|
|
41
|
+
tools_scope: "daemon_advertised_before_account_role_filtering";
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const profileFields = ["allowWrite", "execMode", "unrestrictedPaths", "minimalEnv", "exposeAbsolutePaths"] as const;
|
|
45
|
+
const profiles = policyContract.profiles as Record<string, Pick<DaemonPolicy, typeof profileFields[number]> & { profile: string }>;
|
|
46
|
+
const execRank: Record<DaemonPolicy["execMode"], number> = { off: 0, direct: 1, shell: 2 };
|
|
47
|
+
|
|
48
|
+
export function describeDaemonCeiling(value: Record<string, unknown>): DaemonCeilingStatus {
|
|
49
|
+
return {
|
|
50
|
+
...value,
|
|
51
|
+
policy: isDaemonPolicy(value.policy) ? value.policy : null,
|
|
52
|
+
tools: Array.isArray(value.tools) ? value.tools.filter((item): item is string => typeof item === "string") : [],
|
|
53
|
+
policy_scope: "daemon_capability_ceiling_not_account_authority",
|
|
54
|
+
tools_scope: "daemon_advertised_before_account_role_filtering",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function accountAuthoritySnapshot(input: AccountIdentity & {
|
|
59
|
+
daemonPolicy: DaemonPolicy | null;
|
|
60
|
+
effectiveTools: string[];
|
|
61
|
+
}): AccountAuthority {
|
|
62
|
+
const accountPolicy = accountRolePolicy(input.role);
|
|
63
|
+
const effectivePolicy = input.daemonPolicy ? intersectPolicies(accountPolicy, input.daemonPolicy) : null;
|
|
64
|
+
const effectiveTools = [...new Set(input.effectiveTools)];
|
|
65
|
+
const daemonProfile = input.daemonPolicy?.profile ?? "disconnected";
|
|
66
|
+
const effectiveProfile = effectivePolicy?.profile ?? "unavailable";
|
|
67
|
+
return {
|
|
68
|
+
account: { account_id: input.accountId, role: input.role, version: input.accountVersion },
|
|
69
|
+
account_policy: { ...accountPolicy, scope: "account_role_capability_ceiling" },
|
|
70
|
+
daemon_policy_ceiling: input.daemonPolicy,
|
|
71
|
+
effective_policy: effectivePolicy,
|
|
72
|
+
effective_tools: effectiveTools,
|
|
73
|
+
effective_tool_count: effectiveTools.length,
|
|
74
|
+
account_role_is_owner: input.role === "owner",
|
|
75
|
+
effective_profile_is_full: effectivePolicy?.profile === "full",
|
|
76
|
+
interpretation: {
|
|
77
|
+
authoritative_permission_fields: ["effective_policy", "effective_tools"],
|
|
78
|
+
daemon_policy: "daemon.policy is only the local daemon capability ceiling; it is not the authenticated account permission",
|
|
79
|
+
host_filtering: "the MCP host may expose a smaller subset than effective_tools, and Machine Bridge cannot observe that post-relay subset",
|
|
80
|
+
},
|
|
81
|
+
summary: input.daemonPolicy
|
|
82
|
+
? `Authenticated account role ${input.role} has effective profile ${effectiveProfile}. daemon.policy.profile=${daemonProfile} is only the daemon capability ceiling, not this account's permission.`
|
|
83
|
+
: `Authenticated account role ${input.role} is configured for profile ${accountPolicy.profile}, but no daemon is connected; only Worker-local tools are currently available.`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function decorateProjectOverview(value: unknown, account: AccountIdentity): unknown {
|
|
88
|
+
if (!isRecord(value)) return value;
|
|
89
|
+
const daemonPolicy = isDaemonPolicy(value.policy) ? value.policy : null;
|
|
90
|
+
const daemonTools = Array.isArray(value.tools) ? value.tools.filter((item): item is string => typeof item === "string") : [];
|
|
91
|
+
const effectiveTools = ["server_info", ...accountRoleToolNames(account.role, daemonTools)];
|
|
92
|
+
const authority = accountAuthoritySnapshot({ ...account, daemonPolicy, effectiveTools });
|
|
93
|
+
return {
|
|
94
|
+
...value,
|
|
95
|
+
daemonPolicy,
|
|
96
|
+
daemonTools,
|
|
97
|
+
policy: authority.effective_policy,
|
|
98
|
+
tools: authority.effective_tools,
|
|
99
|
+
policyScope: "authenticated_account_effective_authority",
|
|
100
|
+
toolsScope: "authenticated_account_effective_tools_before_host_filtering",
|
|
101
|
+
authorization: authority,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function intersectPolicies(accountPolicy: DaemonPolicy, daemonPolicy: DaemonPolicy): EffectivePolicy {
|
|
106
|
+
const execMode = execRank[accountPolicy.execMode] <= execRank[daemonPolicy.execMode] ? accountPolicy.execMode : daemonPolicy.execMode;
|
|
107
|
+
const capabilities = {
|
|
108
|
+
allowWrite: accountPolicy.allowWrite && daemonPolicy.allowWrite,
|
|
109
|
+
execMode,
|
|
110
|
+
unrestrictedPaths: accountPolicy.unrestrictedPaths && daemonPolicy.unrestrictedPaths,
|
|
111
|
+
minimalEnv: accountPolicy.minimalEnv || daemonPolicy.minimalEnv,
|
|
112
|
+
exposeAbsolutePaths: accountPolicy.exposeAbsolutePaths && daemonPolicy.exposeAbsolutePaths,
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
scope: "authenticated_account_effective_authority",
|
|
116
|
+
derived_from: ["account_role_policy", "daemon_capability_ceiling"],
|
|
117
|
+
profile: matchingProfile(capabilities),
|
|
118
|
+
revision: Math.max(accountPolicy.revision, daemonPolicy.revision),
|
|
119
|
+
...capabilities,
|
|
120
|
+
allowExec: execMode !== "off",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function matchingProfile(capabilities: Pick<EffectivePolicy, typeof profileFields[number]>): string {
|
|
125
|
+
for (const [name, profile] of Object.entries(profiles)) {
|
|
126
|
+
if (profileFields.every((field) => profile[field] === capabilities[field])) return name;
|
|
127
|
+
}
|
|
128
|
+
return "custom";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isDaemonPolicy(value: unknown): value is DaemonPolicy {
|
|
132
|
+
if (!isRecord(value)) return false;
|
|
133
|
+
return typeof value.profile === "string"
|
|
134
|
+
&& typeof value.origin === "string"
|
|
135
|
+
&& Number.isInteger(value.revision)
|
|
136
|
+
&& typeof value.allowWrite === "boolean"
|
|
137
|
+
&& typeof value.allowExec === "boolean"
|
|
138
|
+
&& (value.execMode === "off" || value.execMode === "direct" || value.execMode === "shell")
|
|
139
|
+
&& typeof value.unrestrictedPaths === "boolean"
|
|
140
|
+
&& typeof value.minimalEnv === "boolean"
|
|
141
|
+
&& typeof value.exposeAbsolutePaths === "boolean";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
145
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
146
|
+
}
|
package/src/worker/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { WorkerObservability } from "./observability";
|
|
|
7
7
|
import { daemonToolError, publicWorkerToolError, WorkerToolError } from "./errors";
|
|
8
8
|
import { sanitizeDaemonPolicy, sanitizeDaemonTools, type DaemonPolicy } from "./policy";
|
|
9
9
|
import { accountRoleAllowsTool, accountRoleToolNames, type AccountRole } from "./access";
|
|
10
|
+
import { accountAuthoritySnapshot, decorateProjectOverview, describeDaemonCeiling } from "./authority";
|
|
10
11
|
import { accountAdminAuthorized, handleAccountAdminOperation } from "./account-admin";
|
|
11
12
|
import { serverInfoTool, workspaceTools } from "./tool-catalog";
|
|
12
13
|
import {
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
} from "./http";
|
|
23
24
|
|
|
24
25
|
const SERVER_NAME = String(serverMetadata.name);
|
|
25
|
-
const SERVER_VERSION = "1.0.
|
|
26
|
+
const SERVER_VERSION = "1.0.8";
|
|
26
27
|
const MCP_PROTOCOL_VERSION = String(serverMetadata.protocolVersion);
|
|
27
28
|
const MCP_SUPPORTED_PROTOCOL_VERSIONS = serverMetadata.supportedProtocolVersions.map((value) => String(value));
|
|
28
29
|
const JSONRPC_VERSION = "2.0";
|
|
@@ -342,17 +343,17 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
342
343
|
}
|
|
343
344
|
return rpcError(request.id, -32601, `Method not found: ${request.method}`);
|
|
344
345
|
}
|
|
345
|
-
|
|
346
346
|
private async callTool(name: string, args: Record<string, unknown>, base: string, authorized: AuthorizedToken, requestKey?: string): Promise<unknown> {
|
|
347
347
|
if (name === "server_info") {
|
|
348
|
-
const daemon = this.
|
|
349
|
-
const tools = this.allTools(authorized.role).map((tool) => tool.name);
|
|
348
|
+
const { daemon, tools, authorization } = this.authorityContext(authorized);
|
|
350
349
|
return {
|
|
351
350
|
name: SERVER_NAME,
|
|
352
351
|
version: SERVER_VERSION,
|
|
353
352
|
mcp_url: `${base}/mcp`,
|
|
354
353
|
oauth: this.authorizationServerMetadata(base),
|
|
355
|
-
account:
|
|
354
|
+
account: authorization.account,
|
|
355
|
+
authorization,
|
|
356
|
+
authority_summary: authorization.summary,
|
|
356
357
|
daemon,
|
|
357
358
|
worker: {
|
|
358
359
|
pending_calls: this.pending.snapshot(),
|
|
@@ -360,10 +361,13 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
360
361
|
observability: this.observability.snapshot(),
|
|
361
362
|
},
|
|
362
363
|
tools,
|
|
364
|
+
tools_scope: "authenticated_account_effective_tools_before_host_filtering",
|
|
363
365
|
tool_delivery: {
|
|
364
|
-
full_profile_scope: "
|
|
366
|
+
full_profile_scope: "daemon-capability-ceiling-before-account-filtering",
|
|
365
367
|
daemon_advertised_tool_count: daemon.tool_count,
|
|
366
368
|
relay_advertised_tool_count: tools.length,
|
|
369
|
+
effective_account_tool_count: tools.length,
|
|
370
|
+
relay_advertised_scope: "authenticated_account_effective_tools_before_host_filtering",
|
|
367
371
|
host_exposed_tools_known_to_server: false,
|
|
368
372
|
host_may_expose_subset: true,
|
|
369
373
|
},
|
|
@@ -372,11 +376,12 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
372
376
|
if (workspaceTools.some((tool) => tool.name === name)) {
|
|
373
377
|
if (!this.daemonToolEnabled(name)) throw new Error(`tool disabled by local daemon policy: ${name}`);
|
|
374
378
|
if (!accountRoleAllowsTool(authorized.role, name)) throw new WorkerToolError("authorization_denied", "tool is not allowed for this account role");
|
|
375
|
-
|
|
379
|
+
const result = await this.callDaemonTool(name, args, authorized, requestKey);
|
|
380
|
+
return name === "project_overview" ? decorateProjectOverview(result, { accountId: authorized.accountId,
|
|
381
|
+
accountVersion: authorized.accountVersion, role: authorized.role }) : result;
|
|
376
382
|
}
|
|
377
383
|
throw new Error(`unknown tool: ${name}`);
|
|
378
384
|
}
|
|
379
|
-
|
|
380
385
|
private async callDaemonTool(name: string, args: Record<string, unknown>, authorized: AuthorizedToken, requestKey?: string): Promise<unknown> {
|
|
381
386
|
const socket = this.daemonSockets()[0];
|
|
382
387
|
if (!socket) throw new WorkerToolError("unavailable", "local daemon is not connected; keep the CLI start command running", true);
|
|
@@ -419,7 +424,6 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
419
424
|
throw error;
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
|
-
|
|
423
427
|
private cancelClientRequest(requestKey?: string): void {
|
|
424
428
|
if (!requestKey) return;
|
|
425
429
|
this.pending.cancelRequest(requestKey, (record) => {
|
|
@@ -456,11 +460,16 @@ export class BridgeRoom extends DurableObject<BridgeEnv> {
|
|
|
456
460
|
const localTools = workspaceTools.filter((tool) => advertised.has(tool.name));
|
|
457
461
|
return [serverInfoTool, ...localTools].map((tool) => structuredClone(tool));
|
|
458
462
|
}
|
|
459
|
-
|
|
463
|
+
private authorityContext(authorized: AuthorizedToken) {
|
|
464
|
+
const daemon = describeDaemonCeiling(this.daemonStatus(true));
|
|
465
|
+
const tools = this.allTools(authorized.role).map((tool) => String(tool.name));
|
|
466
|
+
const authorization = accountAuthoritySnapshot({ accountId: authorized.accountId, accountVersion: authorized.accountVersion,
|
|
467
|
+
role: authorized.role, daemonPolicy: daemon.policy, effectiveTools: tools });
|
|
468
|
+
return { daemon, tools, authorization };
|
|
469
|
+
}
|
|
460
470
|
private daemonToolEnabled(name: string): boolean {
|
|
461
471
|
return this.daemonAdvertisedTools().has(name);
|
|
462
472
|
}
|
|
463
|
-
|
|
464
473
|
private daemonAdvertisedTools(): Set<string> {
|
|
465
474
|
const socket = this.daemonSockets()[0];
|
|
466
475
|
if (!socket) return new Set();
|