omni-notify-mcp 1.3.347 → 1.3.349
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.
|
@@ -40,6 +40,9 @@ const CLI_COMMAND_START = /^[!/]/;
|
|
|
40
40
|
const ENTER_EVERY_MS = 1_000;
|
|
41
41
|
// GATE: how many Ctrl+U presses clear one line of text the CLI put back into its input box — measured on Claude CLI 2.1.322: one press empties the line, the next joins it to the line above.
|
|
42
42
|
const CLEARS_PER_LINE = 2;
|
|
43
|
+
/** A turn that failed because its CLI can no longer run (a key the vendor refused): BN ends the CLI, and whoever holds the session may carry the same turn on a fresh one. */
|
|
44
|
+
export class CliEnded extends AgentTurnFailed {
|
|
45
|
+
}
|
|
43
46
|
export class CliSession {
|
|
44
47
|
spec;
|
|
45
48
|
provider;
|
|
@@ -55,6 +58,9 @@ export class CliSession {
|
|
|
55
58
|
ending = false;
|
|
56
59
|
/** The sink of the driver's message from the moment it is asked until it ends — also while it waits behind a prompt typed in the browser — so activity of any prompt counts as the CLI at work. */
|
|
57
60
|
listening;
|
|
61
|
+
markGone;
|
|
62
|
+
/** Settles once the CLI has ended and everything watching it is let go: a session that moves a turn to a fresh CLI waits on it. */
|
|
63
|
+
gone = new Promise((done) => { this.markGone = done; });
|
|
58
64
|
constructor(spec, provider, resumes) {
|
|
59
65
|
this.spec = spec;
|
|
60
66
|
this.provider = provider;
|
|
@@ -82,6 +88,7 @@ export class CliSession {
|
|
|
82
88
|
void this.lost(turn.sink).then(turn.reject);
|
|
83
89
|
}
|
|
84
90
|
this.spec.onGone();
|
|
91
|
+
this.markGone();
|
|
85
92
|
});
|
|
86
93
|
}
|
|
87
94
|
/** What the turn held beside its Enter presses is let go as it ends. */
|
|
@@ -393,7 +400,7 @@ export class LoggedCliSession extends CliSession {
|
|
|
393
400
|
const whose = this.open.shift();
|
|
394
401
|
if (whose === "mine" && turn !== undefined) {
|
|
395
402
|
if (news.kind === "failed")
|
|
396
|
-
this.settle(turn, () => turn.reject(new AgentTurnFailed(news.why, `❌ The agent's turn did not end with an answer: ${news.why}`)));
|
|
403
|
+
this.settle(turn, () => turn.reject(news.endsCli === true ? new CliEnded(news.why) : new AgentTurnFailed(news.why, `❌ The agent's turn did not end with an answer: ${news.why}`)));
|
|
397
404
|
else if (news.kind === "silent" || news.answer.trim() === "")
|
|
398
405
|
this.settle(turn, () => turn.reject(new AgentTurnFailed("the agent ended its turn with no text", "❌ The agent ended its turn with no text — nothing was answered.")));
|
|
399
406
|
else
|
|
@@ -24,7 +24,7 @@ function invocation(command, args) {
|
|
|
24
24
|
const script = /"%dp0%[\\/]([^"\r\n]+\.m?js)"/i.exec(shim);
|
|
25
25
|
if (script)
|
|
26
26
|
return { command: process.execPath, args: [resolve(dirname(executable), script[1]), ...args] };
|
|
27
|
-
const binary =
|
|
27
|
+
const binary = /^"%dp0%[\\/]([^"\r\n]+\.exe)"[ \t]+%\*[ \t]*$/im.exec(shim);
|
|
28
28
|
if (binary)
|
|
29
29
|
return { command: resolve(dirname(executable), binary[1]), args };
|
|
30
30
|
}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The CLI runs on the key and store `opencodeRoute` names, chosen when its CLI opens. A key the vendor refuses — a
|
|
12
12
|
* refusing `session.error`, or the `retry` status the CLI reports while it retries a rate limit in silence — is recorded
|
|
13
|
-
* where every switcher reads it
|
|
14
|
-
* session with `-s` on a
|
|
13
|
+
* where every switcher reads it and the CLI is ended; the SAME turn then carries on in a fresh CLI that resumes the
|
|
14
|
+
* session with `-s` on a new route, which skips the refused key, told to carry on from the last message (Meni's ruling
|
|
15
|
+
* on Q808, #4079). With no key left to run on, the turn fails in the route's own words.
|
|
15
16
|
*/
|
|
16
17
|
import { randomUUID } from "crypto";
|
|
17
18
|
import { existsSync, mkdirSync, readdirSync, rmSync } from "fs";
|
|
@@ -19,7 +20,7 @@ import { homedir } from "os";
|
|
|
19
20
|
import { join } from "path";
|
|
20
21
|
import autoSwitch from "../shared/webhost/autoSwitch.cjs";
|
|
21
22
|
import { KEY_REFUSAL_STATUSES, KEY_REFUSAL_WORDS } from "../shared/agentSession.js";
|
|
22
|
-
import { LoggedCliSession } from "./cliSession.js";
|
|
23
|
+
import { CliEnded, LoggedCliSession } from "./cliSession.js";
|
|
23
24
|
import { CONFIG_DIR } from "../notify.js";
|
|
24
25
|
// GATE: the words of a retry status that mean the provider rate-limited THIS key; any other retry (a 5xx, a dropped connection) is the CLI riding out a fault the key did not cause
|
|
25
26
|
const RATE_LIMITED = /rate.?limit|too many requests/i;
|
|
@@ -78,9 +79,9 @@ class OpenCodeLog {
|
|
|
78
79
|
ended() {
|
|
79
80
|
rmSync(this.file, { force: true });
|
|
80
81
|
}
|
|
81
|
-
/** The vendor refused the key this CLI runs on: it is recorded as refused, and the turn
|
|
82
|
+
/** The vendor refused the key this CLI runs on: it is recorded as refused, and the turn ends the CLI naming it so the session can carry the turn on the next key. */
|
|
82
83
|
refused(said) {
|
|
83
|
-
const why = `${this.key.named} was refused by the provider (${said}), so BN
|
|
84
|
+
const why = `${this.key.named} was refused by the provider (${said}), so BN moves this turn on to the next key.`;
|
|
84
85
|
this.key.refuse(said);
|
|
85
86
|
return [{ kind: "failed", why, endsCli: true }];
|
|
86
87
|
}
|
|
@@ -165,10 +166,84 @@ function opencodeCli(spec) {
|
|
|
165
166
|
refusal: () => undefined,
|
|
166
167
|
};
|
|
167
168
|
}
|
|
169
|
+
const KEY_RETRY_PROMPT = "The provider refused the key your last reply was being written on, so that reply never arrived. Carry on from the last message.";
|
|
170
|
+
/**
|
|
171
|
+
* One OpenCode conversation: a LoggedCliSession on one key, and the same turn carried on to the next key when the vendor
|
|
172
|
+
* refuses that one — the refused CLI is ended and awaited, a fresh one resumes the session on a new route, and it is told
|
|
173
|
+
* to carry on (or given the original prompt when the refused CLI never wrote a session).
|
|
174
|
+
*/
|
|
175
|
+
class OpenCodeSession {
|
|
176
|
+
spec;
|
|
177
|
+
inner;
|
|
178
|
+
/** The session id the CLI wrote, or the record's own when it was already written. */
|
|
179
|
+
written;
|
|
180
|
+
carrying = false;
|
|
181
|
+
stopped = false;
|
|
182
|
+
/** The driver already heard that the CLI running now is gone, so no turn may be carried on in a CLI it no longer tracks. */
|
|
183
|
+
told = false;
|
|
184
|
+
constructor(spec) {
|
|
185
|
+
this.spec = spec;
|
|
186
|
+
this.written = spec.started ? spec.sessionId : undefined;
|
|
187
|
+
this.inner = this.launch();
|
|
188
|
+
}
|
|
189
|
+
launch() {
|
|
190
|
+
this.told = false;
|
|
191
|
+
const own = {
|
|
192
|
+
...this.spec,
|
|
193
|
+
// NULL-OK: field written is OPTIONAL and therefore it is ok to check for NULL
|
|
194
|
+
started: this.written !== undefined,
|
|
195
|
+
sessionId: this.written ?? this.spec.sessionId,
|
|
196
|
+
onGone: () => {
|
|
197
|
+
if (this.carrying)
|
|
198
|
+
return;
|
|
199
|
+
this.told = true;
|
|
200
|
+
this.spec.onGone();
|
|
201
|
+
},
|
|
202
|
+
learned: (id) => { this.written = id; this.spec.learned(id); },
|
|
203
|
+
};
|
|
204
|
+
return new LoggedCliSession(own, opencodeCli(own));
|
|
205
|
+
}
|
|
206
|
+
get pid() { return this.inner.pid; }
|
|
207
|
+
get working() { return this.inner.working; }
|
|
208
|
+
quiet() { return this.inner.quiet(); }
|
|
209
|
+
end() { this.stopped = true; return this.inner.end(); }
|
|
210
|
+
async ask(prompt, sink, timeoutMs, token) {
|
|
211
|
+
let said = prompt;
|
|
212
|
+
for (;;) {
|
|
213
|
+
try {
|
|
214
|
+
return await this.inner.ask(said, sink, timeoutMs, token);
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
// OWNER: ITER/LOOP — a key the vendor refused already ended its CLI and is recorded; the same turn runs on the next key, and any other failure, a stop or a cancel is rethrown to the turn's caller
|
|
218
|
+
if (!(err instanceof CliEnded) || this.stopped || this.told || token.isCancellationRequested)
|
|
219
|
+
throw err;
|
|
220
|
+
sink.activity(err.message);
|
|
221
|
+
this.carrying = true;
|
|
222
|
+
try {
|
|
223
|
+
await this.inner.gone;
|
|
224
|
+
if (this.stopped)
|
|
225
|
+
throw err;
|
|
226
|
+
// NULL-OK: field written is OPTIONAL and therefore it is ok to check for NULL
|
|
227
|
+
const before = this.written !== undefined;
|
|
228
|
+
this.inner = this.launch();
|
|
229
|
+
said = before ? KEY_RETRY_PROMPT : prompt;
|
|
230
|
+
}
|
|
231
|
+
catch (failure) {
|
|
232
|
+
this.stopped = true;
|
|
233
|
+
this.spec.onGone();
|
|
234
|
+
throw failure;
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
this.carrying = false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
168
243
|
export const opencodeProvider = {
|
|
169
244
|
name: "opencode",
|
|
170
245
|
label: "OpenCode",
|
|
171
246
|
command: "opencode",
|
|
172
247
|
nativeArgs: (model) => model ? ["-m", model] : [],
|
|
173
|
-
open: (spec) => new
|
|
248
|
+
open: (spec) => new OpenCodeSession(spec),
|
|
174
249
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.349",
|
|
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",
|