opencode-m365-copilot 0.2.1 → 0.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 +50 -0
- package/dist/{agent-BF67A0cd.mjs → agent-BDA00x1V.mjs} +2 -2
- package/dist/cli.mjs +10 -5
- package/dist/{dist-CX5bv-4h.mjs → dist-C8jy_NH0.mjs} +543 -201
- package/dist/{login-Bjybi2AZ.mjs → login-Cb_rQQHO.mjs} +3 -3
- package/dist/{otpauth.node-klD_z4Tx.mjs → otpauth.node-BaAHzqxj.mjs} +18 -9
- package/dist/plugin.d.mts +8 -4
- package/dist/plugin.mjs +84 -24
- package/dist/{server-DDD-Hlhx.mjs → server-DuHBfcPQ.mjs} +2651 -1350
- package/dist/server.d.mts +15 -6
- package/dist/server.mjs +2 -2
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -31,6 +31,9 @@ opencode # models appear as m365/*
|
|
|
31
31
|
`setup` writes only a plugin reference. The provider, the model list, the default model
|
|
32
32
|
and the small model are all registered by the plugin at startup.
|
|
33
33
|
|
|
34
|
+
Works on **opencode 1 and opencode 2** from the one install — see
|
|
35
|
+
[opencode 2](#opencode-2) for what differs.
|
|
36
|
+
|
|
34
37
|
## The thing you need to know first
|
|
35
38
|
|
|
36
39
|
**M365 refuses to work with a full coding-agent toolset.** Its "Disengaged" filter
|
|
@@ -111,6 +114,45 @@ deleted — another host may be mid-conversation with it.
|
|
|
111
114
|
Without Copilot Studio access the plugin still works, just less reliably; it logs a
|
|
112
115
|
warning and carries on.
|
|
113
116
|
|
|
117
|
+
## opencode 2
|
|
118
|
+
|
|
119
|
+
opencode 2 is a separate package family (`@opencode/cli`, `@opencode/plugin`) with a
|
|
120
|
+
different plugin API. This package serves both from a single default export: opencode 1
|
|
121
|
+
calls its `server()`, opencode 2 calls its `setup()`. There is nothing to choose and no
|
|
122
|
+
second install.
|
|
123
|
+
|
|
124
|
+
What differs, and why:
|
|
125
|
+
|
|
126
|
+
| | opencode 1 | opencode 2 |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| config key | `plugin` | `plugins` |
|
|
129
|
+
| entry form | `[spec, options]` | `{ package, options }` |
|
|
130
|
+
| local reference | the built entrypoint | **a directory** — 2.0.11 drops a file path with `configured plugin path must be a directory`, and since it swallows plugin load failures, nothing else tells you |
|
|
131
|
+
| provider registration | `config.provider.m365` | `ctx.provider.transform` → `editor.add` |
|
|
132
|
+
| openai-compatible driver | installs `@ai-sdk/openai-compatible` | bundled as `@opencode/ai/providers/openai-compatible` |
|
|
133
|
+
| title generation | `small_model` | no such setting — see below |
|
|
134
|
+
|
|
135
|
+
`opencode-m365 setup` writes **both** keys, with the right reference for each. Each
|
|
136
|
+
version silently drops the key it does not know, so the one file serves either.
|
|
137
|
+
|
|
138
|
+
Everything in [Where the trimming happens](#where-the-trimming-happens-and-why) is
|
|
139
|
+
unchanged, because it all lives in the proxy. opencode 2 does offer working equivalents
|
|
140
|
+
for the two dead v1 hooks (`ctx.tool.transform`, `session.hook("context")`); neither has
|
|
141
|
+
been measured against a live tenant, so the proxy stays the enforcement point.
|
|
142
|
+
|
|
143
|
+
### Verified how far
|
|
144
|
+
|
|
145
|
+
The opencode 1 path is verified end to end against a real 1.18.31: the plugin loads, the
|
|
146
|
+
provider registers with all 21 models, and the default and small models are set. The
|
|
147
|
+
dual entry shape is also asserted against decompiled loader logic from 1.18.0, 1.18.18,
|
|
148
|
+
1.18.28 and 1.18.31 in `src/plugin-entry.test.ts` — opencode's docs say the object entry
|
|
149
|
+
form arrived in 1.18.29, but 1.18.0 already has the identical detect path, so the peer
|
|
150
|
+
floor did not move.
|
|
151
|
+
|
|
152
|
+
The opencode 2 path is covered by unit tests against a stand-in context, and its catalog
|
|
153
|
+
records are checked against the real `@opencode/plugin` schema constructors. It has
|
|
154
|
+
**not** yet been exercised against a live opencode 2 end to end.
|
|
155
|
+
|
|
114
156
|
## Configuration
|
|
115
157
|
|
|
116
158
|
```jsonc
|
|
@@ -125,6 +167,8 @@ warning and carries on.
|
|
|
125
167
|
}
|
|
126
168
|
```
|
|
127
169
|
|
|
170
|
+
On opencode 2 the same block goes under `plugins`, as `{ "package": ..., "options": ... }`.
|
|
171
|
+
|
|
128
172
|
### Why `small_model` is redirected
|
|
129
173
|
|
|
130
174
|
opencode's `small_model` defaults to your main model, so every new session would generate
|
|
@@ -132,6 +176,12 @@ its title on M365 — opening a **second conversation**. The account-level throt
|
|
|
132
176
|
conversations started, not messages, so that is the fastest way to get throttled. The
|
|
133
177
|
`m365/local-title` model is answered by the proxy itself and never opens a connection.
|
|
134
178
|
|
|
179
|
+
opencode 2 has no `small_model`, and its title hook exposes the model read-only, so the
|
|
180
|
+
same guarantee is reached differently: the plugin marks the title request on a header
|
|
181
|
+
(`x-m365-request-kind: title`) and the proxy answers it locally. Compaction and
|
|
182
|
+
generation are left on the real model — they are real work, and only titling opens the
|
|
183
|
+
extra conversation. `setSmallModel` controls both mechanisms.
|
|
184
|
+
|
|
135
185
|
## Models
|
|
136
186
|
|
|
137
187
|
Models are selected by an M365 *tone*, not a model id. `m365/gpt-5.5-think-deeper` is the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as POWERPLATFORM_SCOPE, h as AGENT_FILE, m as createLogger, o as BAP_SCOPE } from "./server-DuHBfcPQ.mjs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { dirname } from "node:path";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
5
|
//#region src/agent.ts
|
|
6
6
|
/**
|
|
7
7
|
* The Copilot Studio declarative agent.
|
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 LOCAL_TITLE_MODEL, E as DEFAULT_MODEL, _ as CONFIG_DIR, b as PROVIDER_ID, g as CACHE_FILE, h as AGENT_FILE, n as startServer, p as createTokenClient, v as SECRETS_FILE, w as mergeOpencodeConfig } from "./server-DuHBfcPQ.mjs";
|
|
3
|
+
import { t as getOrCreateAgent } from "./agent-BDA00x1V.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
6
6
|
import { homedir } from "node:os";
|
|
@@ -45,7 +45,7 @@ to complete SSO/MFA by hand once — the only option on tenants with push-only
|
|
|
45
45
|
MFA, FIDO2, or a federated IdP.`);
|
|
46
46
|
}
|
|
47
47
|
async function doLogin(args) {
|
|
48
|
-
const { login } = await import("./login-
|
|
48
|
+
const { login } = await import("./login-Cb_rQQHO.mjs");
|
|
49
49
|
const interactive = args.includes("--interactive");
|
|
50
50
|
try {
|
|
51
51
|
const account = await login({
|
|
@@ -66,7 +66,9 @@ async function doLogin(args) {
|
|
|
66
66
|
}
|
|
67
67
|
async function doSetup(args) {
|
|
68
68
|
const local = args.includes("--local");
|
|
69
|
-
const
|
|
69
|
+
const dist = dirname(fileURLToPath(import.meta.url));
|
|
70
|
+
const pluginRef = local ? resolve(dist, "plugin.mjs") : "opencode-m365-copilot";
|
|
71
|
+
const pluginDir = local ? resolve(dist, "..") : pluginRef;
|
|
70
72
|
if (local && !existsSync(pluginRef)) {
|
|
71
73
|
console.error(`No build at ${pluginRef}. Run \`pnpm build\` first.`);
|
|
72
74
|
process.exitCode = 1;
|
|
@@ -80,7 +82,10 @@ async function doSetup(args) {
|
|
|
80
82
|
process.exitCode = 1;
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
|
-
const merged = mergeOpencodeConfig(existing, {
|
|
85
|
+
const merged = mergeOpencodeConfig(existing, {
|
|
86
|
+
pluginRef,
|
|
87
|
+
pluginDir
|
|
88
|
+
});
|
|
84
89
|
mkdirSync(dirname(OPENCODE_CONFIG), { recursive: true });
|
|
85
90
|
writeFileSync(OPENCODE_CONFIG, `${JSON.stringify(merged, null, 2)}\n`);
|
|
86
91
|
console.log(`Added ${pluginRef} to ${OPENCODE_CONFIG}`);
|