Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const (
// ProtocolResponses is the value of `agent.yaml#protocol` for plain
// text /responses agents.
ProtocolResponses = "responses"
// ProtocolInvocationsWS is the value of `agent.yaml#protocol` for
// bidirectional WebSocket /invocations_ws agents.
ProtocolInvocationsWS = "invocations_ws"

// placeholderPayload is the single-quoted literal the resolver
// emits as the body argument when no concrete payload is known —
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,17 +478,23 @@ func loadServiceProtocol(projectPath, relativePath string) string {
}

sawInvocations := false
sawInvocationsWS := false
for _, p := range hosted.Protocols {
switch strings.TrimSpace(p.Protocol) {
case ProtocolResponses:
return ProtocolResponses
case ProtocolInvocationsWS:
sawInvocationsWS = true
case ProtocolInvocations:
sawInvocations = true
}
}
if sawInvocations {
return ProtocolInvocations
}
if sawInvocationsWS {
return ProtocolInvocationsWS
}
return ""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,37 @@ protocols:
protocols:
- protocol: invocations
version: "1.0.0"
`,
want: ProtocolInvocations,
},
{
name: "single invocations_ws protocol",
manifest: `kind: hostedAgent
protocols:
- protocol: invocations_ws
version: "2.0.0"
`,
want: ProtocolInvocationsWS,
},
{
name: "responses wins over invocations_ws regardless of order",
manifest: `kind: hostedAgent
protocols:
- protocol: invocations_ws
version: "2.0.0"
- protocol: responses
version: "2.0.0"
`,
want: ProtocolResponses,
},
{
name: "invocations wins over invocations_ws regardless of order",
manifest: `kind: hostedAgent
protocols:
- protocol: invocations_ws
version: "2.0.0"
- protocol: invocations
version: "1.0.0"
`,
want: ProtocolInvocations,
},
Expand Down