switchroom 0.11.0 → 0.12.0

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.
Files changed (62) hide show
  1. package/README.md +7 -6
  2. package/dist/agent-scheduler/index.js +218 -99
  3. package/dist/auth-broker/index.js +300 -99
  4. package/dist/cli/drive-write-pretool.mjs +45 -12
  5. package/dist/cli/switchroom.js +44972 -42457
  6. package/dist/cli/ui/index.html +1281 -0
  7. package/dist/host-control/main.js +3630 -311
  8. package/dist/vault/approvals/kernel-server.js +209 -100
  9. package/dist/vault/broker/server.js +220 -99
  10. package/examples/personal-google-workspace-mcp/README.md +8 -3
  11. package/examples/switchroom.yaml +91 -42
  12. package/package.json +2 -2
  13. package/profiles/_base/start.sh.hbs +76 -36
  14. package/profiles/default/CLAUDE.md.hbs +4 -2
  15. package/skills/file-bug/SKILL.md +6 -4
  16. package/skills/switchroom-cli/SKILL.md +20 -4
  17. package/skills/switchroom-install/SKILL.md +3 -3
  18. package/telegram-plugin/auth-snapshot-format.ts +4 -4
  19. package/telegram-plugin/auto-fallback-fleet.ts +4 -4
  20. package/telegram-plugin/card-format.ts +3 -3
  21. package/telegram-plugin/dist/bridge/bridge.js +112 -112
  22. package/telegram-plugin/dist/gateway/gateway.js +1029 -628
  23. package/telegram-plugin/dist/server.js +162 -161
  24. package/telegram-plugin/format.ts +71 -0
  25. package/telegram-plugin/gateway/approval-card.test.ts +18 -18
  26. package/telegram-plugin/gateway/approval-card.ts +1 -1
  27. package/telegram-plugin/gateway/auth-broker-client.ts +2 -0
  28. package/telegram-plugin/gateway/auth-command.ts +12 -2
  29. package/telegram-plugin/gateway/boot-card.ts +40 -3
  30. package/telegram-plugin/gateway/boot-probes.ts +71 -27
  31. package/telegram-plugin/gateway/diff-preview-card.test.ts +15 -15
  32. package/telegram-plugin/gateway/diff-preview-card.ts +1 -1
  33. package/telegram-plugin/gateway/drive-write-approval.test.ts +2 -2
  34. package/telegram-plugin/gateway/gateway.ts +244 -46
  35. package/telegram-plugin/gateway/hostd-dispatch.ts +10 -2
  36. package/telegram-plugin/gateway/update-announce.ts +167 -0
  37. package/telegram-plugin/quota-check.ts +0 -195
  38. package/telegram-plugin/retry-api-call.ts +24 -0
  39. package/telegram-plugin/server.ts +8 -5
  40. package/telegram-plugin/tests/auth-add-flow.test.ts +31 -2
  41. package/telegram-plugin/tests/boot-probes.test.ts +53 -0
  42. package/telegram-plugin/tests/bot-runtime.test.ts +23 -1
  43. package/telegram-plugin/tests/quota-check.test.ts +0 -409
  44. package/telegram-plugin/tests/retry-api-call.test.ts +76 -0
  45. package/telegram-plugin/tests/telegram-format.test.ts +84 -1
  46. package/telegram-plugin/tests/update-announce.test.ts +154 -0
  47. package/telegram-plugin/welcome-text.ts +1 -8
  48. package/profiles/default/CLAUDE.md +0 -192
  49. package/skills/docx/scripts/office/validators/__pycache__/__init__.cpython-313.pyc +0 -0
  50. package/skills/docx/scripts/office/validators/__pycache__/base.cpython-313.pyc +0 -0
  51. package/skills/skill-creator/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
  52. package/skills/skill-creator/scripts/__pycache__/generate_report.cpython-313.pyc +0 -0
  53. package/skills/skill-creator/scripts/__pycache__/improve_description.cpython-313.pyc +0 -0
  54. package/skills/skill-creator/scripts/__pycache__/run_eval.cpython-313.pyc +0 -0
  55. package/skills/skill-creator/scripts/__pycache__/run_loop.cpython-313.pyc +0 -0
  56. package/skills/skill-creator/scripts/__pycache__/utils.cpython-313.pyc +0 -0
  57. package/telegram-plugin/first-paint.ts +0 -225
  58. package/telegram-plugin/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  59. package/telegram-plugin/server.js +0 -41795
  60. package/telegram-plugin/tests/html-balanced.ts +0 -63
  61. package/telegram-plugin/tests/snapshot-serializer.ts +0 -79
  62. package/telegram-plugin/tool-error-filter.ts +0 -89
@@ -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/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/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/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/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/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/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/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/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/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/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();
@@ -4000,7 +4000,7 @@ function decodeResponse(line) {
4000
4000
  }
4001
4001
  return ResponseSchema.parse(parsed);
4002
4002
  }
4003
- var MAX_FRAME_BYTES, PROTOCOL_VERSION = 1, ProviderNameSchema, GetCredentialsRequestSchema, ListStateRequestSchema, SetActiveRequestSchema, MarkExhaustedRequestSchema, RefreshAccountRequestSchema, AnthropicCredentialsSchema, GoogleCredentialsSchema, ProviderCredentialsSchema, AddAccountRequestSchema, RmAccountRequestSchema, SetOverrideRequestSchema, ListGoogleAccountsRequestSchema, RequestSchema, GetCredentialsDataSchema, AccountStateSchema, AgentStateSchema, ConsumerStateSchema, ListStateDataSchema, SetActiveDataSchema, MarkExhaustedDataSchema, RefreshAccountDataSchema, AddAccountDataSchema, RmAccountDataSchema, SetOverrideDataSchema, GoogleAccountStateSchema, ListGoogleAccountsDataSchema, ErrorBodySchema, SuccessResponseSchema, ErrorResponseSchema, ResponseSchema;
4003
+ var MAX_FRAME_BYTES, PROTOCOL_VERSION = 1, ProviderNameSchema, GetCredentialsRequestSchema, ListStateRequestSchema, SetActiveRequestSchema, MarkExhaustedRequestSchema, RefreshAccountRequestSchema, AnthropicCredentialsSchema, GoogleCredentialsSchema, ProviderCredentialsSchema, AddAccountRequestSchema, RmAccountRequestSchema, SetOverrideRequestSchema, ListGoogleAccountsRequestSchema, ProbeQuotaRequestSchema, RequestSchema, GetCredentialsDataSchema, AccountStateSchema, AgentStateSchema, ConsumerStateSchema, ListStateDataSchema, SetActiveDataSchema, MarkExhaustedDataSchema, RefreshAccountDataSchema, AddAccountDataSchema, RmAccountDataSchema, SetOverrideDataSchema, GoogleAccountStateSchema, ListGoogleAccountsDataSchema, ErrorBodySchema, SuccessResponseSchema, ErrorResponseSchema, ResponseSchema;
4004
4004
  var init_protocol = __esm(() => {
4005
4005
  init_zod();
4006
4006
  MAX_FRAME_BYTES = 64 * 1024;
@@ -4089,6 +4089,13 @@ var init_protocol = __esm(() => {
4089
4089
  op: exports_external.literal("list-google-accounts"),
4090
4090
  id: exports_external.string().min(1)
4091
4091
  });
4092
+ ProbeQuotaRequestSchema = exports_external.object({
4093
+ v: exports_external.literal(PROTOCOL_VERSION),
4094
+ op: exports_external.literal("probe-quota"),
4095
+ id: exports_external.string().min(1),
4096
+ accounts: exports_external.array(exports_external.string().min(1)).min(1).max(32),
4097
+ timeoutMs: exports_external.number().int().positive().max(60000).optional()
4098
+ });
4092
4099
  RequestSchema = exports_external.discriminatedUnion("op", [
4093
4100
  GetCredentialsRequestSchema,
4094
4101
  ListStateRequestSchema,
@@ -4098,7 +4105,8 @@ var init_protocol = __esm(() => {
4098
4105
  AddAccountRequestSchema,
4099
4106
  RmAccountRequestSchema,
4100
4107
  SetOverrideRequestSchema,
4101
- ListGoogleAccountsRequestSchema
4108
+ ListGoogleAccountsRequestSchema,
4109
+ ProbeQuotaRequestSchema
4102
4110
  ]);
4103
4111
  GetCredentialsDataSchema = exports_external.object({
4104
4112
  account: exports_external.string(),
@@ -4210,6 +4218,14 @@ import { existsSync } from "node:fs";
4210
4218
  import { homedir } from "node:os";
4211
4219
  import { randomUUID } from "node:crypto";
4212
4220
  import { join } from "node:path";
4221
+ function reviveDate(v) {
4222
+ if (v == null)
4223
+ return null;
4224
+ if (v instanceof Date)
4225
+ return Number.isNaN(v.getTime()) ? null : v;
4226
+ const d = new Date(v);
4227
+ return Number.isNaN(d.getTime()) ? null : d;
4228
+ }
4213
4229
  function operatorSocketPath(home = homedir()) {
4214
4230
  return join(home, ".switchroom", "state", "auth-broker-operator", "sock");
4215
4231
  }
@@ -4277,6 +4293,23 @@ class AuthBrokerClient {
4277
4293
  });
4278
4294
  return data;
4279
4295
  }
4296
+ async probeQuota(accounts, timeoutMs) {
4297
+ const data = await this.send({
4298
+ v: PROTOCOL_VERSION,
4299
+ id: randomUUID(),
4300
+ op: "probe-quota",
4301
+ accounts: [...accounts],
4302
+ ...timeoutMs !== undefined ? { timeoutMs } : {}
4303
+ });
4304
+ const parsed = data;
4305
+ for (const entry of parsed.results) {
4306
+ if (entry.result.ok) {
4307
+ entry.result.data.fiveHourResetAt = reviveDate(entry.result.data.fiveHourResetAt);
4308
+ entry.result.data.sevenDayResetAt = reviveDate(entry.result.data.sevenDayResetAt);
4309
+ }
4310
+ }
4311
+ return parsed;
4312
+ }
4280
4313
  async setActive(account) {
4281
4314
  const data = await this.send({
4282
4315
  v: PROTOCOL_VERSION,