You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4ac667c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/Squad.Agents.AI/README.md
+80-7Lines changed: 80 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,10 @@
8
8
9
9
Public surface in this preview:
10
10
11
-
-`SquadAgent` — sealed `AIAgent` wrapper over the Copilot-backed inner agent.
12
-
-`SquadAgentOptions` — team root, CLI path/args, environment, token, logging, and instruction settings.
11
+
-`SquadAgent` — sealed `AIAgent` wrapper over the Copilot-backed inner agent. Supports both non-streaming and streaming via `RunStreamingAsync`.
12
+
-`SquadAgentOptions` — team root, CLI path/args, environment, token, logging, instruction settings, and a `ConfigureCopilotClient` delegate for advanced SDK customization.
13
13
-`SquadConnectionFactory` — parses PATH or `squad://` connection strings into options.
14
-
-`SquadServiceCollectionExtensions` — registers `SquadAgent` and base `AIAgent` in DI.
14
+
-`SquadServiceCollectionExtensions` — registers `SquadAgent` and base `AIAgent` in DI, with standard and keyed overloads.
@@ -56,13 +56,77 @@ var response = await squad.RunAsync("What can this Squad team do?", session);
56
56
Console.WriteLine(response.Text);
57
57
```
58
58
59
+
## Streaming
60
+
61
+
`SquadAgent` supports streaming via the MAF `RunStreamingAsync` method. The inner Copilot-backed agent streams response updates as they arrive from the CLI process:
varresponse=awaitagent.RunAsync("What's the latest?", session);
93
+
returnresponse.Text;
94
+
});
95
+
```
96
+
97
+
Keyed registrations include `AddKeyedSquadAgent` overloads for service key, optional connection-string name, and lifetime. Keyed and non-keyed registrations can coexist.
98
+
99
+
## Advanced: ConfigureCopilotClient (BYOK)
100
+
101
+
Use `ConfigureCopilotClient` to customize the underlying `CopilotClientOptions` after Squad applies its standard values. This is the extension point for injecting custom environment variables, providing a BYOK token, or tuning SDK settings:
102
+
103
+
```csharp
104
+
builder.Services.AddSquadAgent(o=>
105
+
{
106
+
o.SquadFolderPath=@"C:\team";
107
+
o.ConfigureCopilotClient=clientOpts=>
108
+
{
109
+
// Inject a BYOK token from your own credential store
> **Routing guard:** Squad enforces a hard routing gate — if the delegate changes `Cwd`, `CliPath`, or `CliArgs`, the original values are restored and a warning is logged. Configure these via `SquadAgentOptions` instead.
122
+
59
123
## GitHub Copilot authentication
60
124
61
125
The default path mirrors the base GitHub Copilot SDK examples: leave `GitHubToken` and `GitHubTokenProvider` unset, then run with a locally signed-in GitHub Copilot user. For local development, sign in before running the app, for example with `gh auth login`, the Copilot CLI sign-in flow, or a Copilot-supported local sign-in that the SDK runtime can access.
62
126
63
127
The SDK documents the credential priority order in [Authenticate Copilot SDK](https://github.com/github/copilot-sdk/blob/main/docs/auth/authenticate.md) and the broader [authentication overview](https://github.com/github/copilot-sdk/blob/main/docs/auth/index.md). Explicit tokens and environment variables are supported by the SDK, but they are not required for the minimal happy path.
64
128
65
-
Use `GitHubTokenProvider` only when the host owns token retrieval, such as Key Vault, managed identity, or CI secret flow scenarios. Use `GitHubToken` only when you already have a Copilot-supported token in process and cannot use a provider callback. In both cases, treat these as advanced escape hatches and never hardcode tokens.
129
+
Use `GitHubTokenProvider` only when the host owns token retrieval, such as Key Vault, managed identity, or CI secret flow scenarios. Use `GitHubToken` only when you already have a Copilot-supported token in process and cannot use a provider callback. Use `ConfigureCopilotClient` when you need full control over the SDK's `CopilotClientOptions`, including BYOK token injection.
|`SquadFolderPath`| Squad team root; PATH connection strings set this and `Cwd`. |
87
151
|`CliPath` / `CliArgs`| Override the Copilot CLI executable and add extra CLI flags. |
88
152
|`Cwd`| Working directory for the Copilot CLI process; defaults to `SquadFolderPath`. |
89
-
|`Environment`| Additional environment variables for the CLI process. Avoid user-controlled values. |
90
-
|`GitHubToken`| Advanced direct token escape hatch; redacted by `ToString()`. |
153
+
|`Environment`| Additional environment variables for the CLI process. Excluded from JSON serialization; token-pattern keys are redacted in `ToString()`. |
154
+
|`GitHubToken`| Advanced direct token escape hatch; excluded from JSON serialization and redacted by `ToString()`. |
91
155
|`GitHubTokenProvider`| Advanced callback for secure token retrieval; wins over `GitHubToken`. |
156
+
|`ConfigureCopilotClient`| Advanced delegate for customizing `CopilotClientOptions`. Routing properties are guarded; see BYOK section. |
92
157
|`TraceEvents`| Enables verbose SDK logging and emits a startup warning when enabled. |
93
158
|`AgentName`| Display name for the resulting `AIAgent`; defaults to `Squad`. |
94
159
|`Instructions`| Optional system instructions passed to the inner Copilot agent. |
95
160
161
+
## Security
162
+
163
+
-**Credential redaction:**`GitHubToken` and `Environment` values whose keys match `*TOKEN*`, `*KEY*`, `*SECRET*`, `*HMAC*`, `*PASSWORD*`, or `*CREDENTIAL*` are always redacted in `ToString()` output.
164
+
-**JSON safety:**`GitHubToken`, `GitHubTokenProvider`, `Environment`, and `ConfigureCopilotClient` are marked `[JsonIgnore]` and will not appear in JSON serialization output.
165
+
-**Routing guard:** The `ConfigureCopilotClient` delegate cannot change `Cwd`, `CliPath`, or `CliArgs` — changes are silently restored to prevent routing the agent to an unintended CLI process.
166
+
-**TraceEvents warning:** Enabling `TraceEvents` logs a startup warning because verbose SDK traces may include sensitive operational details.
167
+
-**Avoid hardcoded tokens:** Never embed tokens in source code. Use `GitHubTokenProvider` for production token retrieval from Key Vault, managed identity, or similar secure stores.
168
+
96
169
## Notes for v0.1-preview
97
170
98
171
- Default DI lifetime is scoped. An overload accepts any `ServiceLifetime`.
99
-
- DI registers both `SquadAgent` and base `AIAgent`.
172
+
- DI registers both `SquadAgent` and base `AIAgent` (non-keyed). Keyed DI registers both `SquadAgent` and `AIAgent` under the same key.
100
173
- Multi-targeting and Aspire telemetry remain candidates for a later preview.
101
174
- The package does not validate that `SquadFolderPath` exists; consumers should validate their deployment paths.
102
175
-`TraceEvents` can log sensitive operational details. Keep it off unless debugging.
@@ -46,7 +57,7 @@ public sealed class SquadAgentOptions
46
57
/// The value is ignored by JSON serialization and redacted by <see cref="ToString"/>, but still lives in the options object.
47
58
/// Prefer leaving this unset for local signed-in user authentication; use <see cref="GitHubTokenProvider"/> for production hosts that retrieve tokens dynamically.
48
59
/// </remarks>
49
-
[System.Text.Json.Serialization.JsonIgnore]
60
+
[JsonIgnore]
50
61
publicstring?GitHubToken{get;set;}
51
62
52
63
/// <summary>
@@ -55,6 +66,7 @@ public sealed class SquadAgentOptions
55
66
/// <remarks>
56
67
/// When set, this provider takes precedence over <see cref="GitHubToken"/>.
0 commit comments