@crouton-kit/crouter 0.3.34 → 0.3.35
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/builtin-pi-packages/pi-mode-switch/extensions/index.ts +10 -5
- package/dist/clients/attach/attach-cmd.js +732 -704
- package/dist/core/__tests__/fixtures/fake-engine.js +18 -8
- package/dist/core/__tests__/flagship-lifecycle.test.js +4 -1
- package/dist/core/__tests__/full/broker-navigate-tree-rewelcome.test.js +1 -1
- package/dist/core/__tests__/full/detach-focus.test.js +15 -1
- package/dist/core/__tests__/live-mutation-verbs.test.js +8 -2
- package/dist/core/__tests__/live-mutation.test.js +7 -2
- package/dist/core/hearth/config.js +3 -6
- package/dist/core/hearth/index.d.ts +0 -1
- package/dist/core/hearth/index.js +0 -1
- package/dist/core/hearth/model-auth-guest.js +9 -14
- package/dist/core/hearth/providers/blaxel.js +3 -3
- package/dist/core/hearth/types.d.ts +0 -1
- package/dist/web-client/assets/index-DUThOUzU.css +2 -0
- package/dist/web-client/assets/index-IAJVtuVe.js +80 -0
- package/dist/web-client/index.html +2 -2
- package/package.json +2 -3
- package/dist/core/hearth/registry.d.ts +0 -15
- package/dist/core/hearth/registry.js +0 -180
- package/dist/hearth/wake-proxy/__tests__/anthropic-oauth.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/anthropic-oauth.test.js +0 -289
- package/dist/hearth/wake-proxy/__tests__/config-timeout.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/config-timeout.test.js +0 -34
- package/dist/hearth/wake-proxy/__tests__/guest-source.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/guest-source.test.js +0 -203
- package/dist/hearth/wake-proxy/__tests__/hardening.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/hardening.test.js +0 -59
- package/dist/hearth/wake-proxy/__tests__/hearth-status-route.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/hearth-status-route.test.js +0 -372
- package/dist/hearth/wake-proxy/__tests__/http-running-route-fast-path.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/http-running-route-fast-path.test.js +0 -258
- package/dist/hearth/wake-proxy/__tests__/model-auth-routes.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/model-auth-routes.test.js +0 -437
- package/dist/hearth/wake-proxy/__tests__/static-asset-allowlist.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/static-asset-allowlist.test.js +0 -15
- package/dist/hearth/wake-proxy/__tests__/warm-path-concurrency.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/warm-path-concurrency.test.js +0 -141
- package/dist/hearth/wake-proxy/__tests__/ws-teardown-accounting.test.d.ts +0 -1
- package/dist/hearth/wake-proxy/__tests__/ws-teardown-accounting.test.js +0 -143
- package/dist/hearth/wake-proxy/anthropic-oauth.d.ts +0 -58
- package/dist/hearth/wake-proxy/anthropic-oauth.js +0 -189
- package/dist/hearth/wake-proxy/auth.d.ts +0 -22
- package/dist/hearth/wake-proxy/auth.js +0 -128
- package/dist/hearth/wake-proxy/config.d.ts +0 -2
- package/dist/hearth/wake-proxy/config.js +0 -151
- package/dist/hearth/wake-proxy/guest-source.d.ts +0 -14
- package/dist/hearth/wake-proxy/guest-source.js +0 -130
- package/dist/hearth/wake-proxy/hearth-status.d.ts +0 -44
- package/dist/hearth/wake-proxy/hearth-status.js +0 -267
- package/dist/hearth/wake-proxy/home.d.ts +0 -61
- package/dist/hearth/wake-proxy/home.js +0 -333
- package/dist/hearth/wake-proxy/main.d.ts +0 -1
- package/dist/hearth/wake-proxy/main.js +0 -134
- package/dist/hearth/wake-proxy/model-auth.d.ts +0 -13
- package/dist/hearth/wake-proxy/model-auth.js +0 -345
- package/dist/hearth/wake-proxy/proxy.d.ts +0 -35
- package/dist/hearth/wake-proxy/proxy.js +0 -716
- package/dist/hearth/wake-proxy/public-source-gate.d.ts +0 -9
- package/dist/hearth/wake-proxy/public-source-gate.js +0 -409
- package/dist/hearth/wake-proxy/redact.d.ts +0 -1
- package/dist/hearth/wake-proxy/redact.js +0 -17
- package/dist/hearth/wake-proxy/server.d.ts +0 -11
- package/dist/hearth/wake-proxy/server.js +0 -142
- package/dist/hearth/wake-proxy/state.d.ts +0 -18
- package/dist/hearth/wake-proxy/state.js +0 -342
- package/dist/hearth/wake-proxy/types.d.ts +0 -76
- package/dist/hearth/wake-proxy/types.js +0 -1
- package/dist/web-client/assets/index-BRKxe-hy.js +0 -80
- package/dist/web-client/assets/index-BZUxTkv5.css +0 -2
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { general } from '../../core/errors.js';
|
|
4
|
-
import { getHome, putHome, updateHome } from '../../core/hearth/registry.js';
|
|
5
|
-
import { nowIso } from '../../core/fs-utils.js';
|
|
6
|
-
const LOCK_STALE_MS = 2 * 60_000;
|
|
7
|
-
const DEFAULT_VERSION = 1;
|
|
8
|
-
const tenantLocks = new Map();
|
|
9
|
-
const tenantRuntimes = new Map();
|
|
10
|
-
function ensureParentDir(path) {
|
|
11
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
12
|
-
}
|
|
13
|
-
function atomicWriteJson(path, value) {
|
|
14
|
-
ensureParentDir(path);
|
|
15
|
-
const tmp = `${path}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
16
|
-
writeFileSync(tmp, JSON.stringify(value, null, 2) + '\n', { encoding: 'utf8', mode: 0o600 });
|
|
17
|
-
try {
|
|
18
|
-
renameSync(tmp, path);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
try {
|
|
22
|
-
rmSync(tmp, { force: true });
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
/* ignore */
|
|
26
|
-
}
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function readJsonFile(path) {
|
|
31
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
32
|
-
}
|
|
33
|
-
function normalizeProxyState(value) {
|
|
34
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
35
|
-
throw general('invalid hearth proxy state file', { valueType: value === null ? 'null' : typeof value });
|
|
36
|
-
}
|
|
37
|
-
const obj = value;
|
|
38
|
-
const owner = obj.owner;
|
|
39
|
-
if (owner === null || typeof owner !== 'object' || Array.isArray(owner)) {
|
|
40
|
-
throw general('invalid hearth proxy state owner', { valueType: typeof owner });
|
|
41
|
-
}
|
|
42
|
-
const ownerObj = owner;
|
|
43
|
-
if (typeof ownerObj.ownerUserId !== 'string' || typeof ownerObj.defaultTenantId !== 'string' || typeof ownerObj.tokenHash !== 'string') {
|
|
44
|
-
throw general('invalid hearth proxy state owner fields', { owner });
|
|
45
|
-
}
|
|
46
|
-
const tenantsRaw = obj.tenants;
|
|
47
|
-
const tenants = {};
|
|
48
|
-
if (tenantsRaw !== undefined) {
|
|
49
|
-
if (tenantsRaw === null || typeof tenantsRaw !== 'object' || Array.isArray(tenantsRaw)) {
|
|
50
|
-
throw general('invalid hearth proxy tenants map', { tenantsRaw });
|
|
51
|
-
}
|
|
52
|
-
for (const [tenantId, tenant] of Object.entries(tenantsRaw)) {
|
|
53
|
-
if (tenant === null || typeof tenant !== 'object' || Array.isArray(tenant))
|
|
54
|
-
continue;
|
|
55
|
-
const draft = tenant;
|
|
56
|
-
if (typeof draft.tenantId !== 'string' || typeof draft.ownerUserId !== 'string' || typeof draft.m0RegistryPath !== 'string' || typeof draft.idleAfterMs !== 'number' || typeof draft.updatedAt !== 'string') {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
tenants[tenantId] = {
|
|
60
|
-
tenantId: draft.tenantId,
|
|
61
|
-
ownerUserId: draft.ownerUserId,
|
|
62
|
-
m0RegistryPath: draft.m0RegistryPath,
|
|
63
|
-
idleAfterMs: draft.idleAfterMs,
|
|
64
|
-
lastActivityAt: typeof draft.lastActivityAt === 'string' ? draft.lastActivityAt : null,
|
|
65
|
-
lastWakeAt: typeof draft.lastWakeAt === 'string' ? draft.lastWakeAt : null,
|
|
66
|
-
lastPauseAt: typeof draft.lastPauseAt === 'string' ? draft.lastPauseAt : null,
|
|
67
|
-
updatedAt: draft.updatedAt,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
version: DEFAULT_VERSION,
|
|
73
|
-
owner: {
|
|
74
|
-
ownerUserId: ownerObj.ownerUserId,
|
|
75
|
-
defaultTenantId: ownerObj.defaultTenantId,
|
|
76
|
-
tokenHash: ownerObj.tokenHash,
|
|
77
|
-
createdAt: typeof ownerObj.createdAt === 'string' ? ownerObj.createdAt : nowIso(),
|
|
78
|
-
},
|
|
79
|
-
tenants,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export function loadProxyState(statePath) {
|
|
83
|
-
if (!existsSync(statePath))
|
|
84
|
-
return null;
|
|
85
|
-
return normalizeProxyState(readJsonFile(statePath));
|
|
86
|
-
}
|
|
87
|
-
export function saveProxyState(statePath, state) {
|
|
88
|
-
atomicWriteJson(statePath, state);
|
|
89
|
-
return state;
|
|
90
|
-
}
|
|
91
|
-
export function ensureProxyState(config) {
|
|
92
|
-
const existing = loadProxyState(config.statePath);
|
|
93
|
-
const now = nowIso();
|
|
94
|
-
const base = existing ?? {
|
|
95
|
-
version: DEFAULT_VERSION,
|
|
96
|
-
owner: {
|
|
97
|
-
ownerUserId: config.ownerUserId,
|
|
98
|
-
defaultTenantId: config.defaultTenantId,
|
|
99
|
-
tokenHash: config.ownerTokenHash,
|
|
100
|
-
createdAt: now,
|
|
101
|
-
},
|
|
102
|
-
tenants: {},
|
|
103
|
-
};
|
|
104
|
-
base.owner.ownerUserId = config.ownerUserId;
|
|
105
|
-
base.owner.defaultTenantId = config.defaultTenantId;
|
|
106
|
-
base.owner.tokenHash = config.ownerTokenHash;
|
|
107
|
-
if (base.owner.createdAt.trim() === '')
|
|
108
|
-
base.owner.createdAt = now;
|
|
109
|
-
base.tenants[config.defaultTenantId] = ensureTenantState(base.tenants[config.defaultTenantId], config, now);
|
|
110
|
-
return saveProxyState(config.statePath, base);
|
|
111
|
-
}
|
|
112
|
-
export function getTenantState(state, tenantId) {
|
|
113
|
-
return state.tenants[tenantId] ?? null;
|
|
114
|
-
}
|
|
115
|
-
function ensureTenantState(existing, config, now = nowIso()) {
|
|
116
|
-
return {
|
|
117
|
-
tenantId: existing?.tenantId ?? config.defaultTenantId,
|
|
118
|
-
ownerUserId: existing?.ownerUserId ?? config.ownerUserId,
|
|
119
|
-
m0RegistryPath: existing?.m0RegistryPath ?? config.m0RegistryPath,
|
|
120
|
-
idleAfterMs: existing?.idleAfterMs ?? config.idlePauseMs,
|
|
121
|
-
lastActivityAt: existing?.lastActivityAt ?? null,
|
|
122
|
-
lastWakeAt: existing?.lastWakeAt ?? null,
|
|
123
|
-
lastPauseAt: existing?.lastPauseAt ?? null,
|
|
124
|
-
updatedAt: now,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
export function updateTenantState(config, tenantId, mutate) {
|
|
128
|
-
const state = ensureProxyState(config);
|
|
129
|
-
const current = state.tenants[tenantId] ?? ensureTenantState(undefined, config);
|
|
130
|
-
const draft = { ...current, tenantId, ownerUserId: config.ownerUserId, m0RegistryPath: config.m0RegistryPath, idleAfterMs: config.idlePauseMs };
|
|
131
|
-
const next = mutate(draft) ?? draft;
|
|
132
|
-
next.updatedAt = nowIso();
|
|
133
|
-
state.tenants[tenantId] = next;
|
|
134
|
-
return saveProxyState(config.statePath, state).tenants[tenantId];
|
|
135
|
-
}
|
|
136
|
-
export function touchTenantActivity(config, tenantId) {
|
|
137
|
-
return updateTenantState(config, tenantId, (tenant) => {
|
|
138
|
-
tenant.lastActivityAt = nowIso();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
export function touchTenantWake(config, tenantId) {
|
|
142
|
-
return updateTenantState(config, tenantId, (tenant) => {
|
|
143
|
-
tenant.lastWakeAt = nowIso();
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
export function touchTenantPause(config, tenantId) {
|
|
147
|
-
return updateTenantState(config, tenantId, (tenant) => {
|
|
148
|
-
tenant.lastPauseAt = nowIso();
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
export function withTenantLock(tenantId, fn) {
|
|
152
|
-
const previous = tenantLocks.get(tenantId) ?? Promise.resolve();
|
|
153
|
-
let release;
|
|
154
|
-
const current = new Promise((resolve) => {
|
|
155
|
-
release = resolve;
|
|
156
|
-
});
|
|
157
|
-
const tail = previous.then(() => current, () => current);
|
|
158
|
-
tenantLocks.set(tenantId, tail);
|
|
159
|
-
return previous
|
|
160
|
-
.catch(() => undefined)
|
|
161
|
-
.then(() => Promise.resolve(fn()))
|
|
162
|
-
.finally(() => {
|
|
163
|
-
release();
|
|
164
|
-
if (tenantLocks.get(tenantId) === tail) {
|
|
165
|
-
tenantLocks.delete(tenantId);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function runtimeFor(tenantId) {
|
|
170
|
-
const existing = tenantRuntimes.get(tenantId);
|
|
171
|
-
if (existing !== undefined)
|
|
172
|
-
return existing;
|
|
173
|
-
const created = {
|
|
174
|
-
counts: { http: 0, ws: 0, wake: 0 },
|
|
175
|
-
idleDeadlineAt: null,
|
|
176
|
-
timer: null,
|
|
177
|
-
};
|
|
178
|
-
tenantRuntimes.set(tenantId, created);
|
|
179
|
-
return created;
|
|
180
|
-
}
|
|
181
|
-
function clearTimer(runtime) {
|
|
182
|
-
if (runtime.timer !== null) {
|
|
183
|
-
clearTimeout(runtime.timer);
|
|
184
|
-
runtime.timer = null;
|
|
185
|
-
}
|
|
186
|
-
runtime.idleDeadlineAt = null;
|
|
187
|
-
}
|
|
188
|
-
export function beginActivity(config, tenantId, kind) {
|
|
189
|
-
const runtime = runtimeFor(tenantId);
|
|
190
|
-
runtime.counts[kind] += 1;
|
|
191
|
-
clearTimer(runtime);
|
|
192
|
-
touchTenantActivity(config, tenantId);
|
|
193
|
-
return {
|
|
194
|
-
tenantId,
|
|
195
|
-
kind,
|
|
196
|
-
acquiredAt: nowIso(),
|
|
197
|
-
closed: false,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
export function endActivity(handle) {
|
|
201
|
-
const runtime = runtimeFor(handle.tenantId);
|
|
202
|
-
if (!handle.closed) {
|
|
203
|
-
handle.closed = true;
|
|
204
|
-
runtime.counts[handle.kind] = Math.max(0, runtime.counts[handle.kind] - 1);
|
|
205
|
-
}
|
|
206
|
-
const total = runtime.counts.http + runtime.counts.ws + runtime.counts.wake;
|
|
207
|
-
return {
|
|
208
|
-
tenantId: handle.tenantId,
|
|
209
|
-
counts: { ...runtime.counts },
|
|
210
|
-
total,
|
|
211
|
-
idleDeadlineAt: runtime.idleDeadlineAt,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
export function getTenantActivitySnapshot(tenantId) {
|
|
215
|
-
const runtime = runtimeFor(tenantId);
|
|
216
|
-
return {
|
|
217
|
-
tenantId,
|
|
218
|
-
counts: { ...runtime.counts },
|
|
219
|
-
total: runtime.counts.http + runtime.counts.ws + runtime.counts.wake,
|
|
220
|
-
idleDeadlineAt: runtime.idleDeadlineAt,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
export function setTenantIdleTimer(tenantId, deadlineAt, timer) {
|
|
224
|
-
const runtime = runtimeFor(tenantId);
|
|
225
|
-
clearTimer(runtime);
|
|
226
|
-
runtime.idleDeadlineAt = deadlineAt;
|
|
227
|
-
runtime.timer = timer;
|
|
228
|
-
}
|
|
229
|
-
export function clearTenantIdleTimer(tenantId) {
|
|
230
|
-
clearTimer(runtimeFor(tenantId));
|
|
231
|
-
}
|
|
232
|
-
export function readTenantHome(config, tenantId) {
|
|
233
|
-
return getHome(config.m0RegistryPath, tenantId);
|
|
234
|
-
}
|
|
235
|
-
function mergeHomeStorage(home, m0Config, volumeId) {
|
|
236
|
-
const next = { ...home };
|
|
237
|
-
next.providerName = m0Config.providerName;
|
|
238
|
-
next.homeStorage = {
|
|
239
|
-
kind: 'volume',
|
|
240
|
-
durability: 'durable-volume',
|
|
241
|
-
longTermContract: true,
|
|
242
|
-
ownerMachineId: home.machineId,
|
|
243
|
-
guestHome: m0Config.guestHome,
|
|
244
|
-
volumeId,
|
|
245
|
-
mountPath: m0Config.guestHome,
|
|
246
|
-
};
|
|
247
|
-
return next;
|
|
248
|
-
}
|
|
249
|
-
export function ensureSeededM0Registry(config, m0Config) {
|
|
250
|
-
const existing = getHome(config.m0RegistryPath, config.defaultTenantId);
|
|
251
|
-
if (existing !== null) {
|
|
252
|
-
if (typeof existing.machineId !== 'string' || existing.machineId.trim() === '') {
|
|
253
|
-
throw general('hearth m0 registry is missing machineId — run the existing M0 provision/bootstrap flow before starting the wake proxy', {
|
|
254
|
-
tenantId: config.defaultTenantId,
|
|
255
|
-
registryPath: config.m0RegistryPath,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
const updated = updateHome(config.m0RegistryPath, config.defaultTenantId, (home) => {
|
|
259
|
-
if (home.providerName !== m0Config.providerName)
|
|
260
|
-
home.providerName = m0Config.providerName;
|
|
261
|
-
if (!home.homeStorage || home.homeStorage.volumeId.trim() === '') {
|
|
262
|
-
if (config.seedHome === null) {
|
|
263
|
-
throw general('hearth m0 registry is missing homeStorage.volumeId and no seed home was provided', {
|
|
264
|
-
tenantId: config.defaultTenantId,
|
|
265
|
-
registryPath: config.m0RegistryPath,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
home.homeStorage = mergeHomeStorage(home, m0Config, config.seedHome.volumeId).homeStorage;
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
home.homeStorage = {
|
|
272
|
-
...home.homeStorage,
|
|
273
|
-
ownerMachineId: home.machineId,
|
|
274
|
-
guestHome: m0Config.guestHome,
|
|
275
|
-
mountPath: m0Config.guestHome,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if ((typeof home.nodeId !== 'string' || home.nodeId.trim() === '') && config.seedHome?.nodeId) {
|
|
279
|
-
home.nodeId = config.seedHome.nodeId;
|
|
280
|
-
}
|
|
281
|
-
if ((typeof home.relayToken !== 'string' || home.relayToken.trim() === '') && config.seedHome?.relayToken) {
|
|
282
|
-
home.relayToken = config.seedHome.relayToken;
|
|
283
|
-
}
|
|
284
|
-
if (home.state === undefined || home.state === null || home.state === '') {
|
|
285
|
-
home.state = config.seedHome?.state ?? 'running';
|
|
286
|
-
}
|
|
287
|
-
if ((home.webRoute === undefined || home.webRoute === null) && config.seedHome?.webRouteUrl) {
|
|
288
|
-
home.webRoute = {
|
|
289
|
-
routeId: config.seedHome.webRouteUrl,
|
|
290
|
-
machineId: home.machineId,
|
|
291
|
-
targetPort: m0Config.webPort,
|
|
292
|
-
url: config.seedHome.webRouteUrl,
|
|
293
|
-
concreteUrl: config.seedHome.webRouteUrl,
|
|
294
|
-
concreteUrlSource: 'config',
|
|
295
|
-
createdAt: nowIso(),
|
|
296
|
-
raw: null,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
home.updatedAt = nowIso();
|
|
300
|
-
});
|
|
301
|
-
return updated;
|
|
302
|
-
}
|
|
303
|
-
if (config.seedHome === null) {
|
|
304
|
-
throw general('hearth m0 registry is empty and no HEARTH_SEED_* values were provided — run the existing M0 provision/bootstrap flow before starting the wake proxy', {
|
|
305
|
-
registryPath: config.m0RegistryPath,
|
|
306
|
-
tenantId: config.defaultTenantId,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
const now = nowIso();
|
|
310
|
-
const home = {
|
|
311
|
-
tenantId: config.seedHome.tenantId,
|
|
312
|
-
providerName: m0Config.providerName,
|
|
313
|
-
machineId: config.seedHome.machineId,
|
|
314
|
-
homeStorage: {
|
|
315
|
-
kind: 'volume',
|
|
316
|
-
durability: 'durable-volume',
|
|
317
|
-
longTermContract: true,
|
|
318
|
-
ownerMachineId: config.seedHome.machineId,
|
|
319
|
-
guestHome: m0Config.guestHome,
|
|
320
|
-
volumeId: config.seedHome.volumeId,
|
|
321
|
-
mountPath: m0Config.guestHome,
|
|
322
|
-
},
|
|
323
|
-
state: config.seedHome.state ?? 'running',
|
|
324
|
-
nodeId: config.seedHome.nodeId,
|
|
325
|
-
relayToken: config.seedHome.relayToken,
|
|
326
|
-
webRoute: config.seedHome.webRouteUrl
|
|
327
|
-
? {
|
|
328
|
-
routeId: config.seedHome.webRouteUrl,
|
|
329
|
-
machineId: config.seedHome.machineId,
|
|
330
|
-
targetPort: m0Config.webPort,
|
|
331
|
-
url: config.seedHome.webRouteUrl,
|
|
332
|
-
concreteUrl: config.seedHome.webRouteUrl,
|
|
333
|
-
concreteUrlSource: 'config',
|
|
334
|
-
createdAt: now,
|
|
335
|
-
raw: null,
|
|
336
|
-
}
|
|
337
|
-
: null,
|
|
338
|
-
createdAt: now,
|
|
339
|
-
updatedAt: now,
|
|
340
|
-
};
|
|
341
|
-
return putHome(config.m0RegistryPath, home);
|
|
342
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { GuestNodeId, MachineId, MachineState, M0Config, RelayToken, TenantId } from '../../core/hearth/types.js';
|
|
2
|
-
export interface HearthProxyOwnerState {
|
|
3
|
-
ownerUserId: string;
|
|
4
|
-
defaultTenantId: TenantId;
|
|
5
|
-
tokenHash: string;
|
|
6
|
-
createdAt: string;
|
|
7
|
-
}
|
|
8
|
-
export interface HearthProxyTenantState {
|
|
9
|
-
tenantId: TenantId;
|
|
10
|
-
ownerUserId: string;
|
|
11
|
-
m0RegistryPath: string;
|
|
12
|
-
idleAfterMs: number;
|
|
13
|
-
lastActivityAt: string | null;
|
|
14
|
-
lastWakeAt: string | null;
|
|
15
|
-
lastPauseAt: string | null;
|
|
16
|
-
updatedAt: string;
|
|
17
|
-
}
|
|
18
|
-
export interface HearthProxyState {
|
|
19
|
-
version: 1;
|
|
20
|
-
owner: HearthProxyOwnerState;
|
|
21
|
-
tenants: Record<TenantId, HearthProxyTenantState>;
|
|
22
|
-
}
|
|
23
|
-
export interface HearthProxySeedHome {
|
|
24
|
-
tenantId: TenantId;
|
|
25
|
-
machineId: MachineId;
|
|
26
|
-
nodeId: GuestNodeId;
|
|
27
|
-
relayToken: RelayToken;
|
|
28
|
-
volumeId: string;
|
|
29
|
-
state?: MachineState | null;
|
|
30
|
-
webRouteUrl?: string | null;
|
|
31
|
-
}
|
|
32
|
-
export interface HearthProxyConfig {
|
|
33
|
-
host: string;
|
|
34
|
-
port: number;
|
|
35
|
-
publicOrigin: string;
|
|
36
|
-
statePath: string;
|
|
37
|
-
m0RegistryPath: string;
|
|
38
|
-
ownerUserId: string;
|
|
39
|
-
defaultTenantId: TenantId;
|
|
40
|
-
ownerTokenHash: string;
|
|
41
|
-
idlePauseMs: number;
|
|
42
|
-
wakeTimeoutMs: number;
|
|
43
|
-
readyTimeoutMs: number;
|
|
44
|
-
cookieSecure: boolean;
|
|
45
|
-
seedHome: HearthProxySeedHome | null;
|
|
46
|
-
}
|
|
47
|
-
export interface HearthWakeProxyRuntime {
|
|
48
|
-
proxy: HearthProxyConfig;
|
|
49
|
-
m0: M0Config;
|
|
50
|
-
}
|
|
51
|
-
export type ActivityKind = 'http' | 'ws' | 'wake';
|
|
52
|
-
export interface TenantActivitySnapshot {
|
|
53
|
-
tenantId: TenantId;
|
|
54
|
-
counts: Record<ActivityKind, number>;
|
|
55
|
-
total: number;
|
|
56
|
-
idleDeadlineAt: string | null;
|
|
57
|
-
}
|
|
58
|
-
export interface ActivityHandle {
|
|
59
|
-
tenantId: TenantId;
|
|
60
|
-
kind: ActivityKind;
|
|
61
|
-
acquiredAt: string;
|
|
62
|
-
closed: boolean;
|
|
63
|
-
}
|
|
64
|
-
export interface AwakenedHome {
|
|
65
|
-
tenantId: TenantId;
|
|
66
|
-
nodeId: GuestNodeId;
|
|
67
|
-
routeUrl: string;
|
|
68
|
-
relayToken: RelayToken;
|
|
69
|
-
machineId: MachineId;
|
|
70
|
-
webPort: number;
|
|
71
|
-
}
|
|
72
|
-
export interface WakeProxyLogger {
|
|
73
|
-
info(message: string, details?: Record<string, unknown>): void;
|
|
74
|
-
warn(message: string, details?: Record<string, unknown>): void;
|
|
75
|
-
error(message: string, details?: Record<string, unknown>): void;
|
|
76
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|