omni-notify-mcp 1.3.364 → 1.3.365

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.
@@ -504,15 +504,26 @@ export function workspaceOf(named) {
504
504
  export function conversationInScope(id, viewer) {
505
505
  return listConversations().some((c) => c.id === id && inScope(c, viewer));
506
506
  }
507
- /** The viewer a REST request is scoped to by its header (#4120), or undefined — the machine view — when it names none. A REST caller never creates a conversation outside its workspace, so its creator name matches nothing the MCP door stamps. */
508
- export function viewerOfHeaders(headers) {
507
+ /**
508
+ * The workspace a request names in its header (#4120), refused when it names none and does not come through the public gateway: only a request that crossed the passkey-signed
509
+ * gateway (`local` is false: it carries a proxy's headers, and the door admits it only on a signed-in session) may name no workspace and keep the whole-machine view; a local caller must name its own.
510
+ */
511
+ export function namedWorkspace(headers, local) {
509
512
  const raw = headers[SCOPE_HEADER];
510
513
  const named = (Array.isArray(raw) ? raw[0] : raw)?.trim();
511
514
  // NULL-OK: field header x-bullseye-project is OPTIONAL and therefore it is ok to check for NULL
512
- if (named === undefined || named === "")
515
+ if (named === undefined || named === "") {
516
+ if (local)
517
+ throw new GatewayError(400, `a local caller names its workspace in the ${SCOPE_HEADER} header; only the passkey-signed public gateway answers for the whole machine`);
513
518
  return undefined;
514
- const folder = workspaceOf(named);
515
- return { folder, creator: `rest:${folder}` };
519
+ }
520
+ return workspaceOf(named);
521
+ }
522
+ /** The viewer a REST request is scoped to by its header (#4120), or undefined — the machine view — for a public-gateway caller that names none. A REST caller never creates a conversation outside its workspace, so its creator name matches nothing the MCP door stamps. */
523
+ export function viewerOfHeaders(headers, local) {
524
+ const folder = namedWorkspace(headers, local);
525
+ // NULL-OK: field folder is OPTIONAL and therefore it is ok to check for NULL
526
+ return folder === undefined ? undefined : { folder, creator: `rest:${folder}` };
516
527
  }
517
528
  /** Whether two folder paths name the same folder: a trailing separator, and on Windows letter case, do not name another folder. */
518
529
  function sameFolder(a, b) {
@@ -21,12 +21,12 @@ import { performance } from "perf_hooks";
21
21
  import { z } from "zod";
22
22
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
23
23
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
24
- import { GatewayError, MAX_WAIT_SECONDS, archiveConversation, deleteConversation, describeConversation, lastEventNumber, listProjects, namedProject, namedProvider, openConversation, readConversation, routeAsk, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, stampWaitReturn, startConversation, stopConversation, unarchiveConversation, waitForEvents, waitForTurn, workspaceRoot, allowedProjects, requireOwnCli, scopedConversation, workspaceOf, SCOPE_HEADER, } from "./conversations.js";
24
+ import { GatewayError, MAX_WAIT_SECONDS, archiveConversation, deleteConversation, describeConversation, lastEventNumber, listProjects, namedProject, namedProvider, openConversation, readConversation, routeAsk, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, stampWaitReturn, startConversation, stopConversation, unarchiveConversation, waitForEvents, waitForTurn, workspaceRoot, allowedProjects, requireOwnCli, scopedConversation, namedWorkspace, } from "./conversations.js";
25
25
  import { workspacesFile } from "../shared/webhost/workspaceList.js";
26
26
  import { PROVIDER_NAMES } from "./providers.js";
27
27
  import { iconsFor } from "./iconDoor.js";
28
28
  import { grantClient, publicBase } from "./oauthDoor.js";
29
- import { bearer, personId, sessionSignIn, tokenProves } from "./passkeyDoor.js";
29
+ import { bearer, fromThisMachine, personId, sessionSignIn, tokenProves } from "./passkeyDoor.js";
30
30
  import { closeNativeTerminal, consoleSession, nativeTerminal, terminalArriving } from "./nativeTerminal.js";
31
31
  import { dimensions, openTerminal, terminalListing, validFiles } from "./terminalDoor.js";
32
32
  import { conversationSwitchRead, panelState, saveConversationSwitch, saveSetting } from "./panel.js";
@@ -361,9 +361,7 @@ export async function handleMcp(req, res) {
361
361
  if (req.method !== "POST")
362
362
  throw new GatewayError(405, "the MCP door takes POST only; it holds no session to stream or close");
363
363
  const machineCaller = callerOf(req);
364
- const named = headerOf(req, SCOPE_HEADER);
365
- // NULL-OK: field header x-bullseye-project is OPTIONAL and therefore it is ok to check for NULL
366
- const folder = named === undefined ? undefined : workspaceOf(named);
364
+ const folder = namedWorkspace(req.headers, fromThisMachine(req));
367
365
  // The caller's name carries its workspace, so two workspaces sharing the gateway token never share a current agent or each other's created conversations.
368
366
  const caller = folder === undefined ? machineCaller : `${machineCaller}@${folder}`;
369
367
  const viewer = folder === undefined ? undefined : { folder, creator: caller };
@@ -14,7 +14,7 @@ import { CHAT_HEADERS } from "./chatPage.js";
14
14
  import { isIconPath, serveIcon } from "./iconDoor.js";
15
15
  import { handleMcp } from "./mcpDoor.js";
16
16
  import { MCP_PATH, accessGranted, challenge, handleOAuth, isOAuthPath, publicBase } from "./oauthDoor.js";
17
- import { bearer, bearerAdmitted, handlePasskey, isPasskeyPath, localOnly } from "./passkeyDoor.js";
17
+ import { bearer, bearerAdmitted, fromThisMachine, handlePasskey, isPasskeyPath, localOnly } from "./passkeyDoor.js";
18
18
  import { terminalConsole, terminalRoute, terminalSockets } from "./terminalDoor.js";
19
19
  import { conversationSwitchRead, panelState, saveConversationSwitch, saveSetting } from "./panel.js";
20
20
  import { PANEL_PAGES, panelHtml } from "./panelPage.js";
@@ -125,12 +125,12 @@ async function route(req, url, arrivedAt) {
125
125
  }
126
126
  // The conversation page's project picker offers the folders that hold a board (#2723), so it reads them from the one list BN resolves projects with.
127
127
  if (resource === "projects" && parts.length === 2 && method === "GET")
128
- return { status: 200, body: listProjects(viewerOfHeaders(req.headers)) };
128
+ return { status: 200, body: listProjects(viewerOfHeaders(req.headers, fromThisMachine(req))) };
129
129
  if (resource !== "conversations")
130
130
  throw new GatewayError(404, "unknown route");
131
131
  requireConversationEnabled();
132
132
  // Every route that names a conversation reads it through the caller's scope (#4120).
133
- const viewer = viewerOfHeaders(req.headers);
133
+ const viewer = viewerOfHeaders(req.headers, fromThisMachine(req));
134
134
  if (id !== undefined && viewer !== undefined)
135
135
  scopedConversation(id, viewer);
136
136
  if (id === undefined) {
@@ -2,7 +2,7 @@ import { WebSocketServer, WebSocket } from "ws";
2
2
  import { GatewayError, deleteConversation, namedProject, namedProvider, openConversation, requireOwnCli, requireConversationEnabled, scopedConversation, conversationInScope, viewerOfHeaders } from "./conversations.js";
3
3
  import { closeNativeTerminal, consoleSession, nativeTerminal, nativeTerminals, terminalArriving } from "./nativeTerminal.js";
4
4
  import { AgentGateway } from "../agentGateway.js";
5
- import { bearer, bearerAdmitted, personId, sessionExpiresAt } from "./passkeyDoor.js";
5
+ import { bearer, bearerAdmitted, fromThisMachine, personId, sessionExpiresAt } from "./passkeyDoor.js";
6
6
  import { PROVIDER_NAMES, providerFor } from "./providers.js";
7
7
  export function dimensions(body) {
8
8
  const cols = Number(body.cols), rows = Number(body.rows);
@@ -139,7 +139,7 @@ export async function terminalConsole(req, res, url) {
139
139
  throw new GatewayError(400, "after must be a non-negative whole number");
140
140
  const disconnected = new AbortController();
141
141
  req.on("close", () => disconnected.abort());
142
- const viewer = viewerOfHeaders(req.headers);
142
+ const viewer = viewerOfHeaders(req.headers, fromThisMachine(req));
143
143
  if (viewer !== undefined)
144
144
  scopedConversation(id, viewer);
145
145
  requireOwnCli(id);
@@ -221,7 +221,7 @@ export async function openTerminal(body) {
221
221
  export async function terminalRoute(req, url, readJson) {
222
222
  requireConversationEnabled();
223
223
  const owner = personId();
224
- const viewer = viewerOfHeaders(req.headers);
224
+ const viewer = viewerOfHeaders(req.headers, fromThisMachine(req));
225
225
  const parts = url.pathname.split("/").filter(Boolean);
226
226
  const method = req.method;
227
227
  if (parts.length === 2) {
@@ -406,6 +406,39 @@ function decide(input) {
406
406
  }
407
407
  return none(`every subscription is spent and falling back to a key is off (${providerId}.byokFallback in ~/.bullseye/auto-switch/settings.json)`);
408
408
  }
409
+ // GATE: the agent tier kinds a subscription Meni already pays for serves — every other kind a chain names bills a key per token and is ranked after all of them
410
+ const SUBSCRIPTION_TIER_KINDS = Object.freeze(["claude-cli", "claude", "codex-cli", "copilot-cli"]);
411
+ // GATE: the agent tier kinds a Claude subscription serves — a chain naming one of them gains the key rung, last
412
+ const CLAUDE_TIER_KINDS = Object.freeze(["claude-cli", "claude"]);
413
+ // GATE: the key rung each kind of call gains behind a Claude tier — a text ask on the box's paid pair, an act through the claude CLI on it
414
+ const KEY_RUNGS = Object.freeze({ ask: "configured-byok", act: "claude-byok" });
415
+ /**
416
+ * The key rung a chain gains, or undefined: the rung of its `kind` when the chain names a Claude tier and does not
417
+ * already declare that rung itself. Whether it is then offered is Meni's `claude.byokFallback` box, read only for a
418
+ * chain that has a rung to offer.
419
+ * @param {{ chain: string[], kinds?: Record<string, string>, kind?: string }} input
420
+ * @returns {string | undefined}
421
+ */
422
+ function keyRungOf({ chain, kinds = {}, kind }) {
423
+ const rung = kind === undefined ? undefined : KEY_RUNGS[kind];
424
+ return rung !== undefined && !chain.includes(rung) && chain.some((tier) => CLAUDE_TIER_KINDS.includes(kinds[tier] || tier)) ? rung : undefined;
425
+ }
426
+ /**
427
+ * THE one cross-provider ranking every AI chain runs in, Python, shell and Java alike (Meni 2026-11-15: "we always use the
428
+ * besy avail agentic provider that first uses sub and only if all is exhusted we use BYOK"): every tier a subscription
429
+ * serves, in the chain's declared order, then every tier a key bills, in its declared order, then the chain's key rung
430
+ * (`keyRungOf`) last, each tier once, and only while Meni's `claude.byokFallback` box is on. A tier the answer holds that
431
+ * the chain did not declare is that rung, which its caller asks only on a box that configures a paid pair. Room is weighed
432
+ * inside each subscription tier, account by account, by the chain that runs it. An explicit provider choice is never
433
+ * ranked: the caller that names one runs it as named.
434
+ * @param {{ chain: string[], kinds?: Record<string, string>, kind?: string, keyFallback: boolean }} input `kinds` maps a tier to its kind when its name is not its kind; `kind` is `ask` or `act`, absent for a chain that never gains a key rung; `keyFallback` is `readByokFallback(home, "claude")`
435
+ * @returns {string[]}
436
+ */
437
+ function subscriptionFirst({ chain, kinds = {}, kind, keyFallback }) {
438
+ const paid = (tier) => SUBSCRIPTION_TIER_KINDS.includes(kinds[tier] || tier);
439
+ const rung = keyFallback ? keyRungOf({ chain, kinds, kind }) : undefined;
440
+ return [...new Set([...chain.filter(paid), ...chain.filter((tier) => !paid(tier)), ...(rung === undefined ? [] : [rung])])];
441
+ }
409
442
  /**
410
443
  * Whether the live work has an account with room to run on, worked out from the readings alone and never from a
411
444
  * decision's words: covered when the live account read room, uncovered when it read spent (or nobody is logged in and
@@ -1542,6 +1575,7 @@ module.exports = {
1542
1575
  readByokKey,
1543
1576
  writeByokKey,
1544
1577
  decide,
1578
+ subscriptionFirst,
1545
1579
  coverageOf,
1546
1580
  transientRetried,
1547
1581
  firstRefillAt,
@@ -1596,6 +1630,14 @@ if (require.main === module) {
1596
1630
  case "agents":
1597
1631
  process.stdout.write(JSON.stringify({ agents: AGENT_CLIS }));
1598
1632
  break;
1633
+ case "subscription-tier-kinds":
1634
+ process.stdout.write(SUBSCRIPTION_TIER_KINDS.join("\n") + "\n");
1635
+ break;
1636
+ case "subscription-first": {
1637
+ const chainAsk = JSON.parse(readStdin());
1638
+ process.stdout.write(subscriptionFirst({ ...chainAsk, keyFallback: keyRungOf(chainAsk) !== undefined && readByokFallback(home, "claude") }).join("\n") + "\n");
1639
+ break;
1640
+ }
1599
1641
  case "deepagent-settings":
1600
1642
  process.stdout.write(JSON.stringify(deepagentSettings()));
1601
1643
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.364",
3
+ "version": "1.3.365",
4
4
  "description": "Reach your AI agents from anywhere — and let them reach you. One resident process on 127.0.0.1:7475 serves the whole tool surface to Claude Code, GitHub Copilot Chat and Codex: desktop, Telegram, Slack, ntfy, Discord, Teams and SMS are configured in one file, and agents notify you when long work finishes or a decision is needed, ask you a question and wait for your answer, and receive and reply to the messages you send them — with Do Not Disturb and idle detection deciding what actually gets through.",
5
5
  "main": "dist/daemon.js",
6
6
  "type": "module",