granttap-mcp 0.8.187 → 0.8.188
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 +65 -14
- package/SECURITY.md +8 -1
- package/apps/bridge/src/account-recovery/offer.ts +6 -6
- package/apps/bridge/src/bin/runtime/monitor.ts +21 -3
- package/apps/bridge/src/device-management/index.ts +17 -4
- package/apps/bridge/src/device-management/maintenance.ts +12 -2
- package/apps/bridge/src/mesh/README.md +5 -0
- package/apps/bridge/src/mesh/catalog/README.md +4 -1
- package/apps/bridge/src/mesh/catalog/binding-state.ts +12 -1
- package/apps/bridge/src/mesh/catalog/index.ts +16 -2
- package/apps/bridge/src/mesh/identity/call-scope.ts +2 -1
- package/apps/bridge/src/mesh/local-remote/README.md +50 -0
- package/apps/bridge/src/mesh/local-remote/folder-meshes.ts +58 -0
- package/apps/bridge/src/mesh/repositories/edit.ts +5 -0
- package/apps/bridge/src/mesh/snapshot/merge.ts +3 -1
- package/apps/bridge/src/mesh/store/base.ts +3 -2
- package/apps/bridge/src/mesh/store/index.ts +3 -1
- package/apps/bridge/src/mesh/store/repositories/index.ts +24 -0
- package/apps/bridge/src/monitor/handlers/user-message.ts +18 -50
- package/apps/bridge/src/monitor/message-delivery/README.md +4 -1
- package/apps/bridge/src/monitor/message-delivery/acceptance.ts +20 -5
- package/apps/bridge/src/monitor/message-delivery/index.ts +3 -1
- package/apps/bridge/src/monitor/message-delivery/late-results.ts +87 -0
- package/apps/bridge/src/monitor/support/runtime.ts +31 -4
- package/apps/bridge/src/paired-phones/README.md +60 -0
- package/apps/bridge/src/paired-phones/admission.ts +53 -0
- package/apps/bridge/src/paired-phones/device-actions.ts +71 -0
- package/apps/bridge/src/paired-phones/index.ts +7 -0
- package/apps/bridge/src/paired-phones/removal.ts +48 -0
- package/apps/bridge/src/paired-phones/roster.ts +82 -0
- package/apps/bridge/src/pairing/controllers.ts +31 -7
- package/apps/bridge/src/pairing/index.ts +14 -9
- package/apps/bridge/src/pairing/presence.ts +24 -0
- package/apps/bridge/src/reply/README.md +4 -0
- package/apps/bridge/src/reply/grok-response/index.ts +5 -0
- package/apps/bridge/src/reply/in-flight.ts +54 -5
- package/apps/bridge/src/reply/index.ts +22 -39
- package/apps/bridge/src/reply/payload/claude-result.ts +33 -0
- package/apps/bridge/src/reply/payload/types.ts +9 -4
- package/apps/bridge/src/reply/process/codex-headless.ts +20 -2
- package/apps/bridge/src/reply/process/index.ts +116 -72
- package/apps/bridge/src/reply/process/provider-headless.ts +3 -1
- package/apps/bridge/src/reply/survival/README.md +73 -0
- package/apps/bridge/src/reply/survival/adoption.ts +115 -0
- package/apps/bridge/src/reply/survival/answers.ts +67 -0
- package/apps/bridge/src/reply/survival/files.ts +78 -0
- package/apps/bridge/src/reply/survival/index.ts +92 -0
- package/apps/bridge/src/reply/survival/records.ts +123 -0
- package/apps/bridge/src/reply/survival/run.ts +89 -0
- package/apps/bridge/src/runtime-updates/README.md +72 -30
- package/apps/bridge/src/runtime-updates/drain/index.ts +64 -5
- package/apps/bridge/src/runtime-updates/drain/state.ts +112 -0
- package/apps/bridge/src/runtime-updates/index.ts +17 -9
- package/apps/bridge/src/runtime-updates/readiness.ts +2 -0
- package/apps/bridge/src/sessions/README.md +4 -1
- package/apps/bridge/src/task-dispatch/README.md +11 -3
- package/apps/bridge/src/task-dispatch/worker/queue-depth.ts +19 -1
- package/apps/bridge/src/task-transfer/index.ts +8 -3
- package/apps/mcp/src/chat-identity/README.md +53 -0
- package/apps/mcp/src/chat-identity/index.ts +110 -0
- package/apps/mcp/src/chat-identity/processes.ts +135 -0
- package/apps/mcp/src/connection-center/README.md +4 -3
- package/apps/mcp/src/connection-center/state.ts +23 -7
- package/apps/mcp/src/http/create-server.ts +2 -0
- package/apps/mcp/src/mcp-tools/README.md +11 -1
- package/apps/mcp/src/mcp-tools/connect/index.ts +12 -10
- package/apps/mcp/src/mcp-tools/connect/relay.ts +1 -1
- package/apps/mcp/src/mcp-tools/mesh/current.ts +2 -2
- package/apps/mcp/src/mcp-tools/mesh/resource.ts +2 -1
- package/apps/mcp/src/mcp-tools/mesh/session-env.ts +7 -9
- package/apps/mcp/src/mcp-tools/phones/index.ts +63 -0
- package/apps/mcp/src/mcp-tools/phones/removal.ts +113 -0
- package/apps/mcp/src/oauth/session/connect-snapshot.ts +4 -3
- package/apps/mcp/src/status/chat-status.ts +38 -11
- package/apps/mcp/src/status/pairing-status.ts +50 -36
- package/cursor-plugin/README.md +1 -1
- package/cursor-plugin/mcp.json +1 -1
- package/cursor-plugin/stdio-bootstrap.cjs +1 -1
- package/docs/device-management.md +9 -2
- package/package.json +1 -1
- package/packages/core/relay-client.ts +3 -1
- package/packages/protocol/messages/README.md +4 -0
- package/packages/protocol/messages/device/management.ts +50 -0
- package/packages/protocol/messages/mesh/tasks.ts +5 -0
package/README.md
CHANGED
|
@@ -144,6 +144,36 @@ The Mac app can join the Account Mesh before the helper is present and links it
|
|
|
144
144
|
when the installed helper becomes available. A one-time QR still provides direct
|
|
145
145
|
device pairing without a passkey account.
|
|
146
146
|
|
|
147
|
+
## Phones paired with a computer
|
|
148
|
+
|
|
149
|
+
Every phone or iPad that scanned a QR for a computer keeps a key there until someone removes it, so test and
|
|
150
|
+
debug installs pile up. In the app, **Devices → a computer → Phones** lists each phone with its name or label,
|
|
151
|
+
**This iPhone**, and when it last reached the computer, and removes one (swipe or context menu), several, or
|
|
152
|
+
every phone not seen for 30 days. Removing the phone in use is its own confirmed action, **Unpair this
|
|
153
|
+
phone**, and the last phone always stays. A removed phone stops receiving from the computer at once, in every
|
|
154
|
+
running GrantTap process, without a restart; it needs a new QR to pair again. Removing the first pairing hands
|
|
155
|
+
its place to the phone heard from most recently.
|
|
156
|
+
|
|
157
|
+
A computer accepts its first pairing plus 16 added phones. At the limit a new phone takes the place of the
|
|
158
|
+
added phone idle longest, provided that phone has not reached the computer, and was not added, for 30 days;
|
|
159
|
+
the first pairing, a phone used in the last 30 days and an open QR are never taken. When every place is in
|
|
160
|
+
use the new phone is refused with a pointer to the Phones screen.
|
|
161
|
+
|
|
162
|
+
The phone asks over the encrypted `device.manage` request it already uses for the computer's MCP and agent
|
|
163
|
+
controls, and the answer goes only to the phone that asked:
|
|
164
|
+
|
|
165
|
+
| Request | Fields | Answer |
|
|
166
|
+
| --- | --- | --- |
|
|
167
|
+
| `status` | — | `snapshot.phones`: `id` (sha256 of the phone key, 64 hex), `label` (its first 6 hex), `name` when the phone reported one, `thisPhone`, `primary`, `addedAt` and `lastSeenAt` in ms (absent when unknown). Absent from MCP 0.8.187 and older. |
|
|
168
|
+
| `phones-remove` | `computerId`, `phoneIds` (1–32) | Removes those other phones; refused when the list holds the phone asking. |
|
|
169
|
+
| `phones-remove-stale` | `computerId`, `notSeenForDays` (1–3650) | Removes every other phone not seen, and not added, for that many days. |
|
|
170
|
+
| `phones-unpair-self` | `computerId` | Removes the phone asking, answered before its key goes; refused for the only phone. |
|
|
171
|
+
|
|
172
|
+
A removal answers `device.manage.result` with `phase: "completed"`, `removedPhoneIds` and the updated
|
|
173
|
+
`snapshot` (none after `phones-unpair-self`); a refusal answers `phase: "failed"` with the reason in
|
|
174
|
+
`message`. An agent uses `remove_phones` instead, confirmed by the person on a phone. See
|
|
175
|
+
[paired phones](apps/bridge/src/paired-phones/README.md).
|
|
176
|
+
|
|
147
177
|
## Mac, iPhone, iPad, and Apple Watch
|
|
148
178
|
|
|
149
179
|
<p align="center">
|
|
@@ -439,6 +469,14 @@ snapshots that still list it, do not bind it again until it is added back.
|
|
|
439
469
|
Only a controller paired with the computer is answered, and the answer goes
|
|
440
470
|
to that controller alone.
|
|
441
471
|
|
|
472
|
+
A Mesh made for a folder without Git never holds a repository that has its own
|
|
473
|
+
remote. A task begun in `~/dev` that works in `~/dev/app` keeps its history in
|
|
474
|
+
the folder's Mesh, while `app`'s chats, new ones at once, go to `app`'s own
|
|
475
|
+
Mesh. A folder Mesh whose folder has since become a clone of a repository with
|
|
476
|
+
a Mesh of its own is published with `project.supersededBy` naming that Mesh, so
|
|
477
|
+
the phone can leave it out of New Task and keep its tasks visible. See
|
|
478
|
+
[folder Meshes](apps/bridge/src/mesh/local-remote/README.md).
|
|
479
|
+
|
|
442
480
|
### Task reports
|
|
443
481
|
|
|
444
482
|
<p align="center">
|
|
@@ -602,15 +640,16 @@ trust.
|
|
|
602
640
|
|
|
603
641
|
## MCP contract
|
|
604
642
|
|
|
605
|
-
`tools/list` returns exactly
|
|
643
|
+
`tools/list` returns exactly eleven public tools:
|
|
606
644
|
|
|
607
645
|
| Tool | Contract |
|
|
608
646
|
| --- | --- |
|
|
609
647
|
| `set_runtime_auto_update` | When the user asks, turn automatic GrantTap runtime updates on this computer on or off; saves the preference without restarting services or changing pairing, tasks, or provider policy, and returns the connection state |
|
|
610
|
-
| `connection_status` | Read-only: saved pairing and paired
|
|
648
|
+
| `connection_status` | Read-only: saved pairing and every paired phone with its id and when it last reached this computer, QR expiry, relay observations, provider readiness, a newer runtime waiting to take over and why, and for the calling chat (Claude Code, Codex, Grok Build, Cursor) the phone messages queued behind its turn and its continuation after a subscription limit |
|
|
611
649
|
| `connect_with_passkey` | Link this computer to the user's GrantTap account so a signed-in phone can connect without a QR; returns a 15-minute granttap.com link, the passkey is entered only there, and existing QR pairings stay unchanged |
|
|
612
650
|
| `connect` | Show the existing pairing on the connection card, or on an unpaired computer create a one-time QR shown only on the card |
|
|
613
651
|
| `reconnect` | After explicit confirmation, show a one-time QR to reconnect or add an independent controller device while retaining the current room |
|
|
652
|
+
| `remove_phones` | Ask the person to remove paired phones that are no longer used, by `notSeenForDays` and/or `phoneIds` from `connection_status`; nothing is removed without a yes on a phone, and the phone that answers, any phone heard from while the question is open, and the last phone stay |
|
|
614
653
|
| `notify` | Send a non-blocking status of at most 2,000 characters that nobody answers, and/or one task-scoped Mesh event |
|
|
615
654
|
| `ask_yes_no` | Ask a yes/no question and wait about three minutes for the explicit answer; a timeout is neither yes nor no |
|
|
616
655
|
| `ask` | Ask an open question and wait about three minutes for typed or spoken text |
|
|
@@ -625,7 +664,8 @@ available to a model through prompt injection.
|
|
|
625
664
|
|
|
626
665
|
A phone message delivered while more phone messages wait for the same chat carries one GrantTap
|
|
627
666
|
line after the person's words, saying how many follow and that repository-wide checks, full test
|
|
628
|
-
runs and publishing can wait for the last of them
|
|
667
|
+
runs and publishing can wait for the last of them — whether it came through the durable queue or
|
|
668
|
+
directly, and in a moved Task's chat too. The phone's transcript view does not show it.
|
|
629
669
|
|
|
630
670
|
`notify` may alternatively carry one bounded task-scoped Mesh event. This does
|
|
631
671
|
not add another MCP tool or grant any global setup capability, and it publishes
|
|
@@ -745,11 +785,17 @@ question still unanswered — and names the MCP resource `granttap://mesh/map`,
|
|
|
745
785
|
one page of markdown with the whole Project: Tasks, who edits which module,
|
|
746
786
|
the other side of each repository, dependencies, and what just happened. That
|
|
747
787
|
resource is listed, because Claude Code reads only listed resources, and it is
|
|
748
|
-
scoped without a token:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
788
|
+
scoped without a token: the host that starts an MCP server for one chat names
|
|
789
|
+
that chat, which nothing said over the connection can change — Claude Code in
|
|
790
|
+
`CLAUDE_CODE_SESSION_ID`, Grok Build in `GROK_SESSION_ID`, and a Codex CLI chat
|
|
791
|
+
by the one rollout its Codex process holds open (Codex gives its servers a bare
|
|
792
|
+
environment). Only the nearest host above the server counts, so a run a chat
|
|
793
|
+
started from its shell is not taken for that chat. `granttap://mesh/current`
|
|
794
|
+
serves the same chat's scoped state there. Cursor shares one server between a
|
|
795
|
+
window's chats; it and a Codex process with several chats open keep the
|
|
796
|
+
tokened `granttap://mesh/{capability}` and `…/map` forms from an attributed
|
|
797
|
+
`notify`, and `connection_status` names their chat from the provider hook's
|
|
798
|
+
record of that call. See [chat identity](apps/mcp/src/chat-identity/README.md). Background runs themselves
|
|
753
799
|
receive nothing from the hook; the journal is kept for the session a person
|
|
754
800
|
is in.
|
|
755
801
|
|
|
@@ -963,12 +1009,17 @@ Verified updates are staged separately and applied after active requests and pen
|
|
|
963
1009
|
decisions finish. Startup failures restore the previous version. Pairing and task
|
|
964
1010
|
policies are retained; source checkouts and running provider processes stay in place.
|
|
965
1011
|
|
|
966
|
-
A computer that always has a chat running is never idle on its own.
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1012
|
+
A computer that always has a chat running is never idle on its own. A chat's turn started
|
|
1013
|
+
from the phone therefore keeps running through the switch: its output goes to a private
|
|
1014
|
+
file instead of a pipe, the new version takes the run over by its process, and sends its
|
|
1015
|
+
answer when it ends. When an update is ready, the background monitor stops starting newly
|
|
1016
|
+
arrived phone messages while the work it cannot hand over ends — usually seconds, ten
|
|
1017
|
+
minutes at most — and then switches. Messages that arrive meanwhile are kept and
|
|
1018
|
+
delivered by the new version; none is refused or run twice. If such work outlasts the ten
|
|
1019
|
+
minutes, messages run again and the update follows when it has ended. `connection_status`
|
|
1020
|
+
and the phone's computer status say what a waiting update waits for, since when, and when
|
|
1021
|
+
it is tried again. See [runtime updates](apps/bridge/src/runtime-updates/README.md) and
|
|
1022
|
+
[runs that outlive their monitor](apps/bridge/src/reply/survival/README.md).
|
|
972
1023
|
|
|
973
1024
|
In the plugin's GrantTap connection card, use **Automatic updates: On / Off**.
|
|
974
1025
|
The choice is saved for this computer and takes effect without restarting the
|
package/SECURITY.md
CHANGED
|
@@ -102,9 +102,16 @@ report the observation as read-only instead of implying enforcement.
|
|
|
102
102
|
|
|
103
103
|
`setup` is CLI-only because it writes local provider configuration and installs
|
|
104
104
|
background services. The public MCP server can only connect an existing or new
|
|
105
|
-
phone pairing, notify, and ask bounded questions; it cannot reconfigure the
|
|
105
|
+
phone pairing, remove phones the person confirms, notify, and ask bounded questions; it cannot reconfigure the
|
|
106
106
|
machine or select a custom relay.
|
|
107
107
|
|
|
108
|
+
A phone key stays authorized until someone removes it. The phone app removes phones from **Devices → a
|
|
109
|
+
computer → Phones**; `remove_phones` lets an agent ask, and removes nothing until the person answers yes on a
|
|
110
|
+
phone, never the phone that answered, any phone heard from while the question was open, or the last phone.
|
|
111
|
+
Every relay link rereads the pairing file before each send and each received message, so a removed key gets
|
|
112
|
+
no new ciphertext at once. Ciphertext the relay already holds for it, such as a bounded read cache, is not
|
|
113
|
+
recalled. At the 17-phone limit only an added phone idle for 30 days gives its place to a new one.
|
|
114
|
+
|
|
108
115
|
`request_sign_in` sends an https page to the phone and may deliver one loopback
|
|
109
116
|
redirect back. That delivery is a single `GET` to `127.0.0.1` or `::1` on the
|
|
110
117
|
port the pending request declared, made once, only while the request waits, and
|
|
@@ -5,7 +5,9 @@ import { createPairing, DEFAULT_RELAY_URL, machineConfigPath, phonePairingPath,
|
|
|
5
5
|
import { applyNetworkRoute } from "../device-network/settings";
|
|
6
6
|
import { readNetworkSettings } from "../device-network/settings";
|
|
7
7
|
import { parkedPairingHalves } from "../pairing";
|
|
8
|
-
import { prunePendingControllers
|
|
8
|
+
import { prunePendingControllers } from "../pairing/controllers";
|
|
9
|
+
import { recordControllerAdded } from "../pairing/presence";
|
|
10
|
+
import { admitPhoneKey, evictionFor } from "../paired-phones";
|
|
9
11
|
|
|
10
12
|
export type RecoveryRequest = { id: string; phonePublicKey: string; expiresAt: number };
|
|
11
13
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
@@ -27,13 +29,11 @@ export function createRecoveryOffer(request: RecoveryRequest, machineId: string)
|
|
|
27
29
|
let { machineCfg, phoneCfg } = existing ?? createPairing(relayUrl);
|
|
28
30
|
if (existing) {
|
|
29
31
|
machineCfg = prunePendingControllers(machineCfg);
|
|
30
|
-
|
|
31
|
-
if (extra.length >= 16) throw new Error("This computer has reached its controller device limit.");
|
|
32
|
+
evictionFor(machineCfg);
|
|
32
33
|
const keys = generateKeyPair();
|
|
33
34
|
phoneCfg = { ...phoneCfg, peerPublicKey: machineCfg.myPublicKey,
|
|
34
35
|
senderId: randomId(8), myPublicKey: keys.publicKey,
|
|
35
36
|
mySecretKey: keys.secretKey };
|
|
36
|
-
machineCfg = { ...machineCfg, extraPeerPublicKeys: [...extra, keys.publicKey] };
|
|
37
37
|
}
|
|
38
38
|
const routedPhone = applyNetworkRoute(phoneCfg);
|
|
39
39
|
const ephemeral = generateKeyPair();
|
|
@@ -45,9 +45,9 @@ export function createRecoveryOffer(request: RecoveryRequest, machineId: string)
|
|
|
45
45
|
if (!existing) {
|
|
46
46
|
saveConfig(machineConfigPath(), machineCfg);
|
|
47
47
|
saveConfig(phonePairingPath(), phoneCfg);
|
|
48
|
+
recordControllerAdded(phoneCfg.myPublicKey);
|
|
48
49
|
} else {
|
|
49
|
-
|
|
50
|
-
saveConfig(machineConfigPath(), machineCfg);
|
|
50
|
+
admitPhoneKey(machineCfg.room, phoneCfg.myPublicKey, request.expiresAt);
|
|
51
51
|
}
|
|
52
52
|
return JSON.stringify({ senderPublicKey: ephemeral.publicKey, ...box });
|
|
53
53
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { startRuntimeUpdates } from "../../runtime-updates";
|
|
2
2
|
import { runtimeUpdateReadiness } from "../../runtime-updates/readiness";
|
|
3
|
-
import { UpdateDrain } from "../../runtime-updates/drain";
|
|
4
|
-
import {
|
|
3
|
+
import { UpdateDrain, writeHoldState } from "../../runtime-updates/drain";
|
|
4
|
+
import { oldestBlockingDeliveryStartedAt } from "../../reply/in-flight";
|
|
5
|
+
import { freezeSurvivingRuns, liveRunCounts, thawSurvivingRuns } from "../../reply/survival";
|
|
6
|
+
import { adoptSurvivingRuns } from "../../reply/survival/adoption";
|
|
7
|
+
import { registerLateResults } from "../../monitor/message-delivery/late-results";
|
|
5
8
|
/** Persistent, terminal-free task sync for the GrantTap phone app on macOS. */
|
|
6
9
|
import { join } from "node:path";
|
|
7
10
|
import { RelayClient } from "../../../../../packages/core/relay-client";
|
|
@@ -35,8 +38,16 @@ let stopEngineRecovery = () => {};
|
|
|
35
38
|
let stopRuntimeUpdates = () => {};
|
|
36
39
|
let stopUpdateReadiness = () => {};
|
|
37
40
|
const stopWatchdog = startRuntimeWatchdog();
|
|
41
|
+
let stopAdoption = () => {};
|
|
42
|
+
const updateDirectory = join(configDir(), "runtime-updates");
|
|
43
|
+
// What a waiting update waits for is told to status views in other processes; a monitor starts with none.
|
|
44
|
+
writeHoldState(updateDirectory, undefined);
|
|
38
45
|
// Messages keep arriving, so a newer runtime cannot wait for an idle moment: queued work is held for it instead.
|
|
39
|
-
|
|
46
|
+
// Chats' runs keep going through the switch and the new monitor takes them over (`reply/survival`).
|
|
47
|
+
const updateDrain = new UpdateDrain({ oldestRun: oldestBlockingDeliveryStartedAt,
|
|
48
|
+
blockers: () => monitor?.updateBlockers() ?? [], survivingRuns: () => liveRunCounts().survivable,
|
|
49
|
+
report: hold => writeHoldState(updateDirectory, hold),
|
|
50
|
+
onHandoff: freezeSurvivingRuns, onHandoffLapsed: thawSurvivingRuns,
|
|
40
51
|
log: line => process.stderr.write(`[monitor] ${line}\n`) });
|
|
41
52
|
|
|
42
53
|
publishStableNode();
|
|
@@ -50,6 +61,10 @@ try {
|
|
|
50
61
|
peerAllowed: controllerPeerGate(cfg),
|
|
51
62
|
});
|
|
52
63
|
monitor = startSessionMonitor(client, { primary: process.env.GRANTTAP_MONITOR_PRIMARY === "1", config: cfg });
|
|
64
|
+
// Runs the previous monitor left running hold their chats before any queued message is started.
|
|
65
|
+
registerLateResults(client);
|
|
66
|
+
stopAdoption = adoptSurvivingRuns({ connected: () => client.isConnected,
|
|
67
|
+
log: line => process.stderr.write(`[monitor] ${line}\n`) });
|
|
53
68
|
stopTaskDispatch = startTaskDispatchMonitor({ config: cfg, client,
|
|
54
69
|
isLeader: monitor.isLeader, peerAllowed: controllerPeerGate(cfg), publish: monitor.publish,
|
|
55
70
|
held: () => updateDrain.holding(), track: monitor.track });
|
|
@@ -68,6 +83,9 @@ try {
|
|
|
68
83
|
const stop = (exitCode = 0): void => {
|
|
69
84
|
if (stopping) return;
|
|
70
85
|
stopping = true;
|
|
86
|
+
// Whatever stops this monitor, a run that ends now leaves its answer for the next one.
|
|
87
|
+
freezeSurvivingRuns();
|
|
88
|
+
stopAdoption();
|
|
71
89
|
stopWatchdog();
|
|
72
90
|
stopRuntimeUpdates();
|
|
73
91
|
stopUpdateReadiness();
|
|
@@ -6,6 +6,7 @@ import { observedComputerId } from '../mesh/identity/computer';
|
|
|
6
6
|
import { clearComputerCache } from './cache';
|
|
7
7
|
import { providerLogins } from './login';
|
|
8
8
|
import { managementSnapshot, maintenanceIdle, prepareRestart, restartProvider, restartRuntime, runtimeRoot, updateRuntime, updateProvider } from './maintenance';
|
|
9
|
+
import { isPhoneAction, planPhoneChange } from '../paired-phones';
|
|
9
10
|
|
|
10
11
|
type Send = (result: DeviceManagementResult) => Promise<void>;
|
|
11
12
|
type Entry = { fingerprint: string; result?: DeviceManagementResult; pending?: Promise<void>; at: number; ttl: number };
|
|
@@ -42,14 +43,16 @@ export async function handleDeviceManagement(client: RelayClient, request: Devic
|
|
|
42
43
|
const entry: Entry = { fingerprint, at: Date.now(), ttl: request.action === 'status' ? 60_000 : 15 * 60_000 };
|
|
43
44
|
requests.set(key, entry);
|
|
44
45
|
const report: Send = async result => { entry.result = result; await send(result); };
|
|
45
|
-
entry.pending = execute(request, client.room
|
|
46
|
+
entry.pending = execute(request, { room: client.room, peer }, computerId, report)
|
|
46
47
|
.catch(async () => { /* disconnected phones recover with a new status request */ })
|
|
47
48
|
.finally(() => { entry.pending = undefined; });
|
|
48
49
|
// Commands run independently of message delivery; repeated taps reuse their operation.
|
|
49
50
|
return true;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
async function execute(request: DeviceManagementRequest,
|
|
53
|
+
async function execute(request: DeviceManagementRequest, origin: { room: string; peer: string }, computerId: string,
|
|
54
|
+
send: Send): Promise<void> {
|
|
55
|
+
const scope = origin.room + ':' + origin.peer;
|
|
53
56
|
const base = { type: 'device.manage.result' as const, requestId: request.requestId, computerId,
|
|
54
57
|
action: request.action, agent: request.agent };
|
|
55
58
|
const result = (phase: DeviceManagementResult['phase'], message: string): DeviceManagementResult =>
|
|
@@ -72,7 +75,16 @@ async function execute(request: DeviceManagementRequest, scope: string, computer
|
|
|
72
75
|
await send(result('running', request.action === 'status' ? 'Reading this computer…' : 'Working on this computer…'));
|
|
73
76
|
if (request.action === 'status') providerLogins.replay(scope);
|
|
74
77
|
let message = 'Computer status refreshed.';
|
|
75
|
-
|
|
78
|
+
let removedPhoneIds: string[] | undefined;
|
|
79
|
+
if (isPhoneAction(request.action)) {
|
|
80
|
+
const change = planPhoneChange(request, origin.peer, origin.room);
|
|
81
|
+
if (change.selfOutcome) {
|
|
82
|
+
// Once its key is gone this phone can no longer be answered, so it hears first and the key goes after.
|
|
83
|
+
await send({ ...result('completed', change.selfOutcome.message), removedPhoneIds: change.selfOutcome.removedPhoneIds });
|
|
84
|
+
change.commit(); return;
|
|
85
|
+
}
|
|
86
|
+
({ message, removedPhoneIds } = change.commit());
|
|
87
|
+
} else if (request.action === 'clear-cache') {
|
|
76
88
|
if (!maintenanceIdle()) throw Error('Finish active requests and sign-in before clearing computer caches.');
|
|
77
89
|
const bytes = await clearComputerCache(runtimeRoot);
|
|
78
90
|
message = `Cleared ${(bytes / 1024 / 1024).toFixed(1)} MB of disposable cache.`;
|
|
@@ -88,7 +100,8 @@ async function execute(request: DeviceManagementRequest, scope: string, computer
|
|
|
88
100
|
await send(result('waiting', 'Restart requested. Waiting for MCP to reconnect…'));
|
|
89
101
|
restartRuntime(); return;
|
|
90
102
|
}
|
|
91
|
-
await send({ ...result('completed', message), snapshot: await managementSnapshot()
|
|
103
|
+
await send({ ...result('completed', message), snapshot: await managementSnapshot(origin.peer),
|
|
104
|
+
...(removedPhoneIds ? { removedPhoneIds } : {}) });
|
|
92
105
|
} catch (error) {
|
|
93
106
|
await send(result('failed', error instanceof Error ? error.message.slice(0, 512) : 'This action failed on the computer.'));
|
|
94
107
|
} finally { if (exclusive) mutating = false; }
|
|
@@ -12,6 +12,7 @@ import { automaticUpdatesAllowed } from '../runtime-updates/preferences/storage.
|
|
|
12
12
|
import { newerVersion, readState, runtimeVersion } from '../runtime-updates/selection.mjs';
|
|
13
13
|
import { latestRelease, trustedRelease } from '../runtime-updates/registry';
|
|
14
14
|
import { checkForRuntimeUpdate } from '../runtime-updates';
|
|
15
|
+
import { holdSentence, readHoldState } from '../runtime-updates/drain/state';
|
|
15
16
|
import { binaryVersion } from '../tools/version';
|
|
16
17
|
import { providerCommand, providerAuthentication, installedProvider, providerEnvironment } from './provider-command';
|
|
17
18
|
import { computerCache } from './cache';
|
|
@@ -20,6 +21,7 @@ import { ownedProviderProcesses } from '../reply/process';
|
|
|
20
21
|
import { prepareRuntimeRestart, stopOwnedChildren } from './runtime-restart';
|
|
21
22
|
import { approvalsStatus } from '../approvals/state';
|
|
22
23
|
import { inspectTool, updateTool } from '../tools/updater';
|
|
24
|
+
import { phonesFor } from '../paired-phones';
|
|
23
25
|
|
|
24
26
|
export const runtimeRoot = fileURLToPath(new URL('../../../../', import.meta.url));
|
|
25
27
|
const runtimeEpoch = randomUUID();
|
|
@@ -57,7 +59,8 @@ async function availableRuntimeVersion(): Promise<string | undefined> {
|
|
|
57
59
|
return version && newerVersion(version, runtimeVersion(runtimeRoot)) ? version : undefined;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
/** `requester` is the phone asking; the phones it is shown mark it as "this phone". */
|
|
63
|
+
export async function managementSnapshot(requester?: string): Promise<DeviceManagementSnapshot> {
|
|
61
64
|
const observedAt = Date.now();
|
|
62
65
|
const directory = join(configDir(), 'runtime-updates');
|
|
63
66
|
const selected = readState(directory);
|
|
@@ -68,12 +71,19 @@ export async function managementSnapshot(): Promise<DeviceManagementSnapshot> {
|
|
|
68
71
|
updateSupported: installed && inspectTool(agent, providerEnvironment()).update != null,
|
|
69
72
|
activeRequests: ownedProviderProcesses(command).length };
|
|
70
73
|
}));
|
|
74
|
+
const hold = readHoldState(directory);
|
|
71
75
|
return { computerId: observedComputerId(), computerName: hostname(), observedAt,
|
|
72
76
|
runtimeVersion: runtimeVersion(runtimeRoot), runtimeEpoch, selectedRuntimeVersion: selected.version,
|
|
73
77
|
availableRuntimeVersion: await availableRuntimeVersion(),
|
|
78
|
+
...(hold ? { runtimeUpdateHold: { ...hold, summary: holdSentence(hold).slice(0, 1_000) } } : {}),
|
|
74
79
|
automaticUpdatesEnabled: automaticUpdatesAllowed(directory),
|
|
75
80
|
runtimeUpdateSupported: runtimeRoot.includes('/node_modules/'), runtimeRestartSupported: runtimeRestartSupported(),
|
|
76
|
-
cache: (await computerCache(runtimeRoot)).map(({ paths: _paths, ...category }) => category), providers
|
|
81
|
+
cache: (await computerCache(runtimeRoot)).map(({ paths: _paths, ...category }) => category), providers,
|
|
82
|
+
...(requester ? { phones: readPhones(requester) } : {}) };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function readPhones(requester: string): DeviceManagementSnapshot['phones'] {
|
|
86
|
+
try { return phonesFor(requester); } catch { return []; }
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
export async function updateRuntime(): Promise<string> {
|
|
@@ -87,6 +87,11 @@ published: the catalog and snapshot merges skip a removed binding for this
|
|
|
87
87
|
computer until the person adds it back. Edits are answered once per request id,
|
|
88
88
|
and a repeated request is given the first answer.
|
|
89
89
|
|
|
90
|
+
A Mesh made for a folder without Git (canonical repository `local:<path>`)
|
|
91
|
+
never binds or routes a repository that has its own remote; see
|
|
92
|
+
[folder Meshes](local-remote/README.md), which also says when such a Mesh is
|
|
93
|
+
published as `project.supersededBy` another.
|
|
94
|
+
|
|
90
95
|
The Mesh brief guides an agent with Project scope, relevant restrictions,
|
|
91
96
|
repository topology, dependencies, and neighboring work. The local hook and
|
|
92
97
|
Engine enforce Governance decisions. GrantTap measures
|
|
@@ -6,7 +6,10 @@ sessions to stable Tasks, and records endpoint bindings and execution history.
|
|
|
6
6
|
An execution may discover a checkout after its Task started in a non-Git parent
|
|
7
7
|
workspace. The catalog retains the Task and Project identity and records the
|
|
8
8
|
observed repository on its execution. An observation does not grant Project
|
|
9
|
-
membership or prove a code dependency.
|
|
9
|
+
membership or prove a code dependency. A local repository without a remote is
|
|
10
|
+
bound to the parent folder's Mesh as before; one with its own remote is not
|
|
11
|
+
(`local-remote/folder-meshes.ts`), and a binding an older runtime made for it
|
|
12
|
+
there is taken out with a removal record. Apple clients partition workspace Tasks
|
|
10
13
|
using those observations without moving them between access scopes.
|
|
11
14
|
|
|
12
15
|
Git facts are shared only within one catalog batch. The next reading refreshes
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProjectBindingSummary,
|
|
3
|
+
type Project as ProjectValue,
|
|
3
4
|
type ProjectBindingSummary as BindingValue,
|
|
4
5
|
} from "../../../../../packages/protocol/schema";
|
|
5
6
|
import { bindingRemoved, type StoreState } from "../store/state";
|
|
7
|
+
import { folderMeshHoldsRemote } from "../local-remote/folder-meshes";
|
|
8
|
+
|
|
9
|
+
export { folderIdentity, folderMeshHoldsRemote } from "../local-remote/folder-meshes";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* The binding this endpoint owns for this repository, and nothing else.
|
|
@@ -22,11 +26,18 @@ export function bindingForEndpoint(
|
|
|
22
26
|
item.endpointId === endpointId && item.repositoryId === repositoryId);
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The binding that routes a repository's chats. Given the Projects, a folder Mesh's binding of a
|
|
31
|
+
* repository with its own remote is passed over, so the repository's chats go to its own Mesh.
|
|
32
|
+
*/
|
|
25
33
|
export function bindingForRepository(
|
|
26
|
-
|
|
34
|
+
allBindings: BindingValue[],
|
|
27
35
|
repositoryId: string,
|
|
28
36
|
endpointId?: string,
|
|
37
|
+
knownProjects?: readonly ProjectValue[],
|
|
29
38
|
): BindingValue | undefined {
|
|
39
|
+
const bindings = knownProjects ? allBindings.filter((item) => !folderMeshHoldsRemote(
|
|
40
|
+
knownProjects.find((project) => project.projectId === item.projectId), item.repositoryId)) : allBindings;
|
|
30
41
|
const exact = endpointId == null
|
|
31
42
|
? undefined
|
|
32
43
|
: bindingForEndpoint(bindings, repositoryId, endpointId);
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { formerComputerNames } from "../identity/computer";
|
|
18
18
|
import { readIntegrationMap } from "../observed/integration-map";
|
|
19
19
|
import type { MeshStore } from "../store";
|
|
20
|
+
import { folderMeshHoldsRemote } from "../local-remote/folder-meshes";
|
|
20
21
|
import { queueProjectBindingSync } from "../../engine/runtime/engine-projects";
|
|
21
22
|
import { isCursorTaskCloneId } from "../../sessions/cursor/catalog";
|
|
22
23
|
import { localTaskTransfers } from '../../task-transfer';
|
|
@@ -235,13 +236,26 @@ function linkSession(input: {
|
|
|
235
236
|
/**
|
|
236
237
|
* Bind the chat's checkout to its Project on this computer. A repository the
|
|
237
238
|
* person took out of that Project here stays out, however many chats run in it.
|
|
239
|
+
*
|
|
240
|
+
* A repository with its own remote is never bound to a Mesh made for a folder
|
|
241
|
+
* without Git: a task begun in `~/dev` that works in `~/dev/app` stays in the
|
|
242
|
+
* folder Mesh with its history, and `app` keeps its own Mesh. A binding such a
|
|
243
|
+
* task made before this rule is taken out of the folder Mesh, so the
|
|
244
|
+
* repository's new chats, which already route past it, can bind it to its own.
|
|
238
245
|
*/
|
|
239
246
|
function bindSessionRepository(
|
|
240
247
|
store: MeshStore, project: Project, repository: RepositoryFacts, computerId: string, lastSeenAt: number,
|
|
241
248
|
): void {
|
|
242
249
|
const { projectId } = project;
|
|
243
|
-
|
|
244
|
-
|
|
250
|
+
const repositoryId = repository.canonicalRepositoryId;
|
|
251
|
+
if (folderMeshHoldsRemote(project, repositoryId)) {
|
|
252
|
+
store.releaseFromFolderMesh(computerId, repositoryId);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (store.bindingRemoved(projectId, computerId, repositoryId)) return;
|
|
256
|
+
let knownBinding = store.bindingForEndpoint(repositoryId, computerId);
|
|
257
|
+
if (knownBinding && knownBinding.projectId !== projectId
|
|
258
|
+
&& store.releaseFromFolderMesh(computerId, repositoryId)) knownBinding = undefined;
|
|
245
259
|
const binding = {
|
|
246
260
|
bindingId: knownBinding?.bindingId
|
|
247
261
|
?? projectBindingIdentity(projectId, computerId, repository.canonicalRepositoryId),
|
|
@@ -49,7 +49,8 @@ function canonical(value: unknown): unknown {
|
|
|
49
49
|
export function grantTapToolName(rawToolName: unknown): string | undefined {
|
|
50
50
|
const raw = String(rawToolName ?? "").trim();
|
|
51
51
|
const tool = raw.includes("__") ? raw.split("__").at(-1)! : raw;
|
|
52
|
-
return ["notify", "connect", "ask", "ask_yes_no", "offload_task", "request_sign_in"].includes(tool)
|
|
52
|
+
return ["notify", "connect", "ask", "ask_yes_no", "offload_task", "request_sign_in", "connection_status", "remove_phones"].includes(tool)
|
|
53
|
+
? tool : undefined;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export function meshCallKey(tool: string, args: unknown): string {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Local store, remotes and folder Meshes
|
|
2
|
+
|
|
3
|
+
`local.ts` holds this computer's Mesh store. `remote.ts` is the one place a Git remote is touched:
|
|
4
|
+
a handoff's push and fetch (see the Mesh README).
|
|
5
|
+
|
|
6
|
+
## A folder Mesh never takes a repository with its own remote
|
|
7
|
+
|
|
8
|
+
A chat started in a folder without Git (`~/dev`) makes a Mesh named by the folder: its canonical
|
|
9
|
+
repository is `local:<path>`. When that chat goes on to work in `~/dev/app`, a clone with its own
|
|
10
|
+
remote, the Task stays in the folder Mesh with its history, and the execution records where it
|
|
11
|
+
worked. `folder-meshes.ts` keeps the repository out of that Mesh:
|
|
12
|
+
|
|
13
|
+
- The catalog does not bind a repository with a remote to a folder Mesh. A local repository without
|
|
14
|
+
a remote may still join its parent folder's Mesh, as before.
|
|
15
|
+
- Routing (`MeshStore.projectIdForRepository` and `bindingForRepository`, which also pick a phone
|
|
16
|
+
task's Mesh, a run's Project environment and Governance) passes over a folder Mesh's binding of such
|
|
17
|
+
a repository, on any computer, so the repository's new chats go to its own Mesh at once.
|
|
18
|
+
- A binding an older runtime made for it on this computer is taken out of the folder Mesh the next
|
|
19
|
+
time a chat in either is cataloged, with a `removedBindings` record, so a phone or another computer
|
|
20
|
+
that still lists it does not bind it again; the repository's next chat binds it to its own Mesh.
|
|
21
|
+
The Engine keeps its own copy of the old binding: it has no operation to remove one.
|
|
22
|
+
- The phone cannot add such a repository to a folder Mesh (`mesh.repository.edit` answers
|
|
23
|
+
`invalid` and says why).
|
|
24
|
+
|
|
25
|
+
Tasks that already ran in the folder Mesh are not moved.
|
|
26
|
+
|
|
27
|
+
## A folder Mesh superseded by its folder's repository
|
|
28
|
+
|
|
29
|
+
A folder Mesh made while `~/dev/inbox` was a plain folder is left behind when that folder later
|
|
30
|
+
becomes a clone of a repository with its own Mesh: new chats in the folder land in the repository's
|
|
31
|
+
Mesh. The snapshot this computer publishes for the old Mesh then carries
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
"project": { "projectId": "project-…", "name": "inbox", "canonicalRepositoryId": "local:/Users/…/inbox",
|
|
35
|
+
"supersededBy": "project-<the repository's Mesh>" }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`project.supersededBy` (optional, a Project id) means: this Mesh's folder is now a Git checkout at
|
|
39
|
+
the same path, and the most recent chat at its root runs in the named Mesh, whose repository has
|
|
40
|
+
its own remote. The old Mesh keeps its tasks and stays published, so they remain visible and
|
|
41
|
+
searchable; a controller should leave it out of New Task and may point to the named Mesh instead.
|
|
42
|
+
The field is absent for every other Mesh, and it disappears again if the folder stops being a
|
|
43
|
+
checkout. It is read from this computer's own folders at publication and never stored: a snapshot
|
|
44
|
+
that comes back with it is merged without it. Phones that do not know the field ignore it (it is
|
|
45
|
+
inside `project`); a computer on an older runtime rejects a snapshot that carries it, which only
|
|
46
|
+
the superseded Mesh's snapshot does.
|
|
47
|
+
|
|
48
|
+
Tests: `tests/folder-meshes.test.ts`, `../../../../../tests/agentic/codex-workspace-binding.test.ts`.
|
|
49
|
+
|
|
50
|
+
License: [GrantTap Commercial Source License](../../../../../LICENSE).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meshes made for a folder without Git, and the repositories with a remote of their own that come
|
|
3
|
+
* near them.
|
|
4
|
+
*
|
|
5
|
+
* A folder Mesh is named by its folder (`local:<path>`). A repository that has its own remote has a
|
|
6
|
+
* Mesh of its own: a folder Mesh neither binds it nor routes its chats, whichever task first worked
|
|
7
|
+
* in it from the folder. A folder that has since become a checkout of such a repository leaves its
|
|
8
|
+
* old Mesh behind: that Mesh keeps its tasks, and is reported as superseded by the repository's Mesh.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import type {
|
|
13
|
+
ExecutionSessionLink,
|
|
14
|
+
MeshTask,
|
|
15
|
+
Project,
|
|
16
|
+
} from "../../../../../packages/protocol/schema";
|
|
17
|
+
|
|
18
|
+
const FOLDER = "local:";
|
|
19
|
+
|
|
20
|
+
export function folderIdentity(repositoryId: string): boolean {
|
|
21
|
+
return repositoryId.startsWith(FOLDER);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Whether `project` is a folder Mesh and `repositoryId` a repository with its own remote. */
|
|
25
|
+
export function folderMeshHoldsRemote(project: Pick<Project, "canonicalRepositoryId"> | undefined,
|
|
26
|
+
repositoryId: string): boolean {
|
|
27
|
+
return !!project && folderIdentity(project.canonicalRepositoryId) && !folderIdentity(repositoryId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type Facts = { projects: readonly Project[]; tasks: readonly MeshTask[]; executions: readonly ExecutionSessionLink[] };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The Mesh that took over a folder Mesh's folder: the folder is a Git checkout now, and chats run
|
|
34
|
+
* at its root in a repository with its own remote, in that repository's Mesh. The most recent such
|
|
35
|
+
* chat names it. Undefined for a repository Mesh, and for a folder that is still a plain folder.
|
|
36
|
+
*/
|
|
37
|
+
export function supersedingProject(project: Project, facts: Facts,
|
|
38
|
+
isCheckout: (folder: string) => boolean = folder => existsSync(join(folder, ".git")),
|
|
39
|
+
/** The folder is read on this computer, so only this computer's chats count when it is known. */
|
|
40
|
+
computerId?: string): string | undefined {
|
|
41
|
+
if (!folderIdentity(project.canonicalRepositoryId)) return undefined;
|
|
42
|
+
const folders = new Set([project.canonicalRepositoryId.slice(FOLDER.length), project.repositoryRoot]
|
|
43
|
+
.filter((folder): folder is string => !!folder));
|
|
44
|
+
if (![...folders].some(isCheckout)) return undefined;
|
|
45
|
+
const projectOf = new Map(facts.tasks.map((task) => [task.taskId, task.projectId]));
|
|
46
|
+
const owners = new Map(facts.projects.map((item) => [item.projectId, item]));
|
|
47
|
+
const latest = facts.executions
|
|
48
|
+
.filter((row) => (computerId === undefined || row.computerId === computerId)
|
|
49
|
+
&& row.worktree && folders.has(row.worktree) && row.repositoryId && !folderIdentity(row.repositoryId))
|
|
50
|
+
.flatMap((row) => {
|
|
51
|
+
const projectId = projectOf.get(row.taskId);
|
|
52
|
+
const owner = projectId ? owners.get(projectId) : undefined;
|
|
53
|
+
return owner && owner.projectId !== project.projectId && !folderIdentity(owner.canonicalRepositoryId)
|
|
54
|
+
? [{ projectId: owner.projectId, at: row.activeAt ?? 0 }] : [];
|
|
55
|
+
})
|
|
56
|
+
.sort((left, right) => right.at - left.at)[0];
|
|
57
|
+
return latest?.projectId;
|
|
58
|
+
}
|
|
@@ -16,6 +16,7 @@ import { projectBindingIdentity, sanitizedRepositoryRemote } from "../identity";
|
|
|
16
16
|
import { readIntegrationMap } from "../observed/integration-map";
|
|
17
17
|
import type { MeshStore } from "../store";
|
|
18
18
|
import { checkoutName, readCheckout, type InspectRepository } from "./checkout";
|
|
19
|
+
import { folderMeshHoldsRemote } from "../local-remote/folder-meshes";
|
|
19
20
|
|
|
20
21
|
export type RepositoryEditOutcome = {
|
|
21
22
|
ok: boolean;
|
|
@@ -46,6 +47,10 @@ export async function addMeshRepository(
|
|
|
46
47
|
: refusal("not-a-repository", "That folder is not inside a Git checkout.");
|
|
47
48
|
}
|
|
48
49
|
const { root, facts } = reading;
|
|
50
|
+
if (folderMeshHoldsRemote(store.project(request.projectId), facts.canonicalRepositoryId)) {
|
|
51
|
+
return refusal("invalid", "This repository has its own remote, so its chats go to a Mesh of its own. "
|
|
52
|
+
+ "A Mesh for a folder without Git does not take it.");
|
|
53
|
+
}
|
|
49
54
|
const binding: ProjectBindingSummary = {
|
|
50
55
|
bindingId: projectBindingIdentity(request.projectId, endpointId, facts.canonicalRepositoryId),
|
|
51
56
|
projectId: request.projectId,
|
|
@@ -15,8 +15,10 @@ export function mergeSnapshotState(state: StoreState, input: SnapshotValue): voi
|
|
|
15
15
|
}
|
|
16
16
|
// repositoryRoot is an endpoint-local path. A snapshot from another
|
|
17
17
|
// computer cannot replace this endpoint's verified checkout binding.
|
|
18
|
+
// Whether a Mesh is superseded is this endpoint's reading of its own folders, made at publication.
|
|
19
|
+
const { supersededBy: _published, ...incoming } = snapshot.project;
|
|
18
20
|
const project = {
|
|
19
|
-
...
|
|
21
|
+
...incoming,
|
|
20
22
|
repositoryRoot: existing?.repositoryRoot,
|
|
21
23
|
};
|
|
22
24
|
candidate.projects = mergeBy(candidate.projects, [project], (item) => item.projectId);
|
|
@@ -211,14 +211,15 @@ export class MeshStoreBase {
|
|
|
211
211
|
this.save();
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/** The Mesh a repository's chats go to; a folder Mesh never takes a repository that has its own remote. */
|
|
214
215
|
projectIdForRepository(repositoryId: string, endpointId?: string): string | undefined {
|
|
215
216
|
this.sync();
|
|
216
|
-
return bindingForRepository(this.state.bindings, repositoryId, endpointId)?.projectId;
|
|
217
|
+
return bindingForRepository(this.state.bindings, repositoryId, endpointId, this.state.projects)?.projectId;
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
bindingForRepository(repositoryId: string, endpointId?: string): BindingValue | undefined {
|
|
220
221
|
this.sync();
|
|
221
|
-
return bindingForRepository(this.state.bindings, repositoryId, endpointId);
|
|
222
|
+
return bindingForRepository(this.state.bindings, repositoryId, endpointId, this.state.projects);
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
/** This endpoint's own binding, never another computer's. */
|