@cat-factory/kernel 0.213.0 → 0.215.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 (44) hide show
  1. package/dist/domain/binary-generator-registry.d.ts +66 -0
  2. package/dist/domain/binary-generator-registry.d.ts.map +1 -0
  3. package/dist/domain/binary-generator-registry.js +89 -0
  4. package/dist/domain/binary-generator-registry.js.map +1 -0
  5. package/dist/domain/binary-generators.d.ts +97 -0
  6. package/dist/domain/binary-generators.d.ts.map +1 -0
  7. package/dist/domain/binary-generators.js +212 -0
  8. package/dist/domain/binary-generators.js.map +1 -0
  9. package/dist/domain/binary-output-paths.d.ts +25 -0
  10. package/dist/domain/binary-output-paths.d.ts.map +1 -0
  11. package/dist/domain/binary-output-paths.js +47 -0
  12. package/dist/domain/binary-output-paths.js.map +1 -0
  13. package/dist/domain/binary-outputs.d.ts +24 -18
  14. package/dist/domain/binary-outputs.d.ts.map +1 -1
  15. package/dist/domain/binary-outputs.js +78 -45
  16. package/dist/domain/binary-outputs.js.map +1 -1
  17. package/dist/domain/models.d.ts +1 -1
  18. package/dist/domain/models.d.ts.map +1 -1
  19. package/dist/domain/models.js +190 -41
  20. package/dist/domain/models.js.map +1 -1
  21. package/dist/index.d.ts +4 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +11 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/ports/agent-executor.d.ts +13 -0
  26. package/dist/ports/agent-executor.d.ts.map +1 -1
  27. package/dist/ports/agent-executor.js.map +1 -1
  28. package/dist/ports/agent-runs.d.ts +22 -0
  29. package/dist/ports/agent-runs.d.ts.map +1 -1
  30. package/dist/ports/agent-tools.d.ts +36 -13
  31. package/dist/ports/agent-tools.d.ts.map +1 -1
  32. package/dist/ports/index.d.ts +3 -2
  33. package/dist/ports/index.d.ts.map +1 -1
  34. package/dist/ports/index.js +1 -0
  35. package/dist/ports/index.js.map +1 -1
  36. package/dist/ports/llm-trace-sink.d.ts +26 -5
  37. package/dist/ports/llm-trace-sink.d.ts.map +1 -1
  38. package/dist/ports/llm-trace-sink.js +52 -56
  39. package/dist/ports/llm-trace-sink.js.map +1 -1
  40. package/dist/ports/operational-metrics.d.ts +87 -0
  41. package/dist/ports/operational-metrics.d.ts.map +1 -0
  42. package/dist/ports/operational-metrics.js +67 -0
  43. package/dist/ports/operational-metrics.js.map +1 -0
  44. package/package.json +2 -2
@@ -0,0 +1,67 @@
1
+ // The operational-metrics port: the counters and gauges that describe how the DEPLOYMENT is
2
+ // behaving, as opposed to how a run went.
3
+ //
4
+ // `PlatformMetricsRepository` already answers "how are the RUNS doing" by aggregating
5
+ // `agent_runs` per account. It structurally cannot answer the questions an operator asks
6
+ // during an incident — how often a container dispatch is failing, how many stale runs the
7
+ // sweeper is re-driving, whether the queue is draining, whether telemetry batches are being
8
+ // dropped — because none of those are rows in a table. They are EVENTS that happen and are
9
+ // gone. This port is where they are counted.
10
+ //
11
+ // Two shapes, because the two facts have different lifetimes:
12
+ // - a COUNTER is a delta accumulated since the last flush (evictions, re-drives, cache
13
+ // misses). Exported with delta temporality, so a partial flush from one process/isolate
14
+ // still sums correctly with every other one.
15
+ // - a GAUGE is read at export time from something that already knows the answer (queue
16
+ // depth). It is never accumulated here; the sweep probes for it.
17
+ //
18
+ // The whole surface is fire-and-forget and MUST NOT throw, for the same reason `Logger` must
19
+ // not: instrumentation that can fail turns observability into a new failure class.
20
+ /** The disposition for a deployment that exports nothing: count into the void, cheaply. */
21
+ export const noopOperationalMetrics = { increment: () => { } };
22
+ /**
23
+ * A dimension map's stable identity, so `{a:'1',b:'2'}` and `{b:'2',a:'1'}` accumulate onto
24
+ * the same counter rather than two. Keys are sorted; the separators are control characters
25
+ * that cannot appear in a metric dimension value.
26
+ */
27
+ function dimensionKey(dimensions) {
28
+ const keys = Object.keys(dimensions).sort();
29
+ return keys.map((k) => `${k}${dimensions[k]}`).join('');
30
+ }
31
+ /**
32
+ * Build an in-memory {@link OperationalMetricsCollector}. One per process (Node/local, drained
33
+ * by the platform-metrics sweep) or one per isolate (the Worker, drained at the end of each
34
+ * invocation — an isolate can be discarded at any moment, so anything it holds unflushed is
35
+ * simply lost).
36
+ */
37
+ export function createOperationalMetricsCollector() {
38
+ // Keyed by `counter` then by the dimension identity, so a drain can rebuild both halves
39
+ // without parsing the composite key back apart.
40
+ const counters = new Map();
41
+ return {
42
+ increment(counter, dimensions = {}, value = 1) {
43
+ let byDimensions = counters.get(counter);
44
+ if (!byDimensions) {
45
+ byDimensions = new Map();
46
+ counters.set(counter, byDimensions);
47
+ }
48
+ const key = dimensionKey(dimensions);
49
+ const existing = byDimensions.get(key);
50
+ if (existing)
51
+ existing.value += value;
52
+ else
53
+ byDimensions.set(key, { dims: dimensions, value });
54
+ },
55
+ drain() {
56
+ const samples = [];
57
+ for (const [counter, byDimensions] of counters) {
58
+ for (const { dims, value } of byDimensions.values()) {
59
+ samples.push({ counter, dimensions: dims, value });
60
+ }
61
+ }
62
+ counters.clear();
63
+ return samples;
64
+ },
65
+ };
66
+ }
67
+ //# sourceMappingURL=operational-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operational-metrics.js","sourceRoot":"","sources":["../../src/ports/operational-metrics.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,0CAA0C;AAC1C,EAAE;AACF,sFAAsF;AACtF,yFAAyF;AACzF,0FAA0F;AAC1F,4FAA4F;AAC5F,2FAA2F;AAC3F,6CAA6C;AAC7C,EAAE;AACF,8DAA8D;AAC9D,yFAAyF;AACzF,4FAA4F;AAC5F,iDAAiD;AACjD,yFAAyF;AACzF,qEAAqE;AACrE,EAAE;AACF,6FAA6F;AAC7F,mFAAmF;AA8FnF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,sBAAsB,GAAuB,EAAE,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAA;AAEjF;;;;GAIG;AACH,SAAS,YAAY,CAAC,UAAiC;IACrD,MAAM,IAAI,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,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;gBACpD,CAAC;YACH,CAAC;YACD,QAAQ,CAAC,KAAK,EAAE,CAAA;YAChB,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/kernel",
3
- "version": "0.213.0",
3
+ "version": "0.215.0",
4
4
  "description": "Shared vocabulary, pure logic, and port interfaces for the Agent Architecture Board.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "ai": "^7.0.47",
28
28
  "yaml": "^2.9.0",
29
- "@cat-factory/contracts": "0.210.1"
29
+ "@cat-factory/contracts": "0.212.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@vitest/coverage-v8": "^4.1.10",