Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func main() {
Name: "My Custom Model",
Capabilities: copilot.ModelCapabilities{
Supports: copilot.ModelSupports{Vision: false, ReasoningEffort: false},
Limits: copilot.ModelLimits{MaxContextWindowTokens: 128000},
Limits: copilot.ModelLimits{MaxContextWindowTokens: copilot.Int(128000)},
},
},
}, nil
Expand Down Expand Up @@ -478,7 +478,7 @@ When using BYOK, be aware of these limitations:

### Identity limitations

BYOK authentication uses **static credentials only**.
BYOK authentication uses **static credentials only**.

You must use an API key or static bearer token that you manage yourself.

Expand Down
2 changes: 1 addition & 1 deletion docs/features/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func main() {
"my-local-server": copilot.MCPStdioServerConfig{
Command: "node",
Args: []string{"./mcp-server.js"},
Tools: &[]string{"*"},
Tools: []string{"*"},
},
},
})
Expand Down
11 changes: 5 additions & 6 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,10 @@ name, ok, err := ui.Input(ctx, "Enter the release name", &copilot.UIInputOptions
})

// Full custom elicitation with a schema
result, err := ui.Elicitation(ctx, "Configure deployment", rpc.RequestedSchema{
Type: rpc.RequestedSchemaTypeObject,
Properties: map[string]rpc.Property{
"target": {Type: rpc.PropertyTypeString, Enum: []string{"staging", "production"}},
"force": {Type: rpc.PropertyTypeBoolean},
result, err := ui.Elicitation(ctx, "Configure deployment", copilot.ElicitationSchema{
Properties: map[string]any{
"target": map[string]any{"type": "string", "enum": []string{"staging", "production"}},
"force": map[string]any{"type": "boolean"},
},
Required: []string{"target"},
})
Expand All @@ -839,7 +838,7 @@ session, err := client.CreateSession(ctx, &copilot.SessionConfig{

// Return the user's response
return copilot.ElicitationResult{
Action: "accept",
Action: copilot.ElicitationActionAccept,
Content: map[string]any{"confirmed": true},
}, nil
},
Expand Down
4 changes: 2 additions & 2 deletions go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func TestListModelsWithCustomHandler(t *testing.T) {
Name: "My Custom Model",
Capabilities: ModelCapabilities{
Supports: ModelSupports{Vision: false, ReasoningEffort: false},
Limits: ModelLimits{MaxContextWindowTokens: 128000},
Limits: ModelLimits{MaxContextWindowTokens: Int(128000)},
},
},
}
Expand Down Expand Up @@ -899,7 +899,7 @@ func TestListModelsHandlerCachesResults(t *testing.T) {
Name: "Cached Model",
Capabilities: ModelCapabilities{
Supports: ModelSupports{Vision: false, ReasoningEffort: false},
Limits: ModelLimits{MaxContextWindowTokens: 128000},
Limits: ModelLimits{MaxContextWindowTokens: Int(128000)},
},
},
}
Expand Down
60 changes: 22 additions & 38 deletions go/internal/e2e/commands_and_elicitation_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
return copilot.ElicitationResult{Action: copilot.ElicitationActionAccept, Content: map[string]any{}}, nil
},
})
if err != nil {
Expand Down Expand Up @@ -481,7 +481,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
t.Errorf("Expected RequestedSchema to contain 'confirmed' property")
}
return copilot.ElicitationResult{
Action: "accept",
Action: copilot.ElicitationActionAccept,
Content: map[string]any{"confirmed": true},
}, nil
},
Expand All @@ -505,7 +505,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
OnElicitationRequest: func(ec copilot.ElicitationContext) (copilot.ElicitationResult, error) {
return copilot.ElicitationResult{Action: "decline"}, nil
return copilot.ElicitationResult{Action: copilot.ElicitationActionDecline}, nil
},
})
if err != nil {
Expand Down Expand Up @@ -534,7 +534,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
t.Errorf("Expected RequestedSchema to contain 'selection' property")
}
return copilot.ElicitationResult{
Action: "accept",
Action: copilot.ElicitationActionAccept,
Content: map[string]any{"selection": "beta"},
}, nil
},
Expand Down Expand Up @@ -568,7 +568,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
t.Errorf("Expected RequestedSchema to contain 'value' property")
}
return copilot.ElicitationResult{
Action: "accept",
Action: copilot.ElicitationActionAccept,
Content: map[string]any{"value": "typed value"},
}, nil
},
Expand Down Expand Up @@ -601,9 +601,9 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
ctx.ConfigureForTest(t)

responses := []copilot.ElicitationResult{
{Action: "accept", Content: map[string]any{"name": "Mona"}},
{Action: "decline"},
{Action: "cancel"},
{Action: copilot.ElicitationActionAccept, Content: map[string]any{"name": "Mona"}},
{Action: copilot.ElicitationActionDecline},
{Action: copilot.ElicitationActionCancel},
}
var idx int

Expand All @@ -625,9 +625,8 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
t.Fatalf("CreateSession failed: %v", err)
}

schema := rpc.UIElicitationSchema{
Type: rpc.UIElicitationSchemaTypeObject,
Properties: map[string]rpc.UIElicitationSchemaProperty{
schema := copilot.ElicitationSchema{
Properties: map[string]any{
"name": &rpc.UIElicitationSchemaPropertyString{},
},
Required: []string{"name"},
Expand All @@ -637,26 +636,26 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
if err != nil {
t.Fatalf("Elicitation accept call failed: %v", err)
}
if accept.Action != "accept" {
if accept.Action != copilot.ElicitationActionAccept {
t.Errorf("Expected accept.Action='accept', got %q", accept.Action)
}
if accept.Content == nil || fmt.Sprintf("%v", accept.Content["name"]) != "Mona" {
if accept.Content == nil || accept.Content["name"] != "Mona" {
t.Errorf("Expected accept.Content[name]='Mona', got %v", accept.Content)
}

decline, err := session.UI().Elicitation(t.Context(), "Name?", schema)
if err != nil {
t.Fatalf("Elicitation decline call failed: %v", err)
}
if decline.Action != "decline" {
if decline.Action != copilot.ElicitationActionDecline {
t.Errorf("Expected decline.Action='decline', got %q", decline.Action)
}

cancel, err := session.UI().Elicitation(t.Context(), "Name?", schema)
if err != nil {
t.Fatalf("Elicitation cancel call failed: %v", err)
}
if cancel.Action != "cancel" {
if cancel.Action != copilot.ElicitationActionCancel {
t.Errorf("Expected cancel.Action='cancel', got %q", cancel.Action)
}
})
Expand All @@ -681,7 +680,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
OnElicitationRequest: func(ec copilot.ElicitationContext) (copilot.ElicitationResult, error) {
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
return copilot.ElicitationResult{Action: copilot.ElicitationActionAccept, Content: map[string]any{}}, nil
},
})
if err != nil {
Expand All @@ -694,29 +693,14 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
})
}

// schemaHasProperty reports whether the elicitation schema map has a top-level
// property with the given name. RequestedSchema["properties"] is typically a
// map[string]rpc.UIElicitationSchemaProperty, but we accept any map[string]X.
func schemaHasProperty(schema map[string]any, name string) bool {
// schemaHasProperty reports whether the elicitation schema has a top-level
// property with the given name.
func schemaHasProperty(schema *copilot.ElicitationSchema, name string) bool {
if schema == nil {
return false
}
props, ok := schema["properties"]
if !ok || props == nil {
return false
}
switch p := props.(type) {
case map[string]any:
_, found := p[name]
return found
case map[string]rpc.UIElicitationSchemaProperty:
_, found := p[name]
return found
default:
// Fallback: marshal/unmarshal via reflection-friendly route.
// For test diagnostic purposes we treat unknown shapes as not found.
return false
}
_, found := schema.Properties[name]
return found
}

func TestUIElicitationMultiClientE2E(t *testing.T) {
Expand Down Expand Up @@ -776,7 +760,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
SuppressResumeEvent: true,
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
return copilot.ElicitationResult{Action: copilot.ElicitationActionAccept, Content: map[string]any{}}, nil
},
})
if err != nil {
Expand Down Expand Up @@ -836,7 +820,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
SuppressResumeEvent: true,
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
return copilot.ElicitationResult{Action: copilot.ElicitationActionAccept, Content: map[string]any{}}, nil
},
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go/internal/e2e/mcp_and_agents_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestMCPServersE2E(t *testing.T) {
mcpServers := map[string]copilot.MCPServerConfig{
"test-server": copilot.MCPStdioServerConfig{
Command: "git",
Tools: &[]string{"*"},
Tools: []string{"*"},
},
}

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestMCPServersE2E(t *testing.T) {
"env-echo": copilot.MCPStdioServerConfig{
Command: "node",
Args: []string{mcpServerPath},
Tools: &[]string{"*"},
Tools: []string{"*"},
Env: map[string]string{"TEST_SECRET": "hunter2"},
WorkingDirectory: mcpServerDir,
},
Expand Down
2 changes: 1 addition & 1 deletion go/internal/e2e/mcp_server_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func testMCPServers(t *testing.T, serverNames ...string) map[string]copilot.MCPS
mcpServers[serverName] = copilot.MCPStdioServerConfig{
Command: "node",
Args: []string{mcpServerPath},
Tools: &[]string{"*"},
Tools: []string{"*"},
WorkingDirectory: mcpServerDir,
}
}
Expand Down
3 changes: 1 addition & 2 deletions go/internal/e2e/pre_mcp_tool_call_hook_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ func TestPreMCPToolCallHookE2E(t *testing.T) {
metaEchoServer := filepath.Join(testHarnessDir, "test-mcp-meta-echo-server.mjs")

metaEchoConfig := func() map[string]copilot.MCPServerConfig {
tools := []string{"*"}
return map[string]copilot.MCPServerConfig{
"meta-echo": copilot.MCPStdioServerConfig{
Command: "node",
Args: []string{metaEchoServer},
WorkingDirectory: testHarnessDir,
Tools: &tools,
Tools: []string{"*"},
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions go/internal/e2e/rpc_tasks_and_handlers_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func TestRPCTasksAndHandlersE2E(t *testing.T) {
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
handlerContext <- ctx
return copilot.ElicitationResult{
Action: "accept",
Action: copilot.ElicitationActionAccept,
Content: map[string]any{
"answer": "from handler",
"confirmed": true,
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestRPCTasksAndHandlersE2E(t *testing.T) {
if ctx.SessionID != session.SessionID || ctx.Message != "Need details" {
t.Fatalf("Unexpected elicitation context: %+v", ctx)
}
if _, ok := ctx.RequestedSchema["properties"]; !ok {
if ctx.RequestedSchema == nil || ctx.RequestedSchema.Properties == nil {
t.Fatalf("Expected requested schema to include properties, got %+v", ctx.RequestedSchema)
}
if response.Action != rpc.UIElicitationResponseActionAccept {
Expand Down
Loading
Loading