Skip to content

Commit 44ec87f

Browse files
devm33Copilot
andauthored
Forward enableManagedSettings in session.create (all SDKs) (#1925)
* Forward selfFetchManagedSettings in session.create across all SDKs Threads an optional `selfFetchManagedSettings` flag from the SDK session config through the `session.create` / `resumeSession` wire calls, so consumers can opt the runtime into self-fetching enterprise managed settings (bypass-permissions policy) at session bootstrap. Extends the Node.js change from #1846 to every language SDK: - nodejs: `selfFetchManagedSettings?: boolean` on `SessionConfigBase`, forwarded in create/resume payloads. - python: `self_fetch_managed_settings` kwarg on create/resume, forwarded as `selfFetchManagedSettings`. - go: `SelfFetchManagedSettings *bool` on `SessionConfig` / `ResumeSessionConfig` and wire structs. - dotnet: `SelfFetchManagedSettings` on `SessionConfigBase` (+ clone) and wire records. - rust: `self_fetch_managed_settings: Option<bool>` with builders and wire structs. - java: `selfFetchManagedSettings` on config, request classes, and builder. Purely additive and opt-in; unset behaves exactly as before. Requires the session `gitHubToken`; the runtime is expected to reject session creation when omitted (fail-closed). Runtime enforcement lives in the runtime PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Rename selfFetchManagedSettings to enableManagedSettings Follows up runtime rename github/copilot-agent-runtime#12118, which renamed the `session.create` opt-in parameter `selfFetchManagedSettings` to `enableManagedSettings` (wire name `enableManagedSettings`). The new name reads as an "enable managed-settings enforcement" switch rather than describing the fetch mechanism. Renames the field/param across every SDK to match the new wire contract: nodejs, python, go, dotnet, rust, java. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix gofmt and rustfmt formatting after field rename The sed-based rename left misaligned struct-tag whitespace in go/types.go (gofmt) and over-expanded Debug .field() blocks in rust/src/types.rs (rustfmt). Reformat with the source formatters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 953932a commit 44ec87f

14 files changed

Lines changed: 225 additions & 0 deletions

File tree

dotnet/src/Client.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
11471147
Models: config.Models,
11481148
ToolFilterPrecedence: toolFilter.ToolFilterPrecedence,
11491149
ExpAssignments: config.ExpAssignments,
1150+
EnableManagedSettings: config.EnableManagedSettings,
11501151
EnableGitHubTelemetryForwarding: _options.OnGitHubTelemetry != null ? true : null);
11511152

11521153
var rpcTimestamp = Stopwatch.GetTimestamp();
@@ -1357,6 +1358,7 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
13571358
Models: config.Models,
13581359
ToolFilterPrecedence: toolFilter.ToolFilterPrecedence,
13591360
ExpAssignments: config.ExpAssignments,
1361+
EnableManagedSettings: config.EnableManagedSettings,
13601362
EnableGitHubTelemetryForwarding: _options.OnGitHubTelemetry != null ? true : null);
13611363

13621364
var rpcTimestamp = Stopwatch.GetTimestamp();
@@ -2696,6 +2698,7 @@ internal record CreateSessionRequest(
26962698
IList<ProviderModelConfig>? Models = null,
26972699
OptionsUpdateToolFilterPrecedence? ToolFilterPrecedence = null,
26982700
[property: JsonPropertyName("expAssignments")] JsonElement? ExpAssignments = null,
2701+
[property: JsonPropertyName("enableManagedSettings")] bool? EnableManagedSettings = null,
26992702
bool? EnableGitHubTelemetryForwarding = null);
27002703
#pragma warning restore GHCP001
27012704

@@ -2796,6 +2799,7 @@ internal record ResumeSessionRequest(
27962799
IList<ProviderModelConfig>? Models = null,
27972800
OptionsUpdateToolFilterPrecedence? ToolFilterPrecedence = null,
27982801
[property: JsonPropertyName("expAssignments")] JsonElement? ExpAssignments = null,
2802+
[property: JsonPropertyName("enableManagedSettings")] bool? EnableManagedSettings = null,
27992803
bool? EnableGitHubTelemetryForwarding = null);
28002804
#pragma warning restore GHCP001
28012805

dotnet/src/Types.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,6 +2861,7 @@ protected SessionConfigBase(SessionConfigBase? other)
28612861
GitHubToken = other.GitHubToken;
28622862
RemoteSession = other.RemoteSession;
28632863
ExpAssignments = other.ExpAssignments;
2864+
EnableManagedSettings = other.EnableManagedSettings;
28642865
#pragma warning disable GHCP001
28652866
Canvases = other.Canvases is not null ? [.. other.Canvases] : null;
28662867
RequestCanvasRenderer = other.RequestCanvasRenderer;
@@ -3285,6 +3286,16 @@ protected SessionConfigBase(SessionConfigBase? other)
32853286
[EditorBrowsable(EditorBrowsableState.Never)]
32863287
public JsonElement? ExpAssignments { get; set; }
32873288

3289+
/// <summary>
3290+
/// Opt-in: when <c>true</c>, the runtime self-fetches enterprise managed
3291+
/// settings (bypass-permissions policy) at session bootstrap using the
3292+
/// session's <see cref="GitHubToken"/>. Requires <see cref="GitHubToken"/> to
3293+
/// be set; if omitted, the runtime is expected to reject session creation
3294+
/// (fail-closed). When unset, behaves exactly as before. Serialized on the
3295+
/// wire as <c>enableManagedSettings</c>.
3296+
/// </summary>
3297+
public bool? EnableManagedSettings { get; set; }
3298+
32883299
#pragma warning disable GHCP001
32893300
/// <summary>
32903301
/// Canvas declarations advertised by this connection. The runtime forwards

go/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
732732
req.ExtensionSDKPath = config.ExtensionSDKPath
733733
req.ExtensionInfo = config.ExtensionInfo
734734
req.ExpAssignments = config.ExpAssignments
735+
req.EnableManagedSettings = config.EnableManagedSettings
735736

736737
if len(config.Commands) > 0 {
737738
cmds := make([]wireCommand, 0, len(config.Commands))
@@ -1095,6 +1096,7 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
10951096
req.ExtensionSDKPath = config.ExtensionSDKPath
10961097
req.ExtensionInfo = config.ExtensionInfo
10971098
req.ExpAssignments = config.ExpAssignments
1099+
req.EnableManagedSettings = config.EnableManagedSettings
10981100
if config.OnPermissionRequest != nil {
10991101
req.RequestPermission = Bool(true)
11001102
}

go/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,12 @@ type SessionConfig struct {
12471247
// intended for trusted out-of-process integrators, and is not intended for
12481248
// general external use.
12491249
ExpAssignments any
1250+
// EnableManagedSettings, when set to true, opts the runtime into
1251+
// self-fetching enterprise managed settings (bypass-permissions policy) at
1252+
// session bootstrap using the session's GitHubToken. Requires GitHubToken to
1253+
// be set; if omitted, the runtime is expected to reject session creation
1254+
// (fail-closed). Unset behaves exactly as before.
1255+
EnableManagedSettings *bool
12501256
}
12511257

12521258
// ToolDefer controls whether a tool may be deferred (loaded lazily via tool
@@ -1668,6 +1674,10 @@ type ResumeSessionConfig struct {
16681674
// intended for trusted out-of-process integrators, and is not intended for
16691675
// general external use.
16701676
ExpAssignments any
1677+
// EnableManagedSettings injects the same opt-in flag on resume. See
1678+
// SessionConfig.EnableManagedSettings. Re-supply on resume so the runtime
1679+
// re-applies the managed-settings self-fetch after a CLI process restart.
1680+
EnableManagedSettings *bool
16711681
}
16721682

16731683
// ProviderTokenArgs carries the context passed to a [BearerTokenProvider] callback
@@ -2122,6 +2132,7 @@ type createSessionRequest struct {
21222132
ExtensionSDKPath *string `json:"extensionSdkPath,omitempty"`
21232133
ExtensionInfo *ExtensionInfo `json:"extensionInfo,omitempty"`
21242134
ExpAssignments any `json:"expAssignments,omitempty"`
2135+
EnableManagedSettings *bool `json:"enableManagedSettings,omitempty"`
21252136
Traceparent string `json:"traceparent,omitempty"`
21262137
Tracestate string `json:"tracestate,omitempty"`
21272138
}
@@ -2211,6 +2222,7 @@ type resumeSessionRequest struct {
22112222
ExtensionSDKPath *string `json:"extensionSdkPath,omitempty"`
22122223
ExtensionInfo *ExtensionInfo `json:"extensionInfo,omitempty"`
22132224
ExpAssignments any `json:"expAssignments,omitempty"`
2225+
EnableManagedSettings *bool `json:"enableManagedSettings,omitempty"`
22142226
Traceparent string `json:"traceparent,omitempty"`
22152227
Tracestate string `json:"tracestate,omitempty"`
22162228
}

java/src/main/java/com/github/copilot/SessionRequestBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess
185185
request.setRemoteSession(config.getRemoteSession());
186186
request.setCloud(config.getCloud());
187187
request.setExpAssignments(config.getExpAssignments());
188+
config.getEnableManagedSettings().ifPresent(request::setEnableManagedSettings);
188189

189190
return request;
190191
}
@@ -306,6 +307,7 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo
306307
request.setGitHubToken(config.getGitHubToken());
307308
request.setRemoteSession(config.getRemoteSession());
308309
request.setExpAssignments(config.getExpAssignments());
310+
config.getEnableManagedSettings().ifPresent(request::setEnableManagedSettings);
309311

310312
return request;
311313
}

java/src/main/java/com/github/copilot/rpc/CreateSessionRequest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ public final class CreateSessionRequest {
212212
@JsonProperty("expAssignments")
213213
private JsonNode expAssignments;
214214

215+
@JsonProperty("enableManagedSettings")
216+
@JsonInclude(JsonInclude.Include.NON_NULL)
217+
private Boolean enableManagedSettings;
218+
215219
/** Gets the model name. @return the model */
216220
public String getModel() {
217221
return model;
@@ -966,4 +970,27 @@ public JsonNode getExpAssignments() {
966970
public void setExpAssignments(JsonNode expAssignments) {
967971
this.expAssignments = expAssignments;
968972
}
973+
974+
/**
975+
* Gets the self-fetch managed settings flag. @return the flag, or {@code null}
976+
* if not set
977+
*/
978+
public Boolean getEnableManagedSettings() {
979+
return enableManagedSettings;
980+
}
981+
982+
/**
983+
* Sets the self-fetch managed settings flag. @param enableManagedSettings the
984+
* flag
985+
*/
986+
public void setEnableManagedSettings(boolean enableManagedSettings) {
987+
this.enableManagedSettings = enableManagedSettings;
988+
}
989+
990+
/**
991+
* Clears the enableManagedSettings setting, reverting to the default behavior.
992+
*/
993+
public void clearEnableManagedSettings() {
994+
this.enableManagedSettings = null;
995+
}
969996
}

java/src/main/java/com/github/copilot/rpc/ResumeSessionConfig.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public class ResumeSessionConfig {
102102
private String gitHubToken;
103103
private String remoteSession;
104104
private JsonNode expAssignments;
105+
private Boolean enableManagedSettings;
105106

106107
/**
107108
* Gets the AI model to use.
@@ -1745,6 +1746,36 @@ public ResumeSessionConfig setExpAssignments(JsonNode expAssignments) {
17451746
return this;
17461747
}
17471748

1749+
/**
1750+
* Gets whether the runtime self-fetches enterprise managed settings at session
1751+
* bootstrap on resume.
1752+
*
1753+
* @return an {@link java.util.Optional} containing {@code true} to opt into
1754+
* self-fetching managed settings, or {@link java.util.Optional#empty()}
1755+
* to use the default behavior
1756+
*/
1757+
@JsonIgnore
1758+
public Optional<Boolean> getEnableManagedSettings() {
1759+
return Optional.ofNullable(enableManagedSettings);
1760+
}
1761+
1762+
/**
1763+
* Opts the runtime into self-fetching enterprise managed settings on resume.
1764+
* <p>
1765+
* See {@link SessionConfig#setEnableManagedSettings(boolean)} for details.
1766+
* Re-supply on resume so the runtime re-applies the managed-settings self-fetch
1767+
* after a CLI process restart. Serialized on the wire as
1768+
* {@code enableManagedSettings}.
1769+
*
1770+
* @param enableManagedSettings
1771+
* {@code true} to opt into self-fetching managed settings
1772+
* @return this config for method chaining
1773+
*/
1774+
public ResumeSessionConfig setEnableManagedSettings(boolean enableManagedSettings) {
1775+
this.enableManagedSettings = enableManagedSettings;
1776+
return this;
1777+
}
1778+
17481779
/**
17491780
* Creates a shallow clone of this {@code ResumeSessionConfig} instance.
17501781
* <p>
@@ -1819,6 +1850,7 @@ public ResumeSessionConfig clone() {
18191850
copy.gitHubToken = this.gitHubToken;
18201851
copy.remoteSession = this.remoteSession;
18211852
copy.expAssignments = this.expAssignments;
1853+
copy.enableManagedSettings = this.enableManagedSettings;
18221854
return copy;
18231855
}
18241856
}

java/src/main/java/com/github/copilot/rpc/ResumeSessionRequest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ public final class ResumeSessionRequest {
214214
@JsonProperty("expAssignments")
215215
private JsonNode expAssignments;
216216

217+
@JsonProperty("enableManagedSettings")
218+
@JsonInclude(JsonInclude.Include.NON_NULL)
219+
private Boolean enableManagedSettings;
220+
217221
/** Gets the session ID. @return the session ID */
218222
public String getSessionId() {
219223
return sessionId;
@@ -981,4 +985,27 @@ public JsonNode getExpAssignments() {
981985
public void setExpAssignments(JsonNode expAssignments) {
982986
this.expAssignments = expAssignments;
983987
}
988+
989+
/**
990+
* Gets the self-fetch managed settings flag. @return the flag, or {@code null}
991+
* if not set
992+
*/
993+
public Boolean getEnableManagedSettings() {
994+
return enableManagedSettings;
995+
}
996+
997+
/**
998+
* Sets the self-fetch managed settings flag. @param enableManagedSettings the
999+
* flag
1000+
*/
1001+
public void setEnableManagedSettings(boolean enableManagedSettings) {
1002+
this.enableManagedSettings = enableManagedSettings;
1003+
}
1004+
1005+
/**
1006+
* Clears the enableManagedSettings setting, reverting to the default behavior.
1007+
*/
1008+
public void clearEnableManagedSettings() {
1009+
this.enableManagedSettings = null;
1010+
}
9841011
}

java/src/main/java/com/github/copilot/rpc/SessionConfig.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public class SessionConfig {
103103
private String remoteSession;
104104
private CloudSessionOptions cloud;
105105
private JsonNode expAssignments;
106+
private Boolean enableManagedSettings;
106107

107108
/**
108109
* Gets the custom session ID.
@@ -1876,6 +1877,38 @@ public SessionConfig setExpAssignments(JsonNode expAssignments) {
18761877
return this;
18771878
}
18781879

1880+
/**
1881+
* Gets whether the runtime self-fetches enterprise managed settings at session
1882+
* bootstrap.
1883+
*
1884+
* @return an {@link java.util.Optional} containing {@code true} to opt into
1885+
* self-fetching managed settings, or {@link java.util.Optional#empty()}
1886+
* to use the default behavior
1887+
*/
1888+
@JsonIgnore
1889+
public Optional<Boolean> getEnableManagedSettings() {
1890+
return Optional.ofNullable(enableManagedSettings);
1891+
}
1892+
1893+
/**
1894+
* Opts the runtime into self-fetching enterprise managed settings
1895+
* (bypass-permissions policy) at session bootstrap.
1896+
* <p>
1897+
* When {@code true}, the runtime self-fetches enterprise managed settings using
1898+
* the session's {@link #getGitHubToken() gitHubToken}. Requires
1899+
* {@code gitHubToken} to be set; if omitted, the runtime is expected to reject
1900+
* session creation (fail-closed). When unset, behaves exactly as before.
1901+
* Serialized on the wire as {@code enableManagedSettings}.
1902+
*
1903+
* @param enableManagedSettings
1904+
* {@code true} to opt into self-fetching managed settings
1905+
* @return this config instance for method chaining
1906+
*/
1907+
public SessionConfig setEnableManagedSettings(boolean enableManagedSettings) {
1908+
this.enableManagedSettings = enableManagedSettings;
1909+
return this;
1910+
}
1911+
18791912
/**
18801913
* Creates a shallow clone of this {@code SessionConfig} instance.
18811914
* <p>
@@ -1955,6 +1988,7 @@ public SessionConfig clone() {
19551988
copy.remoteSession = this.remoteSession;
19561989
copy.cloud = this.cloud;
19571990
copy.expAssignments = this.expAssignments;
1991+
copy.enableManagedSettings = this.enableManagedSettings;
19581992
return copy;
19591993
}
19601994
}

nodejs/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ export class CopilotClient {
14721472
remoteSession: config.remoteSession,
14731473
cloud: config.cloud,
14741474
expAssignments: config.expAssignments,
1475+
enableManagedSettings: config.enableManagedSettings,
14751476
});
14761477

14771478
const {
@@ -1683,6 +1684,7 @@ export class CopilotClient {
16831684
remoteSession: config.remoteSession,
16841685
openCanvases: config.openCanvases,
16851686
expAssignments: config.expAssignments,
1687+
enableManagedSettings: config.enableManagedSettings,
16861688
});
16871689

16881690
const { workspacePath, capabilities, openCanvases } = response as {

0 commit comments

Comments
 (0)