@staix/agent-hosts 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -5
- package/fixtures/MANIFEST.sha256 +16 -0
- package/fixtures/README.md +10 -0
- package/fixtures/receipts/package/owner-absent.json +15 -0
- package/fixtures/receipts/package/owner-present.json +16 -0
- package/fixtures/v1/copilot.json +168 -0
- package/fixtures/v1/suite-managed.json +295 -0
- package/package.json +1 -1
- package/src/entry.ts +44 -8
- package/src/hosts.ts +7 -0
- package/src/paths.ts +13 -1
- package/src/receipt.ts +7 -1
- package/src/refusal.ts +1 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Install an exact version after it is published.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
bun add --exact @staix/agent-hosts@0.
|
|
8
|
+
bun add --exact @staix/agent-hosts@0.4.0
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Supported hosts
|
|
@@ -20,10 +20,13 @@ bun add --exact @staix/agent-hosts@0.3.0
|
|
|
20
20
|
| `jcode` | user `~/.jcode/mcp.json` | JSON `servers` (alias `mcpServers`) | `0.99.1`, `1.0.3` |
|
|
21
21
|
| `opencode` | user `~/.config/opencode/opencode.json` | JSON `mcp` | `1.18.35`, `1.19.5` |
|
|
22
22
|
| `gemini` | user `~/.gemini/settings.json` | JSON `mcpServers` | `0.61.0`, `0.67.0` |
|
|
23
|
+
| `copilot` | user `~/.copilot/mcp-config.json` | JSON `mcpServers` | `1.0.107` |
|
|
23
24
|
| `agy` | project `.agents/mcp_config.json` | JSON `mcpServers` | `1.5.18` |
|
|
24
25
|
|
|
25
26
|
`HOSTS` records the file scopes, environment overrides, format, entry fields, and verified versions. `HostDefinition.entry` lists the minimum fields read by the host. Extra fields, including `env`, pass through. `CLAUDE_CONFIG_DIR` moves the Claude file into that directory as `.claude.json`. `QWEN_HOME` expands `~` against the injected home. A set but empty `JCODE_HOME` is refused. OpenCode and Gemini honor absolute `XDG_CONFIG_HOME` and `GEMINI_CLI_HOME` respectively, with an empty value treated as unset. Version evidence is available in [PR #5](https://github.com/STAIxBWLB/agent-hosts/pull/5), the [six-host verification receipt](docs/verification/2026-11-28-host-versions.md), and the [Antigravity 1.5.18 receipt](docs/verification/2026-11-27-agy-1.5.18.md).
|
|
26
27
|
|
|
28
|
+
Copilot uses an absolute `COPILOT_HOME` and falls back to `~/.copilot` when it is empty or unset. The resolver refuses relative values to avoid routing a write through the current working directory. See the [Copilot 1.0.107 verification receipt](docs/verification/2026-11-29-copilot-1.0.107.md).
|
|
29
|
+
|
|
27
30
|
Version 0.2.0 adds Antigravity support for the direct workspace file. On the verified version, `agy mcp list` listed the user-scope control and omitted both project files. Pass `scopes: ["project"]` and `workspaceRoot` to resolve the project file.
|
|
28
31
|
|
|
29
32
|
## API
|
|
@@ -50,10 +53,10 @@ if (plan.change === "refused") throw new Error(plan.reason);
|
|
|
50
53
|
|
|
51
54
|
- `realPath(path)` resolves an existing physical path and throws for a missing path or dangling link. It handles Bun's backslash and symlink-parent edge cases.
|
|
52
55
|
- `resolveHostPaths({ env, home, workspaceRoot?, hosts?, scopes?, redirectManagedProfiles? })` returns `home`, per-host `paths`, pre-redirect `legacyPaths`, `redirects`, per-host `refusals`, and per-host `roots.current` and `roots.legacy` for locating sibling files such as hooks. Pass the environment and home explicitly. It selects user files by default. Supply `scopes: ["project"]` and `workspaceRoot` for Kimi or Antigravity project files. Select exactly one file per host when calling the entry API. Managed Claude and Codex profiles redirect to the personal source by default. Set `redirectManagedProfiles: false` to keep the configured path. The resolver trims Claude, Codex, Kimi, and Pi overrides and omits files whose location override is invalid. Other hosts remain available.
|
|
53
|
-
- `planEntry({ host, paths, name, entry })` returns `add`, `replace`, `remove`, `unchanged`, or `refused` with a stable `code` and a human-readable `reason`. A successful preview contains the decoded `current` entry (or `undefined`), the before and after images, and an intent digest. Supply a plain JSON-compatible entry object or use `entry: null` to remove an entry with an undo receipt. Removing an absent entry is unchanged. Preview writes nothing.
|
|
56
|
+
- `planEntry({ host, paths, name, entry, owner? })` returns `add`, `replace`, `remove`, `unchanged`, or `refused` with a stable `code` and a human-readable `reason`. A successful preview contains the decoded `current` entry (or `undefined`), the before and after images, and an intent digest. Supply a plain JSON-compatible entry object or use `entry: null` to remove an entry with an undo receipt. Removing an absent entry is unchanged. Preview writes nothing. A suite receipt owned by `asuite` returns `suite-managed` for other callers and directs them to run `asuite sync`.
|
|
54
57
|
- `applyEntry(plan, { receiptDir, env? })` rechecks file state and host policy under an exclusive lock, publishes the change, and records a versioned receipt. Use an absolute receipt directory. Generate a fresh plan if the file changed since preview. A matching entry with no receipt stays unclaimed. OpenCode requires fresh injected `env` on every apply. The plan carries routing-variable names without storing their values.
|
|
55
58
|
- `undoEntry({ host, paths, name, receiptDir })` restores the prior owned entry or removes the one it installed. A conflicting edit to the entry is left in place and the error names the file. The result identifies the config and receipt paths. If `legacy: true` is returned, the legacy receipt still exists and the consumer manages its cleanup. An unchanged undo carries a code from `UNDO_NOOP_CODES`. If someone deleted an installed entry, undo consumes its package receipt without restoring the prior entry. An explicit removal remains undoable.
|
|
56
|
-
- `readEntryReceipt({ host, paths, name, receiptDir })` reads the current or historical receipt without writing. It returns `file`, `receipt`, `intent`, `before`, `after`, and optional `pending
|
|
59
|
+
- `readEntryReceipt({ host, paths, name, receiptDir })` reads the current or historical receipt without writing. It returns `file`, `receipt`, `intent`, `before`, `after`, and optional `owner`, `pending`, or `legacy`. Entry-only legacy formats yield synthesized MCP images because they store values rather than file snapshots.
|
|
57
60
|
- `REFUSAL_CODES` lists stable refusal identifiers used by both path and entry operations. Apply and undo throw `EntryRefusal` with a `code`, a human-readable `reason`, and `file` when a path is known. Refused plans also include `file` when known.
|
|
58
61
|
- `UNDO_NOOP_CODES` lists `no-receipt`, `entry-already-absent`, and `entry-already-restored` for unchanged undo results.
|
|
59
62
|
|
|
@@ -61,7 +64,9 @@ OpenCode preview and apply refuse nonblank `OPENCODE_CONFIG`, `OPENCODE_CONFIG_D
|
|
|
61
64
|
|
|
62
65
|
Writes use bounded reads, refuse linked paths, and publish through a temporary file while preserving the config's mode. Configuration is capped at 8 MiB. The `<config>.agent-hosts.lock` file serializes package writers. Take any consumer-specific lock around package calls. If a stale lock blocks an operation, confirm that its writer has stopped before removing the named lock.
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
The resolver sets `suiteReceipts` from the first nonblank value in `AGENT_SUITE_HOME/receipts`, `AGENTHUB_HOME/suite/receipts`, and `~/.agenthub/suite/receipts`, trimming the environment values before joining the paths. The suite home is resolved to its physical path before appending `receipts`. The receipt directory and file still refuse links. A relative override refuses entry previews. Apply repeats the suite ownership check under the config lock. A malformed or unsafe suite receipt yields `invalid-receipt`.
|
|
68
|
+
|
|
69
|
+
Package receipts use `entry-<digest([file, name])>.json` and carry version 1. New receipts include the plan's `owner` when supplied. Existing receipts without an owner remain valid and belong to the tool holding them. The owner does not enter the intent digest. A pending replacement can temporarily store its previous receipt at `<receipt>.previous-<digest>`. Consumers scanning the receipt directory should ignore these recovery files. Apply and undo return the receipt intent when one is known. Retry the same plan after interrupted publication. Undo can cancel a pending apply while the config still matches its start image. After publication, finish the apply before undoing.
|
|
65
70
|
|
|
66
71
|
### Use the codecs directly
|
|
67
72
|
|
|
@@ -83,7 +88,7 @@ The JSON codec accepts strict JSON and keeps unrelated bytes. The TOML codecs us
|
|
|
83
88
|
| `HostId`, `HostScope` | Keys of `HOSTS` and the `user` or `project` scope. Pass a hub-owned path through the host's environment override. |
|
|
84
89
|
| `HostDefinition`, `HostConfig`, `HostFormat`, `HomeOverride` | Host metadata, per-file scope and path, JSON key or TOML table, and environment override rules. |
|
|
85
90
|
| `ResolveHostPathsOptions`, `HostPaths`, `HostRedirect`, `HostRefusal` | Resolver inputs, its path maps, managed-profile redirects, and path refusals. |
|
|
86
|
-
| `EntryTarget`, `PlanEntryOptions`, `ApplyEntryOptions` | Host, resolved paths, and name. Planning adds the desired `entry`. Apply takes a receipt directory and optional refreshed environment. |
|
|
91
|
+
| `EntryTarget`, `PlanEntryOptions`, `ApplyEntryOptions` | Host, resolved paths, and name. Planning adds the desired `entry` and optional `owner`. Apply takes a receipt directory and optional refreshed environment. |
|
|
87
92
|
| `EntryPlan`, `EntryResult`, `EntryReceipt` | Preview result, apply or undo result, and read-only receipt projection. |
|
|
88
93
|
| `RefusalCode`, `UndoNoopCode` | Machine-readable identifiers from `REFUSAL_CODES` and `UNDO_NOOP_CODES`. |
|
|
89
94
|
| `ConfigImage`, `JsonMcpCodecOptions` | Base64 `bytes` or `null` for an absent file, plus numeric `mode`, and the JSON codec's key and entry options. |
|
|
@@ -145,3 +150,7 @@ bun scripts/check-pack.ts
|
|
|
145
150
|
CI runs tests with a temporary home. Tests inject fixture host paths and run offline. The npm tarball allowlist covers `src`, `fixtures`, `README.md`, `LICENSE`, and npm's required `package.json`.
|
|
146
151
|
|
|
147
152
|
The npm package owner registers `STAIxBWLB/agent-hosts` with workflow filename `release.yml` and enables direct publishing. Each tag requires the person's consent. The workflow publishes via npm OIDC after checking that the tag matches the manifest version and its commit belongs to `main`. [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/)
|
|
153
|
+
|
|
154
|
+
## Cross-language fixture contract
|
|
155
|
+
|
|
156
|
+
Vendor `fixtures/` at an exact release tag and verify the inventory and each SHA-256 against `fixtures/MANIFEST.sha256`. The fixture families cover host edits, refusal behavior, receipt compatibility, and receipt names. See the [fixture contract](fixtures/README.md).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
5b4a835e205b510bcc5204679ac5ace48d8626e6aaa8063e92217ca4609f7335 DIVERGENCES.md
|
|
2
|
+
7f8391aa32429813b6d1f6e304aacf0de5f2131859ce6b48a75a530a930d3745 README.md
|
|
3
|
+
e79a02446aea6b89d54e30946374f8818f2b69d818a254c431e6b2967ae4b0a2 copies/agent-mem.json
|
|
4
|
+
94abb085f0d438fdf936c93a203db7558bdd671349a53ef241695adcec90b2bf copies/agent-research.json
|
|
5
|
+
1dd918ad5fee48f29367ffd42ef3eeef99d7a2149f453e87bbb764dc4fa492b9 copies/vault-mem.json
|
|
6
|
+
7d934f31aed6fc5a40809b394cf1672ff60cc69187e521a9c6a2a3bfe693425a receipts/agent-mem/agy-v1.json
|
|
7
|
+
553286e724a794cd54887e2e782e588c4e931d3934396cb9de4ccd6025f2a4d0 receipts/agent-mem/v1.json
|
|
8
|
+
25bfd80b252dedb40fe4797a2402975ba32547bbaa434393d116d9fee6f9119e receipts/agent-mem/v2.json
|
|
9
|
+
1c4b8f47cd22f7882dd97646d1e865088189197fad3861f65c87d4678795f6f9 receipts/agent-research/agy-v1.json
|
|
10
|
+
2739899d872b591ae0189f6f4c1c4720a622f30d19d89342fdaf000f55c9e5a8 receipts/agent-research/v1.json
|
|
11
|
+
7aed60699ddbe0e905c40a5c0a084f7fbd295a483cb56efcfaeb98d7f985bff9 receipts/package/owner-absent.json
|
|
12
|
+
c9eb12528a9da84a72c584812c7a729b65e2538e1d6823866a8e3fb06fd1cc59 receipts/package/owner-present.json
|
|
13
|
+
9219de85785b7c9f4b9be0a4194156e866f42caac0da7464cb5e37dfd3d88e04 receipts/vault-mem/agy-v1.json
|
|
14
|
+
6bff19067d9381cb15b44beb8616be3eb940939bc6a523b38d2f7392dca5c29d receipts/vault-mem/v1.json
|
|
15
|
+
1c26dd18d1490b09a2614f23e1948a922030ca3bac87b90f8cd50c7c188be299 v1/copilot.json
|
|
16
|
+
5f442671a0c022ed76d70400271e74f759f0e853d9636d69359b18a9f992f609 v1/suite-managed.json
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Host contract fixtures
|
|
2
|
+
|
|
3
|
+
Vendor these files from an exact agent-hosts release tag. From inside the vendored fixture directory, verify all files with `sha256sum -c MANIFEST.sha256`. Also compare the inventory to the manifest so extra files fail validation. The manifest covers every file under this directory except itself. Preserve raw bytes on checkout and during vendoring.
|
|
4
|
+
|
|
5
|
+
- `v1/` contains versioned host behavior cases and fixed vectors for the receipt basename. Cases use the capture shape from `copies/`. Expand `$FIXTURE` in paths to the absolute temporary home. `owner` identifies the caller, `suiteReceipt` references a package receipt to seed in the resolved suite receipt directory, `links` maps config paths to file symlink targets, and `directoryLinks` maps directory symlinks to their targets before resolving host paths. `suiteReceipts`, when present, is the expected resolved directory. Receipt `file` placeholders are expanded while seeding. Config text and modes are fixture expectations.
|
|
6
|
+
- `copies/` captures configuration behavior from existing TypeScript consumers.
|
|
7
|
+
- `receipts/` holds historical consumer receipts and package v1 receipts.
|
|
8
|
+
- `DIVERGENCES.md` records differences between consumer copies and the package.
|
|
9
|
+
|
|
10
|
+
After adding, removing, or changing a fixture, regenerate the manifest with `bun scripts/fixture-manifest.ts`. Fixture changes ship in a minor release during 0.x.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"host": "copilot",
|
|
4
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
5
|
+
"name": "managed",
|
|
6
|
+
"intent": "0b94d73653701e2cb41bcecfc36ed121f345dc10510128fa8252ec811b9dc884",
|
|
7
|
+
"before": {
|
|
8
|
+
"bytes": "eyJtY3BTZXJ2ZXJzIjp7Im90aGVyIjp7ImNvbW1hbmQiOiJrZWVwIn19LCJrZWVwIjp0cnVlfQo=",
|
|
9
|
+
"mode": 384
|
|
10
|
+
},
|
|
11
|
+
"after": {
|
|
12
|
+
"bytes": "eyJtY3BTZXJ2ZXJzIjp7Im90aGVyIjp7ImNvbW1hbmQiOiJrZWVwIn0sIm1hbmFnZWQiOnsiY29tbWFuZCI6InByZXZpb3VzIiwiYXJncyI6WyJtY3Atc2hpbSIsImV4YW1wbGUiXSwidHlwZSI6ImxvY2FsIiwidG9vbHMiOlsiKiJdfX0sImtlZXAiOnRydWV9Cg==",
|
|
13
|
+
"mode": 384
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"host": "copilot",
|
|
4
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
5
|
+
"name": "managed",
|
|
6
|
+
"intent": "0b94d73653701e2cb41bcecfc36ed121f345dc10510128fa8252ec811b9dc884",
|
|
7
|
+
"before": {
|
|
8
|
+
"bytes": "eyJtY3BTZXJ2ZXJzIjp7Im90aGVyIjp7ImNvbW1hbmQiOiJrZWVwIn19LCJrZWVwIjp0cnVlfQo=",
|
|
9
|
+
"mode": 384
|
|
10
|
+
},
|
|
11
|
+
"after": {
|
|
12
|
+
"bytes": "eyJtY3BTZXJ2ZXJzIjp7Im90aGVyIjp7ImNvbW1hbmQiOiJrZWVwIn0sIm1hbmFnZWQiOnsiY29tbWFuZCI6InByZXZpb3VzIiwiYXJncyI6WyJtY3Atc2hpbSIsImV4YW1wbGUiXSwidHlwZSI6ImxvY2FsIiwidG9vbHMiOlsiKiJdfX0sImtlZXAiOnRydWV9Cg==",
|
|
13
|
+
"mode": 384
|
|
14
|
+
},
|
|
15
|
+
"owner": "asuite"
|
|
16
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cases": [
|
|
3
|
+
{
|
|
4
|
+
"id": "add",
|
|
5
|
+
"host": "copilot",
|
|
6
|
+
"name": "managed",
|
|
7
|
+
"key": "mcpServers",
|
|
8
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
9
|
+
"env": {},
|
|
10
|
+
"entry": {
|
|
11
|
+
"command": "asuite",
|
|
12
|
+
"args": [
|
|
13
|
+
"mcp-shim",
|
|
14
|
+
"example"
|
|
15
|
+
],
|
|
16
|
+
"type": "local",
|
|
17
|
+
"tools": [
|
|
18
|
+
"*"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"plan": {
|
|
22
|
+
"change": "add",
|
|
23
|
+
"files": [
|
|
24
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"before": {
|
|
28
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
29
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"}},\"keep\":true}\n",
|
|
30
|
+
"mode": 384
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"afterApply": {
|
|
34
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
35
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
36
|
+
"mode": 384
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"afterUndo": {
|
|
40
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
41
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"}},\"keep\":true}\n",
|
|
42
|
+
"mode": 384
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "replace",
|
|
48
|
+
"host": "copilot",
|
|
49
|
+
"name": "managed",
|
|
50
|
+
"key": "mcpServers",
|
|
51
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
52
|
+
"env": {},
|
|
53
|
+
"entry": {
|
|
54
|
+
"command": "asuite",
|
|
55
|
+
"args": [
|
|
56
|
+
"mcp-shim",
|
|
57
|
+
"example"
|
|
58
|
+
],
|
|
59
|
+
"type": "local",
|
|
60
|
+
"tools": [
|
|
61
|
+
"*"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"plan": {
|
|
65
|
+
"change": "replace",
|
|
66
|
+
"files": [
|
|
67
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"before": {
|
|
71
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
72
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
73
|
+
"mode": 384
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"afterApply": {
|
|
77
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
78
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
79
|
+
"mode": 384
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"afterUndo": {
|
|
83
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
84
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
85
|
+
"mode": 384
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "unchanged",
|
|
91
|
+
"host": "copilot",
|
|
92
|
+
"name": "managed",
|
|
93
|
+
"key": "mcpServers",
|
|
94
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
95
|
+
"env": {},
|
|
96
|
+
"entry": {
|
|
97
|
+
"command": "asuite",
|
|
98
|
+
"args": [
|
|
99
|
+
"mcp-shim",
|
|
100
|
+
"example"
|
|
101
|
+
],
|
|
102
|
+
"type": "local",
|
|
103
|
+
"tools": [
|
|
104
|
+
"*"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"plan": {
|
|
108
|
+
"change": "unchanged",
|
|
109
|
+
"files": [
|
|
110
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"before": {
|
|
114
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
115
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
116
|
+
"mode": 384
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"afterApply": {
|
|
120
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
121
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
122
|
+
"mode": 384
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"afterUndo": {
|
|
126
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
127
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
128
|
+
"mode": 384
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": "symlinked-config",
|
|
134
|
+
"host": "copilot",
|
|
135
|
+
"name": "managed",
|
|
136
|
+
"key": "mcpServers",
|
|
137
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
138
|
+
"env": {},
|
|
139
|
+
"entry": {
|
|
140
|
+
"command": "asuite",
|
|
141
|
+
"args": [
|
|
142
|
+
"mcp-shim",
|
|
143
|
+
"example"
|
|
144
|
+
],
|
|
145
|
+
"type": "local",
|
|
146
|
+
"tools": [
|
|
147
|
+
"*"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"plan": {
|
|
151
|
+
"change": "refused",
|
|
152
|
+
"files": [
|
|
153
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
154
|
+
],
|
|
155
|
+
"code": "unsafe-path"
|
|
156
|
+
},
|
|
157
|
+
"before": {
|
|
158
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
159
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
160
|
+
"mode": 384
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"links": {
|
|
164
|
+
"$FIXTURE/.copilot/mcp-config.json": "$FIXTURE/linked.json"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
{
|
|
2
|
+
"receiptNames": [
|
|
3
|
+
{
|
|
4
|
+
"file": "/home/fixture/.copilot/mcp-config.json",
|
|
5
|
+
"name": "managed",
|
|
6
|
+
"basename": "entry-f397138c2fc609b00e9b0b400df9488c63928714ff2c098804eb2da1d4bbafaf.json"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"file": "/home/fixture/한글/config.json",
|
|
10
|
+
"name": "quote\"and\\slash",
|
|
11
|
+
"basename": "entry-e8cfc859f3ae4e9015a953958405745f639a9b3fb263e141e69158ab080ffd26.json"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"cases": [
|
|
15
|
+
{
|
|
16
|
+
"id": "other-owner-refused",
|
|
17
|
+
"host": "copilot",
|
|
18
|
+
"name": "managed",
|
|
19
|
+
"key": "mcpServers",
|
|
20
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
21
|
+
"env": {},
|
|
22
|
+
"entry": {
|
|
23
|
+
"command": "asuite",
|
|
24
|
+
"args": [
|
|
25
|
+
"mcp-shim",
|
|
26
|
+
"example"
|
|
27
|
+
],
|
|
28
|
+
"type": "local",
|
|
29
|
+
"tools": [
|
|
30
|
+
"*"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"plan": {
|
|
34
|
+
"change": "refused",
|
|
35
|
+
"files": [
|
|
36
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
37
|
+
],
|
|
38
|
+
"code": "suite-managed"
|
|
39
|
+
},
|
|
40
|
+
"before": {
|
|
41
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
42
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
43
|
+
"mode": 384
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"owner": "ares",
|
|
47
|
+
"suiteReceipt": "receipts/package/owner-present.json"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "missing-owner-refused",
|
|
51
|
+
"host": "copilot",
|
|
52
|
+
"name": "managed",
|
|
53
|
+
"key": "mcpServers",
|
|
54
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
55
|
+
"env": {},
|
|
56
|
+
"entry": {
|
|
57
|
+
"command": "asuite",
|
|
58
|
+
"args": [
|
|
59
|
+
"mcp-shim",
|
|
60
|
+
"example"
|
|
61
|
+
],
|
|
62
|
+
"type": "local",
|
|
63
|
+
"tools": [
|
|
64
|
+
"*"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"plan": {
|
|
68
|
+
"change": "refused",
|
|
69
|
+
"files": [
|
|
70
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
71
|
+
],
|
|
72
|
+
"code": "suite-managed"
|
|
73
|
+
},
|
|
74
|
+
"before": {
|
|
75
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
76
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
77
|
+
"mode": 384
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"suiteReceipt": "receipts/package/owner-present.json"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "suite-owner-can-replace",
|
|
84
|
+
"host": "copilot",
|
|
85
|
+
"name": "managed",
|
|
86
|
+
"key": "mcpServers",
|
|
87
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
88
|
+
"env": {},
|
|
89
|
+
"entry": {
|
|
90
|
+
"command": "asuite",
|
|
91
|
+
"args": [
|
|
92
|
+
"mcp-shim",
|
|
93
|
+
"example"
|
|
94
|
+
],
|
|
95
|
+
"type": "local",
|
|
96
|
+
"tools": [
|
|
97
|
+
"*"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"plan": {
|
|
101
|
+
"change": "replace",
|
|
102
|
+
"files": [
|
|
103
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"before": {
|
|
107
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
108
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
109
|
+
"mode": 384
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"owner": "asuite",
|
|
113
|
+
"suiteReceipt": "receipts/package/owner-present.json",
|
|
114
|
+
"afterApply": {
|
|
115
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
116
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
117
|
+
"mode": 384
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"afterUndo": {
|
|
121
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
122
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"}},\"keep\":true}\n",
|
|
123
|
+
"mode": 384
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "no-suite-receipt",
|
|
129
|
+
"host": "copilot",
|
|
130
|
+
"name": "managed",
|
|
131
|
+
"key": "mcpServers",
|
|
132
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
133
|
+
"env": {},
|
|
134
|
+
"entry": {
|
|
135
|
+
"command": "asuite",
|
|
136
|
+
"args": [
|
|
137
|
+
"mcp-shim",
|
|
138
|
+
"example"
|
|
139
|
+
],
|
|
140
|
+
"type": "local",
|
|
141
|
+
"tools": [
|
|
142
|
+
"*"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"plan": {
|
|
146
|
+
"change": "replace",
|
|
147
|
+
"files": [
|
|
148
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"before": {
|
|
152
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
153
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
154
|
+
"mode": 384
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"owner": "ares",
|
|
158
|
+
"afterApply": {
|
|
159
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
160
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
161
|
+
"mode": 384
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"afterUndo": {
|
|
165
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
166
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
167
|
+
"mode": 384
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "linked-default-hub-without-suite-receipt",
|
|
173
|
+
"host": "copilot",
|
|
174
|
+
"name": "managed",
|
|
175
|
+
"key": "mcpServers",
|
|
176
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
177
|
+
"env": {},
|
|
178
|
+
"entry": {
|
|
179
|
+
"command": "asuite",
|
|
180
|
+
"args": [
|
|
181
|
+
"mcp-shim",
|
|
182
|
+
"example"
|
|
183
|
+
],
|
|
184
|
+
"type": "local",
|
|
185
|
+
"tools": [
|
|
186
|
+
"*"
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
"plan": {
|
|
190
|
+
"change": "replace",
|
|
191
|
+
"files": [
|
|
192
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
"before": {
|
|
196
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
197
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
198
|
+
"mode": 384
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"owner": "ares",
|
|
202
|
+
"afterApply": {
|
|
203
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
204
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"asuite\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
205
|
+
"mode": 384
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"afterUndo": {
|
|
209
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
210
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
211
|
+
"mode": 384
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"directoryLinks": {
|
|
215
|
+
"$FIXTURE/.agenthub": "$FIXTURE/physical-hub"
|
|
216
|
+
},
|
|
217
|
+
"suiteReceipts": "$FIXTURE/physical-hub/suite/receipts"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "linked-hub-override-with-asuite-receipt",
|
|
221
|
+
"host": "copilot",
|
|
222
|
+
"name": "managed",
|
|
223
|
+
"key": "mcpServers",
|
|
224
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
225
|
+
"env": {
|
|
226
|
+
"AGENTHUB_HOME": "$FIXTURE/hub-link"
|
|
227
|
+
},
|
|
228
|
+
"entry": {
|
|
229
|
+
"command": "asuite",
|
|
230
|
+
"args": [
|
|
231
|
+
"mcp-shim",
|
|
232
|
+
"example"
|
|
233
|
+
],
|
|
234
|
+
"type": "local",
|
|
235
|
+
"tools": [
|
|
236
|
+
"*"
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
"plan": {
|
|
240
|
+
"change": "refused",
|
|
241
|
+
"files": [
|
|
242
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
243
|
+
],
|
|
244
|
+
"code": "suite-managed"
|
|
245
|
+
},
|
|
246
|
+
"before": {
|
|
247
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
248
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
249
|
+
"mode": 384
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"suiteReceipt": "receipts/package/owner-present.json",
|
|
253
|
+
"directoryLinks": {
|
|
254
|
+
"$FIXTURE/hub-link": "$FIXTURE/physical-hub"
|
|
255
|
+
},
|
|
256
|
+
"suiteReceipts": "$FIXTURE/physical-hub/suite/receipts"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "linked-suite-receipts-refused",
|
|
260
|
+
"host": "copilot",
|
|
261
|
+
"name": "managed",
|
|
262
|
+
"key": "mcpServers",
|
|
263
|
+
"file": "$FIXTURE/.copilot/mcp-config.json",
|
|
264
|
+
"env": {},
|
|
265
|
+
"entry": {
|
|
266
|
+
"command": "asuite",
|
|
267
|
+
"args": [
|
|
268
|
+
"mcp-shim",
|
|
269
|
+
"example"
|
|
270
|
+
],
|
|
271
|
+
"type": "local",
|
|
272
|
+
"tools": [
|
|
273
|
+
"*"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
"plan": {
|
|
277
|
+
"change": "refused",
|
|
278
|
+
"files": [
|
|
279
|
+
"$FIXTURE/.copilot/mcp-config.json"
|
|
280
|
+
],
|
|
281
|
+
"code": "invalid-receipt"
|
|
282
|
+
},
|
|
283
|
+
"before": {
|
|
284
|
+
"$FIXTURE/.copilot/mcp-config.json": {
|
|
285
|
+
"text": "{\"mcpServers\":{\"other\":{\"command\":\"keep\"},\"managed\":{\"command\":\"previous\",\"args\":[\"mcp-shim\",\"example\"],\"type\":\"local\",\"tools\":[\"*\"]}},\"keep\":true}\n",
|
|
286
|
+
"mode": 384
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"directoryLinks": {
|
|
290
|
+
"$FIXTURE/.agenthub/suite/receipts": "$FIXTURE/physical-receipts"
|
|
291
|
+
},
|
|
292
|
+
"suiteReceipts": "$FIXTURE/.agenthub/suite/receipts"
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
}
|
package/package.json
CHANGED
package/src/entry.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { openCodeRouteReason, type HostPaths, type ResolveHostPathsOptions } fro
|
|
|
6
6
|
import { createJsonMcpCodec, type ConfigImage } from "./json.ts";
|
|
7
7
|
import { SETUP_CONFIG_BYTES, setTomlPath } from "./toml.ts";
|
|
8
8
|
import { publishImage, readImage, sameImage, withConfigLock } from "./fs-safe.ts";
|
|
9
|
-
import { digest, findPackageReceipt, imageDigest, readRecovery, writeReceipt, writeRecovery, type Receipt, type ReceiptTarget } from "./receipt.ts";
|
|
9
|
+
import { digest, findPackageReceipt, imageDigest, isReceiptOwner, readReceipt, readRecovery, receiptPath, writeReceipt, writeRecovery, type Receipt, type ReceiptTarget } from "./receipt.ts";
|
|
10
10
|
import { readLegacyReceipt, type LegacyReceipt } from "./receipt-legacy.ts";
|
|
11
11
|
import { asEntryRefusal, EntryRefusal, type RefusalCode } from "./refusal.ts";
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ export interface EntryTarget {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface PlanEntryOptions extends EntryTarget {
|
|
20
|
+
owner?: string;
|
|
20
21
|
entry: Readonly<Record<string, unknown>> | null;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -31,6 +32,8 @@ export type UndoNoopCode = typeof UNDO_NOOP_CODES[number];
|
|
|
31
32
|
|
|
32
33
|
type Change = "add" | "replace" | "remove" | "unchanged";
|
|
33
34
|
type PlannedEntry = ReceiptTarget & {
|
|
35
|
+
owner?: string;
|
|
36
|
+
suiteReceipts?: string;
|
|
34
37
|
change: Change;
|
|
35
38
|
entry: Readonly<Record<string, unknown>> | null;
|
|
36
39
|
current: unknown;
|
|
@@ -150,7 +153,12 @@ function makePlan(
|
|
|
150
153
|
before: ConfigImage,
|
|
151
154
|
opencodeRoutes?: readonly string[],
|
|
152
155
|
legacyPaths: readonly string[] = [],
|
|
156
|
+
owner?: string,
|
|
157
|
+
suiteReceipts?: string,
|
|
153
158
|
): PlannedEntry {
|
|
159
|
+
if (owner !== undefined && !isReceiptOwner(owner)) {
|
|
160
|
+
throw new EntryRefusal("invalid-entry", "provide a nonempty receipt owner of up to 256 bytes without control characters");
|
|
161
|
+
}
|
|
154
162
|
assertHostEdit(selection, requested, opencodeRoutes);
|
|
155
163
|
return editConfig(selection.file, () => {
|
|
156
164
|
const encoded = JSON.stringify(requested);
|
|
@@ -165,10 +173,28 @@ function makePlan(
|
|
|
165
173
|
if (!isDeepStrictEqual(codec.read(after), desired)) throw new EntryRefusal("invalid-entry", "codec did not produce the requested entry");
|
|
166
174
|
const intent = digest([selection.host, selection.file, selection.name, entry]);
|
|
167
175
|
return { ...selection, entry, change: sameImage(before, after) ? "unchanged" : entry === null ? "remove" : current === undefined ? "add" : "replace",
|
|
168
|
-
before, after, current, intent, legacyPaths, ...(
|
|
176
|
+
before, after, current, intent, legacyPaths, ...(owner === undefined ? {} : { owner }),
|
|
177
|
+
...(suiteReceipts === undefined ? {} : { suiteReceipts }), ...(opencodeRoutes ? { opencodeRoutes } : {}) };
|
|
169
178
|
});
|
|
170
179
|
}
|
|
171
180
|
|
|
181
|
+
function assertSuiteOwnership(selection: ReceiptTarget, directory: string | undefined, owner: string | undefined): void {
|
|
182
|
+
if (directory === undefined) return;
|
|
183
|
+
let receipt: Receipt | undefined;
|
|
184
|
+
try {
|
|
185
|
+
receipt = readReceipt(receiptPath(directory, selection), selection).receipt;
|
|
186
|
+
} catch (cause) {
|
|
187
|
+
throw new EntryRefusal("invalid-receipt", `${selection.file}: cannot read the suite receipt; ${message(cause)}`, {
|
|
188
|
+
cause, file: selection.file,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (receipt?.owner === "asuite" && owner !== "asuite") {
|
|
192
|
+
throw new EntryRefusal("suite-managed", `${selection.file}: this entry is managed by asuite; run asuite sync`, {
|
|
193
|
+
file: selection.file,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
172
198
|
export function planEntry(options: PlanEntryOptions): EntryPlan {
|
|
173
199
|
let file: string | undefined;
|
|
174
200
|
try {
|
|
@@ -177,7 +203,11 @@ export function planEntry(options: PlanEntryOptions): EntryPlan {
|
|
|
177
203
|
const routes = selection.host === "opencode"
|
|
178
204
|
? options.paths.refusals.flatMap((item) => item.host === "opencode" && item.code === "opencode-config-route" && item.variable ? [item.variable] : [])
|
|
179
205
|
: undefined;
|
|
180
|
-
|
|
206
|
+
const legacyPaths = [...options.paths.legacyPaths[selection.host] ?? []];
|
|
207
|
+
const { suiteReceipts, suiteReceiptRefusal } = options.paths;
|
|
208
|
+
if (suiteReceiptRefusal) throw new EntryRefusal(suiteReceiptRefusal.code, suiteReceiptRefusal.reason, { file });
|
|
209
|
+
assertSuiteOwnership(selection, suiteReceipts, options.owner);
|
|
210
|
+
return makePlan(selection, options.entry, readImage(file, SETUP_CONFIG_BYTES), routes, legacyPaths, options.owner, suiteReceipts);
|
|
181
211
|
} catch (error) {
|
|
182
212
|
const refusal = asEntryRefusal(error, file ?? options.host, file);
|
|
183
213
|
return { change: "refused", code: refusal.code, reason: refusal.reason, ...(refusal.file ? { file: refusal.file } : {}) };
|
|
@@ -222,6 +252,7 @@ function applyPlan(plan: PlannedEntry, { receiptDir, env }: ApplyEntryOptions):
|
|
|
222
252
|
if (!Object.hasOwn(HOSTS, plan.host)) throw new EntryRefusal("invalid-target", `${plan.host}: select a supported host and replan`);
|
|
223
253
|
const selection = { host: plan.host, file: plan.file, name: plan.name };
|
|
224
254
|
return withConfigLock(plan.file, () => {
|
|
255
|
+
assertSuiteOwnership(selection, plan.suiteReceipts, plan.owner);
|
|
225
256
|
const current = readImage(plan.file, SETUP_CONFIG_BYTES);
|
|
226
257
|
const { path, image, receipt } = findPackageReceipt(receiptDir, selection, plan.legacyPaths);
|
|
227
258
|
let routes: readonly string[] | undefined;
|
|
@@ -233,7 +264,7 @@ function applyPlan(plan: PlannedEntry, { receiptDir, env }: ApplyEntryOptions):
|
|
|
233
264
|
const updated = HOSTS.opencode.files[0].routeVariables.filter((variable) => env[variable]?.trim());
|
|
234
265
|
routes = [...plan.opencodeRoutes, ...updated];
|
|
235
266
|
}
|
|
236
|
-
const next = makePlan(selection, plan.entry, current, routes);
|
|
267
|
+
const next = makePlan(selection, plan.entry, current, routes, [], plan.owner);
|
|
237
268
|
if (next.intent !== plan.intent) throw new EntryRefusal("invalid-plan", `${plan.file}: plan intent changed; generate a fresh plan`);
|
|
238
269
|
if (receipt?.pending) {
|
|
239
270
|
if (receipt.pending.kind !== "apply" || receipt.intent !== plan.intent) {
|
|
@@ -250,7 +281,7 @@ function applyPlan(plan: PlannedEntry, { receiptDir, env }: ApplyEntryOptions):
|
|
|
250
281
|
if (backup.receipt) writeReceipt(backup.path, backup.image);
|
|
251
282
|
return appliedResult(selection, path, next.change, receipt.intent, legacy);
|
|
252
283
|
}
|
|
253
|
-
if (receipt && receipt.intent === plan.intent && next.change === "unchanged") {
|
|
284
|
+
if (receipt && receipt.intent === plan.intent && receipt.owner === plan.owner && next.change === "unchanged") {
|
|
254
285
|
return result(selection, path, "unchanged", receipt.intent);
|
|
255
286
|
}
|
|
256
287
|
if (!sameImage(current, plan.before) || !sameImage(next.after, plan.after)) {
|
|
@@ -259,9 +290,13 @@ function applyPlan(plan: PlannedEntry, { receiptDir, env }: ApplyEntryOptions):
|
|
|
259
290
|
|
|
260
291
|
const legacy = receipt ? undefined : readLegacyReceipt(receiptDir, selection, plan.legacyPaths);
|
|
261
292
|
const baseline = receipt ? restoreOwned(receipt, current, plan.file) : legacy ? legacyBaseline(selection, legacy, current) : current;
|
|
262
|
-
|
|
293
|
+
const { owner } = plan;
|
|
294
|
+
if (next.change === "unchanged" && !legacy && (!receipt || receipt.owner === owner)) {
|
|
295
|
+
return result(selection, path, "unchanged", next.intent);
|
|
296
|
+
}
|
|
263
297
|
const completed: Receipt = {
|
|
264
298
|
version: 1, ...selection, file: receipt?.file ?? selection.file, intent: next.intent, before: baseline, after: next.after,
|
|
299
|
+
...(owner === undefined ? {} : { owner }),
|
|
265
300
|
};
|
|
266
301
|
if (next.change === "unchanged") {
|
|
267
302
|
writeReceipt(path, image, completed);
|
|
@@ -388,6 +423,7 @@ function legacyBaseline(selection: ReceiptTarget, legacy: LegacyReceipt, current
|
|
|
388
423
|
}
|
|
389
424
|
|
|
390
425
|
export interface EntryReceipt {
|
|
426
|
+
owner?: string;
|
|
391
427
|
file: string;
|
|
392
428
|
receipt: string;
|
|
393
429
|
intent: string;
|
|
@@ -424,8 +460,8 @@ export function readEntryReceipt(options: EntryTarget & { receiptDir: string }):
|
|
|
424
460
|
const legacyPaths = options.paths.legacyPaths[options.host];
|
|
425
461
|
const { path, receipt } = findPackageReceipt(options.receiptDir, selection, legacyPaths);
|
|
426
462
|
if (receipt) {
|
|
427
|
-
const { file, intent, before, after, pending } = receipt;
|
|
428
|
-
return { file, receipt: path, intent, before, after, ...(pending ? { pending } : {}) };
|
|
463
|
+
const { file, intent, before, after, owner, pending } = receipt;
|
|
464
|
+
return { file, receipt: path, intent, before, after, ...(owner === undefined ? {} : { owner }), ...(pending ? { pending } : {}) };
|
|
429
465
|
}
|
|
430
466
|
const legacy = readLegacyReceipt(options.receiptDir, selection, legacyPaths);
|
|
431
467
|
return legacy ? legacyView(selection, legacy) : undefined;
|
package/src/hosts.ts
CHANGED
|
@@ -109,6 +109,13 @@ export const HOSTS = {
|
|
|
109
109
|
entry: stdio,
|
|
110
110
|
verified: ["0.61.0", "0.67.0"],
|
|
111
111
|
},
|
|
112
|
+
copilot: {
|
|
113
|
+
id: "copilot",
|
|
114
|
+
files: [{ scope: "user", path: "mcp-config.json", override: { key: "COPILOT_HOME", rule: "absolute-only", directory: ".copilot" } }],
|
|
115
|
+
format: mcpServers,
|
|
116
|
+
entry: { ...stdio, type: "local", tools: "string[]" },
|
|
117
|
+
verified: ["1.0.107"],
|
|
118
|
+
},
|
|
112
119
|
agy: {
|
|
113
120
|
id: "agy",
|
|
114
121
|
files: [{ scope: "project", path: ".agents/mcp_config.json" }],
|
package/src/paths.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface HostRefusal {
|
|
|
33
33
|
|
|
34
34
|
export interface HostPaths {
|
|
35
35
|
home: string;
|
|
36
|
+
suiteReceipts?: string;
|
|
37
|
+
suiteReceiptRefusal?: Omit<HostRefusal, "host">;
|
|
36
38
|
paths: Partial<Record<HostId, string[]>>;
|
|
37
39
|
/** Pre-redirect paths for validating receipts from older setup versions. */
|
|
38
40
|
legacyPaths: Partial<Record<HostId, string[]>>;
|
|
@@ -140,7 +142,17 @@ export function resolveHostPaths(options: ResolveHostPathsOptions): HostPaths {
|
|
|
140
142
|
legacyPaths[target] = legacy;
|
|
141
143
|
roots[target] = { current: currentRoots, legacy: legacyRoots };
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
const suiteHome = env.AGENT_SUITE_HOME?.trim();
|
|
146
|
+
const hubHome = env.AGENTHUB_HOME?.trim();
|
|
147
|
+
const variable = suiteHome ? "AGENT_SUITE_HOME" : "AGENTHUB_HOME";
|
|
148
|
+
const selectedHome = suiteHome || hubHome;
|
|
149
|
+
if (selectedHome && !isAbsolute(selectedHome)) {
|
|
150
|
+
return { home, paths, legacyPaths, redirects, refusals, roots, suiteReceiptRefusal: {
|
|
151
|
+
code: "relative-override", variable, reason: `${variable} is relative; unset it or supply an absolute directory`,
|
|
152
|
+
} };
|
|
153
|
+
}
|
|
154
|
+
const suiteRoot = suiteHome || join(hubHome || join(home, ".agenthub"), "suite");
|
|
155
|
+
return { home, paths, legacyPaths, redirects, refusals, roots, suiteReceipts: join(canonical(suiteRoot), "receipts") };
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
export interface ResolveSkillRootsOptions extends Omit<ResolveHostPathsOptions, "hosts"> {
|
package/src/receipt.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface ReceiptTarget {
|
|
|
22
22
|
|
|
23
23
|
export interface Receipt extends ReceiptTarget {
|
|
24
24
|
version: 1;
|
|
25
|
+
owner?: string;
|
|
25
26
|
intent: string;
|
|
26
27
|
before: ConfigImage;
|
|
27
28
|
after: ConfigImage;
|
|
@@ -39,6 +40,10 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
|
39
40
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
40
41
|
const isDigest = (value: unknown): value is string => typeof value === "string" && hashPattern.test(value);
|
|
41
42
|
|
|
43
|
+
export function isReceiptOwner(value: unknown): value is string {
|
|
44
|
+
return typeof value === "string" && value.length > 0 && !/[\p{Cc}\p{Cf}]/u.test(value) && Buffer.byteLength(value) <= 256;
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
export function isConfigImage(value: unknown): value is ConfigImage {
|
|
43
48
|
if (!isRecord(value) || typeof value.mode !== "number" || !Number.isInteger(value.mode)
|
|
44
49
|
|| value.mode < 0 || value.mode > 0o7777) return false;
|
|
@@ -66,7 +71,8 @@ export function readReceipt(path: string, target: ReceiptTarget): { image: Confi
|
|
|
66
71
|
throw new EntryRefusal("invalid-receipt", `${path}: invalid or unsupported receipt; inspect or restore the original receipt before retrying`, { file: path });
|
|
67
72
|
};
|
|
68
73
|
if (!isRecord(value) || value.version !== 1 || value.host !== target.host || value.file !== target.file
|
|
69
|
-
|| value.name !== target.name ||
|
|
74
|
+
|| value.name !== target.name || (value.owner !== undefined && !isReceiptOwner(value.owner))
|
|
75
|
+
|| !isDigest(value.intent) || !isConfigImage(value.before) || !isConfigImage(value.after)) return refuse();
|
|
70
76
|
const pending = value.pending;
|
|
71
77
|
if (pending !== undefined && (!isRecord(pending) || (pending.kind !== "apply" && pending.kind !== "undo")
|
|
72
78
|
|| !isDigest(pending.start) || !isDigest(pending.result)
|