switchroom 0.18.12 → 0.18.13
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 +8 -0
- package/dist/auth-broker/index.js +63 -65
- package/dist/cli/ms-365-write-pretool.mjs +31 -8
- package/dist/cli/notion-write-pretool.mjs +9 -1
- package/dist/cli/skill-validate-pretool.mjs +144 -2847
- package/dist/cli/switchroom.js +952 -3126
- package/dist/host-control/main.js +216 -2862
- package/dist/vault/approvals/kernel-server.js +67 -0
- package/dist/vault/broker/server.js +98 -44
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge/bridge.js +49 -3
- package/telegram-plugin/dist/gateway/gateway.js +656 -2326
- package/telegram-plugin/dist/server.js +65 -3
- package/telegram-plugin/format.ts +19 -0
- package/telegram-plugin/gateway/approval-hold.ts +21 -2
- package/telegram-plugin/gateway/callback-query-handlers.ts +12 -0
- package/telegram-plugin/gateway/gateway.ts +221 -73
- package/telegram-plugin/history.ts +51 -0
- package/telegram-plugin/inline-keyboard-callbacks.ts +94 -0
- package/telegram-plugin/model-unavailable.ts +41 -11
- package/telegram-plugin/outbound-field-redact.ts +69 -0
- package/telegram-plugin/render/render.ts +32 -14
- package/telegram-plugin/scoped-approval.ts +11 -2
- package/telegram-plugin/secret-detect/chunker.ts +18 -4
- package/telegram-plugin/secret-detect/index.ts +12 -56
- package/telegram-plugin/send-gate-degraded.test.ts +131 -0
- package/telegram-plugin/send-gate.test.ts +25 -6
- package/telegram-plugin/send-gate.ts +82 -8
- package/telegram-plugin/session-tail.ts +82 -7
- package/telegram-plugin/subagent-watcher.ts +71 -16
- package/telegram-plugin/tests/approval-hold-outcome.test.ts +36 -5
- package/telegram-plugin/tests/callback-query-handlers.test.ts +65 -0
- package/telegram-plugin/tests/gateway-outbound-redact.test.ts +57 -0
- package/telegram-plugin/tests/history.test.ts +115 -0
- package/telegram-plugin/tests/inbound-message-types.test.ts +5 -1
- package/telegram-plugin/tests/inline-keyboard-callbacks.test.ts +164 -0
- package/telegram-plugin/tests/operator-events-session-tail.test.ts +74 -0
- package/telegram-plugin/tests/outbound-field-redact.test.ts +107 -0
- package/telegram-plugin/tests/reaction-gate-routing.test.ts +173 -0
- package/telegram-plugin/tests/render/render.test.ts +88 -0
- package/telegram-plugin/tests/scoped-approval.test.ts +27 -0
- package/telegram-plugin/tests/secret-detect-chunk-overlap.test.ts +65 -0
- package/telegram-plugin/tests/secret-detect-oauth-code.test.ts +5 -4
- package/telegram-plugin/tests/session-tail-sidecar-reap.test.ts +268 -0
- package/telegram-plugin/tests/subagent-watcher-fd-leak.test.ts +275 -0
- package/telegram-plugin/tests/worktree-watch-cwds.test.ts +215 -1
- package/telegram-plugin/worktree-watch-cwds.ts +194 -5
- package/telegram-plugin/secret-detect/secretlint-source.ts +0 -95
- package/telegram-plugin/tests/secret-detect-secretlint.test.ts +0 -105
|
@@ -13120,6 +13120,13 @@ var ApprovalLookupRequestSchema = exports_external.object({
|
|
|
13120
13120
|
action: exports_external.string().min(1),
|
|
13121
13121
|
current_approver_set: exports_external.array(exports_external.string())
|
|
13122
13122
|
});
|
|
13123
|
+
var ApprovalLookupByRequestRequestSchema = exports_external.object({
|
|
13124
|
+
v: exports_external.literal(1),
|
|
13125
|
+
op: exports_external.literal("approval_lookup_by_request"),
|
|
13126
|
+
agent_unit: exports_external.string().min(1),
|
|
13127
|
+
request_id: exports_external.string().regex(/^[0-9a-f]{32}$/),
|
|
13128
|
+
current_approver_set: exports_external.array(exports_external.string())
|
|
13129
|
+
});
|
|
13123
13130
|
var ApprovalConsumeRequestSchema = exports_external.object({
|
|
13124
13131
|
v: exports_external.literal(1),
|
|
13125
13132
|
op: exports_external.literal("approval_consume"),
|
|
@@ -13174,6 +13181,7 @@ var RequestSchema = exports_external.discriminatedUnion("op", [
|
|
|
13174
13181
|
RevokeGrantRequestSchema,
|
|
13175
13182
|
ApprovalRequestRequestSchema,
|
|
13176
13183
|
ApprovalLookupRequestSchema,
|
|
13184
|
+
ApprovalLookupByRequestRequestSchema,
|
|
13177
13185
|
ApprovalConsumeRequestSchema,
|
|
13178
13186
|
ApprovalRevokeRequestSchema,
|
|
13179
13187
|
ApprovalListRequestSchema,
|
|
@@ -7010,6 +7010,41 @@ var require_dist = __commonJS((exports) => {
|
|
|
7010
7010
|
exports.visitAsync = visit.visitAsync;
|
|
7011
7011
|
});
|
|
7012
7012
|
|
|
7013
|
+
// src/util/atomic.ts
|
|
7014
|
+
import { randomBytes } from "node:crypto";
|
|
7015
|
+
import { closeSync, constants, fsyncSync, openSync, renameSync, rmSync, writeSync } from "node:fs";
|
|
7016
|
+
function atomicWriteFileSync(destPath, contents, mode = 384) {
|
|
7017
|
+
const tmp = `${destPath}.tmp-${process.pid}-${randomBytes(4).toString("hex")}`;
|
|
7018
|
+
const buf = typeof contents === "string" ? Buffer.from(contents, "utf-8") : contents;
|
|
7019
|
+
let fd = null;
|
|
7020
|
+
try {
|
|
7021
|
+
fd = openSync(tmp, TMP_OPEN_FLAGS, mode);
|
|
7022
|
+
writeSync(fd, buf, 0, buf.length, 0);
|
|
7023
|
+
fsyncSync(fd);
|
|
7024
|
+
closeSync(fd);
|
|
7025
|
+
fd = null;
|
|
7026
|
+
renameSync(tmp, destPath);
|
|
7027
|
+
} catch (err) {
|
|
7028
|
+
if (fd !== null) {
|
|
7029
|
+
try {
|
|
7030
|
+
closeSync(fd);
|
|
7031
|
+
} catch {}
|
|
7032
|
+
}
|
|
7033
|
+
try {
|
|
7034
|
+
rmSync(tmp, { force: true });
|
|
7035
|
+
} catch {}
|
|
7036
|
+
throw err;
|
|
7037
|
+
}
|
|
7038
|
+
}
|
|
7039
|
+
function atomicWriteJsonSync(destPath, value, mode = 384) {
|
|
7040
|
+
atomicWriteFileSync(destPath, JSON.stringify(value, null, 2) + `
|
|
7041
|
+
`, mode);
|
|
7042
|
+
}
|
|
7043
|
+
var TMP_OPEN_FLAGS;
|
|
7044
|
+
var init_atomic = __esm(() => {
|
|
7045
|
+
TMP_OPEN_FLAGS = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0);
|
|
7046
|
+
});
|
|
7047
|
+
|
|
7013
7048
|
// node_modules/.bun/handlebars@4.7.9/node_modules/handlebars/dist/cjs/handlebars/utils.js
|
|
7014
7049
|
var require_utils = __commonJS((exports) => {
|
|
7015
7050
|
exports.__esModule = true;
|
|
@@ -12570,41 +12605,6 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
12570
12605
|
}
|
|
12571
12606
|
});
|
|
12572
12607
|
|
|
12573
|
-
// src/util/atomic.ts
|
|
12574
|
-
import { randomBytes } from "node:crypto";
|
|
12575
|
-
import { closeSync, constants, fsyncSync, openSync, renameSync, rmSync, writeSync } from "node:fs";
|
|
12576
|
-
function atomicWriteFileSync(destPath, contents, mode = 384) {
|
|
12577
|
-
const tmp = `${destPath}.tmp-${process.pid}-${randomBytes(4).toString("hex")}`;
|
|
12578
|
-
const buf = typeof contents === "string" ? Buffer.from(contents, "utf-8") : contents;
|
|
12579
|
-
let fd = null;
|
|
12580
|
-
try {
|
|
12581
|
-
fd = openSync(tmp, TMP_OPEN_FLAGS, mode);
|
|
12582
|
-
writeSync(fd, buf, 0, buf.length, 0);
|
|
12583
|
-
fsyncSync(fd);
|
|
12584
|
-
closeSync(fd);
|
|
12585
|
-
fd = null;
|
|
12586
|
-
renameSync(tmp, destPath);
|
|
12587
|
-
} catch (err) {
|
|
12588
|
-
if (fd !== null) {
|
|
12589
|
-
try {
|
|
12590
|
-
closeSync(fd);
|
|
12591
|
-
} catch {}
|
|
12592
|
-
}
|
|
12593
|
-
try {
|
|
12594
|
-
rmSync(tmp, { force: true });
|
|
12595
|
-
} catch {}
|
|
12596
|
-
throw err;
|
|
12597
|
-
}
|
|
12598
|
-
}
|
|
12599
|
-
function atomicWriteJsonSync(destPath, value, mode = 384) {
|
|
12600
|
-
atomicWriteFileSync(destPath, JSON.stringify(value, null, 2) + `
|
|
12601
|
-
`, mode);
|
|
12602
|
-
}
|
|
12603
|
-
var TMP_OPEN_FLAGS;
|
|
12604
|
-
var init_atomic = __esm(() => {
|
|
12605
|
-
TMP_OPEN_FLAGS = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0);
|
|
12606
|
-
});
|
|
12607
|
-
|
|
12608
12608
|
// src/auth/broker/index.ts
|
|
12609
12609
|
import { existsSync as existsSync9, readFileSync as readFileSync8 } from "node:fs";
|
|
12610
12610
|
|
|
@@ -18112,7 +18112,7 @@ import {
|
|
|
18112
18112
|
rmSync as rmSync5,
|
|
18113
18113
|
statSync as statSync6,
|
|
18114
18114
|
unlinkSync,
|
|
18115
|
-
writeFileSync as
|
|
18115
|
+
writeFileSync as writeFileSync2
|
|
18116
18116
|
} from "node:fs";
|
|
18117
18117
|
import { closeSync as closeSync2, openSync as openSync2, writeSync as writeSync2 } from "node:fs";
|
|
18118
18118
|
import * as constants2 from "node:constants";
|
|
@@ -18124,6 +18124,7 @@ import { createHash } from "node:crypto";
|
|
|
18124
18124
|
|
|
18125
18125
|
// src/agents/scaffold.ts
|
|
18126
18126
|
import { join as join4, resolve as resolve5 } from "node:path";
|
|
18127
|
+
init_atomic();
|
|
18127
18128
|
|
|
18128
18129
|
// src/config/timezone.ts
|
|
18129
18130
|
var CONTAINER_DEFAULT_UTC_ZONES = new Set([
|
|
@@ -18390,6 +18391,13 @@ var ApprovalLookupRequestSchema = exports_external.object({
|
|
|
18390
18391
|
action: exports_external.string().min(1),
|
|
18391
18392
|
current_approver_set: exports_external.array(exports_external.string())
|
|
18392
18393
|
});
|
|
18394
|
+
var ApprovalLookupByRequestRequestSchema = exports_external.object({
|
|
18395
|
+
v: exports_external.literal(1),
|
|
18396
|
+
op: exports_external.literal("approval_lookup_by_request"),
|
|
18397
|
+
agent_unit: exports_external.string().min(1),
|
|
18398
|
+
request_id: exports_external.string().regex(/^[0-9a-f]{32}$/),
|
|
18399
|
+
current_approver_set: exports_external.array(exports_external.string())
|
|
18400
|
+
});
|
|
18393
18401
|
var ApprovalConsumeRequestSchema = exports_external.object({
|
|
18394
18402
|
v: exports_external.literal(1),
|
|
18395
18403
|
op: exports_external.literal("approval_consume"),
|
|
@@ -18444,6 +18452,7 @@ var RequestSchema = exports_external.discriminatedUnion("op", [
|
|
|
18444
18452
|
RevokeGrantRequestSchema,
|
|
18445
18453
|
ApprovalRequestRequestSchema,
|
|
18446
18454
|
ApprovalLookupRequestSchema,
|
|
18455
|
+
ApprovalLookupByRequestRequestSchema,
|
|
18447
18456
|
ApprovalConsumeRequestSchema,
|
|
18448
18457
|
ApprovalRevokeRequestSchema,
|
|
18449
18458
|
ApprovalListRequestSchema,
|
|
@@ -18643,9 +18652,6 @@ var BIND_MOUNT_EXACT_SOURCE_DENY = new Set(["/var/run/docker.sock"]);
|
|
|
18643
18652
|
var OAUTH_BETA = "oauth-2025-04-20";
|
|
18644
18653
|
var DEFAULT_USER_AGENT = "claude-cli/1.0.0 (external, cli)";
|
|
18645
18654
|
var DEFAULT_PROBE_MODEL = "claude-haiku-4-5-20251001";
|
|
18646
|
-
function isProbeThin(q) {
|
|
18647
|
-
return q.fiveHourUtilPresent === false && q.sevenDayUtilPresent === false;
|
|
18648
|
-
}
|
|
18649
18655
|
function parseFloatHeader(headers, name) {
|
|
18650
18656
|
const v = headers.get(name);
|
|
18651
18657
|
if (v == null || v.trim().length === 0)
|
|
@@ -18742,6 +18748,9 @@ function snapshotFresh(s, now, maxAgeMs = SNAPSHOT_STALE_AGE_MS) {
|
|
|
18742
18748
|
function snapshotWalled(s) {
|
|
18743
18749
|
return s.fiveHourUtilizationPct >= WALL_PCT || s.sevenDayUtilizationPct >= WALL_PCT;
|
|
18744
18750
|
}
|
|
18751
|
+
function snapshotComplete(s) {
|
|
18752
|
+
return s.fiveHourUtilPresent !== false && s.sevenDayUtilPresent !== false;
|
|
18753
|
+
}
|
|
18745
18754
|
function overageLiftsWall(snapshot, inAllowList) {
|
|
18746
18755
|
if (!inAllowList)
|
|
18747
18756
|
return false;
|
|
@@ -18757,16 +18766,19 @@ function snapshotClearlyHealthy(s) {
|
|
|
18757
18766
|
}
|
|
18758
18767
|
function accountEligibility(opts) {
|
|
18759
18768
|
const { mark, snapshot, now, allowOverage = false } = opts;
|
|
18769
|
+
if (snapshotFresh(snapshot, now) && snapshotWalled(snapshot) && !overageLiftsWall(snapshot, allowOverage)) {
|
|
18770
|
+
return "blocked";
|
|
18771
|
+
}
|
|
18760
18772
|
if (snapshotFresh(snapshot, now)) {
|
|
18761
18773
|
const markedAt = mark?.marked_at ?? 0;
|
|
18762
18774
|
if (snapshot.capturedAt >= markedAt) {
|
|
18763
18775
|
if (snapshotWalled(snapshot)) {
|
|
18764
|
-
if (overageLiftsWall(snapshot, allowOverage))
|
|
18776
|
+
if (overageLiftsWall(snapshot, allowOverage))
|
|
18765
18777
|
return "eligible";
|
|
18766
|
-
}
|
|
18767
18778
|
return "blocked";
|
|
18768
18779
|
}
|
|
18769
|
-
|
|
18780
|
+
if (snapshotComplete(snapshot))
|
|
18781
|
+
return "eligible";
|
|
18770
18782
|
}
|
|
18771
18783
|
}
|
|
18772
18784
|
if (mark !== undefined && mark.exhausted_until > now)
|
|
@@ -18783,7 +18795,7 @@ function snapshotShouldClearMark(snapshot, mark, now) {
|
|
|
18783
18795
|
return false;
|
|
18784
18796
|
if (snapshot.capturedAt < (mark.marked_at ?? 0))
|
|
18785
18797
|
return false;
|
|
18786
|
-
if (
|
|
18798
|
+
if (!snapshotComplete(snapshot))
|
|
18787
18799
|
return false;
|
|
18788
18800
|
return snapshotClearlyHealthy(snapshot);
|
|
18789
18801
|
}
|
|
@@ -18792,7 +18804,7 @@ function clampMarkExpiry(opts) {
|
|
|
18792
18804
|
const shortCeil = now + shortMs;
|
|
18793
18805
|
if (proposedUntil <= shortCeil)
|
|
18794
18806
|
return proposedUntil;
|
|
18795
|
-
const liveContradictsWeeklyWall = snapshotFresh(snapshot, now) && snapshot.sevenDayUtilizationPct < WALL_PCT;
|
|
18807
|
+
const liveContradictsWeeklyWall = snapshotFresh(snapshot, now) && snapshot.sevenDayUtilPresent !== false && snapshot.sevenDayUtilizationPct < WALL_PCT;
|
|
18796
18808
|
return liveContradictsWeeklyWall ? shortCeil : proposedUntil;
|
|
18797
18809
|
}
|
|
18798
18810
|
var SOFT_AVOID_FIVE_HOUR_CAP = 98;
|
|
@@ -18885,6 +18897,7 @@ function resolveConsumerProbeIntervalMs(env) {
|
|
|
18885
18897
|
init_atomic();
|
|
18886
18898
|
|
|
18887
18899
|
// src/auth/account-store.ts
|
|
18900
|
+
init_atomic();
|
|
18888
18901
|
import {
|
|
18889
18902
|
chownSync,
|
|
18890
18903
|
existsSync as existsSync5,
|
|
@@ -18893,10 +18906,8 @@ import {
|
|
|
18893
18906
|
readdirSync as readdirSync3,
|
|
18894
18907
|
renameSync as renameSync2,
|
|
18895
18908
|
rmSync as rmSync2,
|
|
18896
|
-
statSync as statSync3
|
|
18897
|
-
writeFileSync as writeFileSync2
|
|
18909
|
+
statSync as statSync3
|
|
18898
18910
|
} from "node:fs";
|
|
18899
|
-
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
18900
18911
|
import { homedir as homedir4 } from "node:os";
|
|
18901
18912
|
import { join as join5, resolve as resolve6 } from "node:path";
|
|
18902
18913
|
var LABEL_MAX = 64;
|
|
@@ -18980,8 +18991,8 @@ function enrichClaudeCreds(value) {
|
|
|
18980
18991
|
}
|
|
18981
18992
|
function writeAccountCredentials(label, value, home2 = homedir4()) {
|
|
18982
18993
|
validateAccountLabel(label);
|
|
18983
|
-
mkdirSync2(accountDir(label, home2), { recursive: true });
|
|
18984
|
-
|
|
18994
|
+
mkdirSync2(accountDir(label, home2), { recursive: true, mode: 448 });
|
|
18995
|
+
atomicWriteJsonSync(accountCredentialsPath(label, home2), enrichClaudeCreds(value));
|
|
18985
18996
|
}
|
|
18986
18997
|
function chownAccountFiles(label, uid, home2 = homedir4()) {
|
|
18987
18998
|
validateAccountLabel(label);
|
|
@@ -19007,8 +19018,8 @@ function readAccountMeta(label, home2 = homedir4()) {
|
|
|
19007
19018
|
}
|
|
19008
19019
|
function writeAccountMeta(label, value, home2 = homedir4()) {
|
|
19009
19020
|
validateAccountLabel(label);
|
|
19010
|
-
mkdirSync2(accountDir(label, home2), { recursive: true });
|
|
19011
|
-
|
|
19021
|
+
mkdirSync2(accountDir(label, home2), { recursive: true, mode: 448 });
|
|
19022
|
+
atomicWriteJsonSync(accountMetaPath(label, home2), value);
|
|
19012
19023
|
}
|
|
19013
19024
|
function patchAccountMeta(label, patch, home2 = homedir4()) {
|
|
19014
19025
|
const existing = readAccountMeta(label, home2) ?? { createdAt: Date.now() };
|
|
@@ -19016,19 +19027,6 @@ function patchAccountMeta(label, patch, home2 = homedir4()) {
|
|
|
19016
19027
|
writeAccountMeta(label, merged, home2);
|
|
19017
19028
|
return merged;
|
|
19018
19029
|
}
|
|
19019
|
-
function atomicWriteJson(destPath, value, mode = 384) {
|
|
19020
|
-
const tmp = `${destPath}.tmp-${process.pid}-${randomBytes2(4).toString("hex")}`;
|
|
19021
|
-
try {
|
|
19022
|
-
writeFileSync2(tmp, JSON.stringify(value, null, 2) + `
|
|
19023
|
-
`, { mode });
|
|
19024
|
-
renameSync2(tmp, destPath);
|
|
19025
|
-
} catch (err) {
|
|
19026
|
-
try {
|
|
19027
|
-
rmSync2(tmp, { force: true });
|
|
19028
|
-
} catch {}
|
|
19029
|
-
throw err;
|
|
19030
|
-
}
|
|
19031
|
-
}
|
|
19032
19030
|
|
|
19033
19031
|
// src/auth/account-refresh.ts
|
|
19034
19032
|
var REFRESH_THRESHOLD_MS = 60 * 60 * 1000;
|
|
@@ -20195,7 +20193,7 @@ class AuthBroker {
|
|
|
20195
20193
|
if (!this.opts.skipHealthyMarker) {
|
|
20196
20194
|
try {
|
|
20197
20195
|
const healthyPath = join8(this.stateDir, "healthy");
|
|
20198
|
-
|
|
20196
|
+
writeFileSync2(healthyPath, String(this.now()) + `
|
|
20199
20197
|
`, { mode: 384 });
|
|
20200
20198
|
} catch (err) {
|
|
20201
20199
|
this.logErr(`failed to write healthy marker: ${err.message}`);
|
|
@@ -24,10 +24,33 @@ var GATED_MS365_WRITE_TOOLS = new Set([
|
|
|
24
24
|
"update-message",
|
|
25
25
|
"delete-message"
|
|
26
26
|
]);
|
|
27
|
+
var KNOWN_SAFE_MS365_READ_TOOLS = new Set([
|
|
28
|
+
"list-files",
|
|
29
|
+
"list-drive-items",
|
|
30
|
+
"get-drive-item",
|
|
31
|
+
"download-bytes",
|
|
32
|
+
"search-files",
|
|
33
|
+
"list-events",
|
|
34
|
+
"get-event",
|
|
35
|
+
"list-calendars",
|
|
36
|
+
"get-calendar",
|
|
37
|
+
"list-messages",
|
|
38
|
+
"get-message",
|
|
39
|
+
"search-mail",
|
|
40
|
+
"list-mail-folders",
|
|
41
|
+
"get-mail-folder",
|
|
42
|
+
"whoami",
|
|
43
|
+
"get-current-user"
|
|
44
|
+
]);
|
|
27
45
|
function isGatedMs365Tool(toolName) {
|
|
28
46
|
if (!toolName.startsWith(TOOL_PREFIX))
|
|
29
47
|
return false;
|
|
30
|
-
|
|
48
|
+
const bare = toolName.slice(TOOL_PREFIX.length);
|
|
49
|
+
if (bare.length === 0)
|
|
50
|
+
return false;
|
|
51
|
+
if (KNOWN_SAFE_MS365_READ_TOOLS.has(bare))
|
|
52
|
+
return false;
|
|
53
|
+
return true;
|
|
31
54
|
}
|
|
32
55
|
function readStdin() {
|
|
33
56
|
try {
|
|
@@ -170,13 +193,12 @@ async function rpcKernel(payload) {
|
|
|
170
193
|
});
|
|
171
194
|
});
|
|
172
195
|
}
|
|
173
|
-
async function
|
|
196
|
+
async function approvalLookupByRequest(agentUnit, requestId, approverSet) {
|
|
174
197
|
const res = await rpcKernel({
|
|
175
198
|
v: 1,
|
|
176
|
-
op: "
|
|
199
|
+
op: "approval_lookup_by_request",
|
|
177
200
|
agent_unit: agentUnit,
|
|
178
|
-
|
|
179
|
-
action: "write",
|
|
201
|
+
request_id: requestId,
|
|
180
202
|
current_approver_set: approverSet
|
|
181
203
|
});
|
|
182
204
|
if (!res.ok)
|
|
@@ -203,7 +225,7 @@ async function main() {
|
|
|
203
225
|
}
|
|
204
226
|
const agentName = process.env.SWITCHROOM_AGENT_NAME;
|
|
205
227
|
if (!agentName) {
|
|
206
|
-
|
|
228
|
+
fail("SWITCHROOM_AGENT_NAME unset \u2014 cannot identify agent to gate write");
|
|
207
229
|
}
|
|
208
230
|
const accountEmail = process.env.SWITCHROOM_MICROSOFT_ACCOUNT ?? "(unknown)";
|
|
209
231
|
const extract = extractMs365Preview(toolName, input.tool_input);
|
|
@@ -230,11 +252,11 @@ async function main() {
|
|
|
230
252
|
if (!response.ok || !response.requestId) {
|
|
231
253
|
fail(response.reason ?? "gateway returned ok=false");
|
|
232
254
|
}
|
|
255
|
+
const requestId = response.requestId;
|
|
233
256
|
const deadline = response.expiresAtMs ?? Date.now() + HOOK_TIMEOUT_MS;
|
|
234
|
-
const scope = `ms-365:write:${preview.itemId}`;
|
|
235
257
|
while (Date.now() < deadline) {
|
|
236
258
|
await new Promise((r) => setTimeout(r, KERNEL_POLL_INTERVAL_MS));
|
|
237
|
-
const lookup = await
|
|
259
|
+
const lookup = await approvalLookupByRequest(agentName, requestId, []);
|
|
238
260
|
if (!lookup)
|
|
239
261
|
continue;
|
|
240
262
|
const state = lookup.state;
|
|
@@ -255,5 +277,6 @@ if (__require.main == __require.module) {
|
|
|
255
277
|
export {
|
|
256
278
|
isGatedMs365Tool,
|
|
257
279
|
extractMs365Preview,
|
|
280
|
+
KNOWN_SAFE_MS365_READ_TOOLS,
|
|
258
281
|
GATED_MS365_WRITE_TOOLS
|
|
259
282
|
};
|
|
@@ -10928,7 +10928,7 @@ function decodeResponse(line) {
|
|
|
10928
10928
|
const obj = JSON.parse(line);
|
|
10929
10929
|
return ResponseSchema.parse(obj);
|
|
10930
10930
|
}
|
|
10931
|
-
var MAX_FRAME_BYTES, AgentNameSchema, GetRequestSchema, PutRequestSchema, ListRequestSchema, MintGrantRequestSchema, ListGrantsRequestSchema, RevokeGrantRequestSchema, StatusRequestSchema, LockRequestSchema, PreflightAccessRequestSchema, OkPreflightAccessResponseSchema, ApprovalRequestRequestSchema, ApprovalLookupRequestSchema, ApprovalConsumeRequestSchema, ApprovalRevokeRequestSchema, ApprovalListRequestSchema, ApprovalDecisionModeSchema, ApprovalRecordRequestSchema, ApprovalConsumeRecordRequestSchema, RequestSchema, VaultEntrySchema, ErrorCode, OkEntryResponseSchema, OkKeysResponseSchema, BrokerStatus, OkStatusResponseSchema, OkLockResponseSchema, OkPutResponseSchema, OkMintGrantResponseSchema, GrantMetaSchema, OkListGrantsResponseSchema, OkRevokeGrantResponseSchema, OkApprovalRequestResponseSchema, ApprovalDecisionMetaSchema, OkApprovalLookupResponseSchema, OkApprovalConsumeResponseSchema, OkApprovalRevokeResponseSchema, OkApprovalListResponseSchema, OkApprovalRecordResponseSchema, OkApprovalConsumeRecordResponseSchema, ErrorResponseSchema, ResponseSchema;
|
|
10931
|
+
var MAX_FRAME_BYTES, AgentNameSchema, GetRequestSchema, PutRequestSchema, ListRequestSchema, MintGrantRequestSchema, ListGrantsRequestSchema, RevokeGrantRequestSchema, StatusRequestSchema, LockRequestSchema, PreflightAccessRequestSchema, OkPreflightAccessResponseSchema, ApprovalRequestRequestSchema, ApprovalLookupRequestSchema, ApprovalLookupByRequestRequestSchema, ApprovalConsumeRequestSchema, ApprovalRevokeRequestSchema, ApprovalListRequestSchema, ApprovalDecisionModeSchema, ApprovalRecordRequestSchema, ApprovalConsumeRecordRequestSchema, RequestSchema, VaultEntrySchema, ErrorCode, OkEntryResponseSchema, OkKeysResponseSchema, BrokerStatus, OkStatusResponseSchema, OkLockResponseSchema, OkPutResponseSchema, OkMintGrantResponseSchema, GrantMetaSchema, OkListGrantsResponseSchema, OkRevokeGrantResponseSchema, OkApprovalRequestResponseSchema, ApprovalDecisionMetaSchema, OkApprovalLookupResponseSchema, OkApprovalConsumeResponseSchema, OkApprovalRevokeResponseSchema, OkApprovalListResponseSchema, OkApprovalRecordResponseSchema, OkApprovalConsumeRecordResponseSchema, ErrorResponseSchema, ResponseSchema;
|
|
10932
10932
|
var init_protocol = __esm(() => {
|
|
10933
10933
|
init_zod();
|
|
10934
10934
|
init_peercred();
|
|
@@ -11028,6 +11028,13 @@ var init_protocol = __esm(() => {
|
|
|
11028
11028
|
action: exports_external.string().min(1),
|
|
11029
11029
|
current_approver_set: exports_external.array(exports_external.string())
|
|
11030
11030
|
});
|
|
11031
|
+
ApprovalLookupByRequestRequestSchema = exports_external.object({
|
|
11032
|
+
v: exports_external.literal(1),
|
|
11033
|
+
op: exports_external.literal("approval_lookup_by_request"),
|
|
11034
|
+
agent_unit: exports_external.string().min(1),
|
|
11035
|
+
request_id: exports_external.string().regex(/^[0-9a-f]{32}$/),
|
|
11036
|
+
current_approver_set: exports_external.array(exports_external.string())
|
|
11037
|
+
});
|
|
11031
11038
|
ApprovalConsumeRequestSchema = exports_external.object({
|
|
11032
11039
|
v: exports_external.literal(1),
|
|
11033
11040
|
op: exports_external.literal("approval_consume"),
|
|
@@ -11082,6 +11089,7 @@ var init_protocol = __esm(() => {
|
|
|
11082
11089
|
RevokeGrantRequestSchema,
|
|
11083
11090
|
ApprovalRequestRequestSchema,
|
|
11084
11091
|
ApprovalLookupRequestSchema,
|
|
11092
|
+
ApprovalLookupByRequestRequestSchema,
|
|
11085
11093
|
ApprovalConsumeRequestSchema,
|
|
11086
11094
|
ApprovalRevokeRequestSchema,
|
|
11087
11095
|
ApprovalListRequestSchema,
|