MCPcopy
hub / github.com/callstack/agent-device / connectionCommand

Function connectionCommand

src/cli/commands/connection.ts:351–375  ·  view source on GitHub ↗
({ positionals, flags })

Source from the content-addressed store, hash-verified

349};
350
351export const connectionCommand: ClientCommandHandler = async ({ positionals, flags }) => {
352 if (positionals[0] !== 'status') {
353 throw new AppError('INVALID_ARGS', 'connection accepts only: status');
354 }
355 const { session, state } = readRequestedConnectionState(flags);
356 if (!state) {
357 writeNoRemoteConnectionOutput(flags, session);
358 return true;
359 }
360 const leasePreparation = buildLeasePreparationNotice(state);
361 const runtimePreparation = buildRuntimePreparationNoticeFromState(state);
362 writeCommandOutput(flags, serializeConnectionState(state, runtimePreparation), () =>
363 [
364 `Connected remote session "${state.session}".`,
365 `tenant=${state.tenant} runId=${state.runId} leaseId=${state.leaseId ?? 'pending'} backend=${state.leaseBackend ?? 'pending'}`,
366 `remoteConfig=${state.remoteConfigPath}`,
367 state.runtime ? 'metro=prepared' : 'metro=not-prepared',
368 leasePreparation?.message,
369 runtimePreparation?.message,
370 ]
371 .filter((line): line is string => Boolean(line))
372 .join('\n'),
373 );
374 return true;
375};
376
377function createRemoteSessionName(stateDir: string): string {
378 for (let attempt = 0; attempt < 8; attempt += 1) {

Callers 1

Tested by

no test coverage detected