@cat-factory/server 0.193.0 → 0.195.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.
- package/dist/agents/ContainerAgentExecutor.d.ts +29 -5
- package/dist/agents/ContainerAgentExecutor.d.ts.map +1 -1
- package/dist/agents/ContainerAgentExecutor.js +44 -21
- package/dist/agents/ContainerAgentExecutor.js.map +1 -1
- package/dist/agents/agentContextRecord.d.ts.map +1 -1
- package/dist/agents/agentContextRecord.js +14 -0
- package/dist/agents/agentContextRecord.js.map +1 -1
- package/dist/agents/binaryGenerators.d.ts +34 -0
- package/dist/agents/binaryGenerators.d.ts.map +1 -0
- package/dist/agents/binaryGenerators.js +66 -0
- package/dist/agents/binaryGenerators.js.map +1 -0
- package/dist/agents/containerAgentBody.d.ts +2 -0
- package/dist/agents/containerAgentBody.d.ts.map +1 -1
- package/dist/agents/containerAgentBody.js +8 -1
- package/dist/agents/containerAgentBody.js.map +1 -1
- package/dist/agents/containerAgentLogging.d.ts +4 -3
- package/dist/agents/containerAgentLogging.d.ts.map +1 -1
- package/dist/agents/containerAgentLogging.js +33 -7
- package/dist/agents/containerAgentLogging.js.map +1 -1
- package/dist/agents/toolServers.d.ts +9 -2
- package/dist/agents/toolServers.d.ts.map +1 -1
- package/dist/agents/toolServers.js +1 -1
- package/dist/agents/toolServers.js.map +1 -1
- package/dist/config/platformAlerts.d.ts +4 -0
- package/dist/config/platformAlerts.d.ts.map +1 -1
- package/dist/config/platformAlerts.js +12 -0
- package/dist/config/platformAlerts.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/workspaces/WorkspaceController.d.ts.map +1 -1
- package/dist/modules/workspaces/WorkspaceController.js +56 -15
- package/dist/modules/workspaces/WorkspaceController.js.map +1 -1
- package/dist/observability/operationalMetrics.d.ts +9 -0
- package/dist/observability/operationalMetrics.d.ts.map +1 -0
- package/dist/observability/operationalMetrics.js +31 -0
- package/dist/observability/operationalMetrics.js.map +1 -0
- package/dist/observability/sweepHealth.d.ts +44 -0
- package/dist/observability/sweepHealth.d.ts.map +1 -0
- package/dist/observability/sweepHealth.js +36 -0
- package/dist/observability/sweepHealth.js.map +1 -0
- package/dist/runtime/platformHealth.d.ts.map +1 -1
- package/dist/runtime/platformHealth.js +6 -1
- package/dist/runtime/platformHealth.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type OperationalMetrics } from '@cat-factory/kernel';
|
|
2
|
+
/** One sweeper's current consecutive-failure streak. */
|
|
3
|
+
export interface SweepFailureStreak {
|
|
4
|
+
sweep: string;
|
|
5
|
+
consecutive: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Records each sweep pass's outcome and answers which sweeper is doing worst.
|
|
9
|
+
*
|
|
10
|
+
* The two signals a failed pass produces — the `sweep.failed` COUNTER (a rate) and the STREAK
|
|
11
|
+
* (this) — are emitted by ONE call on purpose. They shipped as two calls at each site, and the
|
|
12
|
+
* two facades promptly drifted into tracking disjoint sets: on Node every `startSweeper` sweep
|
|
13
|
+
* recorded a streak but the two hand-rolled intervals recorded only the counter, while on the
|
|
14
|
+
* Worker exactly one sweep recorded a streak and nothing else recorded either. A site that can
|
|
15
|
+
* do half the job is a site that eventually does.
|
|
16
|
+
*/
|
|
17
|
+
export interface SweepHealthTracker {
|
|
18
|
+
/**
|
|
19
|
+
* A pass of `sweep` threw: increment its streak AND count it under `sweep.failed`. There is
|
|
20
|
+
* deliberately no way to do one without the other.
|
|
21
|
+
*/
|
|
22
|
+
recordFailure(sweep: string): void;
|
|
23
|
+
/** A pass of `sweep` completed. Resets its streak to 0 — the sweeper is working again. */
|
|
24
|
+
recordSuccess(sweep: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* The worst current streak, or `undefined` when every sweeper's last pass succeeded (or
|
|
27
|
+
* none has run yet). `undefined` rather than a zero-valued entry, because the health
|
|
28
|
+
* evaluation treats an absent streak as "not tracked" and a present one as an observation.
|
|
29
|
+
*/
|
|
30
|
+
worst(): SweepFailureStreak | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build a tracker that reports every failed pass to `metrics` as well as accumulating its
|
|
34
|
+
* streak. A unit test with nothing to export passes `noopOperationalMetrics`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSweepHealthTracker(metrics?: OperationalMetrics): SweepHealthTracker;
|
|
37
|
+
/**
|
|
38
|
+
* The process-wide (Node) / per-isolate (Worker) tracker, exported like `logger` and
|
|
39
|
+
* `operationalMetrics` for the same reason: every sweeper must record into the ONE instance
|
|
40
|
+
* the health sweep reads. Bound to the sibling `operationalMetrics` collector here, so the
|
|
41
|
+
* counter and the streak can never be wired to different places.
|
|
42
|
+
*/
|
|
43
|
+
export declare const sweepHealth: SweepHealthTracker;
|
|
44
|
+
//# sourceMappingURL=sweepHealth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweepHealth.d.ts","sourceRoot":"","sources":["../../src/observability/sweepHealth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,qBAAqB,CAAA;AAuBrF,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,0FAA0F;IAC1F,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC;;;;OAIG;IACH,KAAK,IAAI,kBAAkB,GAAG,SAAS,CAAA;CACxC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,kBAA2C,GACnD,kBAAkB,CAoBpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,kBAAiE,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { noopOperationalMetrics } from '@cat-factory/kernel';
|
|
2
|
+
import { operationalMetrics } from './operationalMetrics.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build a tracker that reports every failed pass to `metrics` as well as accumulating its
|
|
5
|
+
* streak. A unit test with nothing to export passes `noopOperationalMetrics`.
|
|
6
|
+
*/
|
|
7
|
+
export function createSweepHealthTracker(metrics = noopOperationalMetrics) {
|
|
8
|
+
const streaks = new Map();
|
|
9
|
+
return {
|
|
10
|
+
recordFailure(sweep) {
|
|
11
|
+
streaks.set(sweep, (streaks.get(sweep) ?? 0) + 1);
|
|
12
|
+
// Dimensioned by sweep name — a bounded set fixed at boot — so one sick sweeper is
|
|
13
|
+
// identifiable among the fourteen rather than lost in a deployment-wide total.
|
|
14
|
+
metrics.increment('sweep.failed', { sweep });
|
|
15
|
+
},
|
|
16
|
+
recordSuccess(sweep) {
|
|
17
|
+
streaks.delete(sweep);
|
|
18
|
+
},
|
|
19
|
+
worst() {
|
|
20
|
+
let worst;
|
|
21
|
+
for (const [sweep, consecutive] of streaks) {
|
|
22
|
+
if (!worst || consecutive > worst.consecutive)
|
|
23
|
+
worst = { sweep, consecutive };
|
|
24
|
+
}
|
|
25
|
+
return worst;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The process-wide (Node) / per-isolate (Worker) tracker, exported like `logger` and
|
|
31
|
+
* `operationalMetrics` for the same reason: every sweeper must record into the ONE instance
|
|
32
|
+
* the health sweep reads. Bound to the sibling `operationalMetrics` collector here, so the
|
|
33
|
+
* counter and the streak can never be wired to different places.
|
|
34
|
+
*/
|
|
35
|
+
export const sweepHealth = createSweepHealthTracker(operationalMetrics);
|
|
36
|
+
//# sourceMappingURL=sweepHealth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweepHealth.js","sourceRoot":"","sources":["../../src/observability/sweepHealth.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAsD5D;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAO,GAAuB,sBAAsB;IAEpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IACzC,OAAO;QACL,aAAa,CAAC,KAAK;YACjB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;YACjD,mFAAmF;YACnF,+EAA+E;YAC/E,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC9C,CAAC;QACD,aAAa,CAAC,KAAK;YACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;QACD,KAAK;YACH,IAAI,KAAqC,CAAA;YACzC,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC3C,IAAI,CAAC,KAAK,IAAI,WAAW,GAAG,KAAK,CAAC,WAAW;oBAAE,KAAK,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;YAC/E,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAuB,wBAAwB,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformHealth.d.ts","sourceRoot":"","sources":["../../src/runtime/platformHealth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"platformHealth.d.ts","sourceRoot":"","sources":["../../src/runtime/platformHealth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAmBjD;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,eAAe,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyE9C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { distinctAccountIds, evaluatePlatformHealth, platformAlertReasons, platformHealthCardContent, } from '@cat-factory/orchestration';
|
|
2
|
+
import { sweepHealth } from '../observability/sweepHealth.js';
|
|
2
3
|
// Runtime-neutral platform-health ALERT sweep — the push counterpart to the operator dashboard
|
|
3
4
|
// read, shared by both facades' periodic sweeps (the Worker's cron `scheduled` handler and the
|
|
4
5
|
// Node `setInterval` sweeper), exactly like `escalateStaleNotifications`. It evaluates each
|
|
@@ -50,13 +51,17 @@ export async function sweepPlatformHealth(container, logger) {
|
|
|
50
51
|
// workspace with no card is the steady-state common case, and it is now skipped entirely: we
|
|
51
52
|
// only touch `clearByType` for a workspace that actually has a card to clear.
|
|
52
53
|
const withOpenCard = new Set((await notifications.service.listOpenByType(workspaces.map((ws) => ws.id), 'platform_health')).keys());
|
|
54
|
+
const worstSweep = sweepHealth.worst();
|
|
53
55
|
let raised = 0;
|
|
54
56
|
let cleared = 0;
|
|
55
57
|
for (const accountId of distinctAccountIds(workspaces)) {
|
|
56
58
|
const workspaceIds = byAccount.get(accountId) ?? [];
|
|
57
59
|
try {
|
|
58
60
|
const snapshot = await observability.summarize(accountId, cfg.window);
|
|
59
|
-
|
|
61
|
+
// The sweeper streak is deployment-wide, not per account, so it is read once outside
|
|
62
|
+
// the per-account loop and applies to every account's card: a wedged retention sweep is
|
|
63
|
+
// everyone's problem, not the tenant's whose turn it happened to be.
|
|
64
|
+
const reasons = platformAlertReasons(evaluatePlatformHealth(snapshot, cfg.thresholds, worstSweep));
|
|
60
65
|
for (const workspaceId of workspaceIds) {
|
|
61
66
|
if (reasons.length > 0) {
|
|
62
67
|
const { title, body } = platformHealthCardContent(reasons, cfg.window);
|
|
@@ -1 +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;
|
|
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;AAGnC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,+FAA+F;AAC/F,+FAA+F;AAC/F,4FAA4F;AAC5F,+FAA+F;AAC/F,wFAAwF;AACxF,4FAA4F;AAC5F,2DAA2D;AAC3D,0FAA0F;AAC1F,2FAA2F;AAC3F,8EAA8E;AAC9E,EAAE;AACF,0FAA0F;AAC1F,+FAA+F;AAC/F,8FAA8F;AAC9F,4FAA4F;AAE5F;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAA0B,EAC1B,MAAe;IAEf,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,a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C,CAAA;QACJ,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.
|
|
3
|
+
"version": "0.195.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",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"hono": "^4.12.33",
|
|
31
31
|
"pino": "^10.3.1",
|
|
32
32
|
"valibot": "^1.4.2",
|
|
33
|
-
"@cat-factory/
|
|
34
|
-
"@cat-factory/
|
|
35
|
-
"@cat-factory/integrations": "0.
|
|
36
|
-
"@cat-factory/
|
|
37
|
-
"@cat-factory/
|
|
38
|
-
"@cat-factory/prompt-fragments": "0.15.
|
|
39
|
-
"@cat-factory/spend": "0.
|
|
33
|
+
"@cat-factory/contracts": "0.212.0",
|
|
34
|
+
"@cat-factory/agents": "0.105.0",
|
|
35
|
+
"@cat-factory/integrations": "0.117.0",
|
|
36
|
+
"@cat-factory/orchestration": "0.186.0",
|
|
37
|
+
"@cat-factory/kernel": "0.215.0",
|
|
38
|
+
"@cat-factory/prompt-fragments": "0.15.37",
|
|
39
|
+
"@cat-factory/spend": "0.13.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^26.1.2",
|