Repository navigation
Conversation
|
Sorry for the slow review, and thanks for listing the security boundary in the description. This PR trips our community-PR harm check, so I haven't run it. It is held for the maintainer to decide. It changes system trust and opens a new network surface:
There's also a product question beyond the code: the request comes from Anthropic's own add-in, and it would be routed to other providers' models. I'll leave the PR open until the maintainer decides. If it's a yes, I'll do the full run then: tests, vet on the three OSes, and the GUI tests in both engines and every language. |
|
Thanks @svcvit. Letting Claude for Microsoft 365 use magpie is welcome, but not with the certificate setup as it stands. Here are the conditions for merging.
With those in place I'll review it again line by line and run it. |
bf4bf59 to
c768a2a
Compare
c768a2a to
1859a1c
Compare
|
Thanks for the concrete conditions. I rebased onto current
Verification run on this revision:
|
|
Sorry for the slow re-review, and thanks for the fixes and the PowerPoint evidence. I re-reviewed at What I ran (macOS, Go 1.26.8, temp HOME):
Conditions 1–3: met in the code. The constraints are right, the origin follows the switch both ways, and a busy port is reported and rolled back. Still needed before merge:
This also needs the owner's decision. It installs a trust root into the user's trust store. It is name-constrained, the key is thrown away, and it's only installed when the user clicks. Whether magpie ships that at all is @yetone's call, not a reviewer's. I've raised it with him. I haven't merged it. |
Adds an opt-in loopback-only TLS listener at https://127.0.0.1:8787, a local CA whose signing key is never retained, explicit macOS/Windows trust actions, and a named gateway key for the Office add-in. The existing Anthropic handler, routing, streaming, limits and usage remain the request path. Verified with M365 gateway, certificate, CORS/PNA, settings and GUI tests; Chromium English/Chinese UI tests; go vet; production and nogui builds; Windows amd64 cross-compilation; and manual Word/Excel/PowerPoint acceptance against the local app.
Close the Microsoft 365 security boundary before attempting certificate cleanup, roll failed enables back, and allow disable without a locally served ordinary gateway. Remove macOS user trust settings with the certificate and keep automatic trust actions macOS-only until Windows is validated with real Office. Checks: focused gateway/gui M365 and CORS tests; race count 2; darwin/linux/windows vet and nogui builds; Chromium and WebKit M365 GUI tests in en, zh, zh-TW, ja and de; gofmt, node --check and git diff --check. The full nogui suite was attempted but interrupted after unrelated internal/agent tests did not finish.
1859a1c to
dc2d1ee
Compare
|
Thanks for the detailed re-review. I rebased onto current The six requested items are handled as follows:
Additional verification on the rebased head:
The complete |



What changes
Claude for Microsoft 365's Word, Excel and PowerPoint add-ins can connect to magpie at
https://127.0.0.1:8787.Server.HandlerGET /v1/models,POST /v1/messages, and their preflight on that listenerClaude for Microsoft 365gateway key, so limits, model/account restrictions, Routing and Usage work as they do for other callershttps://pivot.claude.aionly while Microsoft 365 support is enabledThe ordinary agent gateway remains HTTP and keeps its current address, so existing agent configuration does not change.
Security boundary and lifecycle
This PR intentionally adds a network listener and an optional macOS trust-store write, called out here for the community-PR safety review:
127.0.0.1:8787; it never binds a LAN interface/v1/models,/v1/messages, and preflight on those pathslocalhost,127.0.0.1/32, and::1/128, with.localhostsubdomains excludedlocalhost,127.0.0.1, and::1; its private key is mode0600security delete-certificate -t, deleting both the certificate and its user trust settingcertutilpath stays unavailable through the UI and API until it has been validated end to end with real Windows OfficeTurning support off commits the security boundary first: it saves
M365=false, removeshttps://pivot.claude.ai, and stops the HTTPS listener. It then removes macOS certificate trust. A listener or trust cleanup failure is reported separately with manual cleanup guidance and cannot leave the setting or origin enabled. Disable also works when this Magpie is not serving the ordinary gateway.A failed enable—whether the ordinary gateway restart fails or the HTTPS listener does not start—rolls the setting and origin back to off. The named gateway key remains so a later enable can reuse it; it can still be revoked from Gateway keys.
Subsystem behavior
The current contract, platform behavior, lifecycle and failure semantics are documented in
docs/subsystems/m365.mdand linked from the subsystem index.The Microsoft 365 setting is machine-local under
Settings.KeepOwn: sync or backup cannot start a listener on another computer or attach it to a key that is absent there.Verification
Passed after rebasing onto
upstream/main674b6ca2:The M365 GUI regression passed in Chromium and WebKit at narrow width in English, Simplified Chinese, Traditional Chinese, Japanese, and German. It covers both the macOS automatic-trust controls and the non-macOS manual-certificate-path UI.
A complete
go test -tags nogui ./...was attempted, but was interrupted after more than four minutes in unrelatedinternal/agenttests. It did not report an M365 failure and is not claimed as a pass.Real-device evidence
The real Claude add-in for PowerPoint on macOS was tested with
https://127.0.0.1:8787and the dedicated Magpie key: it connected successfully, populated routed models, and sent a real prompt through Magpie. The screenshots are in this PR comment and also show that the add-in's Gateway URL is editable.Windows Office real-device validation has not been run. Accordingly, automatic certificate install/removal remains disabled on Windows rather than being presented as verified support.
🎬 界面预览
CI 用这个 PR 的代码构建并真实运行 magpie(沙盒环境,配置了真实的 DeepSeek key),按改动自动操作、截图和录屏 ·
dc2d1ee· 运行记录改动(按代码):在「设置 › 网络与共享」里新增「Microsoft 365」一节:一个开关,以及开启后显示的仅本机 HTTPS 地址、证书状态与信任操作、网关密钥复制和自动加入的允许网页。
Note
沙盒里看不到:沙盒大概不是 macOS,所以「信任证书 / 移除信任」这类自动信任按钮不会出现,只能看到证书路径那一行;Word、Excel、PowerPoint 里的 Claude 加载项本身在沙盒中无法运行,这个 HTTPS 监听器真正被加载项调用也看不到。另外若 127.0.0.1:8787 已被占用或本进程没有在提供网关,开启会失败并在这一节显示错误,而不是显示地址、证书与密钥。
设置中的 Microsoft 365 一节
未开启时这一节显示的内容
开启 Claude for Microsoft 365
开启后这一节显示的内容:地址、证书、密钥、允许的网页
点击「开启」后,Microsoft 365 这一节的显示
点「复制密钥」后这一节的样子