opencode-m365-copilot 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -16
- package/dist/{agent-CRSlpTfS.mjs → agent-DPNplWJY.mjs} +1 -1
- package/dist/cli.mjs +6 -4
- package/dist/{dist-CcVQZgN5.mjs → dist-QjFnJhR3.mjs} +1 -1
- package/dist/{login-B-1yNcEb.mjs → login-Cts_gng-.mjs} +2 -2
- package/dist/plugin.mjs +12 -2
- package/dist/{server-BRXlKFEJ.mjs → server-DXznAk1h.mjs} +953 -73
- package/dist/server.d.mts +38 -0
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,8 +82,10 @@ What gets dropped:
|
|
|
82
82
|
tools were unusable. That section, any line naming `execute`, and the skills
|
|
83
83
|
paragraph go with their tools, as do two harness lines that contradict the
|
|
84
84
|
contract ("prefer parallelizing tool calls", "prefer dedicated tools over shell
|
|
85
|
-
commands").
|
|
86
|
-
|
|
85
|
+
commands"). The whole Code Mode section is removed, catalogue included, even when a
|
|
86
|
+
tool's description in it holds a line that looks like a heading. On opencode 2.2.5
|
|
87
|
+
this takes the system prompt from about 8,000 characters to about 2,000. To reach
|
|
88
|
+
MCP tools anyway, see [MCP tools](#mcp-tools).
|
|
87
89
|
- **The harness's prose system prompt** — replaced with a short one, but **off by
|
|
88
90
|
default**. A long, polished assistant prompt measurably reduces M365's tool
|
|
89
91
|
compliance on another harness's numbers; that is a borrowed result we have not
|
|
@@ -120,10 +122,10 @@ deleted — another host may be mid-conversation with it.
|
|
|
120
122
|
Without Copilot Studio access the plugin still works, just less reliably; it logs a
|
|
121
123
|
warning and carries on.
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
Four things keep a turn on track:
|
|
124
126
|
|
|
125
127
|
- **A tolerant parser.** M365 writes calls loosely: the command as a `command:` header,
|
|
126
|
-
`filePath:` for `path`, quoted values, a copied `$ ` prompt, prose or an invented
|
|
128
|
+
`filePath:` for `path`, quoted values, a copied `$ ` prompt, a fence opened at the end of a sentence (`…first.```shell`), prose or an invented
|
|
127
129
|
`<tool_response>` after the block. These are read as the call the model meant.
|
|
128
130
|
- **One nudge after a give-up.** Chat tones sometimes answer a tool turn with "no tool
|
|
129
131
|
is available" without trying. The proxy then asks once more, softly, in the same
|
|
@@ -132,6 +134,11 @@ Three things keep a turn on track:
|
|
|
132
134
|
- **A pinned backend.** Every turn's connection carries
|
|
133
135
|
`X-RoutingParameter-SessionKey`, which the reference project found stops long
|
|
134
136
|
sessions running on a forked copy of the conversation.
|
|
137
|
+
- **Telling the model what ran.** Only the first tool block in a reply runs. When a
|
|
138
|
+
reply holds more, or goes on to predict its own result, the next turn starts with
|
|
139
|
+
one line saying so, so the model does not assume the rest ran. opencode's tool
|
|
140
|
+
errors arrive as plain text (`Error: …`) rather than a JSON envelope. In the 237
|
|
141
|
+
`quick` turns measured so far, no reply needed the note.
|
|
135
142
|
|
|
136
143
|
Measured on one tenant on 2026-11-09 (`m365/quick`, opencode 2.2.5, 36 conversations,
|
|
137
144
|
alternating builds), with and without the prompt trimming, nudge and routing header.
|
|
@@ -143,10 +150,109 @@ Both builds had the tolerant parser:
|
|
|
143
150
|
| Find a value across six files | 6/6, 2.7 turns | 6/6, 2.0 turns |
|
|
144
151
|
| Edit one config value, leave the rest | 6/6, 3.5 turns | 6/6, 4.5 turns (re-read the file to check, 3 of 6) |
|
|
145
152
|
|
|
146
|
-
Every run made its tool call on the first turn, so the nudge never fired
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
Every run made its tool call on the first turn, so the nudge never fired. No turn
|
|
154
|
+
disengaged, and none ran on a forked conversation (`turnCount` rose by one each turn).
|
|
155
|
+
|
|
156
|
+
Long sessions (2026-11-10, `m365/quick`, with all three): 4/4 solved, no nudges, no
|
|
157
|
+
forks.
|
|
158
|
+
|
|
159
|
+
| Task | Runs | Turns |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| Rename a function across ten modules, one edit at a time, then run the test | 2/2 | 37, 25 |
|
|
162
|
+
| Fix a 1,500-line file whose test fails, then fails again on a second bug | 2/2 | 8, 8 |
|
|
163
|
+
|
|
164
|
+
`turnCount` rose by one on every turn of the 37-turn session. Repeated calls were
|
|
165
|
+
progress checks (grep for what was left, re-reading a file after editing it), not loops.
|
|
166
|
+
These runs had the routing header, so they show it causes no harm. They don't show it
|
|
167
|
+
is needed, because no run without it was tried.
|
|
168
|
+
|
|
169
|
+
## MCP tools
|
|
170
|
+
|
|
171
|
+
opencode 2 does not offer MCP tools as ordinary tools. It lists them in a **Code Mode**
|
|
172
|
+
catalogue in the system prompt (`tools.github.create_issue({ … })` and so on, with
|
|
173
|
+
opencode's own `opencode` namespace among them), and they can be called only as
|
|
174
|
+
JavaScript inside its `execute` tool. The request's `tools` hold opencode's built-ins
|
|
175
|
+
plus `execute`, whose one parameter is a string of code. The lean trim drops `execute`
|
|
176
|
+
and the catalogue goes with it, so by default M365 reaches **no MCP tools** at all.
|
|
177
|
+
Offering the catalogue as it is would put a long list of TypeScript signatures in front
|
|
178
|
+
of M365 and push it back towards the Disengaged threshold.
|
|
179
|
+
|
|
180
|
+
With `{ "mcpProxy": true }` the proxy stands in for the catalogue. M365 never sees
|
|
181
|
+
`execute` or the catalogue, even with `lean` off: the catalogue is stripped from the
|
|
182
|
+
prompt, and the proxy adds **one** extra fenced tool, `mcp`, as the only way to reach
|
|
183
|
+
the MCP tools. Its one-line description summarises what is behind it, by server, so the
|
|
184
|
+
model knows a search is worth making and which words to use:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
mcp — Use 14 tools from my MCP servers — github (create_issue, list_issues, search_code, get_file, +6 more), slack (post_message, list_channels) — by searching with a few words about what you want to do; …
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The summary names up to four tools for each server and up to eight servers, and it is
|
|
191
|
+
prose, not tool blocks. A search looks like this:
|
|
192
|
+
|
|
193
|
+
````
|
|
194
|
+
```mcp
|
|
195
|
+
search: create a github issue
|
|
196
|
+
```
|
|
197
|
+
````
|
|
198
|
+
|
|
199
|
+
The proxy answers that search **itself**; it never reaches opencode. It ranks the
|
|
200
|
+
catalogue against the words (a hit in a tool's name counts more than one in its
|
|
201
|
+
description) and sends the best five back to M365 in the same conversation: each
|
|
202
|
+
match's signature as opencode wrote it, then how to call one. A search for a server's
|
|
203
|
+
prefix, such as `github.`, lists that server's tools, also up to five. The model then
|
|
204
|
+
calls a tool through `mcp` with `call:` and the path the search showed, and its
|
|
205
|
+
arguments as a JSON object:
|
|
206
|
+
|
|
207
|
+
````
|
|
208
|
+
```mcp
|
|
209
|
+
call: tools.github.create_issue
|
|
210
|
+
{"owner": "me", "repo": "project", "title": "The build fails on Node 22"}
|
|
211
|
+
```
|
|
212
|
+
````
|
|
213
|
+
|
|
214
|
+
Scalar arguments may instead be written as `key: value` lines, like any other fenced
|
|
215
|
+
tool; a value that reads as a JSON number, boolean or null is passed as one:
|
|
216
|
+
|
|
217
|
+
````
|
|
218
|
+
```mcp
|
|
219
|
+
call: tools.github.get_issue
|
|
220
|
+
owner: me
|
|
221
|
+
repo: project
|
|
222
|
+
issue_number: 42
|
|
223
|
+
```
|
|
224
|
+
````
|
|
225
|
+
|
|
226
|
+
The proxy turns that block into an `execute` call for opencode to run, with the code
|
|
227
|
+
`return await tools.github.create_issue({"owner":"me",…});`, and opencode's result comes
|
|
228
|
+
back to M365 as an ordinary tool result. In the history M365 is sent, those `execute`
|
|
229
|
+
calls are written back as the `mcp` blocks it wrote. A path that is not in the
|
|
230
|
+
catalogue, or a block the proxy cannot read, is answered in the proxy with a short note
|
|
231
|
+
on what to write instead; nothing reaches opencode. M365 sees the lean set plus one
|
|
232
|
+
tool however many MCP tools you have.
|
|
233
|
+
|
|
234
|
+
When opencode marks its catalogue as **partial** (it lists only some of its tools and
|
|
235
|
+
offers a `search(...)` function for the rest), a search that matches nothing in the
|
|
236
|
+
listed part goes to opencode's own search instead, as an `execute` call with the code
|
|
237
|
+
`return await search("…");`. Its result comes back as a tool result, and a
|
|
238
|
+
well-formed `tools.…` path it returns may then be called even though the catalogue does
|
|
239
|
+
not list it.
|
|
240
|
+
|
|
241
|
+
- **Opt-in.** `mcpProxy` is `false` by default. It takes effect when a request carries a
|
|
242
|
+
Code Mode catalogue and offers `execute`. A standalone `opencode-m365 serve` proxy
|
|
243
|
+
takes `M365_MCP_PROXY=1` instead.
|
|
244
|
+
- **Cost.** Each search answered in the proxy is one extra M365 message in the same
|
|
245
|
+
conversation, like the give-up nudge; it does not start a new conversation. So is the
|
|
246
|
+
note for an unknown path or an unreadable block.
|
|
247
|
+
- **Cap.** At most 3 searches per request, counting those notes. A reply that is still
|
|
248
|
+
an `mcp` block after the third is returned as its prose, and an `mcp` block never
|
|
249
|
+
reaches opencode as an `mcp` tool call.
|
|
250
|
+
- **Not yet measured on a live tenant.** The flow is covered against the offline stub
|
|
251
|
+
only; whether M365 searches and then calls reliably has not been measured.
|
|
252
|
+
|
|
253
|
+
With `M365_TURN_LOG` set, each search is a turn of its own in the log, marked with
|
|
254
|
+
`mcpSearch` and the query. A turn whose reply became an `execute` call is marked with
|
|
255
|
+
`mcpCall` and the tool's path, or `search` when it went to opencode's own search.
|
|
150
256
|
|
|
151
257
|
## opencode 2
|
|
152
258
|
|
|
@@ -172,7 +278,7 @@ any options you set on it, and leaves other plugins' entries alone.
|
|
|
172
278
|
### Verified how far
|
|
173
279
|
|
|
174
280
|
Against a real opencode 2.2.5, end to end, with the proxy running against the offline
|
|
175
|
-
stub rather than Microsoft: the plugin loads from a directory, registers
|
|
281
|
+
stub rather than Microsoft: the plugin loads from a directory, registers the whole model catalogue,
|
|
176
282
|
an attached image is uploaded and attached to the turn, and the session title is
|
|
177
283
|
answered locally — one chat turn reaches the backend, not two. The catalog records are
|
|
178
284
|
also checked against the real `@opencode/plugin` schema constructors in the test suite.
|
|
@@ -187,6 +293,7 @@ That stub run says nothing about Microsoft's side; see [Development](#developmen
|
|
|
187
293
|
"options": {
|
|
188
294
|
"lean": true, // trim the toolset (default: true)
|
|
189
295
|
"leanSystemPrompt": false, // replace opencode's prose prompt (default: false)
|
|
296
|
+
"mcpProxy": false, // reach MCP tools only through one `mcp` tool (default: false)
|
|
190
297
|
"setDefaultModel": true, // set `model` if you have not (default: true)
|
|
191
298
|
"setSmallModel": true, // answer session titles locally (default: true)
|
|
192
299
|
"baseUrl": null, // use an already-running proxy instead of an in-process one
|
|
@@ -203,16 +310,21 @@ in `apiKey`, or export the same `M365_PROXY_KEY` to opencode and leave `apiKey`
|
|
|
203
310
|
|
|
204
311
|
### Errors and the turn log
|
|
205
312
|
|
|
206
|
-
When M365 refuses a turn, the proxy
|
|
207
|
-
|
|
208
|
-
|
|
313
|
+
When M365 refuses a turn, the proxy reports it so that opencode does not retry it.
|
|
314
|
+
Retrying a throttle only extends it, and a refusal like a missing licence never changes.
|
|
315
|
+
opencode streams, so the refusal usually arrives inside a stream that already answered
|
|
316
|
+
200. opencode then decides from the error body alone: it retries an error whose code
|
|
317
|
+
contains "unavailable", whose message says "try again" (M365's own refusals do), or
|
|
318
|
+
which mentions a rate limit. The proxy therefore sends type `invalid_request_error`,
|
|
319
|
+
avoids those words, and uses HTTP 422 when nothing has been streamed yet. In 2.2.0 a
|
|
320
|
+
licence refusal was retried ten times. The error `code` says which refusal it was:
|
|
209
321
|
|
|
210
322
|
| Code | Meaning |
|
|
211
323
|
|---|---|
|
|
212
324
|
| `m365_throttled` | The account is throttled. Wait for a lull. |
|
|
213
|
-
| `
|
|
325
|
+
| `m365_not_served` | M365 answered with its own refusal: no credits, a model this licence does not cover, or a dead tone. Called `m365_unavailable` up to 2.2.0 |
|
|
214
326
|
| `m365_turn_rejected` | The server refused the request outright, typically a retired tone |
|
|
215
|
-
| `m365_disengaged` | M365's filter refused to engage with the prompt |
|
|
327
|
+
| `m365_disengaged` | M365's filter refused to engage with the prompt. A disengaged conversation stays that way, so the proxy drops it: the next request opens a fresh conversation and replays the whole history |
|
|
216
328
|
|
|
217
329
|
Set `M365_TURN_LOG=/path/to/turns.jsonl` before starting opencode to record one line
|
|
218
330
|
per M365 turn: the raw reply, the tool calls parsed from it, and M365's diagnostics
|
|
@@ -236,6 +348,20 @@ on the real model — they are real work, and only titling opens the extra conve
|
|
|
236
348
|
|
|
237
349
|
Models are selected by an M365 *tone*, not a model id. `m365/quick` is the default.
|
|
238
350
|
|
|
351
|
+
Each model is listed once. Older short ids (`auto`, `claude`, `gpt-5.4`, `gpt-5.3` and
|
|
352
|
+
`gpt-5.2`) used to appear alongside their descriptive twins (`m365-copilot`, `claude-sonnet`,
|
|
353
|
+
`gpt-5.4-think-deeper`, `gpt-5.3-quick`, `gpt-5.2-quick`), so the picker showed them twice.
|
|
354
|
+
They are no longer listed, but they are still accepted, with or without the `m365/`
|
|
355
|
+
prefix, so a saved config that names one keeps working.
|
|
356
|
+
|
|
357
|
+
**GPT-6 Sol** (`m365/gpt-6.2-sol`, `m365/gpt-6.1-sol`, `m365/gpt-6-sol`) are reasoning
|
|
358
|
+
models that every account can reach. Their tool turns go **without** the Copilot Studio
|
|
359
|
+
agent: the reference project's notes find that Sol serves with the agent only on a
|
|
360
|
+
premium account, and on any other account that route returns nothing. Without the agent
|
|
361
|
+
the fenced tool contract still applies, but tool use is less reliable, and Sol has a
|
|
362
|
+
remote bash sandbox of its own (`/mnt/data`), so its tool turns use the relay framing
|
|
363
|
+
and ask it to use your terminal instead. Their tool calling has not been measured here.
|
|
364
|
+
|
|
239
365
|
Tool-calling on a live tenant (2026-11-09, one non-Premium account, a single file-read
|
|
240
366
|
task per run; small samples):
|
|
241
367
|
|
|
@@ -244,13 +370,29 @@ task per run; small samples):
|
|
|
244
370
|
| `m365/quick` | 5/5 |
|
|
245
371
|
| `m365/m365-copilot` | 1/1 |
|
|
246
372
|
| `m365/gpt-5.5` (same tone as `quick`) | 0/1 |
|
|
247
|
-
| `m365/gpt-5.6` | 0/1 |
|
|
248
|
-
| `m365/gpt-5.5-think-deeper` | 0/3 —
|
|
373
|
+
| `m365/gpt-5.6` | 0/1 (the reference project: 7/30), so its picker name says "unreliable tool calls" |
|
|
374
|
+
| `m365/gpt-5.5-think-deeper` | 0/3 — said it had no file tool; 4/4 with the relay framing, below |
|
|
249
375
|
|
|
250
376
|
The reference project's README reports 100% tool compliance for `gpt-5.5-think-deeper`;
|
|
251
377
|
its protocol notes (`m365-copilot-api.md`, quirk #13) say reasoning tones disengage with
|
|
252
378
|
an agent attached. Our runs agree with the notes. Reasoning tones still serve plain chat.
|
|
253
379
|
|
|
380
|
+
The reasoning tones now get a different framing on tool turns. The tool block is
|
|
381
|
+
worded as the user asking to be guided through their own terminal, one command at a
|
|
382
|
+
time, pasting back the real output (the reference project's `relay`). A model that
|
|
383
|
+
doubts it can reach the workspace has nothing to doubt, because the user runs the
|
|
384
|
+
commands. Measured on `gpt-5.5-think-deeper` on 2026-11-10, 16 conversations:
|
|
385
|
+
|
|
386
|
+
| Framing | First reply said the tools were unavailable | Solved |
|
|
387
|
+
|---|---|---|
|
|
388
|
+
| Default, before the give-up nudge | 4/4 | 1/4 |
|
|
389
|
+
| Default, with the nudge | 8/8 | 5/8 |
|
|
390
|
+
| Relay, with the nudge | 0/4 | 4/4, with no nudge needed |
|
|
391
|
+
|
|
392
|
+
Claude tones stay on the agent, which M365 answers on GPT. The reference project ran
|
|
393
|
+
Claude without the agent and with `relay`, but an account with no Claude licence then
|
|
394
|
+
refuses every tool turn, and that could not be measured on a licensed account here.
|
|
395
|
+
|
|
254
396
|
A non-default tone (Claude, the reasoning tones) only takes effect when **no** agent is
|
|
255
397
|
attached — with one, M365 silently routes to GPT regardless. The proxy therefore attaches
|
|
256
398
|
the agent only on turns that carry tools, so plain chat reaches the model the tone selects.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as writePrivateFile, h as POWERPLATFORM_SCOPE, p as BAP_SCOPE, w as AGENT_FILE, x as createLogger } from "./server-DXznAk1h.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
// src/agent.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { t as getOrCreateAgent } from "./agent-
|
|
2
|
+
import { D as SECRETS_FILE, E as CONFIG_DIR, F as LOCAL_TITLE_MODEL, I as MODELS, M as mergeOpencodeConfig, P as DEFAULT_MODEL, T as CACHE_FILE, b as createTokenClient, d as CopilotSession, k as PROVIDER_ID, s as startServer, w as AGENT_FILE } from "./server-DXznAk1h.mjs";
|
|
3
|
+
import { t as getOrCreateAgent } from "./agent-DPNplWJY.mjs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
6
6
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -59,7 +59,8 @@ function printHelp() {
|
|
|
59
59
|
login [--interactive] Sign in to Microsoft 365 and store the token cache
|
|
60
60
|
setup [--local] Add the plugin to ~/.config/opencode/opencode.json
|
|
61
61
|
serve [--port <n>] Run the OpenAI-compatible proxy standalone
|
|
62
|
-
(key from M365_PROXY_KEY, else printed
|
|
62
|
+
(key from M365_PROXY_KEY, else printed;
|
|
63
|
+
M365_MCP_PROXY=1 enables the MCP proxy)
|
|
63
64
|
doctor [--live] Check auth, the agent, and the proxy
|
|
64
65
|
(--live also sends one short message per model tone)
|
|
65
66
|
|
|
@@ -70,7 +71,7 @@ to complete SSO/MFA by hand once — the only option on tenants with push-only
|
|
|
70
71
|
MFA, FIDO2, or a federated IdP.`);
|
|
71
72
|
}
|
|
72
73
|
async function doLogin(args) {
|
|
73
|
-
const { login } = await import("./login-
|
|
74
|
+
const { login } = await import("./login-Cts_gng-.mjs");
|
|
74
75
|
const interactive = args.includes("--interactive");
|
|
75
76
|
try {
|
|
76
77
|
const account = await login({
|
|
@@ -150,6 +151,7 @@ async function doServe(args) {
|
|
|
150
151
|
getToken: () => tokens.getToken(),
|
|
151
152
|
resolveAgent: () => getOrCreateAgent({ getTokenForScope: (scopes) => tokens.getTokenForScope(scopes) }),
|
|
152
153
|
port,
|
|
154
|
+
mcpProxy: process.env.M365_MCP_PROXY === "1",
|
|
153
155
|
...fixedKey ? { apiKey: fixedKey } : {}
|
|
154
156
|
});
|
|
155
157
|
console.log(`M365 Copilot proxy listening on ${proxy.url}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as __toESM, R as __commonJSMin, z as __require } from "./server-DXznAk1h.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import http from "http";
|
|
4
4
|
import crypto, { createHash as createHash$1 } from "crypto";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as SECRETS_FILE, E as CONFIG_DIR, S as ensurePrivateDir, _ as SYDNEY_SCOPES, f as AUTHORITY, g as REDIRECT_URI, l as object, m as CLIENT_ID, u as string, v as authCodeFromUrl, x as createLogger, y as createCachePlugin } from "./server-DXznAk1h.mjs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { chmodSync, existsSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
// src/login.ts
|
|
@@ -96,7 +96,7 @@ async function login(options = {}) {
|
|
|
96
96
|
const secrets = loadSecrets(options.secretsFile);
|
|
97
97
|
const interactive = options.interactive ?? !secrets?.mfaSecret;
|
|
98
98
|
if (!interactive && !secrets) throw new Error(`No credentials at ${options.secretsFile ?? SECRETS_FILE}. Create it with { "email", "password", "mfaSecret" }, or sign in interactively with --interactive.`);
|
|
99
|
-
const { PublicClientApplication, CryptoProvider } = await import("./dist-
|
|
99
|
+
const { PublicClientApplication, CryptoProvider } = await import("./dist-QjFnJhR3.mjs");
|
|
100
100
|
const app = new PublicClientApplication({
|
|
101
101
|
auth: {
|
|
102
102
|
clientId: CLIENT_ID,
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { t as getOrCreateAgent } from "./agent-
|
|
1
|
+
import { A as buildModelInfos, L as isLocalModel, N as resolveOptions, O as PLUGIN_ID, P as DEFAULT_MODEL, b as createTokenClient, i as SESSION_ID_HEADER, j as buildProviderInfo, k as PROVIDER_ID, s as startServer, t as AUX_REQUEST_KIND_HEADER, x as createLogger } from "./server-DXznAk1h.mjs";
|
|
2
|
+
import { t as getOrCreateAgent } from "./agent-DPNplWJY.mjs";
|
|
3
3
|
// src/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* What the plugin stands on: the OpenAI-compatible proxy, started in-process (or an
|
|
@@ -63,6 +63,7 @@ async function startRuntime(rawOptions) {
|
|
|
63
63
|
getToken: () => tokens.getToken(),
|
|
64
64
|
resolveAgent: () => getOrCreateAgent({ getTokenForScope: (scopes) => tokens.getTokenForScope(scopes) }),
|
|
65
65
|
lean: options.lean,
|
|
66
|
+
mcpProxy: options.mcpProxy,
|
|
66
67
|
...sharedKey ? { apiKey: sharedKey } : {},
|
|
67
68
|
...options.leanSystemPrompt ? { leanSystemPrompt: LEAN_SYSTEM_PROMPT } : {}
|
|
68
69
|
});
|
|
@@ -76,11 +77,20 @@ async function startRuntime(rawOptions) {
|
|
|
76
77
|
}
|
|
77
78
|
// src/plugin-v2.ts
|
|
78
79
|
const log = createLogger("plugin");
|
|
80
|
+
let warnedAboutDuplicate = false;
|
|
79
81
|
const setup = async (ctx) => {
|
|
80
82
|
const runtime = await startRuntime(ctx.options);
|
|
81
83
|
const info = buildProviderInfo(runtime.baseUrl, runtime.apiKey);
|
|
82
84
|
const models = buildModelInfos();
|
|
83
85
|
await ctx.provider.transform((editor) => {
|
|
86
|
+
const existing = editor.get?.(PROVIDER_ID);
|
|
87
|
+
if (existing && existing.provider.name === info.name) {
|
|
88
|
+
if (!warnedAboutDuplicate) {
|
|
89
|
+
warnedAboutDuplicate = true;
|
|
90
|
+
log.warn("opencode-m365-copilot is loaded more than once; keeping the first. Check your opencode config for a second plugin entry (an npm name and a checkout directory, or opencode.json and opencode.jsonc).");
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
84
94
|
editor.add({
|
|
85
95
|
info,
|
|
86
96
|
models
|