omni-notify-mcp 1.3.475 → 1.3.476
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/dist/gateway/mcpDoor.js
CHANGED
|
@@ -232,8 +232,8 @@ 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, text, receivedMs: Math.round(performance.now() - arrived), arrival }), model)).made.id, turn: 1 }
|
|
236
|
-
: { id: seen(target), turn: sendToConversation(target, text, Math.round(performance.now() - arrived), arrival).n };
|
|
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, viewerNow()?.folder)).made.id, turn: 1 }
|
|
236
|
+
: { id: seen(target), turn: sendToConversation(target, text, Math.round(performance.now() - arrived), arrival, viewerNow()?.folder).n };
|
|
237
237
|
const { events, ended, turn } = await waitForTurn(sent.id, sent.turn, MAX_WAIT_SECONDS);
|
|
238
238
|
const meta = readConversation(sent.id);
|
|
239
239
|
const reply = events.filter((e) => e.turn === turn && REPLY_FIELD[e.kind] !== undefined).at(-1);
|
|
@@ -263,16 +263,16 @@ 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, text, receivedMs: Math.round(performance.now() - arrived), arrival }), model)).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, viewerNow()?.folder)).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, viewerNow()?.folder)).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(() => {
|
|
274
274
|
const arrived = performance.now();
|
|
275
|
-
return { n: sendToConversation(seen(id), text, Math.round(performance.now() - arrived), arrivalOf(requestIdOf(), randomUUID().slice(0, 8))).n };
|
|
275
|
+
return { n: sendToConversation(seen(id), text, Math.round(performance.now() - arrived), arrivalOf(requestIdOf(), randomUUID().slice(0, 8)), viewerNow()?.folder).n };
|
|
276
276
|
}));
|
|
277
277
|
server.tool("agent_wait", `Reads a conversation's events past position 'after' — a long-poll read the caller repeats, not a notification BN pushes. With wait=0 (the default) it returns at once with whatever is there; with wait above 0 it holds the call until a new event arrives or the wait (at most ${MAX_WAIT_SECONDS} seconds) runs out, and an empty events list means nothing new yet. Repeat the call with the reply's after value (the position it leaves you at, a line it wrote itself included) until the turn you wait on ends: an event of kind answer or failed whose turn is that turn's number (1 after agent_start, the n agent_send returned), or an event of kind stopped. A question the agent asks does not end the turn: a status event says it waits on its own CLI screen, and the turn goes on once the user answers there. after=0 reads the log from the start, earlier turns' answers included. The state is not the end of the turn, because a conversation stays running until its idle process is freed. Reading sends nothing, so it is always safe to call again. Each answer or failed event carries its timing, in which a reply's time is three separate figures rather than one number: bnMs, the end-to-end elapsed time from the request arriving at BN's door to the answer being stored; queuedMs (beside queued, whether it stood in line at all — false is the store's own statement that it never stood in line, absent is unmeasured), the part of it the message waited for a free slot or the turn ahead; and agentMs, the part the agent itself worked. totalMs is BN's own total from the message being stored to the answer being stored, never the agent's time, and rows carries the turn layer by layer.`, { id: z.string().min(1), after: z.number().int().min(0).default(0).describe("The last event position n already read; events past it are returned. 1 right after agent_start, the n agent_send returned after a send"), wait: z.number().min(0).default(0).describe(`Seconds to hold the call for a new event, capped at ${MAX_WAIT_SECONDS}; 0 returns at once`) }, ({ id, after, wait }) => {
|
|
278
278
|
const arrived = performance.now();
|
package/dist/gateway/restDoor.js
CHANGED
|
@@ -175,7 +175,7 @@ async function route(req, url, arrivedAt) {
|
|
|
175
175
|
receivedMs = monotonicMs() - arrivedAt;
|
|
176
176
|
const chat = creatorOf(viewer, on.project);
|
|
177
177
|
return text === undefined ? openConversation({ platform: "rest", chat, ...on }) : startConversation({ platform: "rest", chat, ...on, text, receivedMs });
|
|
178
|
-
}, model);
|
|
178
|
+
}, model, viewer?.folder);
|
|
179
179
|
return { status: 201, body: { id: meta.id, state: meta.state, receivedMs } };
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -201,7 +201,7 @@ async function route(req, url, arrivedAt) {
|
|
|
201
201
|
else if (sub === "messages" && method === "POST") {
|
|
202
202
|
const text = requiredText(await readJson(req), "text");
|
|
203
203
|
const receivedMs = monotonicMs() - arrivedAt;
|
|
204
|
-
const event = sendToConversation(id, text, receivedMs);
|
|
204
|
+
const event = sendToConversation(id, text, receivedMs, undefined, viewer?.folder);
|
|
205
205
|
return { status: 202, body: { n: event.n, receivedMs } };
|
|
206
206
|
}
|
|
207
207
|
else if (sub === "events" && method === "GET") {
|
|
@@ -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, viewer?.folder)).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) {
|
|
@@ -16,7 +16,7 @@ import { homedir } from "os";
|
|
|
16
16
|
import { basename, dirname, join, resolve } from "path";
|
|
17
17
|
import autoSwitch from "../webhost/autoSwitch.cjs";
|
|
18
18
|
import { proveStartProviders } from "./providerProof.js";
|
|
19
|
-
import { workspacesFile, workspacesHere } from "../webhost/workspaceList.js";
|
|
19
|
+
import { sameRoot, workspacesFile, workspacesHere } from "../webhost/workspaceList.js";
|
|
20
20
|
import { CLUSTER_OWNER, OwnershipUnreadable, startOwnerOf } from "../providerOwnership.js";
|
|
21
21
|
/** Thrown for a request the caller got wrong; the door turns it into the status code. */
|
|
22
22
|
export class GatewayError extends Error {
|
|
@@ -683,6 +683,18 @@ export function createConversationStore(host, registry) {
|
|
|
683
683
|
const boards = listed.filter((p) => hasBoard(p.folder)).map((p) => p.name);
|
|
684
684
|
return projectFolder(projectNamedIn(text, boards) ?? homeProject(listed.map((p) => p.name), boards));
|
|
685
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* 🔴 #4587 — THE WORKSPACE A CONVERSATION BELONGS TO, from the folder its CLI runs in and the workspace its caller named as its own scope. The folder wins when it IS a listed
|
|
688
|
+
* workspace (the caller named a project, so its work is that project's); otherwise the caller's scope is it (a scoped caller that named no project runs at the workspace root,
|
|
689
|
+
* ABOVE every project); otherwise NONE — a machine-wide conversation belonging to no single workspace is said honestly, never written as the bare workspace root, which carries
|
|
690
|
+
* no board. This is the ONE value a conversation's lane is placed on, so every door shares it and no reader has to guess a board from a folder that has none.
|
|
691
|
+
*
|
|
692
|
+
* The listed workspaces come from `projectsHere()`, never `workspacesHere()` directly: a workspace list that is missing or unreadable is refused as `GatewayError(503)` — the SAME refusal
|
|
693
|
+
* every other create and turn path gives — rather than thrown raw as a `SyntaxError` the caller has no words for, and a test's own `NOTIFY_AGENT_PROJECTS` stands here exactly as it does there.
|
|
694
|
+
*/
|
|
695
|
+
function conversationWorkspace(project, scope) {
|
|
696
|
+
return projectsHere().map((p) => p.folder).find((folder) => sameRoot(folder, project)) ?? scope;
|
|
697
|
+
}
|
|
686
698
|
/**
|
|
687
699
|
* The workspace a session is CREATED in, from the name its creation supplied (#3640): exactly one of the allowed project
|
|
688
700
|
* names, resolved to its folder. A creation that names none runs at the workspace root (#4157), where the root's rules
|
|
@@ -787,9 +799,9 @@ export function createConversationStore(host, registry) {
|
|
|
787
799
|
* 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
|
|
788
800
|
* notice is handed back so a chat that started it hears it too.
|
|
789
801
|
*/
|
|
790
|
-
function createdIn(folder, provider, chatOf, make, model) {
|
|
802
|
+
function createdIn(folder, provider, chatOf, make, model, scope) {
|
|
791
803
|
const creation = pickedCli(provider, folder, model).then((pick) => {
|
|
792
|
-
const made = make({ project: folder, provider: pick.provider, model });
|
|
804
|
+
const made = make({ project: folder, provider: pick.provider, model, scope });
|
|
793
805
|
// NULL-OK: field unreadBecause is OPTIONAL and therefore it is ok to check for NULL
|
|
794
806
|
if (pick.unreadBecause === undefined)
|
|
795
807
|
return { made };
|
|
@@ -813,8 +825,8 @@ export function createConversationStore(host, registry) {
|
|
|
813
825
|
});
|
|
814
826
|
}
|
|
815
827
|
/** A session CREATED on the folder and the agent CLI its creation named or left out (#3640, #4157): see `createdIn`. */
|
|
816
|
-
function createdOn(project, provider, chatOf, make, model) {
|
|
817
|
-
return createdIn(namedProject(project), provider, chatOf, make, model);
|
|
828
|
+
function createdOn(project, provider, chatOf, make, model, scope) {
|
|
829
|
+
return createdIn(namedProject(project), provider, chatOf, make, model, scope);
|
|
818
830
|
}
|
|
819
831
|
/**
|
|
820
832
|
* 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.
|
|
@@ -842,7 +854,7 @@ export function createConversationStore(host, registry) {
|
|
|
842
854
|
// NULL-OK: field chat is OPTIONAL and therefore it is ok to check for NULL
|
|
843
855
|
const beside = input.chat === undefined ? undefined : openConversationOf(input.chat)?.id;
|
|
844
856
|
const meta = {
|
|
845
|
-
id: randomUUID(), platform: input.platform, technical: input.technical, chat: input.chat, slack: input.slack, email: input.email, project: input.project, provider: input.provider, model: input.model,
|
|
857
|
+
id: randomUUID(), platform: input.platform, technical: input.technical, chat: input.chat, slack: input.slack, email: input.email, project: input.project, workspace: input.workspace, provider: input.provider, model: input.model,
|
|
846
858
|
state: input.state, createdAt: now, updatedAt: now, lastMessageAt: now, sessionId: randomUUID(), started: false, consumed: 0, beside, forkOf: input.forkOf,
|
|
847
859
|
};
|
|
848
860
|
writeMeta(meta);
|
|
@@ -853,7 +865,8 @@ export function createConversationStore(host, registry) {
|
|
|
853
865
|
requireConversationEnabled();
|
|
854
866
|
const project = createdFolder(input.project);
|
|
855
867
|
const provider = namedProvider(input.provider);
|
|
856
|
-
const
|
|
868
|
+
const workspace = conversationWorkspace(project, input.scope);
|
|
869
|
+
const meta = newConversation({ platform: input.platform, technical: input.technical, chat: input.chat, slack: input.slack, email: input.email, project, workspace, provider, model: input.model, forkOf: input.forkOf, state: "queued" });
|
|
857
870
|
appendEvent(meta.id, { role: "user", text: input.text, receivedMs: input.receivedMs, ...input.arrival });
|
|
858
871
|
return meta;
|
|
859
872
|
}
|
|
@@ -867,7 +880,8 @@ export function createConversationStore(host, registry) {
|
|
|
867
880
|
requireConversationEnabled();
|
|
868
881
|
const project = createdFolder(input.project);
|
|
869
882
|
const provider = namedProvider(input.provider);
|
|
870
|
-
|
|
883
|
+
const workspace = conversationWorkspace(project, input.scope);
|
|
884
|
+
return newConversation({ platform: input.platform, technical: input.technical, chat: input.chat, project, workspace, provider, model: input.model, state: "idle" });
|
|
871
885
|
}
|
|
872
886
|
/**
|
|
873
887
|
* Sets or switches the folder the conversation's agent works in (#2723), reached by every door that offers it: the Web
|
|
@@ -894,14 +908,22 @@ export function createConversationStore(host, registry) {
|
|
|
894
908
|
if (meta.project !== undefined && sameFolder(meta.project, folder))
|
|
895
909
|
return meta;
|
|
896
910
|
// The record is written first: the folder the next turn runs in comes from it, so a transcript line may never claim a switch the record does not hold. `providerArchived` is cleared because a later finish must confirm the provider's archive again rather than trust a handshake from before this work.
|
|
897
|
-
const switched = updateConversation(id, { project: folder, providerArchived: undefined });
|
|
911
|
+
const switched = updateConversation(id, { project: folder, workspace: conversationWorkspace(folder, meta.workspace), providerArchived: undefined });
|
|
898
912
|
appendEvent(id, { role: "system", kind: "status", text: `📁 Project set to ${basename(folder)} — the next turn carries this same agent on in that folder.` });
|
|
899
913
|
return switched;
|
|
900
914
|
}
|
|
901
915
|
/** Appends the message; a stopped conversation is resumed first, so its next turn picks the agent's own session up where it stopped. A message stored while a turn runs gets its place in line at once, so nobody waits behind it in silence. `receivedMs` is the door's own measured wait, as in `startConversation`. */
|
|
902
|
-
function sendToConversation(id, text, receivedMs, arrival) {
|
|
916
|
+
function sendToConversation(id, text, receivedMs, arrival, scope) {
|
|
903
917
|
requireConversationEnabled();
|
|
904
918
|
resumeConversation(id);
|
|
919
|
+
// 🔴 #4587 — the conversation's workspace is refreshed from the scope its caller names, on every call that names one, so a conversation created before its workspace was recorded (or carried on from a door that names a scope) heals on its next message rather than staying on the bare workspace root for ever.
|
|
920
|
+
if (scope !== undefined) {
|
|
921
|
+
const held = readConversation(id);
|
|
922
|
+
// NULL-OK: field project is OPTIONAL and therefore it is ok to check for NULL
|
|
923
|
+
const workspace = conversationWorkspace(held.project ?? rootFolder(), scope);
|
|
924
|
+
if (workspace !== held.workspace)
|
|
925
|
+
updateConversation(id, { workspace });
|
|
926
|
+
}
|
|
905
927
|
// Read again right here, so a turn that ended while this call was arriving is not named as still running.
|
|
906
928
|
const current = readEvents(id);
|
|
907
929
|
const behind = turnInFlight(current, readConversation(id));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.476",
|
|
4
4
|
"homepage": "https://www.npmjs.com/package/omni-notify-mcp",
|
|
5
5
|
"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.",
|
|
6
6
|
"main": "dist/daemon.js",
|