copilot-sdk-supercharged 2.5.2 → 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: f037082db29f02a659fb8872c0034e9917ea1542ba70dacf0fd608a741b34ab4
4
- data.tar.gz: 5faaeffb467503b09766c52e1052b7dcf529821d8588343a0d47f76dfa347b6a
3
+ metadata.gz: 3f93794617e52dec15bf7b1f05df9504c05776c43eb5bf7ed0d3bd5775053fb5
4
+ data.tar.gz: 0ef5dfa951027a9af13175839d2cc2b3b3add73d7147ad7d159fe9b2d27e84b3
5
5
  SHA512:
6
- metadata.gz: 62a8d4f35acdfcae82332db0cc12cafa1db28e1aec8b877368fb7a9a5557caab6168646f8bc8eb87253ae07c35f93c85622978a520d5c7ab645a5229b5113974
7
- data.tar.gz: 5866284c99f3107676ddd642184230d294a671745901319687b95f779ea22d60f1dff6d9b2410564ab3ec783278545811295722a7976e7ce5ccd2985c8f90a4e
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:
@@ -291,6 +422,86 @@ session.on(Copilot::SessionEventType::ASSISTANT_MESSAGE_DELTA) do |event|
291
422
  end
292
423
  ```
293
424
 
425
+ ## Recent Features (v2.4–v2.5)
426
+
427
+ Recent upstream syncs added a range of session-configuration options. Except where noted, each is a keyword passed to `client.create_session(...)`.
428
+
429
+ ### New in v2.5
430
+
431
+ - **Reasoning effort** — `reasoning_effort:` — set the model's reasoning budget (e.g. `"low"`, `"medium"`, `"high"`).
432
+ - **Tool search** — `tool_search:` — let the agent discover tools on demand instead of pre-loading them.
433
+ - **Content exclusion** — `content_exclusion:` — honor content-exclusion rules that hide files from the agent.
434
+ - **Session rewind** — `rewind_enabled:` — allow rolling a session back to an earlier snapshot; observe `Copilot::SessionEventType::SESSION_SNAPSHOT_REWIND` events.
435
+ - **Additional directories** — `additional_directories:` — extra workspace directories the agent may access.
436
+ - **Disabled MCP servers** — `disabled_mcp_servers:` — turn off specific MCP servers for the session.
437
+ - **GitHub MCP tool config** — `github_mcp_tool_config:` — configure the built-in GitHub MCP toolset.
438
+ - **Canvas provider** — `canvas_provider:` — supply a canvas rendering provider.
439
+ - **Custom agents local-only** — `custom_agents_local_only:` — restrict custom agents to local definitions.
440
+ - **Built-in plugin directories** — `builtin_plugin_directories:` — directories scanned for built-in plugins.
441
+ - **Agent-factory authoring** — `args_schema:` — author agent factories with a typed args schema.
442
+ - **Permission decision context** — `decision_context:` — extra context passed to permission decisions.
443
+ - **In-process transport** — `in_process:` — run the CLI in-process instead of as a subprocess.
444
+ - **Experimental mode** — `experimental_mode:` — opt into experimental CLI behavior.
445
+ - **MCP OAuth handler** — `on_mcp_auth_request:` — handle OAuth token requests from MCP servers.
446
+
447
+ ### New in v2.4
448
+
449
+ - **Session citations** — `enable_citations:` — emit citation metadata.
450
+ - **Excluded built-in agents** — `excluded_builtin_agents:` — hide specific built-in agents.
451
+ - **Spending limits** — `session_limits:` — cap AI-credit spend with `Copilot::SessionLimitsConfig.new(max_ai_credits:)`.
452
+ - **Session memory** — `memory:` — configure persistent memory with `Copilot::MemoryConfiguration.new(enabled:)`.
453
+ - **OTLP protocol** — `otlp_protocol:` — choose the OTLP telemetry wire protocol.
454
+ - **WebSocket responses** — `enable_web_socket_responses:` — stream responses over WebSocket.
455
+ - **Experiment assignments** — `exp_assignments:` — pass experiment assignments to the runtime.
456
+ - **Tool defer loading** — `Copilot::ToolDefer` (`AUTO` / `NEVER`) — defer tool loading until first use.
457
+ - **System-message sections** — `Copilot::SystemMessageSection` (`PREAMBLE` / `PRESERVE`).
458
+ - **GitHub attachments** — `Copilot::GitHubAttachment` (`GITHUB_COMMIT`, `GITHUB_REPOSITORY`, …).
459
+ - **Post-tool-use / prompt-transformed hooks** — `on_post_tool_use`, `on_user_prompt_transformed` on `Copilot::SessionHooks`.
460
+ - **Per-message agent mode / display prompt** — `agent_mode:` and `display_prompt:` on `session.send` / `session.send_and_wait`.
461
+
462
+ ### Examples
463
+
464
+ ```ruby
465
+ # Reasoning effort + on-demand tool search + content exclusion
466
+ session = client.create_session(
467
+ reasoning_effort: "high",
468
+ tool_search: true,
469
+ content_exclusion: true
470
+ )
471
+ ```
472
+
473
+ ```ruby
474
+ # Enable session rewind and observe rewind snapshots
475
+ session = client.create_session(rewind_enabled: true)
476
+ session.on(Copilot::SessionEventType::SESSION_SNAPSHOT_REWIND) do |event|
477
+ puts "Rewound to snapshot: #{event.data}"
478
+ end
479
+ ```
480
+
481
+ ```ruby
482
+ # Grant the agent access to extra workspace directories
483
+ session = client.create_session(
484
+ additional_directories: ["../shared-lib", "../docs"]
485
+ )
486
+ ```
487
+
488
+ ```ruby
489
+ # Cap AI-credit spend and enable persistent memory
490
+ session = client.create_session(
491
+ session_limits: Copilot::SessionLimitsConfig.new(max_ai_credits: 500),
492
+ memory: Copilot::MemoryConfiguration.new(enabled: true)
493
+ )
494
+ ```
495
+
496
+ ```ruby
497
+ # Per-message agent mode and a display-only prompt
498
+ session.send_and_wait(
499
+ prompt: "Summarize the diff",
500
+ agent_mode: "plan",
501
+ display_prompt: "Summarize the staged changes"
502
+ )
503
+ ```
504
+
294
505
  ## API Reference
295
506
 
296
507
  ### `Copilot::CopilotClient`
@@ -311,17 +522,21 @@ end
311
522
  | `delete_session(id)` | Permanently delete a session |
312
523
  | `get_foreground_session_id` | Get TUI foreground session |
313
524
  | `set_foreground_session_id(id)` | Set TUI foreground session |
525
+ | `clear_managed_settings_cache` | Clear cached managed (enterprise policy) settings |
314
526
  | `on(event_type = nil, &block)` | Subscribe to lifecycle events |
315
527
 
316
528
  ### `Copilot::CopilotSession`
317
529
 
318
530
  | Method | Description |
319
531
  |--------|-------------|
320
- | `send(prompt:, attachments:, mode:)` | Send a message |
532
+ | `send(prompt:, attachments:, mode:, client_turn_id:)` | Send a message |
321
533
  | `send_and_wait(prompt:, timeout:)` | Send and wait for idle |
322
534
  | `on(event_type = nil, &block)` | Subscribe to session events |
323
535
  | `get_messages` | Get conversation history |
324
- | `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) |
325
540
  | `abort` | Abort current processing |
326
541
 
327
542
  ### Key Types