opencode-m365-copilot 2.0.0 → 2.1.1

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.
@@ -1,4 +1,4 @@
1
- import { C as SECRETS_FILE, S as CONFIG_DIR, _ as createLogger, c as AUTHORITY, f as REDIRECT_URI, h as createCachePlugin, m as authCodeFromUrl, o as object, p as SYDNEY_SCOPES, s as string, u as CLIENT_ID, v as ensurePrivateDir } from "./server-IXv9y_4x.mjs";
1
+ import { C as SECRETS_FILE, S as CONFIG_DIR, _ as createLogger, c as AUTHORITY, f as REDIRECT_URI, h as createCachePlugin, m as authCodeFromUrl, o as object, p as SYDNEY_SCOPES, s as string, u as CLIENT_ID, v as ensurePrivateDir } from "./server-MaGKSmnd.mjs";
2
2
  import { join } from "node:path";
3
3
  import { chmodSync, existsSync, readFileSync, statSync } from "node:fs";
4
4
  // src/login.ts
@@ -79,7 +79,7 @@ function normaliseTotpSecret(raw) {
79
79
  }
80
80
  /** Current 6-digit code for a base32 seed. */
81
81
  async function totpCode(secret) {
82
- const { TOTP, Secret } = await import("./otpauth.node-DaSYf7YH.mjs");
82
+ const { TOTP, Secret } = await import("./otpauth.node-Cz2NJJEI.mjs");
83
83
  return new TOTP({
84
84
  secret: Secret.fromBase32(normaliseTotpSecret(secret)),
85
85
  digits: 6,
@@ -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-BNzsla4k.mjs");
99
+ const { PublicClientApplication, CryptoProvider } = await import("./dist-DoXU8l_x.mjs");
100
100
  const app = new PublicClientApplication({
101
101
  auth: {
102
102
  clientId: CLIENT_ID,
@@ -201,7 +201,7 @@ import * as crypto from "node:crypto";
201
201
  * Returns random bytes.
202
202
  * @param {number} size Size.
203
203
  * @returns {Uint8Array} Random bytes.
204
- */ const randomBytes$1 = (size) => {
204
+ */ const randomBytes = (size) => {
205
205
  if (crypto?.randomBytes) return crypto.randomBytes(size);
206
206
  else if (globalScope.crypto?.getRandomValues) return globalScope.crypto.getRandomValues(new Uint8Array(size));
207
207
  else throw new Error("Cryptography API not available");
@@ -302,7 +302,7 @@ import * as crypto from "node:crypto";
302
302
  * Secret key.
303
303
  * @type {Uint8Array}
304
304
  * @readonly
305
- */ this.bytes = typeof buffer === "undefined" ? randomBytes$1(size) : new Uint8Array(buffer);
305
+ */ this.bytes = typeof buffer === "undefined" ? randomBytes(size) : new Uint8Array(buffer);
306
306
  Object.defineProperty(this, "bytes", {
307
307
  enumerable: true,
308
308
  writable: false,
@@ -316,7 +316,7 @@ import * as crypto from "node:crypto";
316
316
  * @param {string} a String a.
317
317
  * @param {string} b String b.
318
318
  * @returns {boolean} Equality result.
319
- */ const timingSafeEqual$1 = (a, b) => {
319
+ */ const timingSafeEqual = (a, b) => {
320
320
  if (crypto?.timingSafeEqual) return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
321
321
  else {
322
322
  if (a.length !== b.length) throw new TypeError("Input strings must have the same length");
@@ -407,7 +407,7 @@ import * as crypto from "node:crypto";
407
407
  counter: i,
408
408
  hmac
409
409
  });
410
- if (timingSafeEqual$1(token, generatedToken)) delta = i - counter;
410
+ if (timingSafeEqual(token, generatedToken)) delta = i - counter;
411
411
  };
412
412
  check(counter);
413
413
  for (let i = 1; i <= window && delta === null; ++i) {
package/dist/plugin.d.mts CHANGED
@@ -1,3 +1,23 @@
1
+ /**
2
+ * The plugin entry: one default export, the opencode 2 plugin.
3
+ *
4
+ * opencode 2 imports the package's root entry and validates its default export as
5
+ * `{ id, setup }`. A shape it does not accept is not an error — the plugin simply
6
+ * never loads — so `plugin-entry.test.ts` checks the built artefact.
7
+ *
8
+ * Two rules outlive opencode 1 support, and both are pinned there too:
9
+ *
10
+ * - **Exactly one export.** A loader that walks every export and finds a second
11
+ * plugin-shaped value starts the proxy twice; a non-plugin one can fail the load.
12
+ * - **No `./server` export subpath in package.json.** That name is opencode's for a
13
+ * plugin's server entry. Ours once pointed it at the HTTP proxy, and that was #26.
14
+ *
15
+ * The definition is annotated as `Plugin.Plugin` rather than built with
16
+ * `Plugin.define(...)`: that helper is the identity function, and calling it would
17
+ * mean importing `@opencode/plugin` at runtime. A type-only import keeps the
18
+ * published package free of it, which is also what keeps the dts bundler from
19
+ * inlining effect (see `tsdown.config.ts`).
20
+ */
1
21
  import { Plugin } from "@opencode/plugin";
2
22
  declare const definition: Plugin.Plugin;
3
23
  export { definition as default };
package/dist/plugin.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { A as DEFAULT_MODEL, D as buildProviderInfo, E as buildModelInfos, M as isLocalModel, T as PROVIDER_ID, _ as createLogger, a as startServer, g as createTokenClient, k as resolveOptions, r as SESSION_ID_HEADER, t as AUX_REQUEST_KIND_HEADER, w as PLUGIN_ID } from "./server-IXv9y_4x.mjs";
2
- import { t as getOrCreateAgent } from "./agent-D4_Eut51.mjs";
1
+ import { A as DEFAULT_MODEL, D as buildProviderInfo, E as buildModelInfos, M as isLocalModel, T as PROVIDER_ID, _ as createLogger, a as startServer, g as createTokenClient, k as resolveOptions, r as SESSION_ID_HEADER, t as AUX_REQUEST_KIND_HEADER, w as PLUGIN_ID } from "./server-MaGKSmnd.mjs";
2
+ import { t as getOrCreateAgent } from "./agent-Do_zx7Ev.mjs";
3
3
  // src/runtime.ts
4
4
  /**
5
5
  * What the plugin stands on: the OpenAI-compatible proxy, started in-process (or an
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { homedir } from "node:os";
3
- import { dirname, join, parse, resolve, sep } from "node:path";
3
+ import { dirname, join, parse as parse$1, resolve, sep } from "node:path";
4
4
  import { appendFileSync, chmodSync, closeSync, constants, mkdirSync, openSync, readFileSync, realpathSync, writeFileSync, writeSync } from "node:fs";
5
5
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
6
6
  import { createServer } from "node:http";
@@ -60,6 +60,8 @@ const LOCAL_TITLE_MODEL = "local-title";
60
60
  */
61
61
  const DEFAULT_MODEL = "gpt-5.5-think-deeper";
62
62
  const MODELS = [
63
+ m("work", "M365 Copilot (Work — reads your mailbox)", "magic", false, true),
64
+ m("work-think", "M365 Copilot (Work, Think Deeper)", "Gpt_5_5_Reasoning", true, true),
63
65
  m("gpt-5.6-think-deeper", "GPT-5.6 (Think Deeper)", "Gpt_5_6_Reasoning", true),
64
66
  m("gpt-5.5-think-deeper", "GPT-5.5 (Think Deeper)", "Gpt_5_5_Reasoning", true),
65
67
  m("gpt-5.5", "GPT-5.5", "Gpt_5_5_Chat", false),
@@ -82,12 +84,13 @@ const MODELS = [
82
84
  m("gpt-5.2-think-deeper", "GPT-5.2 (Think Deeper)", "Gpt_5_2_Reasoning", true),
83
85
  m(LOCAL_TITLE_MODEL, "Local titler (no M365 call)", null, false)
84
86
  ];
85
- function m(id, name, tone, reasoning) {
87
+ function m(id, name, tone, reasoning, grounded = false) {
86
88
  return {
87
89
  id,
88
90
  name,
89
91
  tone,
90
92
  reasoning,
93
+ grounded,
91
94
  limit: {
92
95
  context: CONTEXT_TOKENS,
93
96
  output: OUTPUT_TOKENS
@@ -773,7 +776,7 @@ function canonical(path) {
773
776
  */
774
777
  function isHomeOrAbove(dir) {
775
778
  const target = canonical(dir);
776
- if (target === parse(target).root) return true;
779
+ if (target === parse$1(target).root) return true;
777
780
  const home = canonical(homedir());
778
781
  return home === target || home.startsWith(target.endsWith(sep) ? target : `${target}${sep}`);
779
782
  }
@@ -946,7 +949,7 @@ function createTokenClient(options = {}) {
946
949
  const cache = /* @__PURE__ */ new Map();
947
950
  async function client() {
948
951
  if (app) return app;
949
- const { PublicClientApplication } = await import("./dist-BNzsla4k.mjs");
952
+ const { PublicClientApplication } = await import("./dist-DoXU8l_x.mjs");
950
953
  app = new PublicClientApplication({
951
954
  auth: {
952
955
  clientId: CLIENT_ID,
@@ -2019,6 +2022,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2019
2022
  data = this.consume(this._payloadLength);
2020
2023
  if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);
2021
2024
  }
2025
+ this._mask = void 0;
2022
2026
  if (this._opcode > 7) {
2023
2027
  this.controlMessage(data, cb);
2024
2028
  return;
@@ -3060,6 +3064,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3060
3064
  const https = __require("https");
3061
3065
  const http = __require("http");
3062
3066
  const net = __require("net");
3067
+ const querystring = __require("querystring");
3063
3068
  const tls = __require("tls");
3064
3069
  const { randomBytes, createHash } = __require("crypto");
3065
3070
  const { Duplex, Readable } = __require("stream");
@@ -3618,8 +3623,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3618
3623
  } catch {
3619
3624
  throw new SyntaxError(`Invalid URL: ${address}`);
3620
3625
  }
3621
- if (parsedUrl.protocol === "http:") parsedUrl.protocol = "ws:";
3622
- else if (parsedUrl.protocol === "https:") parsedUrl.protocol = "wss:";
3626
+ if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
3627
+ parsedUrl = new URL(parsedUrl);
3628
+ parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
3629
+ }
3623
3630
  websocket._url = parsedUrl.href;
3624
3631
  const isSecure = parsedUrl.protocol === "wss:";
3625
3632
  const isIpcUrl = parsedUrl.protocol === "ws+unix:";
@@ -3672,7 +3679,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3672
3679
  if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
3673
3680
  else opts.headers.Origin = opts.origin;
3674
3681
  }
3675
- if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
3682
+ if (parsedUrl.username || parsedUrl.password) opts.auth = `${querystring.unescape(parsedUrl.username)}:${querystring.unescape(parsedUrl.password)}`;
3676
3683
  if (isIpcUrl) {
3677
3684
  const i = opts.path.indexOf(":");
3678
3685
  if (i === -1) {
@@ -3888,8 +3895,12 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3888
3895
  function receiverOnConclude(code, reason) {
3889
3896
  const websocket = this[kWebSocket];
3890
3897
  websocket._closeFrameReceived = true;
3891
- websocket._closeMessage = reason;
3892
3898
  websocket._closeCode = code;
3899
+ if (reason.length === 0) websocket._closeMessage = EMPTY_BUFFER;
3900
+ else {
3901
+ websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
3902
+ websocket._closeMessage.set(reason);
3903
+ }
3893
3904
  if (websocket._socket[kWebSocket] === void 0) return;
3894
3905
  websocket._socket.removeListener("data", socketOnData);
3895
3906
  process.nextTick(resume, websocket._socket);
@@ -4731,6 +4742,19 @@ const VARIANTS = [
4731
4742
  "feature.EnableSydneyClientCompliance",
4732
4743
  "feature.EnableStreaming"
4733
4744
  ].join(",");
4745
+ /**
4746
+ * The variants the Outlook side-pane client sends, used only for a grounded
4747
+ * turn. Verified live 2026-11-09: without them the mailbox scenario replies
4748
+ * "you don't have a valid license" (contentOrigin "BotConnection"). Cargo-culted
4749
+ * from a captured first-party side-pane session, exactly as VARIANTS above is.
4750
+ */
4751
+ const GROUNDED_VARIANTS = [
4752
+ "feature.OutlookSidepaneWorkCopilotToHelix",
4753
+ "feature.EnableStarterLicenseCheckBypass",
4754
+ "feature.IsStreamingModeInChatRequestEnabled",
4755
+ "feature.isExternalEmailEnabled",
4756
+ "IncludeSourceAttributionsConcise"
4757
+ ].join(",");
4734
4758
  /** The message types we tell the server we are able to render. */
4735
4759
  const ALLOWED_MESSAGE_TYPES = [
4736
4760
  "Chat",
@@ -4766,6 +4790,24 @@ var DisengagedError = class extends Error {
4766
4790
  }
4767
4791
  };
4768
4792
  /**
4793
+ * Strip Copilot's inline citation control tokens from a GROUNDED answer.
4794
+ *
4795
+ * The web UI renders these as citation chips; over the wire they arrive as
4796
+ * literal noise: private-use-area delimiters (U+E000–U+F8FF) wrapping
4797
+ * `cite…turn1search23…` runs, plus `【2-9c5ade】`-style attribution markers.
4798
+ * Only the side-pane (grounded) surface emits them, which is why the caller runs
4799
+ * this on grounded turns only — a coding answer is passed through untouched, so
4800
+ * its indentation is never altered.
4801
+ *
4802
+ * Even here the whitespace tidy is indentation-safe: it collapses only runs that
4803
+ * FOLLOW a non-space character (the double spaces a removed token leaves mid
4804
+ * line), never leading indentation — a grounded answer can still contain a code
4805
+ * block. Measured against live answers 2026-11-09.
4806
+ */
4807
+ function cleanAnswer(text) {
4808
+ return text.replace(/[\u{E000}-\u{F8FF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/gu, "").replace(/cite(?:turn\d+[a-z]+\d+)+/gi, "").replace(/【[^】]{1,60}】/g, "").replace(/[ \t]+\n/g, "\n").replace(/(\S)[ \t]{2,}/g, "$1 ").trim();
4809
+ }
4810
+ /**
4769
4811
  * One M365 conversation.
4770
4812
  *
4771
4813
  * Stateful across turns: the conversation and session ids persist so the server keeps
@@ -4791,7 +4833,7 @@ var CopilotSession = class {
4791
4833
  if (turn.signal?.aborted) throw abortError();
4792
4834
  const token = await this.options.getToken();
4793
4835
  const { oid, tid } = decodeJwt(token);
4794
- const url = this.buildUrl(token, oid, tid);
4836
+ const url = this.buildUrl(token, oid, tid, turn.grounded ?? false);
4795
4837
  const { annotations, note } = await this.uploadImages(token, turn);
4796
4838
  const message = {
4797
4839
  text: note ? `${text}\n\n${note}` : text,
@@ -4833,18 +4875,28 @@ var CopilotSession = class {
4833
4875
  note: images.length === 1 ? "(The user attached an image, but it could not be uploaded, so it is not visible to you. If it matters, let them know.)" : `(${missing} of the ${images.length} attached images could not be uploaded, so they are not visible to you. If they matter, let the user know.)`
4834
4876
  };
4835
4877
  }
4836
- buildUrl(token, oid, tid) {
4837
- return `${this.options.endpoint ?? DEFAULT_ENDPOINT}/m365Copilot/Chathub/${oid}@${tid}?${new URLSearchParams({
4878
+ buildUrl(token, oid, tid, grounded) {
4879
+ const origin = this.options.endpoint ?? DEFAULT_ENDPOINT;
4880
+ const scenarioParams = grounded ? {
4881
+ source: "\"owahub\"",
4882
+ product: "OwaHub",
4883
+ agentHost: "Bizchat.Sidepane",
4884
+ scenario: "OutlookSidepaneWorkCopilot",
4885
+ agent: "work"
4886
+ } : {
4887
+ source: "\"officeweb\"",
4888
+ product: "Office",
4889
+ agentHost: "Bizchat.FullScreen",
4890
+ scenario: "OfficeWebIncludedCopilot"
4891
+ };
4892
+ return `${origin}/m365Copilot/Chathub/${oid}@${tid}?${new URLSearchParams({
4838
4893
  access_token: token,
4839
4894
  ConversationId: this.conversationId,
4840
4895
  chatsessionid: this.sessionId,
4841
4896
  "X-SessionId": this.sessionId,
4842
4897
  clientrequestid: randomUUID(),
4843
- source: "\"officeweb\"",
4844
- product: "Office",
4845
- agentHost: "Bizchat.FullScreen",
4846
- scenario: "OfficeWebIncludedCopilot",
4847
- variants: VARIANTS
4898
+ ...scenarioParams,
4899
+ variants: grounded ? GROUNDED_VARIANTS : VARIANTS
4848
4900
  }).toString()}`;
4849
4901
  }
4850
4902
  /** Drive one turn to completion. */
@@ -4863,7 +4915,8 @@ var CopilotSession = class {
4863
4915
  reject(error);
4864
4916
  return;
4865
4917
  }
4866
- result.text = deltaText.length >= snapshotText.length ? deltaText : snapshotText;
4918
+ const raw = deltaText.length >= snapshotText.length ? deltaText : snapshotText;
4919
+ result.text = turn.grounded ? cleanAnswer(raw) : raw;
4867
4920
  resolve(result);
4868
4921
  };
4869
4922
  const onAbort = () => {
@@ -4951,20 +5004,35 @@ var CopilotSession = class {
4951
5004
  const argument = {
4952
5005
  message,
4953
5006
  tone: turn.tone ?? "magic",
4954
- source: "officeweb",
5007
+ source: turn.grounded ? "owahub" : "officeweb",
4955
5008
  streamingMode: "ConciseWithPadding",
4956
5009
  isStartOfSession: this.turnIndex === 0,
4957
5010
  conversationId: this.conversationId,
4958
5011
  allowedMessageTypes: ALLOWED_MESSAGE_TYPES,
4959
5012
  optionsSets: [],
4960
- clientInfo: {
5013
+ clientInfo: turn.grounded ? {
5014
+ clientPlatform: "OwaHub-web",
5015
+ clientAppName: "OwaHub",
5016
+ clientAppType: "Web",
5017
+ productEntryPoint: "Email"
5018
+ } : {
4961
5019
  clientPlatform: "mcmcopilot-web",
4962
5020
  clientAppName: "Office",
4963
5021
  clientAppVersion: "1.0.0"
4964
5022
  },
4965
5023
  traceId: randomUUID()
4966
5024
  };
4967
- if (turn.agentId) {
5025
+ if (turn.grounded) {
5026
+ argument.gpts = [{
5027
+ id: "bizchat-as-gpt-scenario",
5028
+ source: "BuiltInAgents",
5029
+ clientOverrides: { capabilities: [{ name: "WebSearch" }, { name: "WorkSearch" }] }
5030
+ }];
5031
+ argument.plugins = [{
5032
+ Id: "BingWebSearch",
5033
+ Source: "BuiltIn"
5034
+ }];
5035
+ } else if (turn.agentId) {
4968
5036
  argument.threadLevelGptId = {
4969
5037
  id: turn.agentId,
4970
5038
  source: "MOS3"
@@ -5001,6 +5069,7 @@ var CopilotSession = class {
5001
5069
  log$1.info("sending turn", trunc({
5002
5070
  tone: argument.tone,
5003
5071
  agent: Boolean(turn.agentId),
5072
+ grounded: Boolean(turn.grounded),
5004
5073
  images: outgoing.annotations.length,
5005
5074
  text
5006
5075
  }));
@@ -9499,7 +9568,7 @@ const initializer = (inst, issues) => {
9499
9568
  };
9500
9569
  const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
9501
9570
  // node_modules/zod/v4/classic/parse.js
9502
- const parse$1 = /* @__PURE__ */ _parse(ZodRealError);
9571
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
9503
9572
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
9504
9573
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
9505
9574
  const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -9630,7 +9699,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
9630
9699
  own(this, "~standard", value);
9631
9700
  },
9632
9701
  parse: function _parse(data, params) {
9633
- return parse$1(this, data, params, { callee: _parse });
9702
+ return parse(this, data, params, { callee: _parse });
9634
9703
  },
9635
9704
  parseAsync: async function _parseAsync(data, params) {
9636
9705
  return await parseAsync(this, data, params, { callee: _parseAsync });
@@ -10938,21 +11007,23 @@ async function runTurn(request, response, context, body, conversation, model, to
10938
11007
  getToken: context.deps.getToken,
10939
11008
  ...context.deps.endpoint ? { endpoint: context.deps.endpoint } : {}
10940
11009
  });
11010
+ const effectiveTools = model.grounded ? [] : tools;
10941
11011
  const images = collectImages(body.messages, conversation.sentMessageCount);
10942
- const prompt = buildTurnPrompt(body.messages, tools, conversation.sentMessageCount, { ...context.deps.leanSystemPrompt !== void 0 ? { leanSystemPrompt: context.deps.leanSystemPrompt } : {} });
10943
- const agent = tools.length > 0 ? await context.agentId() : null;
11012
+ const prompt = buildTurnPrompt(body.messages, effectiveTools, conversation.sentMessageCount, { ...context.deps.leanSystemPrompt !== void 0 ? { leanSystemPrompt: context.deps.leanSystemPrompt } : {} });
11013
+ const agent = effectiveTools.length > 0 ? await context.agentId() : null;
10944
11014
  const abort = new AbortController();
10945
11015
  request.on("close", () => {
10946
11016
  if (!response.writableEnded) abort.abort();
10947
11017
  });
10948
11018
  const streaming = body.stream === true;
10949
11019
  const streamId = `chatcmpl-${randomUUID()}`;
10950
- const canStreamText = streaming && tools.length === 0;
11020
+ const canStreamText = streaming && effectiveTools.length === 0 && !model.grounded;
10951
11021
  if (streaming) startSse(response);
10952
11022
  try {
10953
11023
  const result = await conversation.session.run(prompt, {
10954
11024
  ...model.tone ? { tone: model.tone } : {},
10955
11025
  agentId: agent,
11026
+ ...model.grounded ? { grounded: true } : {},
10956
11027
  signal: abort.signal,
10957
11028
  ...images.length > 0 ? { images } : {},
10958
11029
  ...canStreamText ? { onDelta: (chunk) => response.write(streamChunk(streamId, model.id, { content: chunk })) } : {}
@@ -10961,14 +11032,14 @@ async function runTurn(request, response, context, body, conversation, model, to
10961
11032
  if (!streaming) {
10962
11033
  sendJson(response, 200, buildCompletion(result, {
10963
11034
  model: model.id,
10964
- tools,
11035
+ tools: effectiveTools,
10965
11036
  allowMultiple: context.deps.allowMultiTool ?? false
10966
11037
  }));
10967
11038
  return;
10968
11039
  }
10969
- finishStream(response, streamId, model.id, result, tools, canStreamText, context.deps.allowMultiTool ?? false);
11040
+ finishStream(response, streamId, model.id, result, effectiveTools, canStreamText, context.deps.allowMultiTool ?? false);
10970
11041
  } catch (error) {
10971
- handleTurnFailure(response, error, streaming, tools.length);
11042
+ handleTurnFailure(response, error, streaming, effectiveTools.length);
10972
11043
  }
10973
11044
  }
10974
11045
  /** Emit the closing frames of a streamed turn. */
package/dist/server.d.mts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The OpenAI-compatible HTTP surface.
3
+ *
4
+ * Small on purpose: `node:http` rather than a framework, because this runs inside
5
+ * opencode's own process and every dependency here is one opencode has to install.
6
+ * It binds loopback only, and loopback is not a trust boundary: every browser tab on
7
+ * the machine can reach it too. So every request must also carry a per-launch secret
8
+ * (`Authorization: Bearer <apiKey>`), must name a loopback `Host` (DNS rebinding), and
9
+ * must not come from a browser `Origin` the caller did not allow. No CORS headers are
10
+ * ever sent — opencode is a server-side client and needs none.
11
+ */
1
12
  /**
2
13
  * Default when a request carries no model.
3
14
  *
package/dist/server.mjs CHANGED
@@ -1 +1 @@
1
- export { t as AUX_REQUEST_KIND_HEADER, n as DEFAULT_MAX_BODY_BYTES, A as DEFAULT_MODEL, r as SESSION_ID_HEADER, i as generateApiKey, a as startServer } from "./server-IXv9y_4x.mjs";
1
+ export { t as AUX_REQUEST_KIND_HEADER, n as DEFAULT_MAX_BODY_BYTES, A as DEFAULT_MODEL, r as SESSION_ID_HEADER, i as generateApiKey, a as startServer } from "./server-MaGKSmnd.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-m365-copilot",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Use your org's Microsoft 365 Copilot as the model backend for opencode",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,19 +32,19 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@azure/msal-node": "^7.0.0",
36
- "otpauth": "^9.5.0",
37
- "ws": "^8.20.0",
38
- "zod": "^4.3.6"
35
+ "@azure/msal-node": "^7.2.1",
36
+ "otpauth": "^9.6.0",
37
+ "ws": "^8.22.2",
38
+ "zod": "^4.6.7"
39
39
  },
40
40
  "devDependencies": {
41
- "@opencode/plugin": "^2.2.5",
42
- "@types/node": "^26.2.0",
43
- "@types/ws": "^8.18.1",
44
- "playwright": "^1.62.1",
45
- "tsdown": "^0.23.4",
41
+ "@opencode/plugin": "^2.2.6",
42
+ "@types/node": "^26.6.6",
43
+ "@types/ws": "^8.18.2",
44
+ "playwright": "^1.65.0",
45
+ "tsdown": "^0.23.7",
46
46
  "typescript": "^7.0.2",
47
- "vitest": "^5.0.0"
47
+ "vitest": "^5.1.0"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
@@ -73,5 +73,9 @@
73
73
  "playwright": {
74
74
  "optional": true
75
75
  }
76
+ },
77
+ "overrides": {
78
+ "glob": "^14.0.3",
79
+ "minimatch": "^11.0.2"
76
80
  }
77
81
  }