@cat-factory/server 0.134.0 → 0.136.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 (91) hide show
  1. package/dist/config/platformAlerts.d.ts +23 -0
  2. package/dist/config/platformAlerts.d.ts.map +1 -0
  3. package/dist/config/platformAlerts.js +43 -0
  4. package/dist/config/platformAlerts.js.map +1 -0
  5. package/dist/config/types.d.ts +26 -0
  6. package/dist/config/types.d.ts.map +1 -1
  7. package/dist/http/workspaceAccess.d.ts +22 -1
  8. package/dist/http/workspaceAccess.d.ts.map +1 -1
  9. package/dist/http/workspaceAccess.js +29 -0
  10. package/dist/http/workspaceAccess.js.map +1 -1
  11. package/dist/index.d.ts +3 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/modules/bootstrap/BootstrapController.d.ts.map +1 -1
  16. package/dist/modules/bootstrap/BootstrapController.js +2 -0
  17. package/dist/modules/bootstrap/BootstrapController.js.map +1 -1
  18. package/dist/modules/documents/DocumentSourceController.d.ts.map +1 -1
  19. package/dist/modules/documents/DocumentSourceController.js +2 -0
  20. package/dist/modules/documents/DocumentSourceController.js.map +1 -1
  21. package/dist/modules/environments/EnvironmentController.d.ts.map +1 -1
  22. package/dist/modules/environments/EnvironmentController.js +2 -0
  23. package/dist/modules/environments/EnvironmentController.js.map +1 -1
  24. package/dist/modules/fragmentLibrary/FragmentLibraryController.d.ts.map +1 -1
  25. package/dist/modules/fragmentLibrary/FragmentLibraryController.js +7 -0
  26. package/dist/modules/fragmentLibrary/FragmentLibraryController.js.map +1 -1
  27. package/dist/modules/github/GitHubController.d.ts.map +1 -1
  28. package/dist/modules/github/GitHubController.js +2 -0
  29. package/dist/modules/github/GitHubController.js.map +1 -1
  30. package/dist/modules/incidentEnrichment/IncidentEnrichmentController.d.ts.map +1 -1
  31. package/dist/modules/incidentEnrichment/IncidentEnrichmentController.js +2 -0
  32. package/dist/modules/incidentEnrichment/IncidentEnrichmentController.js.map +1 -1
  33. package/dist/modules/merge/RiskPolicyController.d.ts.map +1 -1
  34. package/dist/modules/merge/RiskPolicyController.js +2 -0
  35. package/dist/modules/merge/RiskPolicyController.js.map +1 -1
  36. package/dist/modules/modelPresets/ModelPresetController.d.ts.map +1 -1
  37. package/dist/modules/modelPresets/ModelPresetController.js +2 -0
  38. package/dist/modules/modelPresets/ModelPresetController.js.map +1 -1
  39. package/dist/modules/packageRegistries/PackageRegistriesController.d.ts.map +1 -1
  40. package/dist/modules/packageRegistries/PackageRegistriesController.js +2 -0
  41. package/dist/modules/packageRegistries/PackageRegistriesController.js.map +1 -1
  42. package/dist/modules/preview/PreviewController.d.ts.map +1 -1
  43. package/dist/modules/preview/PreviewController.js +2 -0
  44. package/dist/modules/preview/PreviewController.js.map +1 -1
  45. package/dist/modules/providers/ApiKeyController.d.ts.map +1 -1
  46. package/dist/modules/providers/ApiKeyController.js +2 -0
  47. package/dist/modules/providers/ApiKeyController.js.map +1 -1
  48. package/dist/modules/providers/VendorCredentialController.d.ts.map +1 -1
  49. package/dist/modules/providers/VendorCredentialController.js +2 -0
  50. package/dist/modules/providers/VendorCredentialController.js.map +1 -1
  51. package/dist/modules/publicApi/PublicApiKeyController.d.ts.map +1 -1
  52. package/dist/modules/publicApi/PublicApiKeyController.js +2 -0
  53. package/dist/modules/publicApi/PublicApiKeyController.js.map +1 -1
  54. package/dist/modules/recurring/TrackerSettingsController.d.ts.map +1 -1
  55. package/dist/modules/recurring/TrackerSettingsController.js +2 -0
  56. package/dist/modules/recurring/TrackerSettingsController.js.map +1 -1
  57. package/dist/modules/releaseHealth/ReleaseHealthController.d.ts.map +1 -1
  58. package/dist/modules/releaseHealth/ReleaseHealthController.js +2 -0
  59. package/dist/modules/releaseHealth/ReleaseHealthController.js.map +1 -1
  60. package/dist/modules/runners/RunnerPoolController.d.ts.map +1 -1
  61. package/dist/modules/runners/RunnerPoolController.js +2 -0
  62. package/dist/modules/runners/RunnerPoolController.js.map +1 -1
  63. package/dist/modules/sandbox/SandboxController.d.ts.map +1 -1
  64. package/dist/modules/sandbox/SandboxController.js +2 -0
  65. package/dist/modules/sandbox/SandboxController.js.map +1 -1
  66. package/dist/modules/settings/WorkspaceSettingsController.d.ts.map +1 -1
  67. package/dist/modules/settings/WorkspaceSettingsController.js +2 -0
  68. package/dist/modules/settings/WorkspaceSettingsController.js.map +1 -1
  69. package/dist/modules/sharedStack/SharedStackController.d.ts.map +1 -1
  70. package/dist/modules/sharedStack/SharedStackController.js +2 -0
  71. package/dist/modules/sharedStack/SharedStackController.js.map +1 -1
  72. package/dist/modules/slack/SlackController.d.ts.map +1 -1
  73. package/dist/modules/slack/SlackController.js +2 -0
  74. package/dist/modules/slack/SlackController.js.map +1 -1
  75. package/dist/modules/tasks/TaskSourceController.d.ts.map +1 -1
  76. package/dist/modules/tasks/TaskSourceController.js +2 -0
  77. package/dist/modules/tasks/TaskSourceController.js.map +1 -1
  78. package/dist/modules/testSecrets/TestSecretsController.d.ts.map +1 -1
  79. package/dist/modules/testSecrets/TestSecretsController.js +2 -0
  80. package/dist/modules/testSecrets/TestSecretsController.js.map +1 -1
  81. package/dist/modules/workspaces/WorkspaceController.d.ts.map +1 -1
  82. package/dist/modules/workspaces/WorkspaceController.js +6 -1
  83. package/dist/modules/workspaces/WorkspaceController.js.map +1 -1
  84. package/dist/persistence/rpc.d.ts.map +1 -1
  85. package/dist/persistence/rpc.js +4 -0
  86. package/dist/persistence/rpc.js.map +1 -1
  87. package/dist/runtime/platformHealth.d.ts +20 -0
  88. package/dist/runtime/platformHealth.d.ts.map +1 -0
  89. package/dist/runtime/platformHealth.js +74 -0
  90. package/dist/runtime/platformHealth.js.map +1 -0
  91. package/package.json +8 -8
@@ -0,0 +1,74 @@
1
+ import { distinctAccountIds, evaluatePlatformHealth, platformAlertReasons, platformHealthCardContent, } from '@cat-factory/orchestration';
2
+ /**
3
+ * Run one platform-health alert pass across every account. Returns the number of workspaces a
4
+ * card was raised on and the number cleared. Enumerates accounts from the workspace projection
5
+ * (`workspaceService.list(null)` → distinct non-null account ids), the same tenant-enumeration
6
+ * shape the platform-metrics + artifact-retention sweeps use — NOT a per-row point-read.
7
+ *
8
+ * Time comes from the services' injected clock (`summarize`, `raise` and `clearByType` all
9
+ * stamp `now` themselves), so this helper takes no `now` — unlike `escalateStaleNotifications`,
10
+ * whose cutoff is caller-supplied.
11
+ */
12
+ export async function sweepPlatformHealth(container, logger) {
13
+ const cfg = container.config.platformAlerts;
14
+ const notifications = container.notifications;
15
+ const observability = container.platformObservability;
16
+ if (!cfg.enabled || !notifications || !observability)
17
+ return { raised: 0, cleared: 0 };
18
+ const workspaces = await container.workspaceService.list(null);
19
+ // Group workspaces by account so each account is summarized ONCE (five GROUP BY queries),
20
+ // then the verdict is fanned to every workspace in the account. Legacy null-account boards
21
+ // are skipped: the platform-metrics read is account-scoped (matches `distinctAccountIds`).
22
+ const byAccount = new Map();
23
+ for (const ws of workspaces) {
24
+ if (!ws.accountId)
25
+ continue;
26
+ const list = byAccount.get(ws.accountId);
27
+ if (list)
28
+ list.push(ws.id);
29
+ else
30
+ byAccount.set(ws.accountId, [ws.id]);
31
+ }
32
+ // Which workspaces already hold an open `platform_health` card, learned in ONE batched read
33
+ // up front rather than a `findOpenByType` point-read per workspace inside the loop (that N+1
34
+ // would run across the whole deployment every sweep — every couple of minutes). A healthy
35
+ // workspace with no card is the steady-state common case, and it is now skipped entirely: we
36
+ // only touch `clearByType` for a workspace that actually has a card to clear.
37
+ const withOpenCard = new Set((await notifications.service.listOpenByType(workspaces.map((ws) => ws.id), 'platform_health')).keys());
38
+ let raised = 0;
39
+ let cleared = 0;
40
+ for (const accountId of distinctAccountIds(workspaces)) {
41
+ const workspaceIds = byAccount.get(accountId) ?? [];
42
+ try {
43
+ const snapshot = await observability.summarize(accountId, cfg.window);
44
+ const reasons = platformAlertReasons(evaluatePlatformHealth(snapshot, cfg.thresholds));
45
+ for (const workspaceId of workspaceIds) {
46
+ if (reasons.length > 0) {
47
+ const { title, body } = platformHealthCardContent(reasons, cfg.window);
48
+ await notifications.service.raise(workspaceId, {
49
+ type: 'platform_health',
50
+ blockId: null,
51
+ executionId: null,
52
+ title,
53
+ body,
54
+ payload: { platformWindow: cfg.window, platformAlerts: reasons },
55
+ });
56
+ raised += 1;
57
+ }
58
+ else if (withOpenCard.has(workspaceId) &&
59
+ (await notifications.service.clearByType(workspaceId, 'platform_health'))) {
60
+ cleared += 1;
61
+ }
62
+ }
63
+ }
64
+ catch (err) {
65
+ logger?.warn({
66
+ scope: 'platform-health',
67
+ accountId,
68
+ err: err instanceof Error ? err.message : String(err),
69
+ }, 'platform-health: failed to evaluate account');
70
+ }
71
+ }
72
+ return { raised, cleared };
73
+ }
74
+ //# sourceMappingURL=platformHealth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformHealth.js","sourceRoot":"","sources":["../../src/runtime/platformHealth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAA;AAwBnC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAA0B,EAC1B,MAAkC;IAElC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,cAAc,CAAA;IAC3C,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAA;IAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,qBAAqB,CAAA;IACrD,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;IAEtF,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9D,0FAA0F;IAC1F,2FAA2F;IAC3F,2FAA2F;IAC3F,M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C,EAAE,CAAC;oBACvB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,yBAAyB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;oBACtE,MAAM,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE;wBAC7C,IAAI,EAAE,iBAAiB;wBACvB,OAAO,EAAE,IAAI;wBACb,WAAW,EAAE,IAAI;wBACjB,KAAK;wBACL,IAAI;wBACJ,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE;qBACjE,CAAC,CAAA;oBACF,MAAM,IAAI,CAAC,CAAA;gBACb,CAAC;qBAAM,IACL,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC;oBAC7B,CAAC,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,EACzE,CAAC;oBACD,OAAO,IAAI,CAAC,CAAA;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,EAAE,IAAI,CACV;gBACE,KAAK,EAAE,iBAAiB;gBACxB,SAAS;gBACT,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtD,EACD,6CAA6C,CAC9C,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/server",
3
- "version": "0.134.0",
3
+ "version": "0.136.0",
4
4
  "description": "Runtime-neutral HTTP layer for the Agent Architecture Board: the Hono controllers, middleware (auth/authz/CORS/error), request helpers and the gateway seams shared by every deployment facade (Cloudflare Worker, Node service).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,13 +31,13 @@
31
31
  "p-map": "^7.0.5",
32
32
  "pino": "^10.3.1",
33
33
  "valibot": "^1.4.2",
34
- "@cat-factory/agents": "0.62.6",
35
- "@cat-factory/contracts": "0.145.0",
36
- "@cat-factory/integrations": "0.85.3",
37
- "@cat-factory/kernel": "0.138.0",
38
- "@cat-factory/orchestration": "0.121.0",
39
- "@cat-factory/prompt-fragments": "0.13.34",
40
- "@cat-factory/spend": "0.12.47"
34
+ "@cat-factory/agents": "0.62.8",
35
+ "@cat-factory/contracts": "0.147.0",
36
+ "@cat-factory/integrations": "0.86.0",
37
+ "@cat-factory/kernel": "0.139.0",
38
+ "@cat-factory/orchestration": "0.123.0",
39
+ "@cat-factory/prompt-fragments": "0.13.36",
40
+ "@cat-factory/spend": "0.12.49"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.1.1",