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

Function buildConnectedState

src/cli/commands/connection.ts:197–223  ·  view source on GitHub ↗
(options: {
  flags: CliFlags;
  scope: { tenant: string; runId: string };
  connectionMetadata?: RemoteConnectionRequestMetadata;
  context: ConnectContext;
  remoteConfigPath: string;
})

Source from the content-addressed store, hash-verified

195}
196
197function buildConnectedState(options: {
198 flags: CliFlags;
199 scope: { tenant: string; runId: string };
200 connectionMetadata?: RemoteConnectionRequestMetadata;
201 context: ConnectContext;
202 remoteConfigPath: string;
203}): RemoteConnectionState {
204 const { flags, scope, connectionMetadata, context, remoteConfigPath } = options;
205 const previous = shouldReusePreviousConnectionState(flags, context.previous)
206 ? context.previous
207 : null;
208 const now = new Date().toISOString();
209 const leaseBinding = buildConnectionLeaseBinding(flags, previous, connectionMetadata);
210 const runtimeBinding = buildConnectionRuntimeBinding(flags, previous, now);
211 return {
212 version: 1,
213 session: context.session,
214 remoteConfigPath,
215 remoteConfigHash: context.remoteConfigHash,
216 daemon: context.daemon,
217 tenant: scope.tenant,
218 runId: scope.runId,
219 ...leaseBinding,
220 ...runtimeBinding,
221 updatedAt: now,
222 };
223}
224
225function buildConnectionLeaseBinding(
226 flags: CliFlags,

Callers 1

connectCommandFunction · 0.85

Tested by

no test coverage detected