copilot-sdk-supercharged 2.5.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cec80ffc10ca68337bad45a06d83ca887f5c933fb7d5c0188abe4ea059ff4a84
4
- data.tar.gz: 32bbe2baaed56cec8db0aebc1fe847d2df2cf3a41db3f2ab4b81e61ec98ea602
3
+ metadata.gz: 3f93794617e52dec15bf7b1f05df9504c05776c43eb5bf7ed0d3bd5775053fb5
4
+ data.tar.gz: 0ef5dfa951027a9af13175839d2cc2b3b3add73d7147ad7d159fe9b2d27e84b3
5
5
  SHA512:
6
- metadata.gz: 52ae20795b484d1809c41e24e9483dbde5a9182fddd0be53471f9af560e063f9cb08701111729d2e92e5db3610da221a956c2f36febca77ab146c01ad8ebaa76
7
- data.tar.gz: 333105bc409e00b061de952465137f569f679da1b398764f7edd103b97983f4a5c45dbb3d942812125271d57fbc15a29699f61484588c6edcbfb8d60cbde98b3
6
+ metadata.gz: 0bbefdd1b123e84a8b44cf7d80135c2965af31b9c870755b4ffeff859c4e0d2e74aa7c10223af30a605ad0fde1ccd461efa1f6768884fff23cebc4a5d4aebe70
7
+ data.tar.gz: 31af3e29d6576b9de4a4e822826146381ecb3f055a1deacbc96bfb8ba8d77ef1b926d1c6b19b2cb794007d5b2aeff06327222dda68d324897ee75f9d8a3eda90
data/README.md CHANGED
@@ -52,6 +52,137 @@ session.destroy
52
52
  client.stop
53
53
  ```
54
54
 
55
+ ## What's New in v3.0.0
56
+
57
+ This release speaks **SDK protocol v4**, the protocol of the Microsoft Copilot SDK 2.0 runtime. It requires **Copilot CLI 1.0.113 or newer**; older CLIs are rejected at `start` with an `SDK protocol version mismatch` error.
58
+
59
+ Existing options keep working: you keep passing the same flat keywords to `create_session` / `resume_session`, and the SDK translates them into the grouped v4 wire payload (for example `streaming:` becomes `events.streaming`, `on_permission_request:` becomes `permissions.request`). A legacy single `provider:` (BYOK) is translated into a named `"default"` provider with Copilot API models disabled, matching v1 behavior.
60
+
61
+ ### Named BYOK providers
62
+
63
+ Register several provider connections and model definitions, then select a model with `"provider/id"`:
64
+
65
+ ```ruby
66
+ gateway = Copilot::NamedProviderConfig.new(
67
+ name: "gateway", type: "openai",
68
+ base_url: "https://models.example.com/v1",
69
+ api_key_command: "print-model-key"
70
+ )
71
+
72
+ session = client.create_session(
73
+ model: "gateway/chat",
74
+ providers: [gateway],
75
+ models: [
76
+ Copilot::ProviderModelConfig.new(provider: "gateway", id: "chat", model_id: "gpt-4o", max_output_tokens: 4096)
77
+ ],
78
+ capi: Copilot::CapiConfig.new(enabled: false) # BYOK-only catalog
79
+ )
80
+
81
+ # Route unqualified model names through a connection, and clear it again on resume
82
+ session = client.create_session(model: "deployment", providers: [gateway], default_provider: "gateway",
83
+ capi: { enabled: false })
84
+ client.resume_session(session.session_id, model: "gpt-5.4", capi: { enabled: true }, default_provider: nil)
85
+ ```
86
+
87
+ ### Idempotent tools
88
+
89
+ ```ruby
90
+ lookup = Copilot.define_tool(name: "lookup_order", description: "Look up an order", idempotent: true) do |args, _inv|
91
+ "Order #{args['id']} shipped"
92
+ end
93
+ ```
94
+
95
+ ### Client turn IDs
96
+
97
+ ```ruby
98
+ session.send_and_wait(prompt: "Summarize the diff", client_turn_id: "turn-42")
99
+ ```
100
+
101
+ ### Client mode
102
+
103
+ `mode: "coding-agent"` (the default) keeps today's behavior. `mode: "empty"` requires every session to set `available_tools:` and applies conservative defaults (no telemetry, in-memory OAuth and embedding storage, no cross-session store or memory, no on-demand instruction discovery, repository hooks or host git operations). Values you pass win. `"copilot-cli"` is accepted as an alias of `"coding-agent"`.
104
+
105
+ ```ruby
106
+ client = Copilot::CopilotClient.new(mode: Copilot::ClientMode::EMPTY)
107
+ session = client.create_session(model: "gpt-5.4", available_tools: ["view"])
108
+ ```
109
+
110
+ ### Shell output events
111
+
112
+ ```ruby
113
+ session.on(Copilot::SessionEventType::TOOL_SHELL_OUTPUT) do |event|
114
+ chunk = Copilot::ShellOutputData.from_hash(event.data)
115
+ print chunk.text # chunk.stream is "stdout", "stderr" or nil (stdout)
116
+ end
117
+ ```
118
+
119
+ ### Shell authentication
120
+
121
+ Answer credential prompts from shell programs (for example `git` asking for a password). Return `ShellAuthenticationResponse.accept(value)` or `.cancel`; failures and malformed answers cancel. The answer is never logged.
122
+
123
+ ```ruby
124
+ session = client.create_session(
125
+ on_shell_authentication_request: ->(request, _ctx) {
126
+ # request.program, request.prompt, request.input_kind ("secret", "text" or "confirm"), request.command, request.cwd
127
+ Copilot::ShellAuthenticationResponse.accept(fetch_secret(request.program))
128
+ }
129
+ )
130
+ ```
131
+
132
+ ### Memory store
133
+
134
+ ```ruby
135
+ session = client.create_session(
136
+ store_memory: ->(memory, _ctx) {
137
+ # memory is a Copilot::StoredMemory (subject, fact, citations, reason)
138
+ MyMemoryDb.save(memory.subject, memory.fact)
139
+ }
140
+ )
141
+ ```
142
+
143
+ ### Network callbacks
144
+
145
+ Resolve proxies and answer proxy authentication challenges from your application. Tokens and passwords are never logged.
146
+
147
+ ```ruby
148
+ client = Copilot::CopilotClient.new(
149
+ network: Copilot::NetworkConfig.new(
150
+ scope: Copilot::NetworkScope::RUNTIME,
151
+ resolve_proxy: ->(request) { request.url.start_with?("https://internal") ? "DIRECT" : "PROXY proxy.example:8080" },
152
+ authenticate_basic: ->(request) { request.previous_rejected ? nil : { username: "svc", password: ENV["PROXY_PASSWORD"] } },
153
+ authenticate_negotiate: ->(request) { kerberos_token_for(request.spn) }
154
+ )
155
+ )
156
+ ```
157
+
158
+ ### Policy helper failures
159
+
160
+ ```ruby
161
+ begin
162
+ client.create_session(model: "gpt-5.4")
163
+ rescue Copilot::JsonRpcError => e
164
+ if (failure = e.policy_helper_failure)
165
+ warn "Policy helper failed (#{failure.category}, #{failure.failure_mode}): #{failure.message}"
166
+ end
167
+ raise
168
+ end
169
+ ```
170
+
171
+ ### Permission mode refusal reason
172
+
173
+ ```ruby
174
+ result = session.set_permission_mode(Copilot::PermissionMode::ALLOW_ALL)
175
+ warn "Blocked by managed policy" if result.reason == Copilot::PermissionModeRefusalReason::MANAGED_POLICY
176
+ ```
177
+
178
+ The v2.6.0 features (client info, Auto routing tier, ask-user variant, GitHub token provider, sandbox bypass, feature flags, session detach, message source, managed settings cache clear, policy helper recheck, model allowlist, OAuth client metadata URL, max output tokens override, structured output, agent and hook directories, working directory trust, transcript recovery, image generation config, Autopilot options, subagent lifecycle hooks and BYOK `api_key_command`) are unchanged and are sent in their v4 groups.
179
+
180
+ ### Known limitations
181
+
182
+ * The runtime-supervised AHP host (`startAhpHost`, `ahp.*` / `host.*` RPC families) is not available: it is an experimental upstream surface that depends on the runtime's in-process hosting library.
183
+ * In-process runtime hosting is not the default connection: the Ruby SDK keeps spawning the CLI (or connecting over TCP with `cli_url`).
184
+ * A shell authentication handler runs on its own thread. When the runtime cancels the prompt, the SDK answers `cancel` immediately, but the handler thread keeps running until it returns (its answer is discarded).
185
+
55
186
  ## Connecting to an External Server
56
187
 
57
188
  Instead of spawning a CLI process, connect to an already-running server:
@@ -391,17 +522,21 @@ session.send_and_wait(
391
522
  | `delete_session(id)` | Permanently delete a session |
392
523
  | `get_foreground_session_id` | Get TUI foreground session |
393
524
  | `set_foreground_session_id(id)` | Set TUI foreground session |
525
+ | `clear_managed_settings_cache` | Clear cached managed (enterprise policy) settings |
394
526
  | `on(event_type = nil, &block)` | Subscribe to lifecycle events |
395
527
 
396
528
  ### `Copilot::CopilotSession`
397
529
 
398
530
  | Method | Description |
399
531
  |--------|-------------|
400
- | `send(prompt:, attachments:, mode:)` | Send a message |
532
+ | `send(prompt:, attachments:, mode:, client_turn_id:)` | Send a message |
401
533
  | `send_and_wait(prompt:, timeout:)` | Send and wait for idle |
402
534
  | `on(event_type = nil, &block)` | Subscribe to session events |
403
535
  | `get_messages` | Get conversation history |
404
- | `destroy` | Destroy the session |
536
+ | `set_auto_tier(tier)` | Change the Auto routing preference |
537
+ | `set_permission_mode(mode)` | Change the permission mode (returns `PermissionModeSetResult`) |
538
+ | `recheck_policy_helper` | Re-run the managed-settings policy helper |
539
+ | `destroy` | Detach from the session (state is kept for resume) |
405
540
  | `abort` | Abort current processing |
406
541
 
407
542
  ### Key Types