MCPcopy Index your code
hub / github.com/docker/docker-agent / CreateSession

Method CreateSession

cmd/root/backend.go:206–237  ·  view source on GitHub ↗
(ctx context.Context, _ *teamloader.LoadResult, req runtime.CreateSessionRequest)

Source from the content-addressed store, hash-verified

204}
205
206func (b *remoteBackend) CreateSession(ctx context.Context, _ *teamloader.LoadResult, req runtime.CreateSessionRequest) (runtime.Runtime, *session.Session, func(), error) {
207 client, err := runtime.NewClient(b.flags.remoteAddress)
208 if err != nil {
209 return nil, nil, nil, fmt.Errorf("failed to create remote client: %w", err)
210 }
211
212 sessTemplate := session.New(
213 session.WithToolsApproved(req.ToolsApproved),
214 )
215
216 sess, err := client.CreateSession(ctx, sessTemplate)
217 if err != nil {
218 return nil, nil, nil, err
219 }
220
221 rt, err := runtime.NewRemoteRuntime(client,
222 runtime.WithRemoteCurrentAgent(req.AgentName),
223 runtime.WithRemoteAgentFilename(b.agentFileName),
224 )
225 if err != nil {
226 return nil, nil, nil, fmt.Errorf("failed to create remote runtime: %w", err)
227 }
228
229 slog.DebugContext(ctx, "Using remote runtime", "address", b.flags.remoteAddress, "agent", req.AgentName)
230
231 cleanup := func() {
232 if err := rt.Close(); err != nil {
233 slog.ErrorContext(ctx, "Failed to close remote runtime", "error", err)
234 }
235 }
236 return rt, sess, cleanup, nil
237}
238
239func (b *remoteBackend) Spawner(runtime.Runtime) tui.SessionSpawner {
240 return nil

Callers

nothing calls this directly

Calls 8

CreateSessionMethod · 0.95
CloseMethod · 0.95
NewClientFunction · 0.92
NewFunction · 0.92
WithToolsApprovedFunction · 0.92
NewRemoteRuntimeFunction · 0.92
WithRemoteCurrentAgentFunction · 0.92
WithRemoteAgentFilenameFunction · 0.92

Tested by

no test coverage detected