switchroom 0.18.14 → 0.18.15
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/auth-broker/index.js +41 -39
- package/dist/cli/switchroom.js +1151 -1067
- package/dist/host-control/main.js +53 -51
- package/dist/vault/approvals/kernel-server.js +16 -12
- package/dist/vault/broker/server.js +672 -668
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge/bridge.js +21 -0
- package/telegram-plugin/dist/gateway/gateway.js +150 -5
- package/telegram-plugin/dist/server.js +22 -1
- package/telegram-plugin/gateway/gateway.ts +48 -2
- package/telegram-plugin/model-unavailable.ts +214 -0
- package/telegram-plugin/runtime-metrics.ts +31 -0
- package/telegram-plugin/session-tail.ts +14 -2
- package/telegram-plugin/tests/model-unavailable.test.ts +187 -0
- package/telegram-plugin/tests/operator-events-session-tail.test.ts +55 -0
- package/telegram-plugin/tests/runtime-metrics.test.ts +24 -0
- package/telegram-plugin/tests/throttle-tier.test.ts +176 -0
- package/telegram-plugin/throttle-tier.ts +98 -1
|
@@ -20496,13 +20496,62 @@ async function waitForConfigRecovery(opts) {
|
|
|
20496
20496
|
return config;
|
|
20497
20497
|
}
|
|
20498
20498
|
|
|
20499
|
-
// src/agents/compose.ts
|
|
20500
|
-
import { createHash } from "node:crypto";
|
|
20501
|
-
|
|
20502
20499
|
// src/agents/scaffold.ts
|
|
20503
20500
|
import { join as join5, resolve as resolve5 } from "node:path";
|
|
20504
20501
|
init_atomic();
|
|
20505
20502
|
|
|
20503
|
+
// src/agents/agent-uid.ts
|
|
20504
|
+
import { createHash } from "node:crypto";
|
|
20505
|
+
|
|
20506
|
+
// src/broker-common/peercred-path.ts
|
|
20507
|
+
function matchSocketName(socketPath, patterns, maxNameLen) {
|
|
20508
|
+
if (typeof socketPath !== "string" || socketPath.length === 0)
|
|
20509
|
+
return null;
|
|
20510
|
+
let name = null;
|
|
20511
|
+
for (const re of patterns) {
|
|
20512
|
+
const m = socketPath.match(re);
|
|
20513
|
+
if (m && typeof m[1] === "string") {
|
|
20514
|
+
name = m[1];
|
|
20515
|
+
break;
|
|
20516
|
+
}
|
|
20517
|
+
}
|
|
20518
|
+
if (name === null || name.length === 0)
|
|
20519
|
+
return null;
|
|
20520
|
+
if (maxNameLen !== undefined && name.length > maxNameLen)
|
|
20521
|
+
return null;
|
|
20522
|
+
return name;
|
|
20523
|
+
}
|
|
20524
|
+
function parseSocketIdentity(socketPath, spec) {
|
|
20525
|
+
const name = matchSocketName(socketPath, spec.patterns, spec.maxNameLen);
|
|
20526
|
+
if (name === null)
|
|
20527
|
+
return null;
|
|
20528
|
+
const operatorName = spec.operatorName ?? "operator";
|
|
20529
|
+
if (name === operatorName)
|
|
20530
|
+
return { kind: "operator" };
|
|
20531
|
+
if (spec.reservedNames.has(name))
|
|
20532
|
+
return null;
|
|
20533
|
+
return { kind: "agent", name };
|
|
20534
|
+
}
|
|
20535
|
+
|
|
20536
|
+
// src/vault/broker/peercred.ts
|
|
20537
|
+
var RESERVED_AGENT_NAMES = new Set(["operator", "hostd"]);
|
|
20538
|
+
function isReservedAgentName(name) {
|
|
20539
|
+
return RESERVED_AGENT_NAMES.has(name);
|
|
20540
|
+
}
|
|
20541
|
+
|
|
20542
|
+
// src/agents/agent-uid.ts
|
|
20543
|
+
var AGENT_UID_MIN = 10001;
|
|
20544
|
+
var AGENT_UID_MAX = 10999;
|
|
20545
|
+
function allocateAgentUid(name) {
|
|
20546
|
+
if (isReservedAgentName(name)) {
|
|
20547
|
+
throw new Error(`agent name '${name}' is reserved by switchroom for another identity kind ` + `(see vault/broker/peercred.ts:RESERVED_AGENT_NAMES). Pick a different name.`);
|
|
20548
|
+
}
|
|
20549
|
+
const hash = createHash("sha256").update(name).digest();
|
|
20550
|
+
const u32 = hash.readUInt32BE(0);
|
|
20551
|
+
const range = AGENT_UID_MAX - AGENT_UID_MIN + 1;
|
|
20552
|
+
return AGENT_UID_MIN + u32 % range;
|
|
20553
|
+
}
|
|
20554
|
+
|
|
20506
20555
|
// src/config/timezone.ts
|
|
20507
20556
|
var CONTAINER_DEFAULT_UTC_ZONES = new Set([
|
|
20508
20557
|
"UTC",
|
|
@@ -20648,42 +20697,6 @@ import * as fs from "node:fs";
|
|
|
20648
20697
|
import { homedir as homedir3 } from "node:os";
|
|
20649
20698
|
import { join as join4 } from "node:path";
|
|
20650
20699
|
|
|
20651
|
-
// src/broker-common/peercred-path.ts
|
|
20652
|
-
function matchSocketName(socketPath, patterns, maxNameLen) {
|
|
20653
|
-
if (typeof socketPath !== "string" || socketPath.length === 0)
|
|
20654
|
-
return null;
|
|
20655
|
-
let name = null;
|
|
20656
|
-
for (const re of patterns) {
|
|
20657
|
-
const m = socketPath.match(re);
|
|
20658
|
-
if (m && typeof m[1] === "string") {
|
|
20659
|
-
name = m[1];
|
|
20660
|
-
break;
|
|
20661
|
-
}
|
|
20662
|
-
}
|
|
20663
|
-
if (name === null || name.length === 0)
|
|
20664
|
-
return null;
|
|
20665
|
-
if (maxNameLen !== undefined && name.length > maxNameLen)
|
|
20666
|
-
return null;
|
|
20667
|
-
return name;
|
|
20668
|
-
}
|
|
20669
|
-
function parseSocketIdentity(socketPath, spec) {
|
|
20670
|
-
const name = matchSocketName(socketPath, spec.patterns, spec.maxNameLen);
|
|
20671
|
-
if (name === null)
|
|
20672
|
-
return null;
|
|
20673
|
-
const operatorName = spec.operatorName ?? "operator";
|
|
20674
|
-
if (name === operatorName)
|
|
20675
|
-
return { kind: "operator" };
|
|
20676
|
-
if (spec.reservedNames.has(name))
|
|
20677
|
-
return null;
|
|
20678
|
-
return { kind: "agent", name };
|
|
20679
|
-
}
|
|
20680
|
-
|
|
20681
|
-
// src/vault/broker/peercred.ts
|
|
20682
|
-
var RESERVED_AGENT_NAMES = new Set(["operator", "hostd"]);
|
|
20683
|
-
function isReservedAgentName(name) {
|
|
20684
|
-
return RESERVED_AGENT_NAMES.has(name);
|
|
20685
|
-
}
|
|
20686
|
-
|
|
20687
20700
|
// src/vault/broker/protocol.ts
|
|
20688
20701
|
var MAX_FRAME_BYTES = 64 * 1024;
|
|
20689
20702
|
var AgentNameSchema = exports_external.string().min(1).max(64, "agent name max 64 chars").regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/, "agent name must be kebab-case ASCII (alnum + _- only, first char alnum)").refine((s) => !isReservedAgentName(s), {
|
|
@@ -21131,17 +21144,6 @@ var DOCKER_TELEGRAM_PLUGIN_PATH = "/opt/switchroom/telegram-plugin";
|
|
|
21131
21144
|
var DOCKER_HOOKS_PATH = `${DOCKER_TELEGRAM_PLUGIN_PATH}/hooks`;
|
|
21132
21145
|
|
|
21133
21146
|
// src/agents/compose.ts
|
|
21134
|
-
var AGENT_UID_MIN = 10001;
|
|
21135
|
-
var AGENT_UID_MAX = 10999;
|
|
21136
|
-
function allocateAgentUid(name) {
|
|
21137
|
-
if (isReservedAgentName(name)) {
|
|
21138
|
-
throw new Error(`agent name '${name}' is reserved by switchroom for another identity kind ` + `(see vault/broker/peercred.ts:RESERVED_AGENT_NAMES). Pick a different name.`);
|
|
21139
|
-
}
|
|
21140
|
-
const hash = createHash("sha256").update(name).digest();
|
|
21141
|
-
const u32 = hash.readUInt32BE(0);
|
|
21142
|
-
const range = AGENT_UID_MAX - AGENT_UID_MIN + 1;
|
|
21143
|
-
return AGENT_UID_MIN + u32 % range;
|
|
21144
|
-
}
|
|
21145
21147
|
var BIND_MOUNT_EXACT_SOURCE_DENY = new Set(["/var/run/docker.sock"]);
|
|
21146
21148
|
|
|
21147
21149
|
// src/host-control/server.ts
|
|
@@ -26587,7 +26589,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:f
|
|
|
26587
26589
|
import { dirname as dirname4, join as join7 } from "node:path";
|
|
26588
26590
|
|
|
26589
26591
|
// src/build-info.ts
|
|
26590
|
-
var VERSION = "0.18.
|
|
26592
|
+
var VERSION = "0.18.15";
|
|
26591
26593
|
|
|
26592
26594
|
// src/cli/resolve-version.ts
|
|
26593
26595
|
function readPackageVersion() {
|
|
@@ -18893,12 +18893,27 @@ function getNonce(db, request_id) {
|
|
|
18893
18893
|
}
|
|
18894
18894
|
|
|
18895
18895
|
// src/agents/compose.ts
|
|
18896
|
-
import { createHash } from "node:crypto";
|
|
18897
18896
|
init_schema();
|
|
18898
18897
|
|
|
18899
18898
|
// src/agents/scaffold.ts
|
|
18900
18899
|
import { join as join4, resolve as resolve5 } from "node:path";
|
|
18901
18900
|
init_atomic();
|
|
18901
|
+
|
|
18902
|
+
// src/agents/agent-uid.ts
|
|
18903
|
+
import { createHash } from "node:crypto";
|
|
18904
|
+
var AGENT_UID_MIN = 10001;
|
|
18905
|
+
var AGENT_UID_MAX = 10999;
|
|
18906
|
+
function allocateAgentUid(name) {
|
|
18907
|
+
if (isReservedAgentName(name)) {
|
|
18908
|
+
throw new Error(`agent name '${name}' is reserved by switchroom for another identity kind ` + `(see vault/broker/peercred.ts:RESERVED_AGENT_NAMES). Pick a different name.`);
|
|
18909
|
+
}
|
|
18910
|
+
const hash = createHash("sha256").update(name).digest();
|
|
18911
|
+
const u32 = hash.readUInt32BE(0);
|
|
18912
|
+
const range = AGENT_UID_MAX - AGENT_UID_MIN + 1;
|
|
18913
|
+
return AGENT_UID_MIN + u32 % range;
|
|
18914
|
+
}
|
|
18915
|
+
|
|
18916
|
+
// src/agents/scaffold.ts
|
|
18902
18917
|
init_schema();
|
|
18903
18918
|
|
|
18904
18919
|
// src/config/users.ts
|
|
@@ -19100,17 +19115,6 @@ init_merge();
|
|
|
19100
19115
|
init_paths();
|
|
19101
19116
|
|
|
19102
19117
|
// src/agents/compose.ts
|
|
19103
|
-
var AGENT_UID_MIN = 10001;
|
|
19104
|
-
var AGENT_UID_MAX = 10999;
|
|
19105
|
-
function allocateAgentUid(name) {
|
|
19106
|
-
if (isReservedAgentName(name)) {
|
|
19107
|
-
throw new Error(`agent name '${name}' is reserved by switchroom for another identity kind ` + `(see vault/broker/peercred.ts:RESERVED_AGENT_NAMES). Pick a different name.`);
|
|
19108
|
-
}
|
|
19109
|
-
const hash = createHash("sha256").update(name).digest();
|
|
19110
|
-
const u32 = hash.readUInt32BE(0);
|
|
19111
|
-
const range = AGENT_UID_MAX - AGENT_UID_MIN + 1;
|
|
19112
|
-
return AGENT_UID_MIN + u32 % range;
|
|
19113
|
-
}
|
|
19114
19118
|
var BIND_MOUNT_EXACT_SOURCE_DENY = new Set(["/var/run/docker.sock"]);
|
|
19115
19119
|
|
|
19116
19120
|
// src/vault/approvals/acl.ts
|