omni-notify-mcp 1.3.454 → 1.3.456

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.
@@ -91,7 +91,7 @@ export function namedProvider(...args) { return conversationOwner.store.namedPro
91
91
  export function creationPending(...args) { return conversationOwner.store.creationPending(...args); }
92
92
  export function creationsPending(...args) { return conversationOwner.store.creationsPending(...args); }
93
93
  export function createdIn(folder, provider, chatOf, make) { return conversationOwner.store.createdIn(folder, provider, chatOf, make); }
94
- export function createdOn(project, provider, chatOf, make) { return conversationOwner.store.createdOn(project, provider, chatOf, make); }
94
+ export function createdOn(...args) { return conversationOwner.store.createdOn(...args); }
95
95
  export function requireOwnCli(...args) { return conversationOwner.store.requireOwnCli(...args); }
96
96
  export function listProjects(...args) { return conversationOwner.store.listProjects(...args); }
97
97
  export function startConversation(...args) { return conversationOwner.store.startConversation(...args); }
@@ -232,7 +232,7 @@ function buildServer(caller, base, offer) {
232
232
  const target = conversation !== undefined ? seen(conversation) : (routes ? routeAsk(caller, text)?.id : undefined);
233
233
  // NULL-OK: field target is OPTIONAL and therefore it is ok to check for NULL
234
234
  const sent = target === undefined
235
- ? { id: (await createdOn(project, provider, () => caller, (on) => startConversation({ platform: "mcp", technical: true, chat: caller, ...on, model, text, receivedMs: Math.round(performance.now() - arrived), arrival }))).made.id, turn: 1 }
235
+ ? { id: (await createdOn(project, provider, () => caller, (on) => startConversation({ platform: "mcp", technical: true, chat: caller, ...on, text, receivedMs: Math.round(performance.now() - arrived), arrival }), model)).made.id, turn: 1 }
236
236
  : { id: seen(target), turn: sendToConversation(target, text, Math.round(performance.now() - arrived), arrival).n };
237
237
  const { events, ended, turn } = await waitForTurn(sent.id, sent.turn, MAX_WAIT_SECONDS);
238
238
  const meta = readConversation(sent.id);
@@ -263,11 +263,11 @@ function buildServer(caller, base, offer) {
263
263
  server.tool("agent_start", `Creates a new conversation AND submits text as its first task (turn 1) in one call, and returns {id, state} at once without waiting for the agent. The way to run a long or autonomous task: read its progress and answer with agent_wait {id, after:1, wait:${MAX_WAIT_SECONDS}}, again with the after each reply returned, until an event of kind answer or failed with turn 1, or of kind stopped, arrives. The task is already submitted, so do not also agent_send the same text, and do not call agent_start again for it — each call starts another agent on the task. agent_prompt sends and waits in one blocking call instead.`, { project: projectField(offer).optional().describe(`The workspace this conversation runs in: exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted. Leave it out and the conversation runs at the workspace root (${offer.under}) with every project's rules, which route the request to its project; it is never resolved from the text`), text: z.string().min(1).describe("The first task, submitted by this call itself"), provider: z.string().min(1).optional().describe(`The agent CLI this conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}. Use auto or omit it for the shared subscription-first choice. A permitted funded key is considered once eligible subscriptions are exhausted`), model: z.string().min(1).optional() }, ({ project, text, provider, model }) => act(async () => {
264
264
  const arrived = performance.now();
265
265
  const arrival = arrivalOf(requestIdOf(), randomUUID().slice(0, 8));
266
- const meta = (await createdOn(project, provider, () => caller, (on) => startConversation({ platform: "mcp", technical: true, chat: caller, ...on, model, text, receivedMs: Math.round(performance.now() - arrived), arrival }))).made;
266
+ const meta = (await createdOn(project, provider, () => caller, (on) => startConversation({ platform: "mcp", technical: true, chat: caller, ...on, text, receivedMs: Math.round(performance.now() - arrived), arrival }), model)).made;
267
267
  return { id: meta.id, state: meta.state };
268
268
  }));
269
269
  server.tool("agent_open", `Opens a new conversation with no message and starts no agent: no text, no process started and nothing spent. It returns {id, state} at once. It names the workspace and the agent CLI the conversation opens on — project and provider are both optional: a conversation with no project runs at the workspace root, whose rules route each request to its project, and one with no provider runs on the agent CLI whose subscription has room. Ask it with agent_send and read it with agent_wait; the folder can be switched afterwards with agent_project, and the conversation keeps its id and its whole transcript.`, { project: projectField(offer).optional().describe(`Exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted. Leave it out for the workspace root (${offer.under}), where the rules of every project route the request; it is never resolved from anything else`), provider: z.string().min(1).optional().describe(`The agent CLI the conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}. Use auto or omit it for the shared subscription-first choice. A permitted funded key is considered once eligible subscriptions are exhausted`), model: z.string().min(1).optional() }, ({ project, provider, model }) => act(async () => {
270
- const meta = (await createdOn(project, provider, () => caller, (on) => openConversation({ platform: "mcp", technical: true, chat: caller, ...on, model }))).made;
270
+ const meta = (await createdOn(project, provider, () => caller, (on) => openConversation({ platform: "mcp", technical: true, chat: caller, ...on }), model)).made;
271
271
  return { id: meta.id, state: meta.state };
272
272
  }));
273
273
  server.tool("agent_send", `Sends a message to a conversation that already exists (agent_start or agent_prompt made it) and returns {n} at once without waiting for the agent. n is the message's position in the log and the number of the turn it starts: read its answer with agent_wait {id, after:n, wait:${MAX_WAIT_SECONDS}}. A message sent while a turn runs is queued behind that turn, not an interrupt — also while a conversation's agent waits on a question on its own CLI screen, which the user answers there by opening the conversation in BN, never by a message to it. A stopped or archived conversation resumes. Each call submits its text once more, so do not repeat a send that returned.`, { id: z.string().min(1).describe("The conversation id agent_start returned, or the 'conversation' agent_prompt returned"), text: z.string().min(1).describe("The follow-up message; the first task belongs in agent_start") }, ({ id, text }) => act(() => {
@@ -172,8 +172,8 @@ async function route(req, url, arrivedAt) {
172
172
  const { made: meta } = await createdOn(body.project, body.provider, (folder) => creatorOf(viewer, folder), (on) => {
173
173
  receivedMs = monotonicMs() - arrivedAt;
174
174
  const chat = creatorOf(viewer, on.project);
175
- return text === undefined ? openConversation({ platform: "rest", chat, ...on, model }) : startConversation({ platform: "rest", chat, ...on, model, text, receivedMs });
176
- });
175
+ return text === undefined ? openConversation({ platform: "rest", chat, ...on }) : startConversation({ platform: "rest", chat, ...on, text, receivedMs });
176
+ }, model);
177
177
  return { status: 201, body: { id: meta.id, state: meta.state, receivedMs } };
178
178
  }
179
179
  }
@@ -183,7 +183,7 @@ async function newAgent(body, viewer) {
183
183
  const model = typeof body.model === "string" && body.model.trim() ? body.model.trim() : undefined;
184
184
  if (model !== undefined && !/^[a-zA-Z0-9._:/-]+$/.test(model))
185
185
  throw new GatewayError(400, "Model must be its CLI name, without spaces or shell characters.");
186
- return (await createdOn(body.project, body.provider, (folder) => creatorOf(viewer, folder), (on) => openConversation({ platform: "rest", chat: creatorOf(viewer, on.project), ...on, model }))).made.id;
186
+ return (await createdOn(body.project, body.provider, (folder) => creatorOf(viewer, folder), (on) => openConversation({ platform: "rest", chat: creatorOf(viewer, on.project), ...on }), model)).made.id;
187
187
  }
188
188
  /** The conversation's own CLI, opened by the session driver — never a second one — once it is running, or the reason this machine could not start it. */
189
189
  async function opened(id) {
@@ -647,7 +647,7 @@ export function createConversationStore(host, registry) {
647
647
  * subscription-first pick (`autoProvider`, the one FleetView's AUTO runs) over every CLI this gateway runs — at the
648
648
  * workspace root only those that load every project's rules there — weighed by DeepAgent's `provider_room` read for the folder.
649
649
  */
650
- async function pickedCli(provider, folder) {
650
+ async function pickedCli(provider, folder, model) {
651
651
  if (provider !== undefined && provider !== "auto" && !(typeof provider === "string" && provider.trim() === "")) {
652
652
  const named = namedProvider(provider);
653
653
  if (heldElsewhere(host.startOwner, named))
@@ -671,7 +671,7 @@ export function createConversationStore(host, registry) {
671
671
  }
672
672
  const picked = autoSwitch.autoProvider(registry().names, rooms, startable, {
673
673
  home: homedir(),
674
- usesKey: (name) => registry().get(name)?.usesKey?.(folder) ?? false,
674
+ usesKey: (name) => registry().get(name)?.usesKey?.(folder, model) ?? false,
675
675
  });
676
676
  if (picked === undefined)
677
677
  throw new GatewayError(503, "Auto has no subscription with room and no permitted, funded key for the eligible CLIs.");
@@ -699,9 +699,9 @@ export function createConversationStore(host, registry) {
699
699
  * moment it is called, so an ask from that chat waits for it. A room DeepAgent could not read is written onto the session it makes, and that
700
700
  * notice is handed back so a chat that started it hears it too.
701
701
  */
702
- function createdIn(folder, provider, chatOf, make) {
703
- const creation = pickedCli(provider, folder).then((pick) => {
704
- const made = make({ project: folder, provider: pick.provider });
702
+ function createdIn(folder, provider, chatOf, make, model) {
703
+ const creation = pickedCli(provider, folder, model).then((pick) => {
704
+ const made = make({ project: folder, provider: pick.provider, model });
705
705
  // NULL-OK: field unreadBecause is OPTIONAL and therefore it is ok to check for NULL
706
706
  if (pick.unreadBecause === undefined)
707
707
  return { made };
@@ -725,8 +725,8 @@ export function createConversationStore(host, registry) {
725
725
  });
726
726
  }
727
727
  /** A session CREATED on the folder and the agent CLI its creation named or left out (#3640, #4157): see `createdIn`. */
728
- function createdOn(project, provider, chatOf, make) {
729
- return createdIn(namedProject(project), provider, chatOf, make);
728
+ function createdOn(project, provider, chatOf, make, model) {
729
+ return createdIn(namedProject(project), provider, chatOf, make, model);
730
730
  }
731
731
  /**
732
732
  * Refuses, in words, a conversation with no CLI of its own to open or stream (#3845, #3916): its record names an agent this gateway does not run.
@@ -12,7 +12,7 @@
12
12
  * model's 128000 limit (probe, #2059) — the turn cannot reach the model at all.
13
13
  */
14
14
  import { createHash } from "crypto";
15
- import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from "fs";
15
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "fs";
16
16
  import { homedir } from "os";
17
17
  import { join } from "path";
18
18
  import { LoggedCliSession, folderKey, logRow } from "./cliSession.js";
@@ -23,28 +23,33 @@ export function createCopilotDriver(runtime) {
23
23
  return join(runtime.configDir, "agent", "copilot", createHash("sha256").update(name).digest("hex").slice(0, 16));
24
24
  }
25
25
  function userCopilotDir() {
26
- return join(process.env.XDG_CONFIG_HOME || homedir(), ".copilot");
26
+ if (process.env.COPILOT_HOME)
27
+ return process.env.COPILOT_HOME;
28
+ const current = join(homedir(), ".copilot");
29
+ return SEEDED_USER_FILES.some((name) => existsSync(join(current, name))) ? current : join(process.env.XDG_CONFIG_HOME || homedir(), ".copilot");
27
30
  }
28
31
  /** The selected provider must be one of the external providers in the configuration this child inherits. */
29
- function usesKey() {
32
+ function usesKey(_project, model) {
30
33
  const config = userCopilotDir();
31
34
  const settings = join(config, "settings.json");
32
- const providers = join(config, "providers.json");
33
- if (!existsSync(settings) || !existsSync(providers))
35
+ const providers = process.env.COPILOT_PROVIDERS_CONFIG || join(config, "providers.json");
36
+ if (!existsSync(providers))
34
37
  return false;
35
- const model = JSON.parse(readFileSync(settings, "utf8")).model;
36
- if (typeof model !== "string" || !model.includes("/"))
38
+ const selected = model ?? (existsSync(settings) ? JSON.parse(readFileSync(settings, "utf8")).model : undefined);
39
+ if (typeof selected !== "string" || !selected.includes("/"))
37
40
  return false;
38
- const named = model.split("/", 1)[0];
41
+ const named = selected.split("/", 1)[0];
39
42
  return (JSON.parse(readFileSync(providers, "utf8")).providers ?? []).some((provider) => provider.name === named);
40
43
  }
41
44
  const SEEDED_USER_FILES = ["config.json", "settings.json", "providers.json"];
42
45
  function seedFromUser(configDir) {
43
46
  mkdirSync(configDir, { recursive: true });
44
47
  for (const name of SEEDED_USER_FILES) {
45
- const from = join(userCopilotDir(), name);
48
+ const from = name === "providers.json" && process.env.COPILOT_PROVIDERS_CONFIG ? process.env.COPILOT_PROVIDERS_CONFIG : join(userCopilotDir(), name);
46
49
  if (existsSync(from))
47
50
  copyFileSync(from, join(configDir, name));
51
+ else
52
+ rmSync(join(configDir, name), { force: true });
48
53
  }
49
54
  }
50
55
  /**
@@ -48,7 +48,7 @@ const ACT_FORBIDDEN_HEADERS = ["origin", "referer", "forwarded", "x-forwarded-fo
48
48
  function recordDirectory(extension) {
49
49
  return path.join(os.homedir(), ".bullseye", "webhost", extension);
50
50
  }
51
- // GATE: a page socket is pinged this often so no tunnel or carrier idles it out; one that sent nothing (not even the browser's automatic pong) for a whole beat is ended, and its page reconnects.
51
+ // Keep idle tunnels alive; only the shared client can confirm an unanswered ping while this daemon answers.
52
52
  const SOCKET_BEAT_MS = 20_000;
53
53
  /** Whether a parsed window record carries everything an entry address to that window needs. */
54
54
  function wholeRecord(record) {
@@ -1156,11 +1156,6 @@ class WebHost {
1156
1156
  socket.at = new URLSearchParams(url.searchParams.get("at") ?? "");
1157
1157
  socket.heard = true;
1158
1158
  const beat = setInterval(() => {
1159
- if (!socket.heard) {
1160
- socket.destroy();
1161
- return;
1162
- }
1163
- socket.heard = false;
1164
1159
  writeFrameWithOpcode(socket, 0x9, Buffer.alloc(0));
1165
1160
  }, SOCKET_BEAT_MS);
1166
1161
  const leave = () => {
@@ -1266,7 +1261,7 @@ function indexPage(host, base) {
1266
1261
  const rows = [...host.pages.values()]
1267
1262
  .map((page) => `<li><a href="${escapeAttribute(base === undefined ? page.url : `${base}/${encodeURIComponent(page.name)}/${page.search}`)}">${page.live ? "🟢" : "⚪"} ${escapeAttribute(page.title)}</a></li>`)
1268
1263
  .join("");
1269
- return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(host.extension)}</title></head>
1264
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(host.extension)}</title></head>
1270
1265
  <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div>${escapeAttribute(host.extension)} · ${escapeAttribute(host.label)}</div><ul>${rows}</ul></body></html>`;
1271
1266
  }
1272
1267
  /** The extensions whose page is a roster of work this window owns: another workspace's roster is not shown from here, so a peek at one answers in words instead of a page that could start work. */
@@ -1275,37 +1270,33 @@ function peekedRosterPage(label, home, back, listUnreadable) {
1275
1270
  // NULL-OK: field listUnreadable is OPTIONAL and therefore it is ok to check for NULL
1276
1271
  const unread = listUnreadable === undefined ? "" : `<p>🔴 No way back to ${escapeAttribute(home)}: the workspace list cannot be read — ${escapeAttribute(listUnreadable)}</p>`;
1277
1272
  const link = back === undefined ? unread : `<p><a href="${escapeAttribute(back)}" style="color:#9cdcfe">⬅ Back to ${escapeAttribute(home)}</a></p>`;
1278
- return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>Fleet · peeking</title></head>
1279
- <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div style="background:#5a3d00;color:#fff;padding:6px 10px;border-radius:4px">👁 Peeking at ${escapeAttribute(label)} — look only</div>
1273
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>Fleet · peeking</title></head>
1274
+ <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div style="background:#5a3d00;color:#fff;padding:6px 10px;border-radius:4px">👁 Peeking at ${escapeAttribute(label)} — look only</div>
1280
1275
  <p>This workspace's Fleet roster and queue belong to its own VS Code window, and they are not shown from another workspace yet — so there is nothing here to read, and nothing here can start work or reach that window's main.</p>${link}</body></html>`;
1281
1276
  }
1282
1277
  function closedPage(extension, page) {
1283
- return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
1284
- <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc">⚪ ${escapeAttribute(page.title)} is not open in VS Code right now, so there is nothing to show here — this page loads it the moment it opens.<div id="said" style="margin-top:8px"></div>
1285
- <script>${CONNECTION_SOURCE}</script><script>(function () {
1286
- var WHAT = "this page's live connection to its host";
1287
- var reconnected = false;
1288
- function connect() {
1289
- var opened = false;
1290
- var socket = new WebSocket((location.protocol === "https:" ? "wss:" : "ws:") + "//" + location.host + "/__bullseye/ws?page=${encodeURIComponent(page.name)}&peek=1");
1291
- setTimeout(function () { if (socket.readyState === 0) socket.close(); }, 10000);
1292
- socket.addEventListener("open", function () {
1293
- opened = true;
1294
- var mine = socket;
1295
- window.bullseyeConnection.opened(function () { return mine.readyState === 1; }, function () {
1296
- window.bullseyeConnection.live();
1297
- document.getElementById("said").textContent = "";
1298
- });
1299
- fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { return r.json(); }).then(function (health) { if (health.pages[${JSON.stringify(page.name)}].live) location.reload(); });
1300
- });
1301
- socket.addEventListener("message", function (event) { if (JSON.parse(String(event.data)).type === "reload") location.reload(); });
1302
- socket.addEventListener("close", function () { if (opened) { var w = window.bullseyeConnection.closed(reconnected); reconnected = true; window.bullseyeConnection.reconnecting(WHAT, w); document.getElementById("said").textContent = "⏳ This page's host is not answering — this page reconnects the moment it does"; setTimeout(awaitHost, w); } else { var refused = window.bullseyeConnection.failed(); window.bullseyeConnection.reconnecting(WHAT, refused); document.getElementById("said").textContent = "⏳ This page's host did not accept its connection — this page tries again by itself"; setTimeout(awaitHost, refused); } });
1303
- }
1304
- function awaitHost() {
1305
- window.bullseyeConnection.reconnecting(WHAT, 250);
1306
- fetch("/__bullseye/health", { cache: "no-store", signal: AbortSignal.timeout(8000) }).then(function (r) { if (r.ok) { connect(); } else if (r.status === 401) window.bullseyeConnection.signInAgain(); else setTimeout(awaitHost, 250); }, function () { setTimeout(awaitHost, 250); });
1307
- }
1308
- connect();
1278
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
1279
+ <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc">⚪ ${escapeAttribute(page.title)} is not open in VS Code right now, so there is nothing to show here — this page loads it the moment it opens.<div id="said" style="margin-top:8px"></div>
1280
+ <script>${CONNECTION_SOURCE}</script><script>(function () {
1281
+ var WHAT = "this page's live connection to its host";
1282
+ var kept = window.bullseyeConnection.keep({
1283
+ what: WHAT, path: "/__bullseye/health",
1284
+ open: function () { return new WebSocket((location.protocol === "https:" ? "wss:" : "ws:") + "//" + location.host + "/__bullseye/ws?page=${encodeURIComponent(page.name)}&peek=1"); },
1285
+ attach: function (connect, later) {
1286
+ fetch("/__bullseye/health", { cache: "no-store", signal: AbortSignal.timeout(8000) }).then(function (r) {
1287
+ if (r.ok) connect(); else if (r.status === 401) window.bullseyeConnection.signInAgain(); else later();
1288
+ }, later);
1289
+ },
1290
+ opened: function () {
1291
+ document.getElementById("said").textContent = "";
1292
+ fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { return r.json(); }).then(function (health) { if (health.pages[${JSON.stringify(page.name)}].live) location.reload(); }, function (error) { console.warn("[Bullseye connection] Page availability unread: " + error.message); });
1293
+ },
1294
+ message: function (socket, event) { if (JSON.parse(String(event.data)).type === "reload") location.reload(); },
1295
+ down: function () { document.getElementById("said").textContent = "⏳ Reconnecting"; },
1296
+ closed: function () { return false; },
1297
+ ping: function (socket) { socket.send('{"type":"ping"}'); }
1298
+ });
1299
+ kept.connect();
1309
1300
  })();</script></body></html>`;
1310
1301
  }
1311
1302
  function codeDefect(err) {