@kal-elsam/kairo-runtime 0.16.0 → 0.18.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 (81) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/package.json +2 -1
  3. package/scripts/cockpit-smoke.mjs +1 -1
  4. package/scripts/ux-smoke-test.sh +3 -3
  5. package/src/cli.js +96 -11
  6. package/src/global/agent-capabilities/create-capability-adapter.js +2 -2
  7. package/src/global/architect/architect-cli.js +76 -0
  8. package/src/global/architect/architect-codex.js +146 -0
  9. package/src/global/architect/architect-manager.js +125 -0
  10. package/src/global/architect/architect-store.js +377 -0
  11. package/src/global/architect/architect-types.js +47 -0
  12. package/src/global/cli-help.js +10 -1
  13. package/src/global/cockpit/app.js +493 -0
  14. package/src/global/cockpit/card.js +111 -0
  15. package/src/global/cockpit/cli.js +33 -0
  16. package/src/global/cockpit/gauge.js +31 -0
  17. package/src/global/cockpit/project-overlay.js +693 -0
  18. package/src/global/cockpit/rows.js +148 -0
  19. package/src/global/cockpit/theme.js +118 -0
  20. package/src/global/cockpit/view.js +1298 -0
  21. package/src/global/conversation/bootstrap-analyzer-adapters.js +251 -0
  22. package/src/global/conversation/cli.js +53 -0
  23. package/src/global/conversation/codex-sandbox.js +230 -0
  24. package/src/global/conversation/cursor-sandbox.js +215 -0
  25. package/src/global/conversation/project-analysis.js +204 -0
  26. package/src/global/conversation/project-profile.js +178 -0
  27. package/src/global/conversation/project-router.js +149 -0
  28. package/src/global/conversation/project-strategy-store.js +64 -0
  29. package/src/global/conversation/project-strategy.js +514 -0
  30. package/src/global/conversation/sanitized-snapshot.js +169 -0
  31. package/src/global/conversation/secret-scanner.js +71 -0
  32. package/src/global/conversation/service.js +1090 -0
  33. package/src/global/conversation/session-store.js +75 -0
  34. package/src/global/conversation/transcript-store.js +79 -0
  35. package/src/global/conversation/ui.js +195 -0
  36. package/src/global/intelligence/capability-scoring.js +480 -0
  37. package/src/global/intelligence/execution-router.js +466 -0
  38. package/src/global/intelligence/kairo-telemetry-source.js +59 -0
  39. package/src/global/intelligence/kairobench-runner.js +85 -0
  40. package/src/global/intelligence/kairobench-source.js +34 -0
  41. package/src/global/intelligence/kairobench-tasks.js +47 -0
  42. package/src/global/intelligence/model-candidate-catalog.js +456 -0
  43. package/src/global/intelligence/model-capability-registry-sources.js +145 -0
  44. package/src/global/intelligence/model-capability-registry.js +125 -0
  45. package/src/global/intelligence/model-intelligence.js +1646 -0
  46. package/src/global/intelligence/official-benchmark-snapshots.js +162 -0
  47. package/src/global/intelligence/quick-ask.js +149 -0
  48. package/src/global/intelligence/role-profiles.js +251 -0
  49. package/src/global/intelligence/skill-catalog.js +67 -0
  50. package/src/global/intelligence/subscription-pressure-source.js +41 -0
  51. package/src/global/mcp/kairo-mcp.js +51 -18
  52. package/src/global/mcp/work-snapshot-rule.js +4 -2
  53. package/src/global/mcp/workspace-binding.js +88 -0
  54. package/src/global/mcp/workspace-mcp-entry.js +74 -0
  55. package/src/global/mcp-install.js +8 -1
  56. package/src/global/observability/artificial-analysis-models.js +118 -0
  57. package/src/global/observability/claude-models.js +31 -0
  58. package/src/global/observability/claude-usage.js +112 -0
  59. package/src/global/observability/codex-models.js +96 -0
  60. package/src/global/observability/codex-usage.js +160 -0
  61. package/src/global/observability/cursor-auth.js +88 -0
  62. package/src/global/observability/cursor-models.js +101 -0
  63. package/src/global/observability/huggingface-leaderboard.js +97 -0
  64. package/src/global/observability/opencode-models.js +101 -0
  65. package/src/global/observability/opencode-usage.js +162 -0
  66. package/src/global/paths.js +49 -2
  67. package/src/global/profile.js +23 -1
  68. package/src/global/runtime/execution-adapters/claude.js +63 -30
  69. package/src/global/runtime/execution-adapters/codex.js +9 -2
  70. package/src/global/runtime/execution-adapters/create-execution-adapter.js +6 -1
  71. package/src/global/runtime/execution-adapters/opencode.js +83 -18
  72. package/src/global/runtime/execution-worktree-manager.js +924 -0
  73. package/src/global/runtime/execution-worktree-orchestrator.js +194 -0
  74. package/src/global/runtime/execution-worktree-store.js +83 -0
  75. package/src/global/runtime/execution-worktree-types.js +45 -0
  76. package/src/global/runtime/run-events.js +38 -0
  77. package/src/global/runtime/run-manager.js +22 -6
  78. package/src/global/runtime/run-supervisor.js +41 -12
  79. package/src/global/runtime/usage-manager.js +96 -0
  80. package/src/global/runtime/usage-store.js +69 -0
  81. package/src/global/runtime/usage-types.js +62 -0
@@ -0,0 +1,125 @@
1
+ // The "Model Intelligence Foundation": a raw evidence store, never a
2
+ // computed score. Every fact Kairo knows about a model — regardless of
3
+ // which source it came from — gets recorded here with its provenance
4
+ // (source, benchmark version, model config/harness, date, whether the
5
+ // source itself independently verified it) instead of being collapsed
6
+ // into a single number immediately. Routing (AI TEAM, the old FIT) can
7
+ // later be rebuilt on top of this without re-deriving evidence collection
8
+ // each time a new source is added.
9
+ //
10
+ // Deliberately out of scope here: role scores, confidence-weighted
11
+ // averages across sources, or automatic cross-source consensus. Averaging
12
+ // two benchmark runs from different harnesses/versions isn't honest —
13
+ // they're not measuring the same thing. This module only stores evidence
14
+ // and, at most, picks the single most trustworthy entry for a metric
15
+ // (bestEvidence) — it never blends.
16
+ //
17
+ // No cross-provider identity unification is attempted either: claiming
18
+ // "this Codex model IS this OpenCode model" needs real evidence Kairo
19
+ // doesn't have. Each (adapterId, modelId) pair is its own identity.
20
+
21
+ function identityKey(adapterId, modelId) {
22
+ return `${adapterId}:${modelId}`;
23
+ }
24
+
25
+ const REQUIRED_EVIDENCE_FIELDS = ["metric", "value", "source"];
26
+
27
+ /**
28
+ * @returns {{
29
+ * registerIdentity: (adapterId: string, modelId: string, displayName?: string|null) => string,
30
+ * addEvidence: (id: string, entry: object) => object,
31
+ * getEvidence: (id: string, metric?: string) => object[],
32
+ * getIdentity: (id: string) => object|null,
33
+ * listIdentities: () => object[]
34
+ * }}
35
+ */
36
+ export function createCapabilityRegistry() {
37
+ const identities = new Map();
38
+ const evidence = new Map();
39
+
40
+ return {
41
+ /** Idempotent: re-registering the same (adapterId, modelId) returns the same id without overwriting displayName. */
42
+ registerIdentity(adapterId, modelId, displayName = null) {
43
+ const id = identityKey(adapterId, modelId);
44
+ if (!identities.has(id)) identities.set(id, { id, adapterId, modelId, displayName });
45
+ return id;
46
+ },
47
+
48
+ /**
49
+ * Appends one piece of raw evidence — never overwrites or merges with
50
+ * existing entries, since a model can genuinely have multiple real
51
+ * measurements for the same metric (different sources, versions,
52
+ * configs) that must stay distinguishable.
53
+ * @param {string} id - from registerIdentity()
54
+ * @param {{metric: string, value: number, source: string, benchmarkVersion?: string|null, modelConfig?: string|null, date?: string|null, verified?: boolean}} entry
55
+ */
56
+ addEvidence(id, entry) {
57
+ if (!identities.has(id)) throw new Error(`capability-registry: unknown model identity "${id}" — call registerIdentity() first`);
58
+ for (const key of REQUIRED_EVIDENCE_FIELDS) {
59
+ if (entry[key] == null) throw new Error(`capability-registry: evidence for "${id}" is missing required field "${key}"`);
60
+ }
61
+ if (entry.scale != null && entry.scale !== "unit" && entry.scale !== "hundred") {
62
+ throw new Error(`capability-registry: evidence for "${id}" has invalid scale "${entry.scale}" — must be "unit", "hundred", or omitted`);
63
+ }
64
+ const record = {
65
+ metric: entry.metric,
66
+ value: entry.value,
67
+ source: entry.source,
68
+ benchmarkVersion: entry.benchmarkVersion ?? null,
69
+ modelConfig: entry.modelConfig ?? null,
70
+ date: entry.date ?? null,
71
+ verified: entry.verified === true,
72
+ // The REAL scale this exact value was reported on ("unit": 0-1
73
+ // fraction, "hundred": 0-100 percentage-like score) — set by the
74
+ // ingestion source that actually knows it, e.g.
75
+ // ingestHuggingFaceLeaderboardEvidence's own real, live-verified
76
+ // knowledge that HLE via Hugging Face reports 0-100 (63.9), never
77
+ // a 0-1 fraction. Optional (null when omitted) so capability-
78
+ // scoring.js's own BENCHMARK_IDENTITIES metric-name-based scale
79
+ // stays a valid fallback for older evidence that never declared
80
+ // one — see capability-scoring.js's bestAcrossAliases for the
81
+ // real bug this fixes: two sources sharing one metric NAME
82
+ // ("hle") but reporting in genuinely different real scales must
83
+ // never both defer to a single scale guessed from the name alone.
84
+ scale: entry.scale ?? null
85
+ };
86
+ if (!evidence.has(id)) evidence.set(id, []);
87
+ evidence.get(id).push(record);
88
+ return record;
89
+ },
90
+
91
+ /** All evidence for a model, optionally filtered to one metric. Empty array, never null, when there's none. */
92
+ getEvidence(id, metric = null) {
93
+ const all = evidence.get(id) ?? [];
94
+ return metric ? all.filter((e) => e.metric === metric) : [...all];
95
+ },
96
+
97
+ getIdentity(id) {
98
+ return identities.get(id) ?? null;
99
+ },
100
+
101
+ listIdentities() {
102
+ return [...identities.values()];
103
+ }
104
+ };
105
+ }
106
+
107
+ /**
108
+ * The single most trustworthy piece of evidence for a metric — never an
109
+ * average or blend, since incompatible benchmark versions/harnesses can't
110
+ * be honestly combined into one number. Preference: independently
111
+ * verified first, then most recent. Returns null (never a guess) when no
112
+ * evidence exists for that model/metric.
113
+ * @param {ReturnType<createCapabilityRegistry>} registry
114
+ * @param {string} id
115
+ * @param {string} metric
116
+ */
117
+ export function bestEvidence(registry, id, metric) {
118
+ const entries = registry.getEvidence(id, metric);
119
+ if (!entries.length) return null;
120
+ return [...entries].sort((a, b) => {
121
+ if (a.verified !== b.verified) return a.verified ? -1 : 1;
122
+ const dateValue = (entry) => (entry.date ? Date.parse(entry.date) : Number.NEGATIVE_INFINITY);
123
+ return dateValue(b) - dateValue(a);
124
+ })[0];
125
+ }