Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: bound managed visitor cancellation and uncertain admission
[._.]/ Adam Eivye3cd929ce49a
diff --git a/docs/features/managed-visitors.md b/docs/features/managed-visitors.mdindex 3b71c83b0a..64243a763b 100644--- a/docs/features/managed-visitors.md+++ b/docs/features/managed-visitors.md@@ -51,7 +51,7 @@ One operation per session can be pending. Malformed, mismatched or uncertain hosRequests go only to fixed loopback port 8940 under `/api/managed-visitors/v1`, with the separate host bearer, a three-second deadline, redirects disabled and response buffering capped at 16 KiB. `/version` must negotiate:```json-{"capabilities":{"managedVisitors":{"version":1,"bodies":["fly-v1"],"controllerRaster":{"width":8,"height":4,"channels":3},"actions":["start","pause","rest","move","leave"],"expiryEnforced":true}}}+{"capabilities":{"managedVisitors":{"version":1,"bodies":["fly-v1"],"controllerRaster":{"width":8,"height":4,"channels":3},"actions":["start","pause","rest","move","leave"],"expiryEnforced":true,"admissionDeadline":true}}}```Host admissions add `version:1` and the authenticated `appId` to the app request. Later host operations add `appId` to the scoped body and use the private host session ID, which PortOS never exposes as app authority. Host admission/action responses include `expiresAt`; the broker checks it and clamps the outward deadline to its own earlier limit. Both layers independently enforce scope and expiry.@@ -59,3 +59,11 @@ Host admissions add `version:1` and the authenticated `appId` to the app requestA dedicated unsequenced `POST /sessions/:hostId/leave` takes `{appId,individualId,individualSessionId,worldId,epoch}` for idempotent revocation. It must invalidate a pending action even when its sequence is uncertain. This is how credential revocation avoids racing the normal action sequence. If the host cannot be reached, broker authority is still revoked immediately and independently enforced host expiry bounds the remaining ephemeral presence.This foundation does not implement connectome execution, retained learning, travel consent inference, arbitrary world authority or client-side embodiment. Fly Garden remains paused at home unless its own explicit visitor adapter is subsequently enabled. Source changes do not enable a production visitor.++## Reconcile interrupted admission and return++`POST /sessions/:sessionId/leave` accepts the exact ordinary scope without a sequence. It revokes pending action authority immediately; a late action cannot become current again. Return is acknowledged only after matching host cleanup or the trusted admission deadline. An unconfirmed cleanup retains a revoked receipt so a retry cannot mistake the missing active session for an acknowledged return.++When an admission times out before returning a session ID, use `POST /admissions/cancel` with exactly `{individualId,individualSessionId,worldId}` and the app credential. It cancels matching pending attempts and removes matching published visits, without touching another recipient or runtime session. The response contains `version`, `appId`, those scope IDs, `confirmed`, `pending` and nullable `expiresAt`. Keep local embodiment ownership paused while `confirmed:false`; retry cancellation until confirmed. A pending acknowledgment is cleaned when it arrives and cannot publish authority after cancellation.++Host negotiation additionally requires `admissionDeadline:true`. Every host admission carries `X-Managed-Visitor-Deadline`, an absolute same-machine wall-clock upper bound chosen before the host call. The host must validate it after consuming the body and clamp its lease expiry to that bound. If the host call itself times out without a lease ID, PortOS keeps a revoked unresolved receipt until this trustworthy deadline. Invalid host expiry values cannot extend that bound. A stale or older host lacking this capability is unavailable; no TTL is guessed from receipt time.diff --git a/server/lib/managedVisitorValidation.js b/server/lib/managedVisitorValidation.jsindex 6e440be4b2..2d93664c96 100644--- a/server/lib/managedVisitorValidation.js+++ b/server/lib/managedVisitorValidation.js@@ -1,6 +1,7 @@import { z } from 'zod';const id = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/);export const visitorScopeSchema = z.object({ individualId: id, individualSessionId: id, worldId: id, epoch: id }).strict();+export const visitorCancellationSchema = visitorScopeSchema.omit({ epoch: true }).strict();export const visitorCredentialSchema = z.object({ individualIds: z.array(id).min(1).max(64), worldIds: z.array(id).min(1).max(32),ttlMs: z.number().int().min(60000).max(7 * 86400000) }).strict();export const visitorAdmissionSchema = z.object({ individualId: id, individualSessionId: id, worldId: id,diff --git a/server/routes/managedVisitors.js b/server/routes/managedVisitors.jsindex 1133890698..60bf22111b 100644--- a/server/routes/managedVisitors.js+++ b/server/routes/managedVisitors.js@@ -1,6 +1,6 @@import { Router } from 'express';import { asyncHandler, ServerError } from '../lib/errorHandler.js';-import { visitorCredentialSchema, visitorAdmissionSchema, visitorScopeSchema, visitorActionSchema, visitorIdSchema } from '../lib/managedVisitorValidation.js';+import { visitorCancellationSchema, visitorCredentialSchema, visitorAdmissionSchema, visitorScopeSchema, visitorActionSchema, visitorIdSchema } from '../lib/managedVisitorValidation.js';import { getManagedVisitorBroker } from '../services/managedVisitors.js';import { isCrossOrigin } from '../../lib/portosAuthCore.js';@@ -14,6 +14,12 @@ export function createManagedVisitorRoutes(getBroker = getManagedVisitorBroker)next();});router.get('/capabilities', asyncHandler(async (req, res) => res.json(await getBroker().capabilities(req.managedVisitorAuth))));+ router.post('/admissions/cancel', asyncHandler(async (req, res) => {+ res.json(await getBroker().cancelAdmission(req.managedVisitorAuth, await validateRequest(visitorCancellationSchema, req.body)));+ }));+ router.post('/sessions/:id/leave', asyncHandler(async (req, res) => {+ res.json(await getBroker().leave(req.managedVisitorAuth, await validateRequest(visitorIdSchema, req.params.id), await validateRequest(visitorScopeSchema, req.body)));+ }));router.post('/admissions', asyncHandler(async (req, res) => {const body = await validateRequest(visitorAdmissionSchema, req.body); res.json(await getBroker().admit(req.managedVisitorAuth, body));}));diff --git a/server/routes/managedVisitors.test.js b/server/routes/managedVisitors.test.jsindex ec9562f22e..9211ff15a2 100644--- a/server/routes/managedVisitors.test.js+++ b/server/routes/managedVisitors.test.js@@ -36,7 +36,7 @@ beforeEach(async () => {camera: 'controller', sensorySource: 'engineered-gentle-patch-spatial-proxy-v1', width: 8, height: 4, rgb: Array(96).fill(0), pose: { x: 0, z: 0, yaw: 0 } })),action: vi.fn(async (id, { sequence, action, ...body }) => ({ version: 1, ...body, sessionId: id, sequence, expiresAt: clock + admission.ttlMs,status: { start: 'running', pause: 'paused', rest: 'resting', move: 'running', leave: 'left' }[action.type], pose: { x: 0, z: 0, yaw: 0 } })),- leave: vi.fn(async () => ({ status: 'left' })),+ leave: vi.fn(async (sessionId, body) => ({ version: 1, sessionId, ...body, status: 'left' })),};shared.broker = createManagedVisitorBroker({ path: join(directory, 'credentials.json'), getApp: async id => id === appId ? { id } : null, host, now: () => clock });app = express(); app.use(express.json()); app.use(authGate);@@ -148,3 +148,56 @@ it('revocation during a pending action discards its late response and admissionhost.admit.mockImplementationOnce(async body => { clock += 1001; return admitNormally(body); });await expect(shared.broker.admit(current, { ...admission, ttlMs: 1000 })).rejects.toThrow(/expired/);});++it('unsequenced scoped leave revokes pending actions and retries unconfirmed cleanup without falsely returning home', async () => {+ const auth = await shared.broker.authenticate(credentials.credential), visit = await shared.broker.admit(auth, admission);+ host.leave.mockRejectedValueOnce(new Error('offline'));+ await expect(shared.broker.leave(auth, visit.sessionId, scope(visit))).rejects.toThrow(/unconfirmed/);+ await expect(shared.broker.observe(auth, visit.sessionId, scope(visit))).rejects.toThrow(/scope/);+ expect((await shared.broker.leave(auth, visit.sessionId, scope(visit))).status).toBe('left');+ expect((await shared.broker.leave(auth, visit.sessionId, scope(visit))).status).toBe('left');+});+it('cancels an unknown pending admission by original scope, waits for its acknowledgment and cleans it before confirming', async () => {+ const auth = await shared.broker.authenticate(credentials.credential); let release;+ delayed = new Promise(resolve => { release = resolve; });+ const pending = shared.broker.admit(auth, admission);+ await vi.waitFor(() => expect(host.admit).toHaveBeenCalledTimes(1));+ const original = { individualId, individualSessionId, worldId };+ expect(await shared.broker.cancelAdmission(auth, original)).toMatchObject({ confirmed: false, pending: true, expiresAt: null });+ release(); await expect(pending).rejects.toThrow(/changed/);+ expect(host.leave).toHaveBeenCalledTimes(1);+ expect(await shared.broker.cancelAdmission(auth, original)).toMatchObject({ confirmed: true, pending: false });+});++it('an unknown host admission outcome remains quarantined through the exact broker-supplied deadline', async () => {+ const auth = await shared.broker.authenticate(credentials.credential);+ host.admit.mockRejectedValueOnce(new Error('timeout without acknowledgment'));+ await expect(shared.broker.admit(auth, admission)).rejects.toThrow(/timeout/);+ const original = { individualId, individualSessionId, worldId };+ expect(host.admit.mock.calls[0][1]).toEqual({ deadlineMs: clock + admission.ttlMs });+ expect(await shared.broker.cancelAdmission(auth, original)).toMatchObject({ confirmed: false, pending: false, expiresAt: clock + admission.ttlMs });+ await expect(shared.broker.admit(auth, admission)).rejects.toThrow(/already/);+ clock += admission.ttlMs;+ expect(await shared.broker.cancelAdmission(auth, original)).toMatchObject({ confirmed: true, pending: false });+});++it('an unconfirmed leave revokes a pending action even while retaining its cleanup receipt', async () => {+ const auth = await shared.broker.authenticate(credentials.credential), visit = await shared.broker.admit(auth, admission);+ let release; const normal = host.action.getMockImplementation();+ host.action.mockImplementationOnce(async (...args) => { await new Promise(resolve => { release = resolve; }); return normal(...args); });+ const pending = shared.broker.action(auth, visit.sessionId, { ...scope(visit), sequence: 0, action: { type: 'start' } });+ await vi.waitFor(() => expect(release).toBeTypeOf('function'));+ host.leave.mockRejectedValue(new Error('unconfirmed'));+ await expect(shared.broker.leave(auth, visit.sessionId, scope(visit))).rejects.toThrow(/unconfirmed/);+ release(); await expect(pending).rejects.toThrow(/revoked/);+});+it('an invalid host expiry cannot extend quarantine beyond the broker admission deadline', async () => {+ const auth = await shared.broker.authenticate(credentials.credential), normal = host.admit.getMockImplementation();+ host.admit.mockImplementationOnce(async body => ({ ...await normal(body), expiresAt: clock + 999999 }));+ host.leave.mockRejectedValue(new Error('offline'));+ await expect(shared.broker.admit(auth, admission)).rejects.toThrow(/expired/);+ const original = { individualId, individualSessionId, worldId };+ expect((await shared.broker.cancelAdmission(auth, original)).expiresAt).toBe(clock + admission.ttlMs);+ clock += admission.ttlMs;+ expect((await shared.broker.cancelAdmission(auth, original)).confirmed).toBe(true);+});diff --git a/server/services/managedVisitorBroker.js b/server/services/managedVisitorBroker.jsindex 8107180838..1a93599bb4 100644--- a/server/services/managedVisitorBroker.js+++ b/server/services/managedVisitorBroker.js@@ -4,7 +4,7 @@ import { dirname } from 'node:path';import { atomicWrite, ensureDir } from '../lib/fileCore.js';import { createFileWriteQueue } from '../lib/fileWriteQueue.js';import { ServerError } from '../lib/errorHandler.js';-import { visitorCredentialSchema, visitorAdmissionSchema, visitorScopeSchema, visitorActionSchema, visitorCredentialDocumentSchema,+import { visitorCancellationSchema, visitorCredentialSchema, visitorAdmissionSchema, visitorScopeSchema, visitorActionSchema, visitorCredentialDocumentSchema,visitorHostAdmissionSchema, visitorHostObservationSchema, visitorHostActionSchema, visitorIdSchema } from '../lib/managedVisitorValidation.js';const hash = token => createHash('sha256').update(token).digest('hex');@@ -12,10 +12,10 @@ const fail = (message, status = 409) => new ServerError(message, { status, code:const scopeKeys = ['appId', 'individualId', 'individualSessionId', 'worldId', 'epoch'];const publicCredential = ({ digest, ...record }) => record;export const managedVisitorContract = Object.freeze({ version: 1, bodies: ['fly-v1'], controllerRaster: { width: 8, height: 4, channels: 3 },- actions: ['start', 'pause', 'rest', 'move', 'leave'], expiryEnforced: true });+ actions: ['start', 'pause', 'rest', 'move', 'leave'], expiryEnforced: true, admissionDeadline: true });export function supportsManagedVisitors(capabilities) {const value = capabilities?.managedVisitors;- return value?.version === 1 && value.expiryEnforced === true && Array.isArray(value.bodies) && value.bodies.every(v => typeof v === 'string')+ return value?.version === 1 && value.expiryEnforced === true && value.admissionDeadline === true && Array.isArray(value.bodies) && value.bodies.every(v => typeof v === 'string')&& value.bodies.includes('fly-v1') && Array.isArray(value.actions) && value.actions.every(v => typeof v === 'string')&& value.controllerRaster?.width === 8 && value.controllerRaster?.height === 4 && value.controllerRaster?.channels === 3&& managedVisitorContract.actions.every(action => value.actions?.includes(action));@@ -24,14 +24,13 @@ export function supportsManagedVisitors(capabilities) {/** Local credentials persist; ephemeral admissions do not survive broker restart.* No peer sync, AI provider, arbitrary host URL or private runtime payload is accepted. */export function createManagedVisitorBroker({ path, getApp, host, now = Date.now }) {- const queue = createFileWriteQueue(), sessions = new Map(), pendingAdmissions = new Set();+ const queue = createFileWriteQueue(), sessions = new Map(), pendingAdmissions = new Map();const wallNow = now;let lastTime = wallNow();function time() {const current = wallNow();if (!Number.isSafeInteger(current) || current < lastTime) {for (const session of [...sessions.values()]) close(session).catch(() => null);- sessions.clear();throw fail('Broker clock changed; visitor authority revoked.');}lastTime = current; return current;@@ -64,9 +63,13 @@ export function createManagedVisitorBroker({ path, getApp, host, now = Date.nowconst auth = { appId: record.appId, digest }; await credential(auth); return auth;}async function close(session) {- sessions.delete(session.id);- // Local authority is gone even if the host is disconnected; negotiated host expiry is the backstop.- await host.leave(session.hostId, session.scope).catch(() => null);+ session.revoked = true;+ // Keep an unresolved cleanup receipt so a retry cannot falsely acknowledge return.+ sessions.set(session.id, session);+ const acknowledged = wallNow() >= (session.admissionDeadline ?? session.hostExpiresAt) || session.hostId !== null && await host.leave(session.hostId, session.scope)+ .then(result => result?.status === 'left' && result.sessionId === session.hostId && scopeKeys.every(key => result[key] === session.scope[key]), () => false);+ if (acknowledged) sessions.delete(session.id);+ return acknowledged;}async function revokeSessions(appId) { await Promise.all([...sessions.values()].filter(s => s.scope.appId === appId).map(close)); }async function provision(appId, input) {@@ -103,39 +106,41 @@ export function createManagedVisitorBroker({ path, getApp, host, now = Date.nowconst key = JSON.stringify([auth.appId, value.individualId]);for (const session of [...sessions.values()]) if (session.expiresAt <= time()) await close(session);if (sessions.size + pendingAdmissions.size >= 64 || pendingAdmissions.has(key) || [...sessions.values()].some(s => s.key === key)) throw fail('Individual already visiting or admission capacity reached.');- pendingAdmissions.add(key);+ const attempt = { scope: { appId: auth.appId, individualId: value.individualId, individualSessionId: value.individualSessionId, worldId: value.worldId }, canceled: false };+ pendingAdmissions.set(key, attempt);let candidate = null;return (async () => {const begin = time(), ttlMs = Math.min(value.ttlMs, c.expiresAt - begin);if (ttlMs < 1000) throw fail('Credential expires too soon for admission.');- const response = await host.admit({ version: 1, appId: auth.appId, ...value, ttlMs });+ candidate = { id: randomUUID(), hostId: null, scope: { ...attempt.scope, epoch: null }, key, digest: auth.digest, expiresAt: begin + ttlMs, hostExpiresAt: begin + ttlMs, admissionDeadline: begin + ttlMs, revoked: true };+ const response = await host.admit({ version: 1, appId: auth.appId, ...value, ttlMs }, { deadlineMs: begin + ttlMs });const parsed = visitorHostAdmissionSchema.safeParse(response);const scope = { appId: auth.appId, individualId: value.individualId, individualSessionId: value.individualSessionId, worldId: value.worldId, epoch: response?.epoch };if (!parsed.success || scopeKeys.some(key => parsed.data[key] !== scope[key])) {// A malformed acknowledgement may still represent a live admission. Clean up// only using the request's original identity/world and syntactically valid lease keys.if (visitorIdSchema.safeParse(response?.sessionId).success && visitorIdSchema.safeParse(response?.epoch).success) {- await host.leave(response.sessionId, scope).catch(() => null);+ candidate = { ...candidate, hostId: response.sessionId, scope };}throw fail('Host returned an invalid scoped admission.');}const result = parsed.data;- const session = { id: randomUUID(), hostId: result.sessionId, scope, key, digest: auth.digest, expiresAt: result.expiresAt, hostExpiresAt: result.expiresAt, sequence: -1, frameId: -1, pending: false };+ const session = { id: randomUUID(), hostId: result.sessionId, scope, key, digest: auth.digest, expiresAt: result.expiresAt, hostExpiresAt: result.expiresAt, admissionDeadline: begin + ttlMs, sequence: -1, frameId: -1, pending: false };candidate = session;session.expiresAt = Math.min(result.expiresAt, begin + ttlMs);const valid = session.expiresAt > time() && result.expiresAt <= time() + ttlMs;// Rotation while an admission is pending must not publish fresh authority from the old credential.const current = await credential(auth).then(() => true, () => false);- if (!valid || !current) throw fail('Admission expired or credential changed during negotiation.');+ if (!valid || !current || attempt.canceled) throw fail('Admission expired or credential changed during negotiation.');sessions.set(session.id, session);return { ...result, sessionId: session.id, expiresAt: session.expiresAt };})().catch(async error => { if (candidate) await close(candidate); throw error; })- .finally(() => pendingAdmissions.delete(key));+ .finally(() => { if (pendingAdmissions.get(key) === attempt) pendingAdmissions.delete(key); });}async function sessionFor(auth, id, input) {await credential(auth);const session = sessions.get(id);- if (!session || session.digest !== auth.digest || session.expiresAt <= time() || scopeKeys.some(key => (key === 'appId' ? auth.appId : input[key]) !== session.scope[key])) throw fail('Visitor session scope, epoch or expiry mismatch.', 403);+ if (!session || session.revoked || session.digest !== auth.digest || session.expiresAt <= time() || scopeKeys.some(key => (key === 'appId' ? auth.appId : input[key]) !== session.scope[key])) throw fail('Visitor session scope, epoch or expiry mismatch.', 403);if (session.pending) throw fail('A visitor operation is already pending.');return session;}@@ -146,7 +151,7 @@ export function createManagedVisitorBroker({ path, getApp, host, now = Date.nowreturn (async () => {const reply = await (observation ? host.observe(session.hostId, session.scope) : host.action(session.hostId, { ...session.scope, sequence: request.sequence, action: request.action }));const stillValid = await credential(auth).then(() => true, () => false);- if (!stillValid || sessions.get(id) !== session || session.expiresAt <= time()) throw fail('Visitor authority changed while the host operation was pending.');+ if (!stillValid || session.revoked || sessions.get(id) !== session || session.expiresAt <= time()) throw fail('Visitor authority changed while the host operation was pending.');const result = validateResult(observation ? visitorHostObservationSchema : visitorHostActionSchema, reply, session.scope);if (result.sessionId !== session.hostId) throw fail('Host session mismatch.');if (observation) {@@ -163,7 +168,26 @@ export function createManagedVisitorBroker({ path, getApp, host, now = Date.now.finally(() => { session.pending = false; });}- return { authenticate, provision, revoke, capabilities, admit,+ async function leave(auth, id, input) {+ const request = visitorScopeSchema.parse(input); await credential(auth);+ const session = sessions.get(id);+ if (!session) return { version: 1, appId: auth.appId, ...request, sessionId: id, status: 'left' };+ if (session.scope.appId !== auth.appId || scopeKeys.some(key => (key === 'appId' ? auth.appId : request[key]) !== session.scope[key])) throw fail('Visitor cleanup scope mismatch.', 403);+ if (!await close(session)) throw fail('Host cleanup is unconfirmed; retain paused ownership until retry or expiry.');+ return { version: 1, appId: auth.appId, ...request, sessionId: id, status: 'left' };+ }+ async function cancelAdmission(auth, input) {+ const request = visitorCancellationSchema.parse(input), c = await credential(auth);+ if (!c.individualIds.includes(request.individualId) || !c.worldIds.includes(request.worldId)) throw fail('Cancellation is outside the approved app scope.', 403);+ const matches = scope => scope.appId === auth.appId && Object.keys(request).every(key => scope[key] === request[key]);+ for (const attempt of pendingAdmissions.values()) if (matches(attempt.scope)) attempt.canceled = true;+ await Promise.all([...sessions.values()].filter(session => matches(session.scope)).map(close));+ const pending = [...pendingAdmissions.values()].some(attempt => matches(attempt.scope));+ const unresolved = [...sessions.values()].filter(session => matches(session.scope));+ return { version: 1, appId: auth.appId, ...request, confirmed: !pending && !unresolved.length, pending,+ expiresAt: pending ? null : unresolved.length ? Math.max(...unresolved.map(session => session.admissionDeadline ?? session.hostExpiresAt)) : null };+ }+ return { authenticate, provision, revoke, capabilities, admit, leave, cancelAdmission,listCredentials: async () => (await read()).credentials.map(publicCredential),observe: (auth, id, input) => operate(auth, id, input, true), action: (auth, id, input) => operate(auth, id, input, false) };}diff --git a/server/services/managedVisitorHost.js b/server/services/managedVisitorHost.jsindex adfdd744bd..47fab5030a 100644--- a/server/services/managedVisitorHost.js+++ b/server/services/managedVisitorHost.js@@ -4,10 +4,11 @@ import { ServerError } from '../lib/errorHandler.js';export function createManagedVisitorHost({ token = process.env.PORTOS_EIDOVERSE_VISITOR_TOKEN, fetchImpl = fetch, port = 8940 } = {}) {if (!Number.isInteger(port) || port < 1 || port > 65535) throw new ServerError('Invalid managed visitor host port.', { status: 400 });const enabled = typeof token === 'string' && /^[a-f0-9]{64}$/.test(token);- async function request(path, body) {+ async function request(path, body, deadlineMs) {if (!enabled) throw new ServerError('Managed visitor host credential is not configured.', { status: 409 });+ if (path === '/admissions' && (!Number.isSafeInteger(deadlineMs) || deadlineMs <= Date.now())) throw new ServerError('Invalid managed visitor admission deadline.', { status: 409 });const response = await fetchImpl(`http://127.0.0.1:${port}/api/managed-visitors/v1${path}`, {- method: body === undefined ? 'GET' : 'POST', headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },+ method: body === undefined ? 'GET' : 'POST', headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', ...(deadlineMs === undefined ? {} : { 'X-Managed-Visitor-Deadline': String(deadlineMs) }) },...(body === undefined ? {} : { body: JSON.stringify(body) }), redirect: 'error', signal: AbortSignal.timeout(3000),});if (!response.ok) throw new ServerError('Managed visitor host refused the operation.', { status: 409 });@@ -25,7 +26,7 @@ export function createManagedVisitorHost({ token = process.env.PORTOS_EIDOVERSE_}return {capabilities: () => enabled ? request('/version').then(value => value.capabilities, () => null) : Promise.resolve(null),- admit: body => request('/admissions', body),+ admit: (body, { deadlineMs } = {}) => request('/admissions', body, deadlineMs),observe: (id, body) => request(`/sessions/${encodeURIComponent(id)}/observations`, body),leave: (id, body) => request(`/sessions/${encodeURIComponent(id)}/leave`, body),action: (id, body) => request(`/sessions/${encodeURIComponent(id)}/actions`, body),diff --git a/server/services/managedVisitorHost.test.js b/server/services/managedVisitorHost.test.jsindex 0ac417fd42..ee884f55d8 100644--- a/server/services/managedVisitorHost.test.js+++ b/server/services/managedVisitorHost.test.js@@ -16,5 +16,5 @@ it('host response buffering is bounded and malformed/non-success replies do notconst host = createManagedVisitorHost({ token: 'a'.repeat(64), fetchImpl });await expect(host.observe('session', {})).rejects.toThrow(/bound/); expect(canceled).toBe(true);fetchImpl.mockResolvedValueOnce(new Response('not json')); expect(await host.capabilities()).toBe(null);- fetchImpl.mockResolvedValueOnce(new Response('{}', { status: 401 })); await expect(host.admit({})).rejects.toThrow(/refused/);+ fetchImpl.mockResolvedValueOnce(new Response('{}', { status: 401 })); await expect(host.admit({}, { deadlineMs: Date.now() + 1000 })).rejects.toThrow(/refused/);});