Skip to content

feat(providers): add M365 Copilot with live account model discovery - #7757

Merged
lidge-jun merged 39 commits into
lidge-jun:devfrom
x3M3x:codex/m365-copilot-provider
Nov 19, 2026
Merged

lidge-jun merged 39 commits into
lidge-jun:devfrom
x3M3x:codex/m365-copilot-provider

Conversation

@x3M3x

@x3M3x x3M3x commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an experimental native Microsoft 365 Copilot connector with managed browser OAuth, account model discovery, streamed chat, client-executed tools, image input, estimated usage and pre-output quota failover. Microsoft selector identities are preserved. Original contributor commits and all previous carry fixes remain intact.

The owner's October 28 admission exception remains accepted, including private ChatHub/first-party app reuse, default BingWebSearch and user/tool image uploads. This repository decision does not establish Microsoft authorization or a supported private API contract. Independent maintainer security re-review of 359a57431b is PASS with zero blocking findings, and maintainer-sponsored is applied, as recorded in the maintainer's review comment. This follow-up changes documentation counts only; security-relevant implementation is unchanged.

Current head: d1c708bddfa1cc96bb50d69ae0661f80935128f8.

  • dbe57ed15bf66319616647e54001e75b453980e4: ordinary conflict-free merge of origin/dev at 640a40f6d57fe7613624a4b827b09c8501e277b6; no history rewriting.
  • 8a2aa1111fe8474bd0b87276cd7544c393145204: fixes the test 3/4 provider-count failure in all eight provider guides, all eight quickstarts and the structure operations record. Counts derived from the merged registry are 107 total: 85 key-based, 18 OAuth, 3 local, 1 forward. Both lane commits credit x3M3x.
  • 2d5f3995772c55ae3a189290ff16c2fb44437d91: resolves the ten actionable CodeRabbit findings on the previous head: stream divergence (mid-stream and terminal) fails the turn instead of reporting truncated text, replayed chain-of-thought summaries emit once by messageId, a rebuilt conversation replays only its newest four images and marks the rest sent, account IDs compare case-insensitively, the paid scenario derives from the resolved tone, the unreachable canonical-M365 transport exception is gone, and an identity mismatch reports provider discovery failure. Regression coverage was added to the transport and images suites; the guide, provider contract and manifest record the passed security re-review, the default BingWebSearch inclusion and the discovery sources.
  • b23de9429e47ee000b728d96037bc66ba036f4ac: ordinary merge of origin/dev at 26224ad6c4bae6f3a31f768be450d4ce4a17bea8; the single conflict in structure/gui-and-management-api.md was resolved by keeping both the LM Studio Chat and Microsoft 365 Copilot references. No history rewriting.
  • 81d350442342db8a09562efacdc8a75054bac9fa: discovered rows are displayed as M365 Copilot plus the Microsoft name, so a Copilot selector is distinguishable from the same model on another provider. Display-only: the selector ID remains the request identity, so aliases, wire routing and conversation keys are unchanged.
  • 68f24911f4f4dda0b1a420d9a7b9cebedd10004a: bound keyed reasoning rows (256 entries) and cumulative emitted reasoning; validate every returned tool call before emitting any text or tool event; map the per-image upload deadline to a 504 turn error instead of a raw DOMException; clear the inherited bypass list in the proxy socket test; and record the rebuilt-history image limit in the guide and provider contract.
  • 334e56e73edab80762574e752b2a147908ab658c: ordinary merge of origin/dev at 19ab11394; the single conflict in scripts/test-layout/layout-providers.json was resolved by keeping both the M365 and xAI entries. No history rewriting.
  • 1f85e2e8ed295de7826458dc64c7b4492a376937: ordinary merge of origin/dev at 6f1d3e65c; the same two conflicts (the providers layout map and the management doc) were resolved by keeping both sides. No history rewriting.
  • 116084863: ordinary merge of origin/dev at ad6a80e5c; structure/INDEX.md conflicted, so it was regenerated with bun run structure:index from the merged manifest.
  • d1c708bddfa1cc96bb50d69ae0661f80935128f8: dev narrowed SendBudgetExhaustedError to a branded ErrorDestinationLabel, which the adapter no longer satisfied. It now mints the label with providerErrorDestinationLabel, the same helper the cursor transport uses.

Canonical-provider evidence (checked October 28, 2026)

Requirement Evidence and remaining gap
Documented chat endpoint Microsoft's Chat API overview and conversation reference document POST https://graph.microsoft.com/beta/copilot/conversations. This connector instead uses wss://substrate.office.com/m365Copilot/Chathub/{account}. No Microsoft-published contract for that ChatHub endpoint was found.
Authenticated model discovery This connector reads GET https://copilot.cloud.microsoft/chat/ using account-bound web cookies and parses the main chat picker's modelSelectorMetadata from page bootstrap data. It was live-tested on October 27, 2026. No Microsoft API reference for that bootstrap schema or an authenticated OpenAI-compatible model-list endpoint was found. OpenCodex's local /v1/models is not an upstream API contract.
Operating entity and terms The Copilot API Terms of Use name Microsoft Corporation and define the APIs they cover. The Microsoft 365 Product Terms and the customer's own Microsoft agreement remain relevant to the service. These links establish the documented offering's terms, not permission for the private endpoints.
Model supply and routing authorization Microsoft's privacy documentation, Anthropic subprocessor documentation and OpenAI subprocessor documentation describe model supply and tenant controls. OpenCodex sends directly to Microsoft and does not resell access or send credentials to a third-party gateway. Those sources do not establish authorization to reuse the private ChatHub protocol or first-party app registration.
Authentication identity Microsoft's Entra application dictionary identifies the client ID as M365 Chat Client. That proves the name, not permission for this connector to reuse it. The documented Graph Chat API has separate delegated permissions and requires a Copilot add-on license; this PR does not switch to that API or request its broader permissions.
Maintenance contact @x3M3x, the PR author, is the proposed connector maintenance contact. Report breakage through the repository's Provider or API compatibility issue form with the connector ID, OpenCodex version, browser and redacted error. The ownership arrangement is proposed pending acceptance; it implies no Microsoft affiliation or support commitment.

Admission gap: public product/Graph API documentation and successful local tests do not establish a supported private protocol or permission to reuse Microsoft's first-party app registration.

Owner decision: The owner accepted the private ChatHub and first-party app reuse as a canonical-policy exception, and accepted default BingWebSearch plus user/tool image uploads. Independent maintainer security re-review closed the findings with PASS and zero blockers on 359a574; repository policy acceptance does not establish Microsoft authorization.

Verification

Current-head content validated on Windows with pinned Bun 1.4.4, OCX_TEST_NO_QUEUE=1, and one Bun test process at a time. The branch includes fetched dev 640a40f6d57fe7613624a4b827b09c8501e277b6 (zero commits behind that tip).

  • RED before docs edits, merged head dbe57ed15bf66319616647e54001e75b453980e4: bun test tests/ci-workflows/docs-provider-preset-counts.test.ts -> 1 pass / 17 fail. The existing registry-derived test expects 107 presets and 85 key-based; every locale's guide/quickstart and the structure record still claimed 106 total.
  • Merged head d1c708bddfa1cc96bb50d69ae0661f80935128f8: bun test tests/providers/m365-copilot*.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts -> 89 pass / 0 fail; bun test tests/adapters/adapter-inner-send-budget.test.ts tests/adapters/adapter-inner-send-budget-wiring.test.ts tests/adapters/physical-send.test.ts tests/lib/upstream-retry.test.ts -> 131 pass / 0 fail; bun run typecheck (2,325 files), bun run structure:check, bun run privacy:scan -> PASS.
  • Head 81d350442342db8a09562efacdc8a75054bac9fa: bun test tests/providers/m365-copilot-discovery.test.ts tests/providers/m365-copilot.test.ts tests/providers/m365-copilot-images.test.ts -> 34 pass / 0 fail (includes the prefixed catalog display name); bun test tests/oauth/oauth-login-open-browser.test.ts tests/adapters/adapter-registry-authority.test.ts -> 10 pass / 0 fail; bun run typecheck, bun run structure:check -> PASS.
  • Merged head 1f85e2e8ed295de7826458dc64c7b4492a376937: bun test tests/providers/m365-copilot*.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts -> 89 pass / 0 fail; bun run typecheck (2,275 files) and bun run structure:check -> PASS. The merge resolution had rewritten the management doc with CRLF, which broke every heading anchor other structure docs point at; the file was restored to its committed LF form.
  • Merged head 334e56e73edab80762574e752b2a147908ab658c: bun test tests/providers/m365-copilot*.test.ts -> 60 pass / 0 fail; bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts -> 29 pass / 0 fail; bun run typecheck (2,265 files), bun run structure:check, bun run privacy:scan -> PASS after bun install --frozen-lockfile refreshed the local bun-types.
  • Head 68f24911f4f4dda0b1a420d9a7b9cebedd10004a: bun test tests/providers/m365-copilot.test.ts tests/providers/m365-copilot-images.test.ts tests/providers/m365-copilot-failover.test.ts tests/providers/m365-copilot-discovery.test.ts tests/providers/m365-copilot-executor.test.ts tests/providers/m365-copilot-security.test.ts -> 60 pass / 0 fail (includes new reasoning-cap, tool-call pre-validation, upload-timeout and image-replay regressions); bun run typecheck (2,249 files), bun run structure:check, bun run privacy:scan -> PASS.
  • GREEN after the fix, same unchanged test command -> 18 pass / 0 fail. No assertions were changed, weakened, skipped or deleted. An independent registry read also derived the complete authentication split above.
  • Merged head b23de9429e47ee000b728d96037bc66ba036f4ac: bun test tests/providers/m365-copilot.test.ts tests/providers/m365-copilot-images.test.ts tests/providers/m365-copilot-failover.test.ts tests/providers/m365-copilot-discovery.test.ts tests/providers/m365-copilot-executor.test.ts tests/providers/m365-copilot-security.test.ts at OCX_TEST_NO_QUEUE=1 with pinned Bun 1.4.4 -> 57 pass / 0 fail, including the new divergence, summary-replay and image-replay regressions.
  • Merged head b23de9429e47ee000b728d96037bc66ba036f4ac: bun run typecheck (2,249 files), bun run structure:check, bun run privacy:scan -> PASS.
    Previous head dbe57ed15bf66319616647e54001e75b453980e4 (documentation-counts follow-up): bun install --frozen-lockfile; bun run typecheck (2,241 files); bun run structure:check; bun run privacy:scan; git diff --check -> PASS.
    Previous head dbe57ed15bf66319616647e54001e75b453980e4 (documentation-counts follow-up): bun test tests/ci-workflows/docs-readme-translation-parity.test.ts tests/providers/provider-registry-parity.test.ts tests/ci-workflows/client-support-matrix.test.ts tests/ci-workflows/skill-ocx.test.ts -> 144 pass / 0 fail.
  • bun test tests/providers/m365-copilot-security.test.ts tests/providers/m365-copilot.test.ts -> 26 pass / 0 fail, including real Bun loopback ws/wss proxy refusal cases.
  • bun install --frozen-lockfile; bun run typecheck (2,241 files); bun run structure:check; bun run privacy:scan; git diff --check -> PASS.
  • bun run docs:clients; bun run skill:surface; bun run structure:index -> PASS, regenerated outputs have no additional diff. No test-layout or file-size cap changes; layout.json remains 1,999 lines.
  • bun install --cwd docs-site --frozen-lockfile; bun run --cwd docs-site build -> PASS, 609 pages / 87,891 internal links. Existing sshconfig-highlighter, content and bundle-size advisories are nonfatal.
  • GraphQL reviewThreads: 0 total / 0 unresolved, no next page; 0 replies / 0 resolutions required. Prior security issue-comment findings were closed by the independent maintainer re-review on 359a57431b.
  • GUI files are unchanged by this follow-up. Earlier carry evidence remains historical in the prior carry comments: GUI login-hint regression 10 pass / 0 fail, GUI lint/build PASS; broader runtime/egress 85 pass / 0 fail and layout/boundary gates 93 pass / 0 fail on 359a57431b. Those checks were not rerun on unchanged code for this documentation follow-up.
  • Full-suite exception: the owner explicitly limited concurrent Windows carry lanes to focused files. bun run test and bun run test:changed were not run; broader coverage remains with CI. No workflows were dispatched, rerun or approved, and no labels changed. Current-head hosted CI will be observed once after pushing and reported in the carry comment; completion is not claimed here.
  • NOT RUN: full local suite, changed-files suite, live Microsoft OAuth/inference, macOS/Linux execution, current-head hosted CI completion, repeated independent security review (this follow-up is documentation-only).

Live account discovery

Inherited text/image modalities

Screenshot (current head)

Add provider: M365 Copilot listed with its sign-in entry

Maintainer carry (2026-11-19)

Maintainers merged dev and applied the merge-manager review:

  • OAuth capture and polling conflict resolution, M365 discovery placed before Vertex, structure index regenerated, English and Spanish M365 guides, and presets recounted to 109/87/18 (cf6208e).
  • An m365.cookie no-leak regression (1e335d0).
  • Add Provider exposure fixed (b9f6b95).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. Independent maintainer re-review PASS and sponsorship are recorded on the prior implementation head; this follow-up only updates documentation counts.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Readiness is bound to the current head above. Merge still requires successful exact-head required CI and the maintainer's integration decision.

Co-authored-by: x3M3x 98298256+x3M3x@users.noreply.github.com

Summary by CodeRabbit

  • New Features
    • Added experimental Microsoft 365 Copilot support, including work or school account sign-in, live model discovery, and chat with text and images.
    • Copilot chats can use supported tools and switch to configured backup providers when appropriate.
    • Added a dedicated Copilot icon and tailored sign-in instructions.
  • Documentation
    • Updated provider catalogs and setup guides to reflect 107 built-in presets, including 18 OAuth providers.
    • Added guides covering Copilot setup, capabilities, and limitations.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

This change adds a Microsoft 365 Copilot provider with managed browser sign-in, account-bound model discovery, native ChatHub WebSocket turns, image uploads, and tool handling. It also updates the GUI, tests, provider documentation, and preset counts. A separate change revises Mistral retry-policy wording.

Changes: Microsoft 365 Copilot provider

Layer / File(s) Summary
Provider contracts and registration
src/providers/m365-copilot-models.ts, src/providers/registry/entries-core.ts, src/oauth/model-discovery-auth.ts, src/config/provider-validation.ts, src/adapters/registry.ts, src/types/wire.ts, tests/providers/m365-copilot-security.test.ts
Registers the OAuth provider and model selectors. Validation, discovery eligibility, adapter registration, and model wiring pin the provider to the M365 adapter.
Managed browser sign-in and session storage
src/oauth/m365-copilot.ts, src/oauth/m365-copilot-browser.ts, src/oauth/m365-copilot-web-session.ts, src/oauth/index.ts, src/oauth/store.ts, src/oauth/types.ts, src/server/management/oauth-account-routes.ts, gui/src/components/*, gui/tests/login-hint-browser-launch.test.tsx
Adds PKCE OAuth and managed browser callback capture. Credentials carry account-matched web-session data. The GUI passes provider identity to login hints and suppresses paste controls for M365 Copilot.
Account-bound model discovery
src/providers/m365-copilot-discovery*.ts, src/codex/catalog/m365-copilot-models.ts, src/codex/catalog/provider-models.ts, src/codex/catalog/gather-capture.ts, src/server/management/m365-copilot-provider-probe.ts, tests/providers/m365-copilot-discovery.test.ts
Validates the web session against the OAuth account, reads and parses the model roster, and caches results by identity. Management routes expose discovery results.
Native socket transport and image uploads
src/adapters/m365-copilot/transport.ts, src/adapters/m365-copilot/images.ts, src/lib/provider-egress.ts, src/server/responses/fetch-helpers.ts, tests/providers/m365-copilot-executor.test.ts, tests/providers/m365-copilot-images.test.ts, tests/providers/m365-copilot-security.test.ts
Implements bounded WebSocket turns, proxy routing, executor eligibility checks, cancellation, and image validation and upload. Tests cover socket routing, upload constraints, and failure cases.
Conversation and tool handling
src/adapters/m365-copilot.ts, src/adapters/m365-copilot/tools.ts, src/adapters/m365-copilot/fenced.ts, tests/providers/m365-copilot.test.ts, tests/providers/m365-copilot-failover.test.ts
Maintains conversation state and formats requests and responses. Tool helpers parse and serialize fenced calls. Tests cover adapter behavior, streaming, and quota failover.
GUI assets, documentation, and test layout
gui/src/provider-icons.ts, desktop/src-tauri/src/provider_icons.rs, docs-site/src/content/docs/*, structure/*, scripts/test-layout/*, tests/fixtures/test-layout-expected.json
Adds provider icons and documentation. Updates built-in preset totals from 106 to 107 and OAuth totals from 17 to 18. Maps the new tests into the provider test layout.

Mistral retry-policy documentation

Layer / File(s) Summary
Retry-policy wording
structure/providers-and-adapters.md
Removes “patient” from the description of the bounded same-key 429 policy. The documented retry limits and behavior do not change.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant M365Adapter
  participant M365ImageUpload
  participant M365ChatHub
  M365Adapter->>M365ImageUpload: Validate and upload image attachments
  M365ImageUpload-->>M365Adapter: Return file annotations
  M365Adapter->>M365ChatHub: Send WebSocket turn with message and annotations
  M365ChatHub-->>M365Adapter: Stream text, thinking, and completion frames
Loading
Merge Risk: Moderate · previous review b23de

Several M365 Copilot edge cases remain: malformed tool replies can leave partial output, slow image uploads lose structured error reporting, and excessive reasoning can consume unbounded memory. Address these before merging; the documentation and proxy-test corrections are localized.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title accurately and concisely describes the primary changes: adding the Microsoft 365 Copilot provider and live, account-based model discovery. It is specific, clear, and related to the implement…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title accurately and concisely describes the primary changes: adding the Microsoft 365 Copilot provider and live, account-based model discovery. It is specific, clear, and related to the implementation and documentation changes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added enhancement New feature or request intake: hygiene-blocked Deterministic PR hygiene checks failed labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • empty_catch — An empty catch block was added. Handle, report, or deliberately propagate the error. Paths: src/adapters/m365-copilot/fenced.ts, src/adapters/m365-copilot/tools.ts, src/adapters/m365-copilot/transport.ts, src/oauth/m365-copilot-browser.ts.
  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/oauth/index.ts, src/oauth/m365-copilot-browser.ts, src/oauth/m365-copilot.ts, src/server/management/oauth-account-routes.ts.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

UI screenshot waived by a maintainer comment.
Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

Hygiene

✅ Deterministic PR hygiene checks passed.

@x3M3x
x3M3x force-pushed the codex/m365-copilot-provider branch from 2920ea4 to 59e84e8 Compare October 27, 2026 08:38
@x3M3x x3M3x changed the title feat(providers): add Microsoft 365 Copilot provider feat(providers): add M365 Copilot with live account model discovery Oct 27, 2026
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer triage (2026-10-28, against dev 4bf5728):

This adds a provider dev does not have. The parser follow-up, image/failover coverage, test registrations, attribution notice, screenshots, and documented testing limits are useful.

  1. Complete the canonical-provider evidence package for the new registry entry in src/providers/registry/entries-core.ts, following MAINTAINERS.md ("A new or promoted provider preset ...") and the contributing guide's evidence section: documented endpoint and authenticated model-discovery contract, operating entity and terms, any routing authorization, a named maintenance owner, and dated verification sources.
  2. Explain how the private ChatHub integration satisfies that policy. If the evidence is not available, propose an inert src/providers/free-directory.ts reference row instead of a canonical preset.
  3. Update onto current dev (the branch is 49 commits behind), validate that head, and complete the four readiness boxes.

The PR changes restricted OAuth surfaces (src/oauth/, oauth-account-routes.ts), so it stays in draft until a maintainer completes an explicit security review and decides on sponsorship; the label is a maintainer action. Thank you.

x3M3x added 8 commits October 28, 2026 09:25
Add an M365 Copilot ChatHub connector: managed isolated-browser OAuth sign-in (Firefox/Chrome/Edge, nativeclient callback capture), PKCE token exchange with lazy refresh, a maintained 34-alias static model catalog, and a Bun-native SignalR WebSocket transport with prompt-emulated client-executed tools. GUI surfaces the provider icon and hides the manual callback paste for M365 logins. Vendored grammar/framing from cramt/m365-copilot-proxy under MIT (src/adapters/m365-copilot/LICENSE).
@x3M3x
x3M3x force-pushed the codex/m365-copilot-provider branch from a8b8b62 to 82096c6 Compare October 28, 2026 05:37
@lidge-jun

Copy link
Copy Markdown
Owner

Refreshed onto current dev 1f8405734 as one ordinary merge commit, 547449128 (no conflicts; your commits unchanged), which was item 3 of the 2026-10-28 triage.

Local, Bun 1.4.4: bun run typecheck, structure:check, privacy:scan; test-layout, file-size and import-cycle ratchets with the adapter-registry, OAuth open-browser and all four M365 Copilot test files: 93 pass / 0 fail; GUI login-hint-browser-launch: 10 pass; lint:gui and the GUI build pass.

I have not approved PR CI, because the OAuth surfaces still need the maintainer's security review and sponsorship decision. Items 1–2 of the triage (the canonical-provider evidence package, or an inert free-directory.ts reference instead) and the readiness boxes remain with you.

@x3M3x

x3M3x commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the ordinary merge and the exact-head validation. I have pulled 5474491 locally without rewriting your merge, and updated the description to distinguish your 93-test/10-GUI-test verification from my earlier contributor run.

For items 1–2, the evidence package was added in 82096c6 and is present in your merged head:

  • Evidence and admission status in the guide: dated official Microsoft sources, Microsoft Corporation and terms, direct-to-Microsoft routing/model supply, app identity, proposed @x3M3x maintenance contact, and the exact observed authenticated discovery contract.
  • The updated PR description carries the same requirement-by-requirement table and the reference-only proposal.

The missing evidence is not claimed as complete. Microsoft documents the Graph Copilot Chat API, not this private ChatHub endpoint or the model-picker bootstrap. The first-party application dictionary proves the client ID belongs to Microsoft; it does not establish permission to reuse it. Functional tests and Microsoft product terms do not close that gap. Therefore I cannot attest that this native preset satisfies the documented-endpoint/private-protocol authorization requirement.

My proposed reference-only upstream alternative is the following inert directory row, with the executable canonical preset, OAuth enrollment and native feature registration removed from that narrowed submission:

{
  id: "m365-copilot",
  label: "Microsoft 365 Copilot",
  adapter: "openai-chat",
  baseUrl: "",
  authKind: "key",
  accessGroups: [],
  supportLevel: "reference",
  verification: "unverified",
  discovery: "unsupported",
  liveModels: false,
  documentationUrl: "https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/api/ai-services/chat/overview",
  dashboardUrl: "https://copilot.cloud.microsoft/",
  note: "Reference only. No API endpoint, login flow or model catalog is enabled. Microsoft documents a separate Graph Chat API; the private ChatHub integration is not admitted as a canonical preset.",
} satisfies FreeDirectoryProvider

The empty endpoint and reference status mean no API-key enrollment or network request; authKind is only the directory schema default and is not a claim that Copilot supports API keys. No free-access claim, modelsUrl, or private-endpoint lastVerified date is supplied. The working local connector can remain on its existing branch/package independently of a narrowed reference-only upstream submission.

I have kept readiness at 2/4: local validation and current-dev ancestry are attested; independent review and ready-for-review remain unchecked. I have not requested a full-platform dispatch, applied sponsorship, marked this ready, or claimed PR CI is approved.

Please confirm whether you want the upstream submission narrowed to this inert reference, or whether an experimental native connector can be considered after your policy/security review. This is the remaining admission decision; the implementation and evidence cannot manufacture authorization for the private protocol.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer security review at 547449128 (independent review, read-only): 3 blocking findings. maintainer-sponsored is not applied yet.

  1. High — credential destination pin missing (src/oauth/index.ts:255). An m365-copilot row with authMode=oauth, adapter=openai-chat and a foreign baseUrl resolves the stored Microsoft token (src/server/responses/request-transport.ts:1130), and generic Chat sends it as a Bearer (src/adapters/openai-chat/wire.ts:32); the native adapter's endpoint check never runs. Please add M365 to credentialPinnedProviderConfigError and CREDENTIAL_PINNED_ADAPTERS, reject base-URL retargeting and model wire overrides, and add a regression for the retargeted row.
  2. High — provider egress bypass (src/adapters/m365-copilot/transport.ts:75). NativeSocket receives only headers, so provider proxy/noProxy and incoming.providerFetch never reach inference, while discovery and uploads do follow provider routing. Please honor the provider route when opening the socket, or reject an explicit route you cannot honor before dialing, with a regression.
  3. Admission — canonical preset without required evidence (src/providers/registry/entries-core.ts:158). The guide itself (docs-site/.../guides/m365-copilot.md:56-63) records that documented endpoints and authorization evidence are missing; MAINTAINERS.md requires that evidence before a canonical preset lands. Please supply it, or narrow this to an inert src/providers/free-directory.ts reference.

Open product questions for the maintainers (no action needed from you yet): private ChatHub/first-party app reuse as a policy exception, and default BingWebSearch plus uploading user/tool images to Microsoft.

Once 1 and 2 are fixed on a new head, a maintainer will re-review and approve PR CI.

@x3M3x

x3M3x commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Security-review fixes for findings 1 and 2 are on fc26ed8c3, committed directly on top of your merge 547449128 (no rebase, your commits unchanged).

Finding 1 — credential destination pin. m365-copilot is now in CREDENTIAL_PINNED_ADAPTERS (src/types/wire.ts), so every model wire override resolves to the native adapter, and credentialPinnedProviderConfigError (src/config/provider-validation.ts) rejects an m365-copilot row whose adapter is anything else or whose baseUrl retargets off https://substrate.office.com/m365Copilot (trailing slashes tolerated, same normalization as the dsh-account branch). The retargeted-row / foreign-adapter / model-wire-override cases are regression-tested in tests/providers/m365-copilot.test.ts ("credential pinning").

Finding 2 — provider egress on the ChatHub socket. New m365SocketDialOptions (src/adapters/m365-copilot/transport.ts) resolves the provider route through the same resolveProviderEgress path discovery and uploads use, and the adapter passes route: provider into the turn: an explicit provider proxy is pinned on the socket, direct stays direct, and inherit applies the global decision explicitly because Bun's WebSocket ignores proxy environment variables (probed empirically on Bun 1.3.8: explicit proxy honored, dead proxy fails closed, no silent bypass). A custom fetch executor cannot carry a WebSocket, so it is rejected with a 400 before dialing; the dial options are computed before the Promise so route-config errors surface instead of hiding inside the connection failure path. Covered by the "socket egress" tests, including HTTPS_PROXY inheritance and noProxy.

Validation on fc26ed8c3 (Bun 1.4.4, Windows): bun run typecheck; bun test tests/providers/m365-copilot.test.ts 17/17; the credential-pinned neighbors dsh-account / workbuddy provider and adapter suites 55 pass / 0 fail; bun run privacy:scan; bun run structure:check. None of the touched files are in the file-size ratchet baseline.

Finding 3 is unchanged from my earlier reply: the authorization evidence for the private ChatHub does not exist to supply, and I will not claim it does. If the policy exception is denied, I will narrow the submission to the inert free-directory.ts reference row quoted above in the same session; the native preset stays only if a maintainer explicitly grants the exception. Readiness remains 2/4 — no ready-for-review tick on this push.

@lidge-jun

Copy link
Copy Markdown
Owner

Owner decisions: accepted — the private ChatHub / first-party app reuse is granted as a canonical-policy exception, and default BingWebSearch plus uploading user/tool images to Microsoft are accepted. The admission item (3) in the security review is therefore waived. Findings 1 and 2 (High) still block merge: pin the stored Microsoft token to the M365 destination, and honor or refuse provider proxy routing for the inference socket. After those land on a new head, a maintainer will re-review and approve PR CI.

x3M3x and others added 4 commits October 28, 2026 22:45
Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
Five regressions fail at pre-fix 5474491 and pass with the contributor fixes.
Exercise Bun's real ws/wss HTTP CONNECT path against a refusing loopback proxy.

Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
Bun 1.4.4 WebSocket supports HTTP(S) proxy URLs. Reject explicit and inherited
SOCKS routes with a safe 400 configuration error before opening any socket.
Three regressions fail before this change; all 26 focused provider tests pass.

Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer carry at f1e9110, ready for the independent security re-review. No PR merge, label changes, fork-CI approvals, workflow dispatches, rebases or force pushes were performed.

  • 34e1b33 ordinarily merges dev b16bc09 without conflicts; contributor commits are preserved. All three carry commits include Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>.
  • 6e44d7e adds independent regressions for both HIGH findings, retaining the contributor fixes fc26ed8c3 and 9df3b66f7. Destination validation is at src/config/provider-validation.ts:432; runtime wire pins are at src/types/wire.ts:106. Retargeted generic/native rows and foreign model-wire overrides are covered at tests/providers/m365-copilot-security.test.ts:9.
  • f1e9110 closes a remaining unsupported-route case: src/adapters/m365-copilot/transport.ts:73 rejects explicit/inherited SOCKS proxies with a safe 400 configuration error before any dial. Bun 1.4.4's native socket constructor refused SOCKS URLs in a loopback probe. HTTP(S) proxy options still reach the native constructor at transport.ts:109; the adapter supplies the provider route at src/adapters/m365-copilot.ts:72. HTTP fetch executors cannot carry a WebSocket; custom provider.fetch is explicitly refused at transport.ts:88.
  • Native ws and wss regression cases use Bun's actual WebSocket constructor and HTTP CONNECT implementation against loopback servers. A refusing proxy receives exactly one attempt and the destination receives zero direct connections. No live Microsoft token or network request is used. SOCKS cases assert zero socket-dial callbacks.

Red → green evidence (Bun 1.4.4, Windows, OCX_TEST_NO_QUEUE=1):

  • bun test tests/providers/m365-copilot-security.test.ts: historical five-case revision at pre-fix 547449128b: 0 pass / 5 fail; the same revision with contributor fixes: 5 pass / 0 fail.
  • Before the new SOCKS fix, the extended eight-case revision: 5 pass / 3 fail (explicit SOCKS5/SOCKS5H and inherited SOCKS did not return the required config refusal).
  • Final bun test tests/providers/m365-copilot-security.test.ts tests/providers/m365-copilot.test.ts: 26 pass / 0 fail, including all eight security cases.
  • M365 discovery/images/failover plus DSH/WorkBuddy provider/adapter neighbors: 93 pass / 0 fail before the SOCKS extension; affected transport/provider files were then checked by the final 26-test command. Full file lists are in Verification.
  • Layout/tooling, file-size/import-cycle, adapter-registry, OAuth browser and Lab boundaries: 89 pass / 0 fail.
  • bun run typecheck: PASS, 2,241 files. bun run structure:index, bun run structure:check, bun run privacy:scan, git diff origin/dev...HEAD --check: PASS. Structure index regenerated without drift; layout.json stays at 1,999 lines; ratchet caps unchanged.
  • bun test --cwd gui tests/login-hint-browser-launch.test.tsx: 10 pass / 0 fail; bun run lint:gui, bun run --cwd gui build: PASS. GUI frozen install passed.
  • Docs frozen install and bun run --cwd docs-site build: PASS, 601 pages and 86,235 internal links. Existing syntax-highlighter/bundle advisories remain nonfatal.

Review/hygiene: GraphQL returned 0 reviewThreads, with no next page: 0 replies / 0 resolutions required. This comment responds to the two HIGH findings posted as issue comments. The local deterministic in-branch hygiene scan returns [], including the previously reported empty catches. The remaining unsponsored_surface failure requires independent maintainer security review and the maintainer-sponsored action; the owner must also approve any gated fork CI runs. Those actions are outside this lane's authority. The final description keeps the fourth readiness attestation unchecked while these decisions remain pending.

Full-suite exception: concurrent lanes share this Windows host, and the owner explicitly required focused files only. Broader validation remains with CI; no passing check was rerun just to obtain more confidence.

NOT RUN: full local suite (bun run test), bun run test:changed, live Microsoft OAuth/inference, successful upstream TLS tunnel, macOS/Linux execution, exact-head hosted CI completion, independent maintainer security re-review.

Refuse opaque incoming provider executors before image preparation or socket
dialing. Bind captured socket routes only to built-in request transports that
have no custom fetch, TLS replacement or dispatch override. Preserve the normal
absent-executor path and recheck authority at the physical socket boundary.

Six-case regression revision is red on f1e9110 (2 pass / 4 fail). Expanded
affected coverage passes 85 tests; layout, ratchet, Lab and egress gates pass 93.

Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
x3M3x added 3 commits November 2, 2026 10:42
…vider

# Conflicts:
#	scripts/test-layout/layout-providers.json
#	structure/gui-and-management-api.md
…dget refusal

dev narrowed SendBudgetExhaustedError to a branded ErrorDestinationLabel, so the adapter's plain provider string no longer typechecked after the merge. It now uses providerErrorDestinationLabel, the same helper the cursor transport uses.
@lidge-jun

Copy link
Copy Markdown
Owner

Status (contributor-backlog lane), head d1c708bddf.

Security re-review round 2 passed (2026-10-28), and the conflicts with current dev are only in scripts/test-layout/layout-providers.json, structure/gui-and-management-api.md and structure/providers-and-adapters.md. What is open is admission: this adds a 3,101-line M365 Copilot provider with live account model discovery, an OAuth surface and a desktop icon. Admitting it is the owner's product and maintenance call, so I have put it on the owner-decision list for this lane's report. Please hold the refresh until that answer, so you do not spend a merge on a direction that may change.

…down

The M365 Copilot login runs in the proxy's own isolated browser window, but both dashboard hooks cancelled every active login on pagehide and on unmount, and polled it on a budget sized for a same-sitting browser flow. A tab reload therefore aborted the server-side capture and nothing persisted.

gui/src/oauth-server-owned-login.ts names the server-owned set and a poll budget that outlasts the server's own capture window; the two hooks skip those providers in cancelActiveLogins and poll them on that budget. The explicit Cancel action is unchanged.
@lidge-jun

Copy link
Copy Markdown
Owner

Merge-manager review (owner admission 2026-10-28 stands; security label stays). To bring this current:

  1. Resolve conflicts with dev: in gui/src/pages/use-providers-oauth.ts cancelActiveLogins, keep dev's capture get/delete first, then if (isServerOwnedLogin(provider)) continue;, and in polling use pollAttempts with dev's targetCurrent() (not aliveRef); keep both import sets in use-add-provider-oauth.ts; in src/codex/catalog/provider-models.ts put the m365-copilot branch right after const apiKey = auth.apiKey;, before dev's vertexAuth lines; keep both sides in layout/structure/count docs and run bun run structure:index.
  2. Docs: guides/providers.md was split by docs(providers): split the API-key preset catalog into its own guide page #8768 — put the M365 text in guides/m365-copilot.md with at most a short pointer; recount presets from the registry (with this PR: 18 OAuth) across all locales incl. es, and structure/ops/docs-and-release.md.
  3. Add a test that m365.cookie never appears in account summaries or other responses.
    OAuth/transport commits after the earlier security pass (2d5f399, 68f2491, d1c708b, e4e5200) get a short follow-up security review from us once this is current.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer follow-up security review (lane L3, gpt-6.2-sol, three rounds; the final one at exact head dbbd1ea): SECURITY PASS, code APPROVE. It covers the OAuth/transport commits added after the earlier security pass and the maintainer carry:

  • Managed browser: sign-in uses Chromium's --remote-debugging-pipe over inherited fds, with no TCP listener, and the Firefox managed path is refused.
  • Conversation reuse: reuse is bound to the authenticated caller and the resolved conversation.
  • Credential currentness: checked immediately before the ChatHub dial and before the connectivity probe.
  • Login attempts: polling and cancel are scoped to the M365 flow id, and a retry after cancelling during startup succeeds.
  • Cookie: m365.cookie never appears in summaries, responses or logs.
  • Docs: the en/es guides and the counts (109/87/18) are in place.

maintainer-sponsored stays. This merges once exact-head CI is green and the dev merge freeze is lifted.

@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 18, 2026
lidge-jun and others added 4 commits November 19, 2026 06:29
Recount all provider preset claims from the combined registry. Preserve Microsoft 365 Copilot and Antigravity ACP documentation and test registrations.

Co-authored-by: Amr Obaid <98298256+x3M3x@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration record (lane L3, 2026-11-19).

Integrating exact head c1468f060f940d3958182d9ccaa70d7a8dbe57e7 under the maintainer-integration path. The PR carries maintainer-sponsored and ci:full.

  • Review. The same gpt-6.2-sol reviewer covered every round. The merge check at this head gave APPROVE and SECURITY PASS: count conflicts were resolved to 110 total, 88 key-based, and 18 OAuth, and the Add Provider note lists Chrome, Chromium, or Edge.

  • Security scope. Login is owned per flow ID, so cancel and retry stay ordered. The managed browser uses an inherited debugging pipe, not a TCP listener. Conversation reuse is scoped to the authenticated caller. A stale credential is refused before the socket is dialed. Cookies are redacted.

  • CI and threads. Exact-head PR CI is green, and 0 of 15 threads are unresolved.

  • Union guards on the merge with current dev: file-size ratchet, test layout, Spanish localization, preset counts, and typecheck all passed.

  • Files also changed on dev since the branch base: docs-site/src/content/docs/es/reference/adapters.md docs-site/src/content/docs/reference/adapters.md scripts/test-layout/layout.json src/oauth/store.ts src/oauth/types.ts src/server/management/oauth-account-routes.ts src/server/responses/request-transport.ts structure/INDEX.md structure/adapters/registry.md structure/gui-and-management-api.md structure/manifest.json structure/providers-and-adapters.md structure/transports/byte-accounting.md tests/fixtures/test-layout-expected.json

@lidge-jun
lidge-jun marked this pull request as ready for review November 19, 2026 04:02
@lidge-jun
lidge-jun merged commit f235042 into lidge-jun:dev Nov 19, 2026
60 of 63 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T04:15:01.496479Z c1468f0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1468f060f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +219 to +220
if (Array.isArray(item?.messages)) messages(item.messages);
if (item?.result?.value === "Throttled" || item?.result?.value === "OutOfCredits") throw new M365CopilotTurnError("Microsoft 365 Copilot account quota or rate limit reached", 429);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check terminal quota failures before emitting their messages

In a streaming failover combo without client tools, a terminal frame containing both a bot Chat quota explanation and OutOfCredits or Throttled emits that explanation through onText before detecting the 429. I reproduced this ordering with a loopback ChatHub fixture. The shared comboStreamPayloadCommitsOutput predicate treats the nonempty text as committed output, preventing fallback even though no answer preceded the quota refusal. Inspect the terminal result before emitting its messages, and cover this frame shape in the transport regression tests; the current failover tests inject an already-classified turn error.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +664 to +665
else if (spec.bodyParam !== undefined) {
args[spec.bodyParam] = rest;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve declared types for fenced tool body arguments

For a tool whose selected body parameter is not a string, this branch always assigns the raw fence body as a string. For example, a single ids parameter declared as an array receives the string "[\"a\",\"b\"]" when the fence contains the valid JSON array ["a","b"]. runTurn accepts and emits this invocation because it validates only the outer arguments JSON, leaving the client with arguments that violate its declared tool schema. Decode non-string body values according to spec.parameterTypes while retaining raw text for string parameters.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

const key = id ?? this.target ?? "";
if (!this.messages.has(key) && this.messages.size >= 256) throw new M365CopilotTurnError("Microsoft 365 Copilot returned too many messages", 413);
this.target ??= key;
if (text.length > (this.messages.get(key)?.length ?? 0)) this.messages.set(key, text);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-growing snapshots that rewrite emitted text

When an update or terminal snapshot changes an existing message without increasing its length, this condition silently discards the correction. I reproduced a successful turn returning Hello even though the terminal Success frame supplied Jello for the same message ID. Because the corrected content never reaches the composer, advance() cannot detect its divergence, and the request reports stale content as a successful answer. Check snapshot compatibility before applying the length-based stale-snapshot filter, and add an equal-length terminal-rewrite regression.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the four full Ubuntu test shards on this pull request enhancement New feature or request maintainer-sponsored Maintainer sponsors this change to an auth, workflow, release, or dependency surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants