@cat-factory/server 0.185.2 → 0.188.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/promptOverrides.d.ts +1 -35
- package/dist/agents/promptOverrides.d.ts.map +1 -1
- package/dist/agents/promptOverrides.js +9 -43
- package/dist/agents/promptOverrides.js.map +1 -1
- package/dist/agents/prompts.d.ts +0 -28
- package/dist/agents/prompts.d.ts.map +1 -1
- package/dist/agents/prompts.js +7 -54
- package/dist/agents/prompts.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +11 -0
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/agentPrompts/AgentPromptController.d.ts.map +1 -1
- package/dist/modules/agentPrompts/AgentPromptController.js +3 -2
- package/dist/modules/agentPrompts/AgentPromptController.js.map +1 -1
- package/dist/modules/environments/EnvironmentController.d.ts.map +1 -1
- package/dist/modules/environments/EnvironmentController.js +12 -2
- package/dist/modules/environments/EnvironmentController.js.map +1 -1
- package/dist/modules/execution/ExecutionController.d.ts.map +1 -1
- package/dist/modules/execution/ExecutionController.js +88 -78
- package/dist/modules/execution/ExecutionController.js.map +1 -1
- package/dist/modules/foundationalServices/FoundationalServiceController.d.ts +17 -0
- package/dist/modules/foundationalServices/FoundationalServiceController.d.ts.map +1 -0
- package/dist/modules/foundationalServices/FoundationalServiceController.js +110 -0
- package/dist/modules/foundationalServices/FoundationalServiceController.js.map +1 -0
- package/dist/modules/foundationalServices/sweepFoundationalSources.d.ts +28 -0
- package/dist/modules/foundationalServices/sweepFoundationalSources.d.ts.map +1 -0
- package/dist/modules/foundationalServices/sweepFoundationalSources.js +48 -0
- package/dist/modules/foundationalServices/sweepFoundationalSources.js.map +1 -0
- package/dist/modules/github/GitHubController.d.ts.map +1 -1
- package/dist/modules/github/GitHubController.js +12 -2
- package/dist/modules/github/GitHubController.js.map +1 -1
- package/dist/modules/publicApi/PublicApiController.d.ts.map +1 -1
- package/dist/modules/publicApi/PublicApiController.js +54 -1
- package/dist/modules/publicApi/PublicApiController.js.map +1 -1
- package/dist/modules/telemetry/TelemetryIngestController.d.ts +38 -0
- package/dist/modules/telemetry/TelemetryIngestController.d.ts.map +1 -0
- package/dist/modules/telemetry/TelemetryIngestController.js +182 -0
- package/dist/modules/telemetry/TelemetryIngestController.js.map +1 -0
- package/dist/modules/workspaces/WorkspaceController.d.ts.map +1 -1
- package/dist/modules/workspaces/WorkspaceController.js +21 -0
- package/dist/modules/workspaces/WorkspaceController.js.map +1 -1
- package/dist/persistence/mappers.d.ts +9 -1
- package/dist/persistence/mappers.d.ts.map +1 -1
- package/dist/persistence/mappers.js +21 -0
- package/dist/persistence/mappers.js.map +1 -1
- package/dist/persistence/rpc-allowlist.d.ts.map +1 -1
- package/dist/persistence/rpc-allowlist.js +51 -0
- package/dist/persistence/rpc-allowlist.js.map +1 -1
- package/dist/telemetry/machineTelemetry.d.ts +88 -0
- package/dist/telemetry/machineTelemetry.d.ts.map +1 -0
- package/dist/telemetry/machineTelemetry.js +89 -0
- package/dist/telemetry/machineTelemetry.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Mothership-mode telemetry INGEST (docs/initiatives/mothership-mode.md, PR 5 — the UPSTREAM half).
|
|
2
|
+
//
|
|
3
|
+
// Telemetry is the local-first bucket: a mothership-mode node writes every LLM call, dispatch
|
|
4
|
+
// context and performed search to a `node:sqlite` store on the laptop, because routing them
|
|
5
|
+
// through the per-call persistence RPC would put a network round trip on the hot path of every
|
|
6
|
+
// model call. That capture half landed with the store and its retention prune.
|
|
7
|
+
//
|
|
8
|
+
// What it left open is that the rows never go anywhere. A hosted teammate opening the run a
|
|
9
|
+
// laptop drove sees an empty observability panel, zero token rollups and no web-search log — and
|
|
10
|
+
// once the local retention window passes, so does the node that produced them. This module is the
|
|
11
|
+
// runtime-neutral spine of the sync UP: the wire envelope, the fetch client the laptop posts
|
|
12
|
+
// through, and nothing else. It is deliberately a DEDICATED `/internal/*` endpoint rather than a
|
|
13
|
+
// hole in the persistence proxy (ADR 0009): the whole reason telemetry is local-first is that its
|
|
14
|
+
// writes must not be per-row RPCs, so re-admitting them one at a time would undo the bucket.
|
|
15
|
+
//
|
|
16
|
+
// The batch is APPEND-ONLY and idempotent by row id, which is what lets the node retry a chunk
|
|
17
|
+
// whose ack was lost without corrupting a stored prompt delta (see the ports' `recordMany`).
|
|
18
|
+
/** Per-request row caps. A batch above these is refused (413) rather than silently truncated. */
|
|
19
|
+
export const TELEMETRY_INGEST_LIMITS = {
|
|
20
|
+
/** Per-call rows: the lightest of the three, though each carries prompt + response bodies. */
|
|
21
|
+
metrics: 200,
|
|
22
|
+
/** Dispatch snapshots: one row is routinely megabytes (composed prompt + injected files). */
|
|
23
|
+
snapshots: 20,
|
|
24
|
+
/** Performed searches: no unbounded body, so the cap is purely on row count. */
|
|
25
|
+
searchQueries: 500,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Upper bound on a whole ingest request body (characters), checked before parsing costs anything
|
|
29
|
+
* meaningful. The row caps above bound COUNT; this bounds BYTES, which is the axis a single
|
|
30
|
+
* pathological snapshot moves. Generous enough for a full chunk of real rows.
|
|
31
|
+
*/
|
|
32
|
+
export const MAX_TELEMETRY_INGEST_CHARS = 8_000_000;
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when the node holds no machine token yet (booted before the mothership login), so
|
|
35
|
+
* nothing was uploaded and nothing COULD have been.
|
|
36
|
+
*
|
|
37
|
+
* It is an error rather than an empty-but-successful result because the caller's success path
|
|
38
|
+
* advances a high-water mark: a zeroed `TelemetryIngestResult` is indistinguishable from "the run
|
|
39
|
+
* had no rows", which would mark the run uploaded and let the local prune delete rows the
|
|
40
|
+
* mothership never saw. Distinct from a transport failure only so the sweep can log it as the
|
|
41
|
+
* benign, self-healing condition it is — both dispositions leave the mark alone and retry.
|
|
42
|
+
*/
|
|
43
|
+
export class MachineTokenUnavailableError extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super('no machine token: node has not completed the mothership login yet');
|
|
46
|
+
this.name = 'MachineTokenUnavailableError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
50
|
+
/**
|
|
51
|
+
* A fetch-based {@link MachineTelemetryClient} posting to a mothership's
|
|
52
|
+
* `POST /internal/telemetry/ingest` with the node's machine token. Mirrors
|
|
53
|
+
* `HttpMachineNotificationClient`'s auth contract (a fixed token OR a per-request provider, so a
|
|
54
|
+
* token cached after boot by the mothership login flow is picked up without a restart).
|
|
55
|
+
*/
|
|
56
|
+
export class HttpMachineTelemetryClient {
|
|
57
|
+
opts;
|
|
58
|
+
constructor(opts) {
|
|
59
|
+
this.opts = opts;
|
|
60
|
+
}
|
|
61
|
+
async ingest(batch) {
|
|
62
|
+
const token = typeof this.opts.token === 'function' ? this.opts.token() : this.opts.token;
|
|
63
|
+
// No token yet (a node booted before the mothership login): there is nothing to sync to, and a
|
|
64
|
+
// guaranteed-403 upload of megabytes is pure waste — so the upload is SKIPPED, but it is
|
|
65
|
+
// skipped by THROWING. Returning a zeroed result here would read to the sweep as "the range is
|
|
66
|
+
// stored", advancing the run's high-water mark over rows that never left the laptop and
|
|
67
|
+
// handing them to the retention prune. The rows stay local and the run stays a candidate, so
|
|
68
|
+
// the sweep picks it up once the SPA login completes.
|
|
69
|
+
if (!token)
|
|
70
|
+
throw new MachineTokenUnavailableError();
|
|
71
|
+
const fetchImpl = this.opts.fetchImpl ?? fetch;
|
|
72
|
+
const res = await fetchImpl(`${this.opts.baseUrl.replace(/\/$/, '')}/internal/telemetry/ingest`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` },
|
|
75
|
+
body: JSON.stringify(batch),
|
|
76
|
+
signal: AbortSignal.timeout(this.opts.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
77
|
+
});
|
|
78
|
+
if (!res.ok) {
|
|
79
|
+
throw new Error(`mothership telemetry ingest failed with HTTP ${res.status}`);
|
|
80
|
+
}
|
|
81
|
+
const body = (await res.json());
|
|
82
|
+
return {
|
|
83
|
+
metrics: body.stored?.metrics ?? 0,
|
|
84
|
+
snapshots: body.stored?.snapshots ?? 0,
|
|
85
|
+
searchQueries: body.stored?.searchQueries ?? 0,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=machineTelemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machineTelemetry.js","sourceRoot":"","sources":["../../src/telemetry/machineTelemetry.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,EAAE;AACF,8FAA8F;AAC9F,4FAA4F;AAC5F,+FAA+F;AAC/F,+EAA+E;AAC/E,EAAE;AACF,4FAA4F;AAC5F,iGAAiG;AACjG,kGAAkG;AAClG,6FAA6F;AAC7F,iGAAiG;AACjG,kGAAkG;AAClG,6FAA6F;AAC7F,EAAE;AACF,+FAA+F;AAC/F,6FAA6F;AAE7F,iGAAiG;AACjG,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,8FAA8F;IAC9F,OAAO,EAAE,GAAG;IACZ,6FAA6F;IAC7F,SAAS,EAAE,EAAE;IACb,gFAAgF;IAChF,aAAa,EAAE,GAAG;CACV,CAAA;AAEV;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAA;AA4BnD;;;;;;;;;GASG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD;QACE,KAAK,CAAC,mEAAmE,CAAC,CAAA;QAC1E,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAC5C,CAAC;CACF;AA2BD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,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AM,EAAE,SAAS,IAAI,CAAC;YACtC,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,IAAI,CAAC;SAC/C,CAAA;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.188.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.32",
|
|
31
31
|
"pino": "^10.3.1",
|
|
32
32
|
"valibot": "^1.4.2",
|
|
33
|
-
"@cat-factory/agents": "0.
|
|
34
|
-
"@cat-factory/contracts": "0.
|
|
35
|
-
"@cat-factory/integrations": "0.113.
|
|
36
|
-
"@cat-factory/kernel": "0.
|
|
37
|
-
"@cat-factory/orchestration": "0.
|
|
38
|
-
"@cat-factory/prompt-fragments": "0.15.
|
|
39
|
-
"@cat-factory/spend": "0.12.
|
|
33
|
+
"@cat-factory/agents": "0.96.0",
|
|
34
|
+
"@cat-factory/contracts": "0.204.0",
|
|
35
|
+
"@cat-factory/integrations": "0.113.8",
|
|
36
|
+
"@cat-factory/kernel": "0.203.0",
|
|
37
|
+
"@cat-factory/orchestration": "0.179.0",
|
|
38
|
+
"@cat-factory/prompt-fragments": "0.15.27",
|
|
39
|
+
"@cat-factory/spend": "0.12.134"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^26.1.1",
|