Skip to content

Upstream sync: post-v1.0.0-beta.4 round 4 (schema 1.0.52-1, #1366)#110

Merged
krukow merged 3 commits into
mainfrom
upstream-sync/v1.0.0-beta.6
May 22, 2026
Merged

Upstream sync: post-v1.0.0-beta.4 round 4 (schema 1.0.52-1, #1366)#110
krukow merged 3 commits into
mainfrom
upstream-sync/v1.0.0-beta.6

Conversation

@krukow
Copy link
Copy Markdown
Collaborator

@krukow krukow commented May 22, 2026

Generated via Copilot on behalf of @krukow

Round-4 sync against upstream github/copilot-sdk v1.0.0-beta.6. The session plan lives in
~/.copilot/session-state/c6cf4b0c-f936-4106-ba24-5201cfdd5e2d/plan.md.

Changes (3 logical commits)

1. chore(codegen): schema bump 1.0.51 → 1.0.52-1

Regenerated event_specs.clj and coerce.clj via bb codegen. Additive
changes only:

  • session.compaction_complete-data gains optional :custom-instructions
  • tool.execution_complete-data gains optional :sandboxed
  • session.shutdown-data relaxes :total-premium-requests from required to optional

2. feat(hooks): :on-pre-mcp-tool-call hook (upstream PR #1366)

New :hooks entry that fires before an MCP tool call is dispatched.

  • Input: kebab-cased base fields (:server-name, :tool-name,
    :tool-call-id, :session-id, :timestamp, :cwd) plus two opaque
    fields preserved verbatim through wire normalization: :arguments
    (MCP tool args) and :_meta (MCP request metadata; leading
    underscore preserved despite csk's default collapse).
  • Output — tri-state :meta-to-use:
    • absent / {} → preserve existing _meta
    • {:meta-to-use {…}} → replace _meta with the given map; inner
      keys are NOT camelCased (opaque payload)
    • {:meta-to-use nil} → JSON null on the wire (remove _meta)

Wire conversion lives in protocol.clj:

  • Inbound: normalize-incoming adds a per-method/per-hookType escape
    hatch that re-keys :arguments and :_meta verbatim from the raw
    params, sidestepping csk recursion.
  • Outbound: preserve-outgoing-opaque-fields uses contains? (not
    truthiness) on :meta-to-use so explicit nil survives as JSON null.

3. fix(specs): align ::session.shutdown-data with relaxed schema

GPT-5.5 review caught that the hand-curated idiom spec still required
:total-premium-requests after the schema relaxed it.

Validation

  • bb test — 274 tests, 1303 assertions, 0 failures, 0 errors
  • bb test with COPILOT_E2E_TESTS=true0 failures, 1 error
    • The one error is test-e2e-blob-attachment timing out after 30s
      against the real Copilot CLI. Reproduced identically on origin/main
      (i.e. pre-existing flake unrelated to these changes).
  • ./run-all-examples.sh — all examples succeed
  • bb validate-docs — 13 files, 0 warnings

Multi-model code review

Reviewers: Claude Opus 4.7 + GPT-5.5 (both ran via the code-review
subagent).

# Finding Source Severity Decision
1 No issues found; traced all three tri-state cases Opus 4.7
2 ::session.shutdown-data still requires :total-premium-requests after schema relaxed it GPT-5.5 Medium Fixed (commit 3)
3 PR #1366 also renamed hook-input cwdworkingDirectory in JS; Clojure still uses :cwd GPT-5.5 Medium Deferred: rename would be inconsistent if applied only to preMcpToolCall; tracked with the broader PR #1357 deferral (see CHANGELOG)

Tracked-but-not-ported

  • PR #1357 (TypeScript SDK API review fixes) — Coordinated cross-SDK
    naming churn (cwd → workingDirectory, onExitPlanMode → onExitPlanModeRequest, disableResume → suppressResumeEvent,
    getMessages → getEvents, InputOptions → UiInputOptions,
    maxInputTokens → maxPromptTokens, removal of autoStart /
    autoRestart). All breaking; deferred to a separate PR with
    deprecation aliases. Clojure's existing :max-input-tokens
    maxPromptTokens wire shim already matches the new world.
  • PRs #1370 / #1371 (1.0.52-x schema bumps) — Picked up by commit 1.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

krukow and others added 3 commits May 22, 2026 08:31
Additive schema changes:
- session.compaction_complete-data: +:custom-instructions (optional string)
- tool.execution_complete-data: +:sandboxed (optional boolean)
- session.shutdown-data: :total-premium-requests moved from :req-un to :opt-un (relaxation)

All other diffs are description / x-opaque-json annotation churn that does
not affect the generated specs.

Regenerated event_specs.clj and coerce.clj via 'bb codegen'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add support for the new preMcpToolCall hook type that fires before an
MCP tool call is dispatched. The hook can inspect, modify, or remove
the outgoing MCP request _meta via a tri-state :meta-to-use field.

Wire conversion changes (protocol.clj):

- Incoming escape hatch on hooks.invoke + hookType=preMcpToolCall:
  preserve :arguments and :_meta as opaque verbatim payloads. csk would
  also collapse :_meta to :meta, so we explicitly dissoc :meta and
  re-assoc :_meta to preserve the leading underscore.

- Outgoing escape hatch on hooks.invoke responses: when the result map
  contains :meta-to-use (checked via contains?, not truthiness), translate
  the key to :metaToUse and preserve the inner map verbatim so MCP-source
  keys are not camelCased. The contains? check makes the explicit-null
  case round-trip as JSON null (the runtime tri-state contract for
  removing _meta vs preserving it vs replacing it).

Tests cover:
- input shape (kebab-cased base fields, opaque :arguments / :_meta);
- output {:meta-to-use {…}} → metaToUse with inner keys preserved;
- output {:meta-to-use nil} → metaToUse: null on the wire;
- output {} / nil → no metaToUse key on the wire.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Upstream schema 1.0.52-1 made totalPremiumRequests optional on the
session.shutdown event (regenerated event_specs.clj already reflects
this in :opt-un). The hand-curated idiom spec was still requiring it,
which would reject otherwise-valid 1.0.52+ CLI shutdown events at the
public API boundary.

Reviewer finding (GPT-5.5 multi-model review).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Round-4 upstream sync against @github/copilot schema 1.0.52-1 and Node.js SDK v1.0.0-beta.6, adding the upstream PR #1366 preMcpToolCall hook and aligning curated specs with regenerated wire schemas.

Changes:

  • Bumped pinned Copilot schemas to 1.0.52-1 and regenerated generated wire event specs.
  • Added new lifecycle hook :on-pre-mcp-tool-call with explicit preservation of opaque :arguments and :_meta, plus tri-state outgoing :meta-to-usemetaToUse behavior.
  • Relaxed curated idiom spec for ::session.shutdown-data to make :total-premium-requests optional (matching the updated schema).
Show a summary per file
File Description
test/github/copilot_sdk/integration_test.clj Adds integration tests covering preMcpToolCall hook input shape and meta-to-use tri-state output wiring.
src/github/copilot_sdk/specs.clj Extends ::hooks spec with ::on-pre-mcp-tool-call and relaxes ::session.shutdown-data.
src/github/copilot_sdk/session.clj Routes "preMcpToolCall" hookType to :on-pre-mcp-tool-call handler key.
src/github/copilot_sdk/protocol.clj Preserves opaque incoming :arguments/:_meta for preMcpToolCall and preserves outgoing :meta-to-use inner keys without camel-casing.
src/github/copilot_sdk/generated/event_specs.clj Regenerated wire event specs reflecting schema 1.0.52-1 additive updates.
src/github/copilot_sdk/client.clj Updates create-session docstring to document the new hook and its meta-to-use contract.
schemas/session-events.schema.json Updated vendored upstream schema (opaque-json annotations + additive fields + shutdown required relaxation).
schemas/api.schema.json Updated vendored upstream schema (adds secrets RPC + opaque-json annotations + other upstream schema tweaks).
schemas/README.md Updates pinned schema version text to 1.0.52-1.
doc/reference/API.md Documents :on-pre-mcp-tool-call hook usage and input/output behavior.
CHANGELOG.md Adds Unreleased entries for the new hook and schema bump, including deferrals context.
.copilot-schema-version Bumps pinned schema version to 1.0.52-1.

Copilot's findings

  • Files reviewed: 11/12 changed files
  • Comments generated: 0

@krukow krukow merged commit ca45e98 into main May 22, 2026
3 checks passed
@krukow krukow deleted the upstream-sync/v1.0.0-beta.6 branch May 22, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants