Commit 94ad7ab
feat(client): implement client mode :empty (multitenancy hardening)
Add :mode #{:copilot-cli :empty} client option (default :copilot-cli)
mirroring upstream PR github/copilot-sdk#1428.
In :empty mode the SDK:
- Requires at least one tenant-scoped storage root at construction time
(:copilot-home, :session-fs, :cli-url, or :is-child-process?) so the
spawned CLI never falls back to the user's home directory.
- Forces COPILOT_DISABLE_KEYTAR=1 on the spawned CLI via the
cli-env-overrides :overrides slot so the caller cannot accidentally
re-enable the host keychain.
- Requires every create-session / resume-session call (sync + async) to
supply :available-tools; an empty vector is legitimate, the key just
has to be present so silently-empty filters cannot happen.
- Spreads 9 safe defaults UNDER caller session config (caller always
wins): :enable-session-telemetry? false,
:mcp-oauth-token-storage :in-memory, :skip-embedding-retrieval true,
:embedding-cache-storage :in-memory,
:enable-on-demand-instruction-discovery false,
:enable-file-hooks false, :enable-host-git-operations false,
:enable-session-store false, :enable-skills false.
- Normalizes :system-message so environment_context is stripped unless
the app has taken control of it (mirrors upstream
getSystemMessageConfigForMode): no system-message emits
{:mode customize :sections {:environment_context {:action remove}}};
:append is promoted to :customize preserving content; :customize
without an env-context override gets one added; :replace passes
through unchanged. :copilot-cli mode keeps legacy behavior.
- After session.create / session.resume succeeds, issues a follow-up
session.options.update RPC carrying four overridable feature flags
(:skip-custom-instructions true, :custom-agents-local-only true,
:coauthor-enabled false, :manage-schedule-enabled false) plus
:installed-plugins []. In :copilot-cli mode only flags the caller
explicitly set are forwarded; an empty patch skips the RPC entirely.
On failure the SDK disconnects and removes the half-configured
session before rethrowing. Wired into create-session,
resume-session, <create-session, <resume-session.
Both modes always emit :tool-filter-precedence "excluded" on
session.create / session.resume so the ordering between
:available-tools and :excluded-tools is deterministic regardless of
CLI version, and reject bare "*" in :available-tools / :excluded-tools
at the SDK boundary (matches upstream resolveToolFilterOptions).
Adds 23 new integration tests covering validation, env-var overrides,
wire payload mode-defaults, system-message normalization, and the
session.options.update RPC (including async path + cleanup-on-failure).
339 tests / 1578 assertions / 0 failures.
Upstream: github/copilot-sdk#1428
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 451d47c commit 94ad7ab
6 files changed
Lines changed: 857 additions & 21 deletions
File tree
- src/github/copilot_sdk
- test/github/copilot_sdk
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| |||
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
189 | 201 | | |
190 | 202 | | |
191 | 203 | | |
192 | 204 | | |
193 | 205 | | |
194 | 206 | | |
195 | | - | |
| 207 | + | |
| 208 | + | |
196 | 209 | | |
197 | 210 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
206 | 223 | | |
207 | 224 | | |
208 | 225 | | |
| |||
601 | 618 | | |
602 | 619 | | |
603 | 620 | | |
604 | | - | |
| 621 | + | |
605 | 622 | | |
606 | 623 | | |
607 | 624 | | |
| |||
610 | 627 | | |
611 | 628 | | |
612 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
613 | 639 | | |
614 | 640 | | |
615 | 641 | | |
| |||
648 | 674 | | |
649 | 675 | | |
650 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
651 | 681 | | |
652 | 682 | | |
653 | 683 | | |
| |||
682 | 712 | | |
683 | 713 | | |
684 | 714 | | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
685 | 719 | | |
686 | 720 | | |
687 | 721 | | |
| |||
710 | 744 | | |
711 | 745 | | |
712 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
713 | 751 | | |
714 | 752 | | |
715 | 753 | | |
| |||
741 | 779 | | |
742 | 780 | | |
743 | 781 | | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
744 | 786 | | |
745 | 787 | | |
746 | 788 | | |
| |||
774 | 816 | | |
775 | 817 | | |
776 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
777 | 823 | | |
778 | 824 | | |
779 | 825 | | |
| |||
0 commit comments