Skip to content
Open
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
36 changes: 36 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@ Avoid logging it indiscriminately: server-provided data may contain sensitive
information. Its fields and data bytes are shared with the wrapped error; copy
them before mutation.

JSON-RPC read, decode, and response-send diagnostics are disabled by default.
Set `ClientOptions.ProtocolLogger` to a `*slog.Logger` to opt in for that client.
The transport emits error-level records with a static message and an `error`
attribute; the logger's handler controls the destination, filtering, and
redaction. There is no fallback to the global logger or process stdout/stderr.
`ClientOptions.LogLevel` configures runtime logging independently.

For example, explicitly capture diagnostics in memory:

```go
package main

import (
"bytes"
"log/slog"

copilot "github.com/github/copilot-sdk/go"
)

func main() {
var diagnostics bytes.Buffer
client := copilot.NewClient(&copilot.ClientOptions{
ProtocolLogger: slog.New(slog.NewJSONHandler(&diagnostics, nil)),
})
_ = client
}
```

Opted-in diagnostics can contain sensitive peer-provided text; the SDK does not
redact arbitrary secrets. Apply your application's redaction and retention
policy, for example with `slog.HandlerOptions.ReplaceAttr` for the `error`
attribute. Custom handlers must support concurrent calls, as required by `slog`.
Errors returned by SDK calls remain unchanged and also require deliberate
handling before logging.

## Skill providers (experimental)

Use `SessionConfig.SkillProvider` or `ResumeSessionConfig.SkillProvider` to
Expand Down Expand Up @@ -354,6 +389,7 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec
- `ExtensionLaunchProvider` (ExtensionLaunchProvider): Experimental connection-level resolver for extension launch profiles. `Start` installs the reverse-RPC handler and registers the provider before sessions can be created.
- `InstallationConfirmationHandler` (InstallationConfirmationHandler): Experimental connection-global human review for `installations.confirm`. Receives the typed request, a per-request cancellation context and a separate connection-closed signal, then returns an explicit decision. Does not enable installation capabilities.
- `LogLevel` (string): Log level. When empty (default), the runtime uses its own default level (the SDK does not pass `--log-level`).
- `ProtocolLogger` (\*slog.Logger): Optional per-client JSON-RPC diagnostics logger (default: nil, disabled). Independent of `LogLevel`; error details can contain sensitive peer-provided text. See [JSON-RPC errors](#json-rpc-errors).
- `Env` ([]string): Environment variables for the runtime process (default: inherits from current process)
- `GitHubToken` (string): GitHub token for authentication. When provided, takes priority over other auth methods.
- `UseLoggedInUser` (\*bool): Whether to use logged-in user for authentication (default: true, but false when `GitHubToken` is provided). Cannot be used with `URIConnection`.
Expand Down
3 changes: 3 additions & 0 deletions go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,7 @@ func (c *Client) startCLIServer(ctx context.Context) error {

// Create JSON-RPC client immediately
c.client = jsonrpc2.NewClient(stdin, stdout)
c.client.SetLogger(c.options.ProtocolLogger)
c.client.SetProcessDone(c.processDone, c.processErrorPtr)
c.client.SetOnClose(c.handleConnectionClose)
c.RPC = rpc.NewServerRPC(c.client)
Expand Down Expand Up @@ -2443,6 +2444,7 @@ func (c *Client) startInProcess(ctx context.Context) error {
}

c.client = jsonrpc2.NewClient(host.Writer(), host.Reader())
c.client.SetLogger(c.options.ProtocolLogger)
c.client.SetOnClose(c.handleConnectionClose)
c.RPC = rpc.NewServerRPC(c.client)
c.internalRPC = rpc.NewInternalServerRPC(c.client)
Expand Down Expand Up @@ -2594,6 +2596,7 @@ func (c *Client) connectViaTCP(ctx context.Context) error {

// Create JSON-RPC client with the connection
c.client = jsonrpc2.NewClient(conn, conn)
c.client.SetLogger(c.options.ProtocolLogger)
if c.processDone != nil {
c.client.SetProcessDone(c.processDone, c.processErrorPtr)
}
Expand Down
Loading
Loading