switchroom 0.19.26 → 0.19.28

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 (92) hide show
  1. package/bin/git-agent-attribution-hook.sh +144 -0
  2. package/dist/agent-scheduler/index.js +60 -2
  3. package/dist/auth-broker/index.js +244 -13
  4. package/dist/cli/autoaccept-poll.js +225 -17
  5. package/dist/cli/notion-write-pretool.mjs +60 -2
  6. package/dist/cli/switchroom.js +2843 -1220
  7. package/dist/host-control/main.js +245 -14
  8. package/dist/vault/approvals/kernel-server.js +242 -13
  9. package/dist/vault/broker/server.js +242 -13
  10. package/package.json +7 -2
  11. package/profiles/_base/cron-session.sh.hbs +8 -0
  12. package/profiles/_base/start.sh.hbs +175 -15
  13. package/telegram-plugin/card-layout.ts +328 -0
  14. package/telegram-plugin/dist/bridge/bridge.js +94 -1
  15. package/telegram-plugin/dist/gateway/gateway.js +2544 -1182
  16. package/telegram-plugin/dist/server.js +97 -1
  17. package/telegram-plugin/edit-flood-fuse.ts +841 -57
  18. package/telegram-plugin/flood-429-ledger.ts +526 -0
  19. package/telegram-plugin/flood-circuit-breaker.ts +18 -0
  20. package/telegram-plugin/gateway/callback-query-handlers.ts +6 -0
  21. package/telegram-plugin/gateway/flood-reply-queue.ts +168 -0
  22. package/telegram-plugin/gateway/gateway.ts +67 -70
  23. package/telegram-plugin/gateway/mcp-failure-hook.ts +74 -0
  24. package/telegram-plugin/gateway/narrative-lane.ts +14 -0
  25. package/telegram-plugin/gateway/outbound-send-path.ts +36 -0
  26. package/telegram-plugin/gateway/outbox-sweep.ts +183 -6
  27. package/telegram-plugin/gateway/pinned-message-handler.ts +12 -16
  28. package/telegram-plugin/gateway/status-pin-retarget.ts +72 -36
  29. package/telegram-plugin/gateway/status-pin-store.ts +58 -9
  30. package/telegram-plugin/gateway/worker-pin-reaper.ts +56 -7
  31. package/telegram-plugin/inline-keyboard-callbacks.ts +202 -21
  32. package/telegram-plugin/llm-error-present.ts +61 -2
  33. package/telegram-plugin/mcp-credential-failure.ts +459 -0
  34. package/telegram-plugin/model-unavailable.ts +8 -0
  35. package/telegram-plugin/operator-events.ts +110 -5
  36. package/telegram-plugin/outbound-class.ts +81 -0
  37. package/telegram-plugin/provider-credit.ts +237 -0
  38. package/telegram-plugin/scripts/bun-test-ci.sh +36 -6
  39. package/telegram-plugin/send-gate.ts +24 -2
  40. package/telegram-plugin/status-no-truncate.ts +10 -48
  41. package/telegram-plugin/status-pin-driver.ts +33 -45
  42. package/telegram-plugin/status-pin.ts +18 -1
  43. package/telegram-plugin/tests/card-golden.test.ts +69 -0
  44. package/telegram-plugin/tests/card-lifecycle-render.test.ts +362 -0
  45. package/telegram-plugin/tests/card-type-distinguishability.test.ts +187 -164
  46. package/telegram-plugin/tests/card-variants.golden.txt +211 -0
  47. package/telegram-plugin/tests/card-variants.ts +366 -0
  48. package/telegram-plugin/tests/edit-flood-fuse-ban-awareness.test.ts +373 -0
  49. package/telegram-plugin/tests/edit-flood-fuse-default-deny.test.ts +319 -0
  50. package/telegram-plugin/tests/edit-flood-fuse-reply-reserve.test.ts +340 -0
  51. package/telegram-plugin/tests/edit-flood-fuse.test.ts +11 -2
  52. package/telegram-plugin/tests/feed-edit-rate-ceiling.test.ts +462 -0
  53. package/telegram-plugin/tests/finalize-callback-flood-policy.test.ts +298 -0
  54. package/telegram-plugin/tests/finalize-callback.test.ts +41 -8
  55. package/telegram-plugin/tests/fixtures/real-429-stream.ts +220 -0
  56. package/telegram-plugin/tests/flood-429-ledger.test.ts +278 -0
  57. package/telegram-plugin/tests/flood-429-recorder-wiring.test.ts +128 -0
  58. package/telegram-plugin/tests/flood-reply-queue.test.ts +418 -0
  59. package/telegram-plugin/tests/mcp-credential-failure.test.ts +310 -0
  60. package/telegram-plugin/tests/outbox-sweep-flood-breaker.test.ts +221 -0
  61. package/telegram-plugin/tests/pinned-card-collapse.test.ts +19 -24
  62. package/telegram-plugin/tests/pinned-message-handler.test.ts +15 -15
  63. package/telegram-plugin/tests/provider-credit-402.test.ts +243 -0
  64. package/telegram-plugin/tests/status-pin-api.test.ts +11 -11
  65. package/telegram-plugin/tests/status-pin-boot-recovery.test.ts +36 -37
  66. package/telegram-plugin/tests/status-pin-lifecycle.test.ts +602 -0
  67. package/telegram-plugin/tests/status-pin-retarget.test.ts +90 -62
  68. package/telegram-plugin/tests/status-pin-service-message-suppression.test.ts +7 -3
  69. package/telegram-plugin/tests/status-pin-store.test.ts +109 -60
  70. package/telegram-plugin/tests/status-pin.test.ts +56 -5
  71. package/telegram-plugin/tests/test-runner-coverage.test.ts +133 -0
  72. package/telegram-plugin/tests/worker-activity-feed.test.ts +12 -10
  73. package/telegram-plugin/tests/worker-feed-coalesce.test.ts +23 -29
  74. package/telegram-plugin/tests/worker-feed-pin-persistence.test.ts +56 -59
  75. package/telegram-plugin/tests/worker-feed-terminal-edit-class.test.ts +335 -0
  76. package/telegram-plugin/tests/worker-visibility-prose-silent-harness.test.ts +1 -1
  77. package/telegram-plugin/tool-activity-summary.ts +239 -365
  78. package/telegram-plugin/uat/assertions.ts +22 -11
  79. package/telegram-plugin/uat/feed-matcher.test.ts +24 -17
  80. package/telegram-plugin/worker-activity-feed.ts +105 -47
  81. package/vendor/hindsight-memory/CLAUDE.md +45 -0
  82. package/vendor/hindsight-memory/scripts/drain_pending.py +433 -11
  83. package/vendor/hindsight-memory/scripts/lib/config.py +33 -0
  84. package/vendor/hindsight-memory/scripts/lib/pending.py +193 -28
  85. package/vendor/hindsight-memory/scripts/recall.py +176 -7
  86. package/vendor/hindsight-memory/scripts/tests/test_config_recall_passthrough_env.py +170 -0
  87. package/vendor/hindsight-memory/scripts/tests/test_drain_circuit_breaker.py +401 -0
  88. package/vendor/hindsight-memory/scripts/tests/test_drain_serialisation.py +286 -0
  89. package/vendor/hindsight-memory/scripts/tests/test_pending_drops.py +817 -8
  90. package/vendor/hindsight-memory/scripts/tests/test_recall_min_score.py +464 -0
  91. package/vendor/hindsight-memory/settings.json +1 -1
  92. package/vendor/hindsight-memory/tests/test_hooks.py +11 -2
@@ -23029,6 +23029,90 @@ function isLitellmProxyAuthMisconfig(text) {
23029
23029
  return lower.includes("fallback") && lower.includes("x-api-key");
23030
23030
  }
23031
23031
 
23032
+ // provider-credit.ts
23033
+ var PROVIDER_CREDIT_REGISTRY = [
23034
+ {
23035
+ id: "openrouter",
23036
+ label: "OpenRouter",
23037
+ vaultKey: "openrouter/api-key",
23038
+ consoleUrl: "https://openrouter.ai/credits",
23039
+ action: "Top up the OpenRouter balance (or raise the key\u2019s credit limit) in the OpenRouter console.",
23040
+ markers: ["openrouter", "openrouter.ai"]
23041
+ },
23042
+ {
23043
+ id: "openai",
23044
+ label: "OpenAI",
23045
+ vaultKey: "openai/api-key",
23046
+ consoleUrl: "https://platform.openai.com/settings/organization/billing",
23047
+ action: "Add credit / raise the billing limit in the OpenAI console.",
23048
+ markers: ["api.openai.com", "openai.", "openaiexception", "openai_api"]
23049
+ },
23050
+ {
23051
+ id: "perplexity",
23052
+ label: "Perplexity",
23053
+ vaultKey: "perplexity/api-key",
23054
+ consoleUrl: "https://www.perplexity.ai/settings/api",
23055
+ action: "Top up the Perplexity API balance (or re-issue the key) in the Perplexity console.",
23056
+ markers: ["perplexity", "api.perplexity.ai", "pplx"]
23057
+ }
23058
+ ];
23059
+ var CREDIT_EXHAUSTION_SIGNALS = [
23060
+ "payment_required",
23061
+ "payment required",
23062
+ "insufficient credits",
23063
+ "insufficient_credits",
23064
+ "more credits are required",
23065
+ "requires more credits",
23066
+ "add more credits",
23067
+ "out of credits",
23068
+ "insufficient_quota",
23069
+ "exceeded your current quota",
23070
+ "billing_hard_limit_reached",
23071
+ "billing hard limit",
23072
+ "insufficient balance",
23073
+ "insufficient_balance",
23074
+ "credit balance is too low",
23075
+ "credit balance too low",
23076
+ "credit_balance_too_low",
23077
+ "no credits remaining",
23078
+ "quota exceeded for credits"
23079
+ ];
23080
+ var CREDIT_EXHAUSTION_STATUSES = [402];
23081
+ var MAX_SCAN_CHARS = 16384;
23082
+ function sample(text) {
23083
+ if (typeof text !== "string" || text.length === 0)
23084
+ return "";
23085
+ return (text.length > MAX_SCAN_CHARS ? text.slice(0, MAX_SCAN_CHARS) : text).toLowerCase();
23086
+ }
23087
+ function isProviderCreditStatus(status) {
23088
+ return typeof status === "number" && CREDIT_EXHAUSTION_STATUSES.includes(status);
23089
+ }
23090
+ function hasCreditExhaustionWording(text) {
23091
+ const lower = sample(text);
23092
+ if (lower.length === 0)
23093
+ return false;
23094
+ return CREDIT_EXHAUSTION_SIGNALS.some((s) => lower.includes(s));
23095
+ }
23096
+ function attributeProvider(text) {
23097
+ const lower = sample(text);
23098
+ if (lower.length === 0)
23099
+ return null;
23100
+ for (const entry of PROVIDER_CREDIT_REGISTRY) {
23101
+ if (entry.markers.some((m) => lower.includes(m)))
23102
+ return entry;
23103
+ }
23104
+ return null;
23105
+ }
23106
+ function detectProviderCreditExhaustion(text, status) {
23107
+ if (isProviderCreditStatus(status)) {
23108
+ return { provider: attributeProvider(text), via: "status" };
23109
+ }
23110
+ if (hasCreditExhaustionWording(text)) {
23111
+ return { provider: attributeProvider(text), via: "wording" };
23112
+ }
23113
+ return null;
23114
+ }
23115
+
23032
23116
  // operator-events.ts
23033
23117
  function classifyClaudeError(raw) {
23034
23118
  try {
@@ -23062,9 +23146,16 @@ ${message}`)) {
23062
23146
  if (errorType === "invalid_api_key" || errorCode === "invalid_api_key" || sdkCode === "invalid_api_key" || message.toLowerCase().includes("invalid_api_key") || message.toLowerCase().includes("invalid api key")) {
23063
23147
  return "credentials-invalid";
23064
23148
  }
23065
- if (errorType === "credit_balance_too_low" || errorCode === "credit_balance_too_low" || sdkCode === "credit_balance_too_low" || message.toLowerCase().includes("credit_balance_too_low") || message.toLowerCase().includes("credit balance")) {
23149
+ const creditScanText = `${errorType}
23150
+ ${errorCode}
23151
+ ${sdkCode}
23152
+ ${message}`;
23153
+ if ((errorType === "credit_balance_too_low" || errorCode === "credit_balance_too_low" || sdkCode === "credit_balance_too_low" || message.toLowerCase().includes("credit_balance_too_low") || message.toLowerCase().includes("credit balance")) && attributeProvider(creditScanText) == null) {
23066
23154
  return "credit-exhausted";
23067
23155
  }
23156
+ if (detectProviderCreditExhaustion(creditScanText, status) != null) {
23157
+ return "provider-credit-exhausted";
23158
+ }
23068
23159
  if (errorType === "rate_limit_error" || errorCode === "rate_limit_error" || sdkCode === "rate_limit_error" || message.toLowerCase().includes("rate_limit_error") || message.toLowerCase().includes("rate limit")) {
23069
23160
  return "rate-limited";
23070
23161
  }
@@ -23103,6 +23194,8 @@ var OPERATOR_ACTIONABLE_KINDS = new Set([
23103
23194
  "credentials-expired",
23104
23195
  "credentials-invalid",
23105
23196
  "credit-exhausted",
23197
+ "provider-credit-exhausted",
23198
+ "mcp-dependency-blocked",
23106
23199
  "proxy-misconfig"
23107
23200
  ]);
23108
23201