switchroom 0.13.55 → 0.13.57
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/agent-scheduler/index.js +80 -80
- package/dist/auth-broker/index.js +80 -80
- package/dist/cli/ack-first-pretool.mjs +75 -0
- package/dist/cli/drive-write-pretool.mjs +10 -10
- package/dist/cli/notion-write-pretool.mjs +90 -84
- package/dist/cli/skill-validate-pretool.mjs +72 -72
- package/dist/cli/switchroom.js +367 -358
- package/dist/host-control/main.js +148 -148
- package/dist/vault/approvals/kernel-server.js +82 -82
- package/dist/vault/broker/server.js +83 -83
- package/package.json +1 -1
- package/skills/notion/SKILL.md +13 -9
- package/telegram-plugin/ack-flag.ts +66 -0
- package/telegram-plugin/dist/bridge/bridge.js +112 -112
- package/telegram-plugin/dist/gateway/gateway.js +991 -601
- package/telegram-plugin/dist/server.js +160 -160
- package/telegram-plugin/gateway/gateway.ts +151 -1
- package/telegram-plugin/runtime-metrics.ts +17 -0
- package/telegram-plugin/silence-poke.ts +82 -0
- package/telegram-plugin/tests/ack-flag.test.ts +65 -0
- package/telegram-plugin/tests/post-fallback-outbound-count.test.ts +78 -0
- package/telegram-plugin/tests/silence-poke.test.ts +117 -7
- package/telegram-plugin/tests/tool-intent-surface.test.ts +128 -0
- package/telegram-plugin/tool-intent-surface.ts +155 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/cli/ack-first-pretool.ts
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
var REPLY_TOOL_NAMES = new Set([
|
|
5
|
+
"mcp__switchroom-telegram__reply",
|
|
6
|
+
"mcp__switchroom-telegram__stream_reply"
|
|
7
|
+
]);
|
|
8
|
+
var ACK_SENT_MARKER = "ack-sent.flag";
|
|
9
|
+
function decide(input, stateDir) {
|
|
10
|
+
const toolName = input.tool_name ?? "";
|
|
11
|
+
if (toolName === "") {
|
|
12
|
+
return { decision: "allow" };
|
|
13
|
+
}
|
|
14
|
+
if (REPLY_TOOL_NAMES.has(toolName)) {
|
|
15
|
+
return { decision: "allow" };
|
|
16
|
+
}
|
|
17
|
+
if (!stateDir) {
|
|
18
|
+
return { decision: "allow" };
|
|
19
|
+
}
|
|
20
|
+
const markerPath = join(stateDir, ACK_SENT_MARKER);
|
|
21
|
+
let ackAlreadySent = false;
|
|
22
|
+
try {
|
|
23
|
+
ackAlreadySent = existsSync(markerPath);
|
|
24
|
+
} catch {
|
|
25
|
+
return { decision: "allow" };
|
|
26
|
+
}
|
|
27
|
+
if (ackAlreadySent) {
|
|
28
|
+
return { decision: "allow" };
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
decision: "block",
|
|
32
|
+
reason: "First call `mcp__switchroom-telegram__reply` with a brief one-line " + "acknowledgement in your persona's voice before using any other tool \u2014 " + 'e.g. "on it \u2014 checking", "good question \u2014 one sec", "let me dig in". ' + "This is the framework's enforcement of the human-feel design " + "(`reference/conversational-pacing.md` beat 1): a colleague answers " + "in a beat. The reply can be the entire short answer if you have one " + "ready (then no further work needed); otherwise it's a brief status " + "and you continue with the work after."
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async function runHook() {
|
|
36
|
+
if (process.env.SWITCHROOM_DISABLE_ACK_FIRST_GATE === "1") {
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
const stdin = await readStdin();
|
|
40
|
+
let input;
|
|
41
|
+
try {
|
|
42
|
+
input = JSON.parse(stdin);
|
|
43
|
+
} catch {
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
const stateDir = process.env.TELEGRAM_STATE_DIR;
|
|
47
|
+
const decision = decide(input, stateDir);
|
|
48
|
+
if (decision.decision === "block") {
|
|
49
|
+
process.stdout.write(JSON.stringify({ decision: "block", reason: decision.reason }) + `
|
|
50
|
+
`);
|
|
51
|
+
}
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
async function readStdin() {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const chunks = [];
|
|
57
|
+
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
58
|
+
process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
|
|
59
|
+
process.stdin.on("error", reject);
|
|
60
|
+
if (process.stdin.isTTY)
|
|
61
|
+
resolve("");
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (typeof process !== "undefined" && process.argv?.[1]?.endsWith("ack-first-pretool.mjs")) {
|
|
65
|
+
runHook().catch((err) => {
|
|
66
|
+
process.stderr.write(`ack-first-pretool: hook failed unexpectedly: ${err}
|
|
67
|
+
`);
|
|
68
|
+
process.exit(0);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
runHook,
|
|
73
|
+
decide,
|
|
74
|
+
ACK_SENT_MARKER
|
|
75
|
+
};
|
|
@@ -14,7 +14,7 @@ var __export = (target, all) => {
|
|
|
14
14
|
};
|
|
15
15
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
16
16
|
|
|
17
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
17
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
18
18
|
var util, objectUtil, ZodParsedType, getParsedType = (data) => {
|
|
19
19
|
const t = typeof data;
|
|
20
20
|
switch (t) {
|
|
@@ -145,7 +145,7 @@ var init_util = __esm(() => {
|
|
|
145
145
|
]);
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
|
|
148
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
|
|
149
149
|
var ZodIssueCode, quotelessJson = (obj) => {
|
|
150
150
|
const json = JSON.stringify(obj, null, 2);
|
|
151
151
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
@@ -266,7 +266,7 @@ var init_ZodError = __esm(() => {
|
|
|
266
266
|
};
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
269
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
270
270
|
var errorMap = (issue, _ctx) => {
|
|
271
271
|
let message;
|
|
272
272
|
switch (issue.code) {
|
|
@@ -373,7 +373,7 @@ var init_en = __esm(() => {
|
|
|
373
373
|
en_default = errorMap;
|
|
374
374
|
});
|
|
375
375
|
|
|
376
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
|
|
376
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
|
|
377
377
|
function setErrorMap(map) {
|
|
378
378
|
overrideErrorMap = map;
|
|
379
379
|
}
|
|
@@ -386,7 +386,7 @@ var init_errors = __esm(() => {
|
|
|
386
386
|
overrideErrorMap = en_default;
|
|
387
387
|
});
|
|
388
388
|
|
|
389
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
389
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
390
390
|
function addIssueToContext(ctx, issueData) {
|
|
391
391
|
const overrideMap = getErrorMap();
|
|
392
392
|
const issue = makeIssue({
|
|
@@ -491,10 +491,10 @@ var init_parseUtil = __esm(() => {
|
|
|
491
491
|
});
|
|
492
492
|
});
|
|
493
493
|
|
|
494
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
|
|
494
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
|
|
495
495
|
var init_typeAliases = () => {};
|
|
496
496
|
|
|
497
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
497
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
498
498
|
var errorUtil;
|
|
499
499
|
var init_errorUtil = __esm(() => {
|
|
500
500
|
(function(errorUtil2) {
|
|
@@ -503,7 +503,7 @@ var init_errorUtil = __esm(() => {
|
|
|
503
503
|
})(errorUtil || (errorUtil = {}));
|
|
504
504
|
});
|
|
505
505
|
|
|
506
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
|
|
506
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
|
|
507
507
|
class ParseInputLazyPath {
|
|
508
508
|
constructor(parent, value, path, key) {
|
|
509
509
|
this._cachedPath = [];
|
|
@@ -3854,7 +3854,7 @@ var init_types = __esm(() => {
|
|
|
3854
3854
|
NEVER = INVALID;
|
|
3855
3855
|
});
|
|
3856
3856
|
|
|
3857
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
3857
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
3858
3858
|
var exports_external = {};
|
|
3859
3859
|
__export(exports_external, {
|
|
3860
3860
|
void: () => voidType,
|
|
@@ -3974,7 +3974,7 @@ var init_external = __esm(() => {
|
|
|
3974
3974
|
init_ZodError();
|
|
3975
3975
|
});
|
|
3976
3976
|
|
|
3977
|
-
// node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
|
|
3977
|
+
// ../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
|
|
3978
3978
|
var init_zod = __esm(() => {
|
|
3979
3979
|
init_external();
|
|
3980
3980
|
init_external();
|