Repository navigation
feat(providers): add M365 Copilot with live account model discovery - #7757
Conversation
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
|
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. UI screenshot waived by a maintainer comment. Hygiene✅ Deterministic PR hygiene checks passed. |
2920ea4 to
59e84e8
Compare
|
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.
The PR changes restricted OAuth surfaces ( |
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).
a8b8b62 to
82096c6
Compare
|
Refreshed onto current dev Local, Bun 1.4.4: 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 |
|
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:
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 FreeDirectoryProviderThe 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. |
|
Maintainer security review at
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. |
…s on the ChatHub socket
|
Security-review fixes for findings 1 and 2 are on Finding 1 — credential destination pin. Finding 2 — provider egress on the ChatHub socket. New Validation on 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 |
|
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. |
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>
|
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.
Red → green evidence (Bun 1.4.4, Windows,
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 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 ( |
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>
…vider # Conflicts: # scripts/test-layout/layout-providers.json # structure/gui-and-management-api.md
…vider # Conflicts: # structure/INDEX.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.
|
Status (contributor-backlog lane), head Security re-review round 2 passed (2026-10-28), and the conflicts with current |
…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.
|
Merge-manager review (owner admission 2026-10-28 stands; security label stays). To bring this current:
|
Track the pending start through flow ID parsing so both dashboard surfaces can queue a same-target retry behind cancellation. Release the retry when startup fails without sending an unscoped cancel.
|
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:
|
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>
|
Maintainer integration record (lane L3, 2026-11-19). Integrating exact head
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| else if (spec.bodyParam !== undefined) { | ||
| args[spec.bodyParam] = rest; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 👍 / 👎.
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
359a57431bis PASS with zero blocking findings, andmaintainer-sponsoredis 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 oforigin/devat640a40f6d57fe7613624a4b827b09c8501e277b6; 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 oforigin/devat26224ad6c4bae6f3a31f768be450d4ce4a17bea8; the single conflict instructure/gui-and-management-api.mdwas resolved by keeping both the LM Studio Chat and Microsoft 365 Copilot references. No history rewriting.81d350442342db8a09562efacdc8a75054bac9fa: discovered rows are displayed asM365 Copilotplus 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 oforigin/devat19ab11394; the single conflict inscripts/test-layout/layout-providers.jsonwas resolved by keeping both the M365 and xAI entries. No history rewriting.1f85e2e8ed295de7826458dc64c7b4492a376937: ordinary merge oforigin/devat6f1d3e65c; the same two conflicts (the providers layout map and the management doc) were resolved by keeping both sides. No history rewriting.116084863: ordinary merge oforigin/devatad6a80e5c;structure/INDEX.mdconflicted, so it was regenerated withbun run structure:indexfrom the merged manifest.d1c708bddfa1cc96bb50d69ae0661f80935128f8: dev narrowedSendBudgetExhaustedErrorto a brandedErrorDestinationLabel, which the adapter no longer satisfied. It now mints the label withproviderErrorDestinationLabel, the same helper the cursor transport uses.Canonical-provider evidence (checked October 28, 2026)
POST https://graph.microsoft.com/beta/copilot/conversations. This connector instead useswss://substrate.office.com/m365Copilot/Chathub/{account}. No Microsoft-published contract for that ChatHub endpoint was found.GET https://copilot.cloud.microsoft/chat/using account-bound web cookies and parses the main chat picker'smodelSelectorMetadatafrom 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/modelsis not an upstream API contract.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 dev640a40f6d57fe7613624a4b827b09c8501e277b6(zero commits behind that tip).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.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.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.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) andbun 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.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 afterbun install --frozen-lockfilerefreshed the localbun-types.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.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.tsatOCX_TEST_NO_QUEUE=1with pinned Bun 1.4.4 -> 57 pass / 0 fail, including the new divergence, summary-replay and image-replay regressions.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.359a57431b.359a57431b. Those checks were not rerun on unchanged code for this documentation follow-up.bun run testandbun run test:changedwere 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.Screenshot (current head)
Maintainer carry (2026-11-19)
Maintainers merged
devand applied the merge-manager review:m365.cookieno-leak regression (1e335d0).Checklist
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