@andorra-labs/code 0.1.16 → 0.1.17
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/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-execution.js +11 -8
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +19 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +358 -32
- package/dist/src/app-server.js +2429 -509
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.js +182 -32
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +14 -2
- package/dist/src/compaction-phrases.js +1 -1
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.js +0 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +6 -1
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +2 -1
- package/dist/src/graph-runner.js +64 -3
- package/dist/src/graph-server.js +3 -3
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +91 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +158 -14
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +23 -2
- package/dist/src/providers.js +25 -4
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +327 -7
- package/dist/src/pull-requests.js +429 -51
- package/dist/src/react-runtime.js +1 -1
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +366 -89
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +10 -2
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { changeConfigFile, configDirectory, loadConfig } from '../config.js';
|
|
3
|
-
import { InviteRejectedError } from './errors.js';
|
|
4
|
-
import { isAllowedPeerHost } from './network.js';
|
|
5
|
-
export const INVITE_TTL_MS = 10 * 60 * 1000;
|
|
6
|
-
const BASE64URL_32 = /^[A-Za-z0-9_-]{43}$/;
|
|
7
|
-
export function encodePairingCode(code) {
|
|
8
|
-
return `andorra-pair://${Buffer.from(JSON.stringify(code)).toString('base64url')}`;
|
|
9
|
-
}
|
|
10
|
-
export function decodePairingCode(value) {
|
|
11
|
-
const text = typeof value === 'string' ? value.trim() : '';
|
|
12
|
-
if (!text.startsWith('andorra-pair://'))
|
|
13
|
-
throw new InviteRejectedError('That is not an Andorra pairing code.');
|
|
14
|
-
let parsed;
|
|
15
|
-
try {
|
|
16
|
-
const decoded = Buffer.from(text.slice('andorra-pair://'.length), 'base64url');
|
|
17
|
-
if (decoded.toString('base64url') !== text.slice('andorra-pair://'.length))
|
|
18
|
-
throw new Error('not canonical');
|
|
19
|
-
parsed = JSON.parse(decoded.toString('utf8'));
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
throw new InviteRejectedError('That pairing code could not be read.');
|
|
23
|
-
}
|
|
24
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
25
|
-
throw new InviteRejectedError('That pairing code could not be read.');
|
|
26
|
-
const raw = parsed;
|
|
27
|
-
const allowed = new Set(['v', 'hosts', 'port', 'invite', 'fp', 'transport', 'n']);
|
|
28
|
-
if (Object.keys(raw).some(key => !allowed.has(key)))
|
|
29
|
-
throw new InviteRejectedError('That pairing code is from an unsupported version.');
|
|
30
|
-
if (raw.v !== 1)
|
|
31
|
-
throw new InviteRejectedError('That pairing code is from an unsupported version.');
|
|
32
|
-
if (!Array.isArray(raw.hosts) || raw.hosts.length < 1 || raw.hosts.length > 8 || raw.hosts.some(host => typeof host !== 'string' || !isAllowedPeerHost(host))) {
|
|
33
|
-
throw new InviteRejectedError('That pairing code names an address that is not private or on Tailscale.');
|
|
34
|
-
}
|
|
35
|
-
if (!Number.isSafeInteger(raw.port) || raw.port < 1 || raw.port > 65535)
|
|
36
|
-
throw new InviteRejectedError('That pairing code has an invalid port.');
|
|
37
|
-
if (typeof raw.invite !== 'string' || !BASE64URL_32.test(raw.invite))
|
|
38
|
-
throw new InviteRejectedError('That pairing code has an invalid invitation.');
|
|
39
|
-
if (typeof raw.fp !== 'string' || !BASE64URL_32.test(raw.fp))
|
|
40
|
-
throw new InviteRejectedError('That pairing code has an invalid fingerprint.');
|
|
41
|
-
if (raw.transport !== 'https' && raw.transport !== 'http')
|
|
42
|
-
throw new InviteRejectedError('That pairing code has an invalid transport.');
|
|
43
|
-
if (typeof raw.n !== 'string' || !raw.n.trim() || raw.n.length > 64 || /[\0\r\n]/.test(raw.n))
|
|
44
|
-
throw new InviteRejectedError('That pairing code has an invalid name.');
|
|
45
|
-
return { v: 1, hosts: raw.hosts, port: raw.port, invite: raw.invite, fp: raw.fp, transport: raw.transport, n: raw.n };
|
|
46
|
-
}
|
|
47
|
-
export function invitationIsUsable(invitation, now = Date.now()) {
|
|
48
|
-
if (!invitation)
|
|
49
|
-
return false;
|
|
50
|
-
if (invitation.redeemedAt !== undefined)
|
|
51
|
-
return false;
|
|
52
|
-
return Date.parse(invitation.expiresAt) > now;
|
|
53
|
-
}
|
|
54
|
-
export async function createRemoteInvitation(directory = configDirectory(), now = Date.now(), grant = 'browse') {
|
|
55
|
-
const token = randomBytes(32).toString('base64url');
|
|
56
|
-
const createdAt = new Date(now).toISOString();
|
|
57
|
-
const expiresAt = new Date(now + INVITE_TTL_MS).toISOString();
|
|
58
|
-
await changeConfigFile(directory, config => ({
|
|
59
|
-
...config,
|
|
60
|
-
remote: { ...config.remote, hosting: { ...config.remote?.hosting, invitation: { token, createdAt, expiresAt, ...(grant === 'full' ? { grant } : {}) } } },
|
|
61
|
-
}));
|
|
62
|
-
return { token, createdAt, expiresAt, ...(grant === 'full' ? { grant } : {}) };
|
|
63
|
-
}
|
|
64
|
-
export async function clearRemoteInvitation(directory = configDirectory()) {
|
|
65
|
-
await changeConfigFile(directory, config => ({
|
|
66
|
-
...config,
|
|
67
|
-
remote: { ...config.remote, hosting: { ...config.remote?.hosting, invitation: null } },
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
export async function redeemRemoteInvitation(invite, options = {}) {
|
|
71
|
-
const directory = options.directory ?? configDirectory();
|
|
72
|
-
const now = options.now ?? Date.now();
|
|
73
|
-
const deviceId = randomBytes(8).toString('hex');
|
|
74
|
-
const credential = randomBytes(32).toString('base64url');
|
|
75
|
-
const label = typeof options.label === 'string' && options.label.trim() && options.label.length <= 64 && !/[\0\r\n]/.test(options.label) ? options.label.trim() : undefined;
|
|
76
|
-
let granted = 'browse';
|
|
77
|
-
await changeConfigFile(directory, config => {
|
|
78
|
-
const invitation = config.remote?.hosting?.invitation;
|
|
79
|
-
if (!invitation || invitation.token !== invite)
|
|
80
|
-
throw new InviteRejectedError('That pairing code is not active on this machine.');
|
|
81
|
-
if (invitation.redeemedAt !== undefined)
|
|
82
|
-
throw new InviteRejectedError('That pairing code has already been used.');
|
|
83
|
-
if (Date.parse(invitation.expiresAt) <= now)
|
|
84
|
-
throw new InviteRejectedError('That pairing code has expired. Generate a new one.');
|
|
85
|
-
if (invitation.grant === 'full' && config.remote?.hosting?.transport === 'http')
|
|
86
|
-
throw new InviteRejectedError('Full-control pairing is not permitted over insecure HTTP.');
|
|
87
|
-
granted = invitation.grant === 'full' ? 'full' : 'browse';
|
|
88
|
-
const device = { id: deviceId, token: credential, ...(label ? { label } : {}), ...(invitation.grant === 'full' ? { grant: 'full' } : {}), addedAt: new Date(now).toISOString() };
|
|
89
|
-
const devices = [...(config.remote?.hosting?.devices ?? []), device];
|
|
90
|
-
if (devices.length > 32)
|
|
91
|
-
throw new InviteRejectedError('This machine already has the maximum number of paired devices.');
|
|
92
|
-
return {
|
|
93
|
-
...config,
|
|
94
|
-
remote: {
|
|
95
|
-
...config.remote,
|
|
96
|
-
hosting: {
|
|
97
|
-
...config.remote?.hosting,
|
|
98
|
-
invitation: { ...invitation, redeemedAt: new Date(now).toISOString() },
|
|
99
|
-
devices,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
return { deviceId, credential, grant: granted };
|
|
105
|
-
}
|
|
106
|
-
export async function revokeRemoteDevice(deviceId, directory = configDirectory()) {
|
|
107
|
-
let removed = false;
|
|
108
|
-
const next = await changeConfigFile(directory, config => {
|
|
109
|
-
const devices = config.remote?.hosting?.devices ?? [];
|
|
110
|
-
const kept = devices.filter(device => device.id !== deviceId);
|
|
111
|
-
removed = kept.length !== devices.length;
|
|
112
|
-
if (!removed)
|
|
113
|
-
return config;
|
|
114
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, devices: kept } } };
|
|
115
|
-
});
|
|
116
|
-
return removed && !(next.remote?.hosting?.devices ?? []).some(device => device.id === deviceId);
|
|
117
|
-
}
|
|
118
|
-
export async function grantRemoteDevice(deviceId, directory = configDirectory()) {
|
|
119
|
-
let granted = null;
|
|
120
|
-
await changeConfigFile(directory, config => {
|
|
121
|
-
if ((config.remote?.hosting?.transport ?? 'https') === 'http') {
|
|
122
|
-
throw new Error('Full-control consent requires HTTPS. Stop insecure HTTP hosting before granting owner authority.');
|
|
123
|
-
}
|
|
124
|
-
const devices = config.remote?.hosting?.devices ?? [];
|
|
125
|
-
const device = devices.find(entry => entry.id === deviceId);
|
|
126
|
-
if (!device)
|
|
127
|
-
return config;
|
|
128
|
-
const raised = { ...device, grant: 'full' };
|
|
129
|
-
granted = raised;
|
|
130
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, devices: devices.map(entry => entry.id === deviceId ? raised : entry) } } };
|
|
131
|
-
});
|
|
132
|
-
return granted;
|
|
133
|
-
}
|
|
134
|
-
export async function addRemoteShare(path, options = {}) {
|
|
135
|
-
const directory = options.directory ?? configDirectory();
|
|
136
|
-
const share = { id: randomBytes(6).toString('hex'), path, ...(options.label && options.label.trim() ? { label: options.label.trim().slice(0, 64) } : {}) };
|
|
137
|
-
let stored = share;
|
|
138
|
-
await changeConfigFile(directory, config => {
|
|
139
|
-
const shares = config.remote?.hosting?.shares ?? [];
|
|
140
|
-
const existing = shares.find(entry => entry.path === share.path);
|
|
141
|
-
if (existing) {
|
|
142
|
-
stored = existing;
|
|
143
|
-
return config;
|
|
144
|
-
}
|
|
145
|
-
if (shares.length >= 64)
|
|
146
|
-
throw new Error('This machine already shares the maximum number of folders.');
|
|
147
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, shares: [...shares, share] } } };
|
|
148
|
-
});
|
|
149
|
-
return stored;
|
|
150
|
-
}
|
|
151
|
-
export async function removeRemoteShare(shareId, directory = configDirectory()) {
|
|
152
|
-
let removed = false;
|
|
153
|
-
await changeConfigFile(directory, config => {
|
|
154
|
-
const shares = config.remote?.hosting?.shares ?? [];
|
|
155
|
-
const kept = shares.filter(share => share.id !== shareId);
|
|
156
|
-
removed = kept.length !== shares.length;
|
|
157
|
-
return removed ? { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, shares: kept } } } : config;
|
|
158
|
-
});
|
|
159
|
-
return removed;
|
|
160
|
-
}
|
|
161
|
-
export async function persistRemotePort(port, directory = configDirectory()) {
|
|
162
|
-
await changeConfigFile(directory, config => {
|
|
163
|
-
if (config.remote?.hosting?.port === port)
|
|
164
|
-
return config;
|
|
165
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, port } } };
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
export async function ensureRemoteInstallId(directory = configDirectory()) {
|
|
169
|
-
const current = await loadConfig(directory);
|
|
170
|
-
if (current.remote?.hosting?.installId)
|
|
171
|
-
return current.remote.hosting.installId;
|
|
172
|
-
const installId = randomBytes(16).toString('hex');
|
|
173
|
-
await changeConfigFile(directory, config => {
|
|
174
|
-
if (config.remote?.hosting?.installId)
|
|
175
|
-
return config;
|
|
176
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, installId } } };
|
|
177
|
-
});
|
|
178
|
-
return installId;
|
|
179
|
-
}
|
|
180
|
-
export async function setRemoteTransport(transport, directory = configDirectory()) {
|
|
181
|
-
await changeConfigFile(directory, config => {
|
|
182
|
-
if (config.remote?.hosting?.transport === transport)
|
|
183
|
-
return config;
|
|
184
|
-
return { ...config, remote: { ...config.remote, hosting: { ...config.remote?.hosting, transport } } };
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
export function newWorkspaceId() {
|
|
188
|
-
return `ws-${randomBytes(6).toString('hex')}`;
|
|
189
|
-
}
|
|
190
|
-
export async function addRemoteWorkspace(workspace, directory = configDirectory()) {
|
|
191
|
-
await changeConfigFile(directory, config => {
|
|
192
|
-
const workspaces = config.remote?.workspaces ?? [];
|
|
193
|
-
if (workspaces.length >= 32)
|
|
194
|
-
throw new Error('This machine already pairs with the maximum number of workspaces.');
|
|
195
|
-
return { ...config, remote: { ...config.remote, workspaces: [...workspaces, workspace] } };
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
export async function removeRemoteWorkspace(workspaceId, directory = configDirectory()) {
|
|
199
|
-
let removed = false;
|
|
200
|
-
await changeConfigFile(directory, config => {
|
|
201
|
-
const workspaces = config.remote?.workspaces ?? [];
|
|
202
|
-
const kept = workspaces.filter(workspace => workspace.id !== workspaceId);
|
|
203
|
-
removed = kept.length !== workspaces.length;
|
|
204
|
-
return removed ? { ...config, remote: { ...config.remote, workspaces: kept } } : config;
|
|
205
|
-
});
|
|
206
|
-
return removed;
|
|
207
|
-
}
|
|
208
|
-
export async function updateRemoteWorkspace(workspaceId, changes, directory = configDirectory()) {
|
|
209
|
-
let updated;
|
|
210
|
-
await changeConfigFile(directory, config => {
|
|
211
|
-
const workspaces = config.remote?.workspaces ?? [];
|
|
212
|
-
const current = workspaces.find(workspace => workspace.id === workspaceId);
|
|
213
|
-
if (!current)
|
|
214
|
-
return config;
|
|
215
|
-
const next = {
|
|
216
|
-
...current,
|
|
217
|
-
...(changes.nickname !== undefined ? { nickname: changes.nickname } : {}),
|
|
218
|
-
};
|
|
219
|
-
if (changes.host === null)
|
|
220
|
-
delete next.host;
|
|
221
|
-
else if (changes.host !== undefined)
|
|
222
|
-
next.host = changes.host;
|
|
223
|
-
updated = next;
|
|
224
|
-
return { ...config, remote: { ...config.remote, workspaces: workspaces.map(workspace => workspace.id === workspaceId ? next : workspace) } };
|
|
225
|
-
});
|
|
226
|
-
return updated;
|
|
227
|
-
}
|
|
228
|
-
export async function addProjectEntry(path, options = {}) {
|
|
229
|
-
const directory = options.directory ?? configDirectory();
|
|
230
|
-
const name = typeof options.name === 'string' && options.name.trim() ? options.name.trim().slice(0, 100) : undefined;
|
|
231
|
-
await changeConfigFile(directory, config => {
|
|
232
|
-
const projects = config.projects ?? [];
|
|
233
|
-
if (projects.some(project => project.path === path))
|
|
234
|
-
return config;
|
|
235
|
-
if (projects.length >= 256)
|
|
236
|
-
throw new Error('The project registry is full.');
|
|
237
|
-
return { ...config, projects: [...projects, { path, ...(name ? { name } : {}), addedAt: new Date().toISOString() }] };
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
export async function relinkProjectEntry(from, to, options = {}) {
|
|
241
|
-
const directory = options.directory ?? configDirectory();
|
|
242
|
-
const name = typeof options.name === 'string' && options.name.trim() ? options.name.trim().slice(0, 100) : undefined;
|
|
243
|
-
let relinked = false;
|
|
244
|
-
await changeConfigFile(directory, config => {
|
|
245
|
-
const projects = config.projects ?? [];
|
|
246
|
-
if (!projects.some(project => project.path === from) || projects.some(project => project.path === to))
|
|
247
|
-
return config;
|
|
248
|
-
relinked = true;
|
|
249
|
-
return { ...config, projects: projects.map(project => {
|
|
250
|
-
if (project.path !== from)
|
|
251
|
-
return project;
|
|
252
|
-
const { name: _previous, ...kept } = project;
|
|
253
|
-
return { ...kept, path: to, ...(name ? { name } : {}) };
|
|
254
|
-
}) };
|
|
255
|
-
});
|
|
256
|
-
return relinked;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* The id `path` answers to, storing `candidate` when it has none yet and returning whichever id is actually on the entry.
|
|
260
|
-
* Two tasks created at the same moment on a folder that has just been added would otherwise each store their own id, and
|
|
261
|
-
* the loser keeps an identity the registry never accepted, splitting the project's browser profiles for good.
|
|
262
|
-
*/
|
|
263
|
-
export async function ensureProjectIdentity(path, candidate, directory = configDirectory()) {
|
|
264
|
-
let id;
|
|
265
|
-
await changeConfigFile(directory, config => {
|
|
266
|
-
const projects = config.projects ?? [];
|
|
267
|
-
const entry = projects.find(project => project.path === path);
|
|
268
|
-
if (!entry)
|
|
269
|
-
return config;
|
|
270
|
-
if (typeof entry.id === 'string' && /^[a-f0-9]{16}$/.test(entry.id)) {
|
|
271
|
-
id = entry.id;
|
|
272
|
-
return config;
|
|
273
|
-
}
|
|
274
|
-
id = candidate;
|
|
275
|
-
return { ...config, projects: projects.map(project => (project === entry ? { ...project, id: candidate } : project)) };
|
|
276
|
-
});
|
|
277
|
-
return id;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Remembers the project id a folder answers to, so a task started after a rename or a
|
|
281
|
-
* merge belongs to the same project as the tasks that were already there.
|
|
282
|
-
* An id already on the entry wins: a second rename must not restart the project's identity.
|
|
283
|
-
*/
|
|
284
|
-
export async function rememberProjectIdentity(path, id, directory = configDirectory()) {
|
|
285
|
-
await changeConfigFile(directory, config => ({
|
|
286
|
-
...config,
|
|
287
|
-
projects: (config.projects ?? []).map(project => project.path === path && project.id === undefined ? { ...project, id } : project),
|
|
288
|
-
}));
|
|
289
|
-
}
|
|
290
|
-
export async function removeProjectEntry(path, directory = configDirectory()) {
|
|
291
|
-
let removed = false;
|
|
292
|
-
await changeConfigFile(directory, config => {
|
|
293
|
-
const projects = config.projects ?? [];
|
|
294
|
-
const kept = projects.filter(project => project.path !== path);
|
|
295
|
-
removed = kept.length !== projects.length;
|
|
296
|
-
return removed ? { ...config, projects: kept } : config;
|
|
297
|
-
});
|
|
298
|
-
return removed;
|
|
299
|
-
}
|
package/dist/src/remote/pem.d.ts
DELETED
package/dist/src/remote/pem.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { RemoteTransport } from './types.js';
|
|
2
|
-
export interface ServeDescriptor {
|
|
3
|
-
port: number;
|
|
4
|
-
pid: number;
|
|
5
|
-
owner: 'engine' | 'standalone';
|
|
6
|
-
installId: string;
|
|
7
|
-
ownerSecret: string;
|
|
8
|
-
transport: RemoteTransport;
|
|
9
|
-
}
|
|
10
|
-
export interface RemoteServeHandle {
|
|
11
|
-
serving: true;
|
|
12
|
-
owned: boolean;
|
|
13
|
-
port: number;
|
|
14
|
-
transport: RemoteTransport;
|
|
15
|
-
installId: string;
|
|
16
|
-
release(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export interface ServeOptions {
|
|
19
|
-
directory?: string;
|
|
20
|
-
owner: 'engine' | 'standalone';
|
|
21
|
-
port?: number;
|
|
22
|
-
rotateCert?: boolean;
|
|
23
|
-
insecureHttp?: boolean;
|
|
24
|
-
version?: string;
|
|
25
|
-
}
|
|
26
|
-
export declare function probeServeStatus(directory?: string): Promise<{
|
|
27
|
-
serving: boolean;
|
|
28
|
-
port: number;
|
|
29
|
-
transport: RemoteTransport;
|
|
30
|
-
} | null>;
|
|
31
|
-
export interface RemoteNotServing {
|
|
32
|
-
serving: false;
|
|
33
|
-
owned: false;
|
|
34
|
-
reason: string;
|
|
35
|
-
}
|
|
36
|
-
export type RemoteServeOutcome = RemoteServeHandle | RemoteNotServing;
|
|
37
|
-
export declare function ensureRemoteServe(options: ServeOptions): Promise<RemoteServeOutcome>;
|
|
38
|
-
export declare function remoteFingerprint(directory?: string): Promise<string>;
|
|
39
|
-
export interface RemoteHostingSnapshot {
|
|
40
|
-
serving: boolean;
|
|
41
|
-
port: number;
|
|
42
|
-
transport: RemoteTransport;
|
|
43
|
-
hostname: string;
|
|
44
|
-
fingerprint: string;
|
|
45
|
-
code: string | null;
|
|
46
|
-
invitationExpiresAt: string | null;
|
|
47
|
-
invitationGrant?: 'browse' | 'full';
|
|
48
|
-
devices: {
|
|
49
|
-
id: string;
|
|
50
|
-
label?: string;
|
|
51
|
-
addedAt: string;
|
|
52
|
-
lastSeenAt?: string;
|
|
53
|
-
grant?: 'browse' | 'full';
|
|
54
|
-
}[];
|
|
55
|
-
shares: {
|
|
56
|
-
id: string;
|
|
57
|
-
path: string;
|
|
58
|
-
label?: string;
|
|
59
|
-
}[];
|
|
60
|
-
installId?: string;
|
|
61
|
-
serve?: RemoteServeHandle;
|
|
62
|
-
}
|
|
63
|
-
export declare function remoteHostingStatus(options?: {
|
|
64
|
-
directory?: string;
|
|
65
|
-
ensureServing?: boolean;
|
|
66
|
-
owner?: 'engine' | 'standalone';
|
|
67
|
-
version?: string;
|
|
68
|
-
}): Promise<RemoteHostingSnapshot>;
|
package/dist/src/remote/serve.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
-
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { request as httpsRequest } from 'node:https';
|
|
4
|
-
import { hostname as osHostname, platform as osPlatform } from 'node:os';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { configDirectory, loadConfig } from '../config.js';
|
|
7
|
-
import { acquireSaveLock, SaveLockBusyError } from '../save-lock.js';
|
|
8
|
-
import { ensureRemoteTlsIdentity } from './cert.js';
|
|
9
|
-
import { RemoteOwnershipError } from './errors.js';
|
|
10
|
-
import { advertiseHosts } from './network.js';
|
|
11
|
-
import { createRemoteInvitation, encodePairingCode, ensureRemoteInstallId, invitationIsUsable, persistRemotePort, setRemoteTransport } from './pairing.js';
|
|
12
|
-
import { startRemoteServer } from './server.js';
|
|
13
|
-
function liveDirectory(directory) { return join(directory, 'remote-live'); }
|
|
14
|
-
function tlsDirectory(directory) { return join(liveDirectory(directory), 'tls'); }
|
|
15
|
-
function descriptorPath(directory) { return join(liveDirectory(directory), 'serve.json'); }
|
|
16
|
-
async function readDescriptor(directory) {
|
|
17
|
-
try {
|
|
18
|
-
const raw = JSON.parse(await readFile(descriptorPath(directory), 'utf8'));
|
|
19
|
-
if (typeof raw.port !== 'number' || !Number.isSafeInteger(raw.port) || raw.port < 1 || typeof raw.pid !== 'number'
|
|
20
|
-
|| (raw.owner !== 'engine' && raw.owner !== 'standalone') || typeof raw.installId !== 'string'
|
|
21
|
-
|| typeof raw.ownerSecret !== 'string' || (raw.transport !== 'https' && raw.transport !== 'http'))
|
|
22
|
-
return null;
|
|
23
|
-
return { port: raw.port, pid: raw.pid, owner: raw.owner, installId: raw.installId, ownerSecret: raw.ownerSecret, transport: raw.transport };
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async function writeDescriptor(directory, descriptor) {
|
|
30
|
-
await mkdir(liveDirectory(directory), { recursive: true });
|
|
31
|
-
const staged = join(liveDirectory(directory), `serve-${randomBytes(6).toString('hex')}.tmp`);
|
|
32
|
-
await writeFile(staged, JSON.stringify(descriptor), { mode: 0o600 });
|
|
33
|
-
await rename(staged, descriptorPath(directory));
|
|
34
|
-
}
|
|
35
|
-
async function probeListener(directory, descriptor) {
|
|
36
|
-
const request = descriptor.transport === 'https' ? httpsRequest : (await import('node:http')).request;
|
|
37
|
-
let ca;
|
|
38
|
-
if (descriptor.transport === 'https') {
|
|
39
|
-
try {
|
|
40
|
-
ca = [await readFile(join(tlsDirectory(directory), 'cert.pem'), 'utf8')];
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return { alive: false, installIdMatches: false };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return await new Promise(resolve => {
|
|
47
|
-
const req = request({
|
|
48
|
-
host: '127.0.0.1',
|
|
49
|
-
port: descriptor.port,
|
|
50
|
-
path: '/api/health',
|
|
51
|
-
method: 'GET',
|
|
52
|
-
timeout: 4000,
|
|
53
|
-
headers: { 'x-andorra-owner': descriptor.ownerSecret },
|
|
54
|
-
...(descriptor.transport === 'https' ? { ca, checkServerIdentity: () => undefined, rejectUnauthorized: true, agent: false } : {}),
|
|
55
|
-
}, res => {
|
|
56
|
-
const chunks = [];
|
|
57
|
-
let size = 0;
|
|
58
|
-
res.on('data', chunk => {
|
|
59
|
-
size += chunk.length;
|
|
60
|
-
if (size > 64 * 1024) {
|
|
61
|
-
req.destroy();
|
|
62
|
-
resolve({ alive: false, installIdMatches: false });
|
|
63
|
-
}
|
|
64
|
-
chunks.push(chunk);
|
|
65
|
-
});
|
|
66
|
-
res.on('end', () => {
|
|
67
|
-
if (res.statusCode !== 200) {
|
|
68
|
-
resolve({ alive: false, installIdMatches: false });
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
73
|
-
const matches = typeof body.installId === 'string'
|
|
74
|
-
&& Buffer.from(body.installId).length === Buffer.from(descriptor.installId).length
|
|
75
|
-
&& timingSafeEqual(Buffer.from(body.installId), Buffer.from(descriptor.installId));
|
|
76
|
-
resolve({ alive: true, installIdMatches: matches });
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
resolve({ alive: false, installIdMatches: false });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
req.on('error', () => resolve({ alive: false, installIdMatches: false }));
|
|
84
|
-
req.on('timeout', () => { req.destroy(); resolve({ alive: false, installIdMatches: false }); });
|
|
85
|
-
req.end();
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
export async function probeServeStatus(directory = configDirectory()) {
|
|
89
|
-
const descriptor = await readDescriptor(directory);
|
|
90
|
-
if (!descriptor)
|
|
91
|
-
return null;
|
|
92
|
-
const probe = await probeListener(directory, descriptor);
|
|
93
|
-
return probe.alive && probe.installIdMatches ? { serving: true, port: descriptor.port, transport: descriptor.transport } : null;
|
|
94
|
-
}
|
|
95
|
-
const notServing = (reason) => ({ serving: false, owned: false, reason });
|
|
96
|
-
export async function ensureRemoteServe(options) {
|
|
97
|
-
const directory = options.directory ?? configDirectory();
|
|
98
|
-
const config = await loadConfig(directory);
|
|
99
|
-
const hasDevices = (config.remote?.hosting?.devices ?? []).length > 0;
|
|
100
|
-
const invite = config.remote?.hosting?.invitation;
|
|
101
|
-
const hasInvitation = Boolean(invite && invite.redeemedAt === undefined && Date.parse(invite.expiresAt) > Date.now());
|
|
102
|
-
if (!hasDevices && !hasInvitation && options.owner !== 'standalone')
|
|
103
|
-
return notServing('not-paired');
|
|
104
|
-
try {
|
|
105
|
-
const releaseLock = await acquireSaveLock(liveDirectory(directory));
|
|
106
|
-
try {
|
|
107
|
-
const installId = await ensureRemoteInstallId(directory);
|
|
108
|
-
let transport = config.remote?.hosting?.transport ?? 'https';
|
|
109
|
-
if (options.insecureHttp && transport !== 'http') {
|
|
110
|
-
await setRemoteTransport('http', directory);
|
|
111
|
-
transport = 'http';
|
|
112
|
-
}
|
|
113
|
-
const tls = transport === 'https' ? await ensureRemoteTlsIdentity(tlsDirectory(directory), { rotate: options.rotateCert }) : undefined;
|
|
114
|
-
if (options.rotateCert && tls && config.remote?.hosting?.invitation) {
|
|
115
|
-
const { clearRemoteInvitation } = await import('./pairing.js');
|
|
116
|
-
await clearRemoteInvitation(directory);
|
|
117
|
-
}
|
|
118
|
-
const ownerSecret = randomBytes(32).toString('base64url');
|
|
119
|
-
const desiredPort = options.port ?? config.remote?.hosting?.port ?? 0;
|
|
120
|
-
let bound;
|
|
121
|
-
try {
|
|
122
|
-
try {
|
|
123
|
-
bound = await startRemoteServer({
|
|
124
|
-
directory,
|
|
125
|
-
transport,
|
|
126
|
-
...(tls ? { keyPem: tls.keyPem, certPem: tls.certPem } : {}),
|
|
127
|
-
installId,
|
|
128
|
-
ownerSecret,
|
|
129
|
-
hostname: osHostname(),
|
|
130
|
-
platform: osPlatform(),
|
|
131
|
-
version: options.version ?? '0.0.0',
|
|
132
|
-
}, desiredPort);
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (error.code === 'EADDRINUSE' && desiredPort !== 0) {
|
|
136
|
-
throw new RemoteOwnershipError(`Port ${desiredPort} is already in use. Close the other listener or choose another port with --port.`);
|
|
137
|
-
}
|
|
138
|
-
throw error;
|
|
139
|
-
}
|
|
140
|
-
if (config.remote?.hosting?.port !== bound.port)
|
|
141
|
-
await persistRemotePort(bound.port, directory);
|
|
142
|
-
await writeDescriptor(directory, { port: bound.port, pid: process.pid, owner: options.owner, installId, ownerSecret, transport });
|
|
143
|
-
const listener = bound;
|
|
144
|
-
let released = false;
|
|
145
|
-
return {
|
|
146
|
-
serving: true,
|
|
147
|
-
owned: true,
|
|
148
|
-
port: listener.port,
|
|
149
|
-
transport,
|
|
150
|
-
installId,
|
|
151
|
-
release: async () => {
|
|
152
|
-
if (released)
|
|
153
|
-
return;
|
|
154
|
-
released = true;
|
|
155
|
-
await rm(descriptorPath(directory), { force: true }).catch(() => undefined);
|
|
156
|
-
await listener.close();
|
|
157
|
-
await releaseLock();
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
await bound?.close().catch(() => undefined);
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
await releaseLock();
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
if (!(error instanceof SaveLockBusyError))
|
|
173
|
-
throw error;
|
|
174
|
-
const descriptor = await readDescriptor(directory);
|
|
175
|
-
if (!descriptor) {
|
|
176
|
-
throw new RemoteOwnershipError('The remote listener lock is held, but no live serve could be identified. If no `andorra remote serve` is running, restart the machine or remove ~/.andorracode/remote-live/lock.');
|
|
177
|
-
}
|
|
178
|
-
const probe = await probeListener(directory, descriptor);
|
|
179
|
-
if (probe.alive && probe.installIdMatches) {
|
|
180
|
-
if (options.port !== undefined && descriptor.port !== options.port) {
|
|
181
|
-
throw new RemoteOwnershipError(`A remote listener is already serving this installation on port ${descriptor.port}, not ${options.port}. Stop it first, or serve on the port it holds.`);
|
|
182
|
-
}
|
|
183
|
-
if (options.insecureHttp && descriptor.transport !== 'http') {
|
|
184
|
-
throw new RemoteOwnershipError('A remote listener is already serving this installation over HTTPS. Stop it before switching to cleartext with --insecure-http.');
|
|
185
|
-
}
|
|
186
|
-
if (options.rotateCert) {
|
|
187
|
-
throw new RemoteOwnershipError('A remote listener is already serving this installation. Stop it before rotating the certificate — it holds the current identity in memory.');
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
serving: true,
|
|
191
|
-
owned: false,
|
|
192
|
-
port: descriptor.port,
|
|
193
|
-
transport: descriptor.transport,
|
|
194
|
-
installId: descriptor.installId,
|
|
195
|
-
release: async () => { },
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
throw new RemoteOwnershipError('A remote listener holds this installation’s serve lock but did not authenticate as this machine. Refusing to take it over — stop the other process, or run `andorra remote serve` after it exits.');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
export async function remoteFingerprint(directory = configDirectory()) {
|
|
202
|
-
const tls = await ensureRemoteTlsIdentity(tlsDirectory(directory));
|
|
203
|
-
return tls.fingerprint;
|
|
204
|
-
}
|
|
205
|
-
let cachedHosts;
|
|
206
|
-
export async function remoteHostingStatus(options = {}) {
|
|
207
|
-
const directory = options.directory ?? configDirectory();
|
|
208
|
-
const ensureServing = options.ensureServing ?? true;
|
|
209
|
-
let config = await loadConfig(directory);
|
|
210
|
-
const tls = await ensureRemoteTlsIdentity(tlsDirectory(directory));
|
|
211
|
-
if (!invitationIsUsable(config.remote?.hosting?.invitation))
|
|
212
|
-
await createRemoteInvitation(directory);
|
|
213
|
-
let serve;
|
|
214
|
-
if (ensureServing) {
|
|
215
|
-
const outcome = await ensureRemoteServe({ directory, owner: options.owner ?? 'engine', version: options.version });
|
|
216
|
-
if (outcome.serving)
|
|
217
|
-
serve = outcome;
|
|
218
|
-
}
|
|
219
|
-
config = await loadConfig(directory);
|
|
220
|
-
const invitation = config.remote?.hosting?.invitation;
|
|
221
|
-
const probed = await probeServeStatus(directory);
|
|
222
|
-
const now = Date.now();
|
|
223
|
-
if (!cachedHosts || now - cachedHosts.at > 30_000)
|
|
224
|
-
cachedHosts = { at: now, hosts: await advertiseHosts() };
|
|
225
|
-
const port = probed?.port ?? config.remote?.hosting?.port ?? 0;
|
|
226
|
-
const usable = invitationIsUsable(invitation) ? invitation ?? undefined : undefined;
|
|
227
|
-
const code = usable && port > 0 && cachedHosts.hosts.length
|
|
228
|
-
? encodePairingCode({ v: 1, hosts: cachedHosts.hosts, port, invite: usable.token, fp: tls.fingerprint, transport: probed?.transport ?? config.remote?.hosting?.transport ?? 'https', n: osHostname().slice(0, 64) })
|
|
229
|
-
: null;
|
|
230
|
-
return {
|
|
231
|
-
serving: Boolean(probed),
|
|
232
|
-
port,
|
|
233
|
-
transport: probed?.transport ?? config.remote?.hosting?.transport ?? 'https',
|
|
234
|
-
hostname: osHostname(),
|
|
235
|
-
fingerprint: tls.fingerprint,
|
|
236
|
-
code,
|
|
237
|
-
invitationExpiresAt: usable?.expiresAt ?? null,
|
|
238
|
-
invitationGrant: usable?.grant ?? 'browse',
|
|
239
|
-
devices: (config.remote?.hosting?.devices ?? []).map(device => ({ id: device.id, ...(device.label !== undefined ? { label: device.label } : {}), addedAt: device.addedAt, ...(device.lastSeenAt !== undefined ? { lastSeenAt: device.lastSeenAt } : {}), grant: device.grant ?? 'browse' })),
|
|
240
|
-
shares: config.remote?.hosting?.shares ?? [],
|
|
241
|
-
...(config.remote?.hosting?.installId !== undefined ? { installId: config.remote.hosting.installId } : {}),
|
|
242
|
-
...(serve !== undefined ? { serve } : {}),
|
|
243
|
-
};
|
|
244
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { projectRootId } from './roots.js';
|
|
2
|
-
import type { RemoteTransport } from './types.js';
|
|
3
|
-
export declare const REMOTE_BROWSE_ENTRY_CAP = 1000;
|
|
4
|
-
export interface RemoteServerOptions {
|
|
5
|
-
directory: string;
|
|
6
|
-
transport: RemoteTransport;
|
|
7
|
-
keyPem?: string;
|
|
8
|
-
certPem?: string;
|
|
9
|
-
installId: string;
|
|
10
|
-
ownerSecret: string;
|
|
11
|
-
hostname: string;
|
|
12
|
-
platform: string;
|
|
13
|
-
version: string;
|
|
14
|
-
}
|
|
15
|
-
export interface RemoteServerHandle {
|
|
16
|
-
port: number;
|
|
17
|
-
transport: RemoteTransport;
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export declare function startRemoteServer(options: RemoteServerOptions, bindPort?: number): Promise<RemoteServerHandle>;
|
|
21
|
-
export { projectRootId };
|