MCPcopy
hub / github.com/docker/docker-agent / Duration

Method Duration

pkg/session/session.go:597–614  ·  view source on GitHub ↗

Duration calculates the duration of the session from message timestamps.

()

Source from the content-addressed store, hash-verified

595
596// Duration calculates the duration of the session from message timestamps.
597func (s *Session) Duration() time.Duration {
598 messages := s.GetAllMessages()
599 if len(messages) < 2 {
600 return 0
601 }
602
603 first, err := time.Parse(time.RFC3339, messages[0].Message.CreatedAt)
604 if err != nil {
605 return 0
606 }
607
608 last, err := time.Parse(time.RFC3339, messages[len(messages)-1].Message.CreatedAt)
609 if err != nil {
610 return 0
611 }
612
613 return last.Sub(first)
614}
615
616// AllowedDirectories returns the directories that should be considered safe for tools
617func (s *Session) AllowedDirectories() []string {

Callers 15

delayMethod · 0.80
CreateToolSetFunction · 0.80
parseTokenResponseFunction · 0.80
ConnectMethod · 0.80
CallToolMethod · 0.80
CreateToolSetFunction · 0.80
RunShellMethod · 0.80
CreateToolSetFunction · 0.80
CreateToolSetFunction · 0.80
TestAllEventTypesFunction · 0.80

Implementers 7

fakeSessionpkg/tools/lifecycle/supervisor_test.go
sessionClientpkg/tools/mcp/session_client.go
mockMCPClientpkg/tools/mcp/mcp_test.go
reconnectableMockClientpkg/tools/mcp/mcp_test.go
failingInitClientpkg/tools/mcp/reconnect_test.go
clientSessionpkg/tools/mcp/mcp.go
lspSessionpkg/tools/builtin/lsp/lsp_lifecycle.go

Calls 2

GetAllMessagesMethod · 0.95
ParseMethod · 0.80

Tested by 9

TestAllEventTypesFunction · 0.64
typingFunction · 0.64
TestWrapBedrockErrorFunction · 0.64
TestWrapAnthropicErrorFunction · 0.64
TestWrapOpenAIErrorFunction · 0.64
TestWrapHTTPErrorFunction · 0.64
TestClassifyModelErrorFunction · 0.64