open-multi-agent-kit 0.78.1 → 0.78.2
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/CHANGELOG.md +12 -0
- package/MATURITY.md +4 -0
- package/README.md +70 -1
- package/dist/cli/register-spec-agent-goal-commands.js +45 -0
- package/dist/cli/release-promotion-gate.d.ts +14 -0
- package/dist/cli/release-promotion-gate.js +71 -0
- package/dist/cli/v2/release-commands.d.ts +29 -0
- package/dist/cli/v2/release-commands.js +95 -0
- package/dist/commands/chat/native-root-loop.js +14 -1
- package/dist/commands/chat/slash/commands/session.js +19 -1
- package/dist/commands/goal-interview.d.ts +18 -0
- package/dist/commands/goal-interview.js +396 -0
- package/dist/contracts/interview.d.ts +106 -0
- package/dist/contracts/interview.js +9 -0
- package/dist/evidence/index.d.ts +4 -0
- package/dist/evidence/index.js +2 -0
- package/dist/evidence/proof-trust-cli.d.ts +8 -0
- package/dist/evidence/proof-trust-cli.js +27 -0
- package/dist/evidence/proof-trust.d.ts +14 -0
- package/dist/evidence/proof-trust.js +381 -0
- package/dist/evidence/regression-proof-matrix.d.ts +42 -0
- package/dist/evidence/regression-proof-matrix.js +72 -0
- package/dist/goal/intent-frame.d.ts +6 -0
- package/dist/goal/intent-frame.js +21 -9
- package/dist/goal/interview-assimilation.d.ts +13 -0
- package/dist/goal/interview-assimilation.js +383 -0
- package/dist/goal/interview-question-bank.d.ts +11 -0
- package/dist/goal/interview-question-bank.js +225 -0
- package/dist/goal/interview-scoring.d.ts +31 -0
- package/dist/goal/interview-scoring.js +187 -0
- package/dist/goal/interview-session.d.ts +25 -0
- package/dist/goal/interview-session.js +116 -0
- package/dist/input/input-envelope.d.ts +22 -0
- package/dist/input/input-envelope.js +1 -0
- package/dist/runtime/advanced-control-loop.d.ts +60 -0
- package/dist/runtime/advanced-control-loop.js +136 -0
- package/dist/runtime/agent-runtime.d.ts +10 -0
- package/dist/runtime/blast-radius.d.ts +10 -0
- package/dist/runtime/blast-radius.js +14 -0
- package/dist/runtime/contracts/evidence.d.ts +87 -0
- package/dist/runtime/contracts/evidence.js +7 -0
- package/dist/runtime/contracts/router-v2.d.ts +44 -0
- package/dist/runtime/contracts/router-v2.js +4 -0
- package/dist/runtime/contracts/weakness-remediation.d.ts +67 -0
- package/dist/runtime/contracts/weakness-remediation.js +36 -0
- package/dist/runtime/kimi-api-runtime.js +59 -1
- package/dist/runtime/proof-bundle-trust.d.ts +74 -0
- package/dist/runtime/proof-bundle-trust.js +100 -0
- package/dist/runtime/provider-maturity-gate.d.ts +41 -0
- package/dist/runtime/provider-maturity-gate.js +101 -0
- package/dist/runtime/public-surface.d.ts +93 -0
- package/dist/runtime/public-surface.js +146 -0
- package/dist/runtime/router-v2-scoring.d.ts +11 -0
- package/dist/runtime/router-v2-scoring.js +151 -0
- package/dist/runtime/weakness-remediation-index.d.ts +27 -0
- package/dist/runtime/weakness-remediation-index.js +37 -0
- package/dist/schema/proof-bundle.schema.d.ts +26 -26
- package/dist/util/clipboard-image.d.ts +49 -0
- package/dist/util/clipboard-image.js +263 -0
- package/docs/2026-06-09/critical-issues.md +20 -0
- package/docs/2026-06-09/improvements.md +14 -0
- package/docs/2026-06-09/init-checklist.md +25 -0
- package/docs/2026-06-09/plan.md +20 -0
- package/docs/github-organic-promotion.md +127 -0
- package/docs/native-root-runtime-algorithms.md +301 -0
- package/package.json +4 -3
- package/readmeasset/ASSET_INDEX.md +1 -0
- package/templates/skills/agents/omk-agent-reach-websearch/SKILL.md +55 -0
- package/templates/skills/kimi/omk-agent-reach-websearch/SKILL.md +55 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public Surface Compression — Phase 1 of OMK Weakness Remediation.
|
|
3
|
+
*
|
|
4
|
+
* Takes a candidate set of runtime surfaces, scores each item,
|
|
5
|
+
* enforces mandatory anchors, applies budget K, and returns
|
|
6
|
+
* public surface S and hidden set H.
|
|
7
|
+
*
|
|
8
|
+
* Also enforces the 5-step flow invariant:
|
|
9
|
+
* goal → dag → route → verify → replay
|
|
10
|
+
*/
|
|
11
|
+
/** A candidate surface item (e.g., a tool, MCP server, skill, or runtime). */
|
|
12
|
+
export interface SurfaceItem {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly category: "tool" | "mcp" | "skill" | "runtime" | "hook";
|
|
16
|
+
/** How often this surface is invoked per 100 turns. */
|
|
17
|
+
readonly usage: number;
|
|
18
|
+
/** Contribution score from verified runs [0, 1]. */
|
|
19
|
+
readonly verifiedRunContribution: number;
|
|
20
|
+
/** Contribution score from evidence items [0, 1]. */
|
|
21
|
+
readonly evidenceContribution: number;
|
|
22
|
+
/** Onboarding difficulty/cost [0, 1]. */
|
|
23
|
+
readonly onboardingCost: number;
|
|
24
|
+
/** Explainability burden [0, 1]. */
|
|
25
|
+
readonly explainabilityCost: number;
|
|
26
|
+
/** Risk of lineage drift [0, 1]. */
|
|
27
|
+
readonly lineageRisk: number;
|
|
28
|
+
}
|
|
29
|
+
/** Scored surface item with computed score. */
|
|
30
|
+
export interface ScoredSurfaceItem extends SurfaceItem {
|
|
31
|
+
readonly score: number;
|
|
32
|
+
}
|
|
33
|
+
/** Mandatory anchor identifiers. */
|
|
34
|
+
export type MandatoryAnchor = "goal" | "dag" | "route" | "verify" | "replay";
|
|
35
|
+
/** Compression result: public surface S and hidden set H. */
|
|
36
|
+
export interface CompressionResult {
|
|
37
|
+
readonly publicSurface: readonly ScoredSurfaceItem[];
|
|
38
|
+
readonly hiddenSet: readonly ScoredSurfaceItem[];
|
|
39
|
+
readonly mandatoryAnchors: readonly MandatoryAnchor[];
|
|
40
|
+
readonly budget: number;
|
|
41
|
+
readonly invariantPassed: boolean;
|
|
42
|
+
readonly invariantViolations: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compute surface score from item metrics.
|
|
46
|
+
*
|
|
47
|
+
* Formula:
|
|
48
|
+
* 0.30 * usage
|
|
49
|
+
* + 0.30 * verifiedRunContribution
|
|
50
|
+
* + 0.20 * evidenceContribution
|
|
51
|
+
* - 0.10 * onboardingCost
|
|
52
|
+
* - 0.05 * explainabilityCost
|
|
53
|
+
* - 0.05 * lineageRisk
|
|
54
|
+
*/
|
|
55
|
+
export declare function computeSurfaceScore(item: SurfaceItem): number;
|
|
56
|
+
/**
|
|
57
|
+
* Validate the 5-step flow invariant against the public surface.
|
|
58
|
+
*
|
|
59
|
+
* Invariant: The public surface must contain all mandatory anchors
|
|
60
|
+
* in order: goal → dag → route → verify → replay.
|
|
61
|
+
*
|
|
62
|
+
* Returns violations as human-readable strings.
|
|
63
|
+
*/
|
|
64
|
+
export declare function enforceFlowInvariant(publicSurface: readonly ScoredSurfaceItem[]): {
|
|
65
|
+
readonly passed: boolean;
|
|
66
|
+
readonly violations: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
export interface PublicSurfaceCompressorOptions {
|
|
69
|
+
/** Maximum number of items in the public surface (default 5). */
|
|
70
|
+
readonly budget?: number;
|
|
71
|
+
/** Optional custom scoring function. */
|
|
72
|
+
readonly scoreFn?: (item: SurfaceItem) => number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compresses a candidate surface set into public (S) and hidden (H) subsets.
|
|
76
|
+
*
|
|
77
|
+
* Rules:
|
|
78
|
+
* 1. Mandatory anchors A = {goal, dag, route, verify, replay} are always in S.
|
|
79
|
+
* 2. Remaining slots are filled by highest score until budget K is reached.
|
|
80
|
+
* 3. The 5-step flow invariant is enforced and reported.
|
|
81
|
+
*/
|
|
82
|
+
export declare class PublicSurfaceCompressor {
|
|
83
|
+
private readonly budget;
|
|
84
|
+
private readonly scoreFn;
|
|
85
|
+
constructor(options?: PublicSurfaceCompressorOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Compress candidates into public surface S and hidden set H.
|
|
88
|
+
*
|
|
89
|
+
* @param candidates All candidate surface items.
|
|
90
|
+
* @returns CompressionResult with S, H, and invariant status.
|
|
91
|
+
*/
|
|
92
|
+
compress(candidates: readonly SurfaceItem[]): CompressionResult;
|
|
93
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public Surface Compression — Phase 1 of OMK Weakness Remediation.
|
|
3
|
+
*
|
|
4
|
+
* Takes a candidate set of runtime surfaces, scores each item,
|
|
5
|
+
* enforces mandatory anchors, applies budget K, and returns
|
|
6
|
+
* public surface S and hidden set H.
|
|
7
|
+
*
|
|
8
|
+
* Also enforces the 5-step flow invariant:
|
|
9
|
+
* goal → dag → route → verify → replay
|
|
10
|
+
*/
|
|
11
|
+
// ── Constants ───────────────────────────────────────────────────
|
|
12
|
+
const MANDATORY_ANCHORS = [
|
|
13
|
+
"goal",
|
|
14
|
+
"dag",
|
|
15
|
+
"route",
|
|
16
|
+
"verify",
|
|
17
|
+
"replay",
|
|
18
|
+
];
|
|
19
|
+
const DEFAULT_BUDGET = 5;
|
|
20
|
+
// ── Scoring ─────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Compute surface score from item metrics.
|
|
23
|
+
*
|
|
24
|
+
* Formula:
|
|
25
|
+
* 0.30 * usage
|
|
26
|
+
* + 0.30 * verifiedRunContribution
|
|
27
|
+
* + 0.20 * evidenceContribution
|
|
28
|
+
* - 0.10 * onboardingCost
|
|
29
|
+
* - 0.05 * explainabilityCost
|
|
30
|
+
* - 0.05 * lineageRisk
|
|
31
|
+
*/
|
|
32
|
+
export function computeSurfaceScore(item) {
|
|
33
|
+
const raw = 0.30 * item.usage +
|
|
34
|
+
0.30 * item.verifiedRunContribution +
|
|
35
|
+
0.20 * item.evidenceContribution -
|
|
36
|
+
0.10 * item.onboardingCost -
|
|
37
|
+
0.05 * item.explainabilityCost -
|
|
38
|
+
0.05 * item.lineageRisk;
|
|
39
|
+
// Clamp to [0, 1]
|
|
40
|
+
return Math.max(0, Math.min(1, raw));
|
|
41
|
+
}
|
|
42
|
+
// ── Invariant Enforcement ───────────────────────────────────────
|
|
43
|
+
/**
|
|
44
|
+
* Validate the 5-step flow invariant against the public surface.
|
|
45
|
+
*
|
|
46
|
+
* Invariant: The public surface must contain all mandatory anchors
|
|
47
|
+
* in order: goal → dag → route → verify → replay.
|
|
48
|
+
*
|
|
49
|
+
* Returns violations as human-readable strings.
|
|
50
|
+
*/
|
|
51
|
+
export function enforceFlowInvariant(publicSurface) {
|
|
52
|
+
const violations = [];
|
|
53
|
+
const ids = publicSurface.map((s) => s.id);
|
|
54
|
+
for (const anchor of MANDATORY_ANCHORS) {
|
|
55
|
+
if (!ids.includes(anchor)) {
|
|
56
|
+
violations.push(`Missing mandatory anchor: ${anchor}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (violations.length === 0) {
|
|
60
|
+
const orderIndices = MANDATORY_ANCHORS.map((a) => ids.indexOf(a));
|
|
61
|
+
for (let i = 1; i < orderIndices.length; i++) {
|
|
62
|
+
if (orderIndices[i] < orderIndices[i - 1]) {
|
|
63
|
+
violations.push(`Flow order violation: ${MANDATORY_ANCHORS[i - 1]} must precede ${MANDATORY_ANCHORS[i]}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
passed: violations.length === 0,
|
|
69
|
+
violations: Object.freeze(violations),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compresses a candidate surface set into public (S) and hidden (H) subsets.
|
|
74
|
+
*
|
|
75
|
+
* Rules:
|
|
76
|
+
* 1. Mandatory anchors A = {goal, dag, route, verify, replay} are always in S.
|
|
77
|
+
* 2. Remaining slots are filled by highest score until budget K is reached.
|
|
78
|
+
* 3. The 5-step flow invariant is enforced and reported.
|
|
79
|
+
*/
|
|
80
|
+
export class PublicSurfaceCompressor {
|
|
81
|
+
budget;
|
|
82
|
+
scoreFn;
|
|
83
|
+
constructor(options = {}) {
|
|
84
|
+
this.budget = Math.max(MANDATORY_ANCHORS.length, options.budget ?? DEFAULT_BUDGET);
|
|
85
|
+
this.scoreFn = options.scoreFn ?? computeSurfaceScore;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compress candidates into public surface S and hidden set H.
|
|
89
|
+
*
|
|
90
|
+
* @param candidates All candidate surface items.
|
|
91
|
+
* @returns CompressionResult with S, H, and invariant status.
|
|
92
|
+
*/
|
|
93
|
+
compress(candidates) {
|
|
94
|
+
const scored = candidates.map((item) => ({
|
|
95
|
+
...item,
|
|
96
|
+
score: this.scoreFn(item),
|
|
97
|
+
}));
|
|
98
|
+
// Partition mandatory vs elective
|
|
99
|
+
const mandatoryItems = [];
|
|
100
|
+
const electiveItems = [];
|
|
101
|
+
for (const item of scored) {
|
|
102
|
+
if (MANDATORY_ANCHORS.includes(item.id)) {
|
|
103
|
+
mandatoryItems.push(item);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
electiveItems.push(item);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Ensure all mandatory anchors are present; inject placeholders if missing
|
|
110
|
+
const presentIds = new Set(mandatoryItems.map((m) => m.id));
|
|
111
|
+
for (const anchor of MANDATORY_ANCHORS) {
|
|
112
|
+
if (!presentIds.has(anchor)) {
|
|
113
|
+
mandatoryItems.push({
|
|
114
|
+
id: anchor,
|
|
115
|
+
name: anchor,
|
|
116
|
+
category: "runtime",
|
|
117
|
+
usage: 0,
|
|
118
|
+
verifiedRunContribution: 0,
|
|
119
|
+
evidenceContribution: 0,
|
|
120
|
+
onboardingCost: 0,
|
|
121
|
+
explainabilityCost: 0,
|
|
122
|
+
lineageRisk: 0,
|
|
123
|
+
score: 0,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Sort mandatory by canonical order, electives by score desc
|
|
128
|
+
const orderedMandatory = MANDATORY_ANCHORS.map((anchor) => mandatoryItems.find((m) => m.id === anchor));
|
|
129
|
+
electiveItems.sort((a, b) => b.score - a.score);
|
|
130
|
+
const remainingSlots = Math.max(0, this.budget - orderedMandatory.length);
|
|
131
|
+
const publicSurface = Object.freeze([
|
|
132
|
+
...orderedMandatory,
|
|
133
|
+
...electiveItems.slice(0, remainingSlots),
|
|
134
|
+
]);
|
|
135
|
+
const hiddenSet = Object.freeze(electiveItems.slice(remainingSlots));
|
|
136
|
+
const invariant = enforceFlowInvariant(publicSurface);
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
publicSurface,
|
|
139
|
+
hiddenSet,
|
|
140
|
+
mandatoryAnchors: MANDATORY_ANCHORS,
|
|
141
|
+
budget: this.budget,
|
|
142
|
+
invariantPassed: invariant.passed,
|
|
143
|
+
invariantViolations: invariant.violations,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router V2 Scoring Engine — Bayesian-smoothed evidence calibration (Algorithm 6).
|
|
3
|
+
*
|
|
4
|
+
* Composite formula:
|
|
5
|
+
* 0.25*E + 0.15*conf + 0.20*cap + 0.15*mat + 0.10*lat + 0.10*cost
|
|
6
|
+
* - 0.15*pen - 0.10*blast
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentRuntime } from "./agent-runtime.js";
|
|
9
|
+
import type { EvidenceHistoryEntry, NodeIntent, RuntimeScoreV2, RouterV2Options, RouterV2ScoringEngine, BlastRadiusParams } from "./contracts/router-v2.js";
|
|
10
|
+
export declare function createRouterV2ScoringEngine(options?: RouterV2Options, blastRadiusFn?: (params: BlastRadiusParams) => number): RouterV2ScoringEngine;
|
|
11
|
+
export declare function scoreRuntimes(candidates: AgentRuntime[], intent: NodeIntent, history: EvidenceHistoryEntry[], options?: RouterV2Options): RuntimeScoreV2[];
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router V2 Scoring Engine — Bayesian-smoothed evidence calibration (Algorithm 6).
|
|
3
|
+
*
|
|
4
|
+
* Composite formula:
|
|
5
|
+
* 0.25*E + 0.15*conf + 0.20*cap + 0.15*mat + 0.10*lat + 0.10*cost
|
|
6
|
+
* - 0.15*pen - 0.10*blast
|
|
7
|
+
*/
|
|
8
|
+
import { computeBlastRadiusPenalty } from "./blast-radius.js";
|
|
9
|
+
const ALPHA_0 = 1;
|
|
10
|
+
const BETA_0 = 1;
|
|
11
|
+
const INTENT_CAPABILITY_WEIGHTS = {
|
|
12
|
+
research: [["read", 0.35], ["review", 0.2], ["toolCalling", 0.15], ["vision", 0.1]],
|
|
13
|
+
planning: [["read", 0.3], ["review", 0.2], ["toolCalling", 0.15]],
|
|
14
|
+
coding: [["write", 0.3], ["patch", 0.25], ["shell", 0.15], ["toolCalling", 0.1]],
|
|
15
|
+
debugging: [["read", 0.2], ["write", 0.2], ["patch", 0.2], ["shell", 0.15], ["toolCalling", 0.1]],
|
|
16
|
+
refactor: [["write", 0.25], ["patch", 0.25], ["review", 0.15], ["toolCalling", 0.1]],
|
|
17
|
+
review: [["review", 0.35], ["read", 0.25], ["toolCalling", 0.1]],
|
|
18
|
+
"test-generation": [["write", 0.25], ["patch", 0.2], ["review", 0.15], ["toolCalling", 0.1]],
|
|
19
|
+
documentation: [["read", 0.25], ["write", 0.15], ["review", 0.15], ["toolCalling", 0.1]],
|
|
20
|
+
"shell-operation": [["shell", 0.4], ["read", 0.15], ["write", 0.1]],
|
|
21
|
+
};
|
|
22
|
+
function runtimeCapabilityEnabled(capabilities, capability) {
|
|
23
|
+
if (capability === "toolCalling") {
|
|
24
|
+
return capabilities.toolCalling === true || capabilities.supportsToolCalling === true;
|
|
25
|
+
}
|
|
26
|
+
if (capability === "streaming") {
|
|
27
|
+
return capabilities.streaming === true || capabilities.supportsStreaming === true;
|
|
28
|
+
}
|
|
29
|
+
return capabilities[capability] === true;
|
|
30
|
+
}
|
|
31
|
+
function computeCapabilityFit(runtime, intent) {
|
|
32
|
+
const caps = runtime.capabilities;
|
|
33
|
+
if (!caps)
|
|
34
|
+
return 0;
|
|
35
|
+
let score = 0;
|
|
36
|
+
for (const [capability, weight] of INTENT_CAPABILITY_WEIGHTS[intent]) {
|
|
37
|
+
if (runtimeCapabilityEnabled(caps, capability))
|
|
38
|
+
score += weight;
|
|
39
|
+
}
|
|
40
|
+
if (caps.maxTokens != null && caps.maxTokens > 0) {
|
|
41
|
+
score += Math.min(0.1, caps.maxTokens / 1_000_000);
|
|
42
|
+
}
|
|
43
|
+
if (caps.maxContextTokens != null && caps.maxContextTokens > 0) {
|
|
44
|
+
score += Math.min(0.1, caps.maxContextTokens / 1_000_000);
|
|
45
|
+
}
|
|
46
|
+
return score;
|
|
47
|
+
}
|
|
48
|
+
function computeMaturityScore(runtime) {
|
|
49
|
+
const caps = runtime.capabilities;
|
|
50
|
+
if (!caps)
|
|
51
|
+
return 0.5;
|
|
52
|
+
const capabilityCount = [
|
|
53
|
+
caps.read,
|
|
54
|
+
caps.write,
|
|
55
|
+
caps.shell,
|
|
56
|
+
caps.patch,
|
|
57
|
+
caps.review,
|
|
58
|
+
caps.merge,
|
|
59
|
+
caps.vision,
|
|
60
|
+
caps.mcp,
|
|
61
|
+
caps.toolCalling,
|
|
62
|
+
caps.supportsToolCalling,
|
|
63
|
+
].filter(Boolean).length;
|
|
64
|
+
const breadthScore = Math.min(1, capabilityCount / 8);
|
|
65
|
+
const priorityScore = Math.max(0, Math.min(1, runtime.priority / 100));
|
|
66
|
+
return 0.6 * breadthScore + 0.4 * priorityScore;
|
|
67
|
+
}
|
|
68
|
+
function computeLatencyScore(runtime) {
|
|
69
|
+
return runtime.capabilities?.supportsStreaming === true || runtime.capabilities?.streaming === true
|
|
70
|
+
? 0.85
|
|
71
|
+
: 0.70;
|
|
72
|
+
}
|
|
73
|
+
function computeCostScore(runtime) {
|
|
74
|
+
return runtime.priority > 50 ? 0.75 : 0.90;
|
|
75
|
+
}
|
|
76
|
+
export function createRouterV2ScoringEngine(options = {}, blastRadiusFn = computeBlastRadiusPenalty) {
|
|
77
|
+
const { enableBlastRadius = false, blastRadiusParams = { downstreamNodeCount: 0, affectedFileCount: 0, hasGlobalSideEffects: false }, } = options;
|
|
78
|
+
function score(runtime, intent, history) {
|
|
79
|
+
const runtimeHistory = history.filter((e) => e.runtime === runtime.id);
|
|
80
|
+
const totalAttempts = runtimeHistory.length;
|
|
81
|
+
const passedAttempts = runtimeHistory.filter((e) => e.passed).length;
|
|
82
|
+
// Bayesian smoothing with α₀=1, β₀=1
|
|
83
|
+
const bayesianEvidenceScore = (ALPHA_0 + passedAttempts) / (ALPHA_0 + BETA_0 + totalAttempts);
|
|
84
|
+
// Confidence increases with sample size (asymptotic toward 1)
|
|
85
|
+
const confidence = Math.min(1, totalAttempts / 10 + 0.1);
|
|
86
|
+
const recentFailures = runtimeHistory
|
|
87
|
+
.filter((e) => !e.passed)
|
|
88
|
+
.sort((a, b) => b.timestamp.localeCompare(a.timestamp))
|
|
89
|
+
.slice(0, 5);
|
|
90
|
+
const recentFailurePenalty = Math.min(0.3, recentFailures.length * 0.06);
|
|
91
|
+
const capabilityFit = computeCapabilityFit(runtime, intent);
|
|
92
|
+
const maturityScore = computeMaturityScore(runtime);
|
|
93
|
+
const latencyScore = computeLatencyScore(runtime);
|
|
94
|
+
const costScore = computeCostScore(runtime);
|
|
95
|
+
const blastRadiusPenalty = enableBlastRadius ? blastRadiusFn(blastRadiusParams) : 0;
|
|
96
|
+
const composite = 0.25 * bayesianEvidenceScore +
|
|
97
|
+
0.15 * confidence +
|
|
98
|
+
0.20 * capabilityFit +
|
|
99
|
+
0.15 * maturityScore +
|
|
100
|
+
0.10 * latencyScore +
|
|
101
|
+
0.10 * costScore -
|
|
102
|
+
0.15 * recentFailurePenalty -
|
|
103
|
+
0.10 * blastRadiusPenalty;
|
|
104
|
+
return {
|
|
105
|
+
runtimeId: runtime.id,
|
|
106
|
+
bayesianEvidenceScore,
|
|
107
|
+
confidence,
|
|
108
|
+
capabilityFit,
|
|
109
|
+
maturityScore,
|
|
110
|
+
latencyScore,
|
|
111
|
+
costScore,
|
|
112
|
+
recentFailurePenalty,
|
|
113
|
+
blastRadiusPenalty,
|
|
114
|
+
composite,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function select(candidates, intent, history) {
|
|
118
|
+
const scored = candidates.map((runtime) => ({
|
|
119
|
+
runtime,
|
|
120
|
+
score: score(runtime, intent, history),
|
|
121
|
+
}));
|
|
122
|
+
scored.sort((a, b) => b.score.composite - a.score.composite);
|
|
123
|
+
const primary = scored[0].runtime;
|
|
124
|
+
const fallbacks = scored.slice(1).map((s) => s.runtime);
|
|
125
|
+
const bestScore = scored[0].score;
|
|
126
|
+
const reason = [
|
|
127
|
+
`intent=${intent}`,
|
|
128
|
+
`bayesianE=${bestScore.bayesianEvidenceScore.toFixed(2)}`,
|
|
129
|
+
`confidence=${bestScore.confidence.toFixed(2)}`,
|
|
130
|
+
`capability=${bestScore.capabilityFit.toFixed(2)}`,
|
|
131
|
+
`maturity=${bestScore.maturityScore.toFixed(2)}`,
|
|
132
|
+
`latency=${bestScore.latencyScore.toFixed(2)}`,
|
|
133
|
+
`cost=${bestScore.costScore.toFixed(2)}`,
|
|
134
|
+
`penalty=${bestScore.recentFailurePenalty.toFixed(2)}`,
|
|
135
|
+
`blast=${bestScore.blastRadiusPenalty.toFixed(2)}`,
|
|
136
|
+
`composite=${bestScore.composite.toFixed(3)}`,
|
|
137
|
+
].join("; ");
|
|
138
|
+
return {
|
|
139
|
+
runtime: primary,
|
|
140
|
+
reason,
|
|
141
|
+
fallbacks,
|
|
142
|
+
intent,
|
|
143
|
+
scores: scored.map((s) => s.score),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return { score, select };
|
|
147
|
+
}
|
|
148
|
+
export function scoreRuntimes(candidates, intent, history, options = {}) {
|
|
149
|
+
const engine = createRouterV2ScoringEngine(options);
|
|
150
|
+
return candidates.map((runtime) => engine.score(runtime, intent, history));
|
|
151
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weakness Remediation Index — Public factory that instantiates all
|
|
3
|
+
* Phase 1–6 engines with sensible defaults.
|
|
4
|
+
*/
|
|
5
|
+
export { type IntegrationResultKind, type WeaknessRemediationState, type AdvancedControlLoopInput, type AdvancedControlLoopResult, type AdvancedControlLoop, type AdvancedControlLoopOptions, createAdvancedControlLoop, } from "./advanced-control-loop.js";
|
|
6
|
+
export { type SurfaceItem, type ScoredSurfaceItem, type MandatoryAnchor, type CompressionResult, type PublicSurfaceCompressorOptions, computeSurfaceScore, enforceFlowInvariant, PublicSurfaceCompressor, } from "./public-surface.js";
|
|
7
|
+
export { type ProofBundleScores, type TrustScoreResult, type ProofBundleTrustEngine, type DeriveScoresOptions, createProofBundleTrustEngine, } from "./proof-bundle-trust.js";
|
|
8
|
+
export { type MaturityResult, type ProviderMaturityGate, createProviderMaturityGate, } from "./provider-maturity-gate.js";
|
|
9
|
+
export { type RuntimeScoreV2, type RuntimeRouterDecisionV2, type RouterV2Options, type RouterV2ScoringEngine, type BlastRadiusParams, type EvidenceHistoryEntry, type NodeIntent, } from "./contracts/router-v2.js";
|
|
10
|
+
export { createRouterV2ScoringEngine, } from "./router-v2-scoring.js";
|
|
11
|
+
export { type ReleasePromotionInputs, type ReleasePromotionResult, type ReleaseVerdict, RELEASE_GATE_WEIGHTS, TAU_EVIDENCE, TAU_EVIDENCE_HIGH, TAU_PROOF, TAU_STABLE, BETA_PRIOR_ALPHA0, BETA_PRIOR_BETA0, SURFACE_BUDGET_K, } from "./contracts/weakness-remediation.js";
|
|
12
|
+
export { createReleasePromotionGate, type ReleasePromotionGate, } from "../cli/release-promotion-gate.js";
|
|
13
|
+
import { PublicSurfaceCompressor } from "./public-surface.js";
|
|
14
|
+
import { createProofBundleTrustEngine } from "./proof-bundle-trust.js";
|
|
15
|
+
import { createProviderMaturityGate } from "./provider-maturity-gate.js";
|
|
16
|
+
import { createRouterV2ScoringEngine } from "./router-v2-scoring.js";
|
|
17
|
+
import { createReleasePromotionGate } from "../cli/release-promotion-gate.js";
|
|
18
|
+
import { createAdvancedControlLoop } from "./advanced-control-loop.js";
|
|
19
|
+
export interface WeaknessRemediationIndex {
|
|
20
|
+
readonly publicSurfaceCompressor: PublicSurfaceCompressor;
|
|
21
|
+
readonly proofBundleTrustEngine: ReturnType<typeof createProofBundleTrustEngine>;
|
|
22
|
+
readonly providerMaturityGate: ReturnType<typeof createProviderMaturityGate>;
|
|
23
|
+
readonly routerV2ScoringEngine: ReturnType<typeof createRouterV2ScoringEngine>;
|
|
24
|
+
readonly releasePromotionGate: ReturnType<typeof createReleasePromotionGate>;
|
|
25
|
+
readonly advancedControlLoop: ReturnType<typeof createAdvancedControlLoop>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createWeaknessRemediationIndex(): WeaknessRemediationIndex;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weakness Remediation Index — Public factory that instantiates all
|
|
3
|
+
* Phase 1–6 engines with sensible defaults.
|
|
4
|
+
*/
|
|
5
|
+
export { createAdvancedControlLoop, } from "./advanced-control-loop.js";
|
|
6
|
+
export { computeSurfaceScore, enforceFlowInvariant, PublicSurfaceCompressor, } from "./public-surface.js";
|
|
7
|
+
export { createProofBundleTrustEngine, } from "./proof-bundle-trust.js";
|
|
8
|
+
export { createProviderMaturityGate, } from "./provider-maturity-gate.js";
|
|
9
|
+
export { createRouterV2ScoringEngine, } from "./router-v2-scoring.js";
|
|
10
|
+
export { RELEASE_GATE_WEIGHTS, TAU_EVIDENCE, TAU_EVIDENCE_HIGH, TAU_PROOF, TAU_STABLE, BETA_PRIOR_ALPHA0, BETA_PRIOR_BETA0, SURFACE_BUDGET_K, } from "./contracts/weakness-remediation.js";
|
|
11
|
+
export { createReleasePromotionGate, } from "../cli/release-promotion-gate.js";
|
|
12
|
+
// ─── Convenience factory ─────────────────────────────────────────────────────
|
|
13
|
+
import { PublicSurfaceCompressor } from "./public-surface.js";
|
|
14
|
+
import { createProofBundleTrustEngine } from "./proof-bundle-trust.js";
|
|
15
|
+
import { createProviderMaturityGate } from "./provider-maturity-gate.js";
|
|
16
|
+
import { createRouterV2ScoringEngine } from "./router-v2-scoring.js";
|
|
17
|
+
import { createReleasePromotionGate } from "../cli/release-promotion-gate.js";
|
|
18
|
+
import { createAdvancedControlLoop } from "./advanced-control-loop.js";
|
|
19
|
+
export function createWeaknessRemediationIndex() {
|
|
20
|
+
const publicSurfaceCompressor = new PublicSurfaceCompressor();
|
|
21
|
+
const proofBundleTrustEngine = createProofBundleTrustEngine();
|
|
22
|
+
const providerMaturityGate = createProviderMaturityGate();
|
|
23
|
+
const routerV2ScoringEngine = createRouterV2ScoringEngine();
|
|
24
|
+
const releasePromotionGate = createReleasePromotionGate();
|
|
25
|
+
const advancedControlLoop = createAdvancedControlLoop({
|
|
26
|
+
releaseGate: releasePromotionGate,
|
|
27
|
+
releaseGateEnabled: true,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
publicSurfaceCompressor,
|
|
31
|
+
proofBundleTrustEngine,
|
|
32
|
+
providerMaturityGate,
|
|
33
|
+
routerV2ScoringEngine,
|
|
34
|
+
releasePromotionGate,
|
|
35
|
+
advancedControlLoop,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -16,29 +16,29 @@ export declare const ProofBundleFilesSchema: z.ZodObject<{
|
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
17
|
commands: string;
|
|
18
18
|
rawPrompt: string;
|
|
19
|
-
|
|
19
|
+
limitations: string;
|
|
20
20
|
decisionsJsonl: string;
|
|
21
|
-
runManifest: string;
|
|
22
21
|
evidenceJsonl: string;
|
|
23
|
-
|
|
22
|
+
verifyJson: string;
|
|
23
|
+
runManifest: string;
|
|
24
24
|
stdout?: string | undefined;
|
|
25
25
|
stderr?: string | undefined;
|
|
26
26
|
replay?: string | undefined;
|
|
27
|
-
diffPatch?: string | undefined;
|
|
28
27
|
inspectJson?: string | undefined;
|
|
28
|
+
diffPatch?: string | undefined;
|
|
29
29
|
}, {
|
|
30
30
|
commands: string;
|
|
31
31
|
rawPrompt: string;
|
|
32
|
-
|
|
32
|
+
limitations: string;
|
|
33
33
|
decisionsJsonl: string;
|
|
34
|
-
runManifest: string;
|
|
35
34
|
evidenceJsonl: string;
|
|
36
|
-
|
|
35
|
+
verifyJson: string;
|
|
36
|
+
runManifest: string;
|
|
37
37
|
stdout?: string | undefined;
|
|
38
38
|
stderr?: string | undefined;
|
|
39
39
|
replay?: string | undefined;
|
|
40
|
-
diffPatch?: string | undefined;
|
|
41
40
|
inspectJson?: string | undefined;
|
|
41
|
+
diffPatch?: string | undefined;
|
|
42
42
|
}>;
|
|
43
43
|
export declare const ProofBundleSchema: z.ZodObject<{
|
|
44
44
|
schemaVersion: z.ZodLiteral<"omk.proof-bundle.v1">;
|
|
@@ -66,29 +66,29 @@ export declare const ProofBundleSchema: z.ZodObject<{
|
|
|
66
66
|
}, "strip", z.ZodTypeAny, {
|
|
67
67
|
commands: string;
|
|
68
68
|
rawPrompt: string;
|
|
69
|
-
|
|
69
|
+
limitations: string;
|
|
70
70
|
decisionsJsonl: string;
|
|
71
|
-
runManifest: string;
|
|
72
71
|
evidenceJsonl: string;
|
|
73
|
-
|
|
72
|
+
verifyJson: string;
|
|
73
|
+
runManifest: string;
|
|
74
74
|
stdout?: string | undefined;
|
|
75
75
|
stderr?: string | undefined;
|
|
76
76
|
replay?: string | undefined;
|
|
77
|
-
diffPatch?: string | undefined;
|
|
78
77
|
inspectJson?: string | undefined;
|
|
78
|
+
diffPatch?: string | undefined;
|
|
79
79
|
}, {
|
|
80
80
|
commands: string;
|
|
81
81
|
rawPrompt: string;
|
|
82
|
-
|
|
82
|
+
limitations: string;
|
|
83
83
|
decisionsJsonl: string;
|
|
84
|
-
runManifest: string;
|
|
85
84
|
evidenceJsonl: string;
|
|
86
|
-
|
|
85
|
+
verifyJson: string;
|
|
86
|
+
runManifest: string;
|
|
87
87
|
stdout?: string | undefined;
|
|
88
88
|
stderr?: string | undefined;
|
|
89
89
|
replay?: string | undefined;
|
|
90
|
-
diffPatch?: string | undefined;
|
|
91
90
|
inspectJson?: string | undefined;
|
|
91
|
+
diffPatch?: string | undefined;
|
|
92
92
|
}>;
|
|
93
93
|
verdict: z.ZodEnum<["passed", "failed", "partial"]>;
|
|
94
94
|
knownLimitations: z.ZodArray<z.ZodString, "many">;
|
|
@@ -101,21 +101,21 @@ export declare const ProofBundleSchema: z.ZodObject<{
|
|
|
101
101
|
files: {
|
|
102
102
|
commands: string;
|
|
103
103
|
rawPrompt: string;
|
|
104
|
-
|
|
104
|
+
limitations: string;
|
|
105
105
|
decisionsJsonl: string;
|
|
106
|
-
runManifest: string;
|
|
107
106
|
evidenceJsonl: string;
|
|
108
|
-
|
|
107
|
+
verifyJson: string;
|
|
108
|
+
runManifest: string;
|
|
109
109
|
stdout?: string | undefined;
|
|
110
110
|
stderr?: string | undefined;
|
|
111
111
|
replay?: string | undefined;
|
|
112
|
-
diffPatch?: string | undefined;
|
|
113
112
|
inspectJson?: string | undefined;
|
|
113
|
+
diffPatch?: string | undefined;
|
|
114
114
|
};
|
|
115
115
|
providerPolicy: string;
|
|
116
116
|
omkVersion: string;
|
|
117
|
-
runtimeVersion: "v1.2";
|
|
118
117
|
proofId: string;
|
|
118
|
+
runtimeVersion: "v1.2";
|
|
119
119
|
scenario: "no-kimi-smoke" | "evidence-block" | "fallback-route" | "dag-dependent-block" | "replay-inspect" | "example-generation" | "doctor-provider" | "native-safety" | "contract-version-smoke";
|
|
120
120
|
verdict: "failed" | "partial" | "passed";
|
|
121
121
|
knownLimitations: string[];
|
|
@@ -128,21 +128,21 @@ export declare const ProofBundleSchema: z.ZodObject<{
|
|
|
128
128
|
files: {
|
|
129
129
|
commands: string;
|
|
130
130
|
rawPrompt: string;
|
|
131
|
-
|
|
131
|
+
limitations: string;
|
|
132
132
|
decisionsJsonl: string;
|
|
133
|
-
runManifest: string;
|
|
134
133
|
evidenceJsonl: string;
|
|
135
|
-
|
|
134
|
+
verifyJson: string;
|
|
135
|
+
runManifest: string;
|
|
136
136
|
stdout?: string | undefined;
|
|
137
137
|
stderr?: string | undefined;
|
|
138
138
|
replay?: string | undefined;
|
|
139
|
-
diffPatch?: string | undefined;
|
|
140
139
|
inspectJson?: string | undefined;
|
|
140
|
+
diffPatch?: string | undefined;
|
|
141
141
|
};
|
|
142
142
|
providerPolicy: string;
|
|
143
143
|
omkVersion: string;
|
|
144
|
-
runtimeVersion: "v1.2";
|
|
145
144
|
proofId: string;
|
|
145
|
+
runtimeVersion: "v1.2";
|
|
146
146
|
scenario: "no-kimi-smoke" | "evidence-block" | "fallback-route" | "dag-dependent-block" | "replay-inspect" | "example-generation" | "doctor-provider" | "native-safety" | "contract-version-smoke";
|
|
147
147
|
verdict: "failed" | "partial" | "passed";
|
|
148
148
|
knownLimitations: string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform clipboard image reader.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the platform-specific clipboard reading from screenshot-store patterns
|
|
5
|
+
* into a reusable utility for the chat REPL, goal commands, and any input
|
|
6
|
+
* surface that needs Ctrl+V / paste image support.
|
|
7
|
+
*
|
|
8
|
+
* Platforms:
|
|
9
|
+
* - macOS: `pngpaste -` (brew) or `osascript` with TIFF→PNG conversion
|
|
10
|
+
* - Linux: `xclip -selection clipboard -target image/png`
|
|
11
|
+
* - Windows: PowerShell System.Windows.Forms.Clipboard
|
|
12
|
+
*
|
|
13
|
+
* Output: PNG Buffer + saved file path under .omk/screenshots/
|
|
14
|
+
*/
|
|
15
|
+
export declare const SCREENSHOT_DIR = ".omk/screenshots";
|
|
16
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
17
|
+
export interface ClipboardImage {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
/** Absolute path to the saved PNG/JPG/WebP/GIF file. */
|
|
20
|
+
path?: string;
|
|
21
|
+
/** Project-relative path (e.g. .omk/screenshots/2026-06-08/screenshot-....png). */
|
|
22
|
+
relativePath?: string;
|
|
23
|
+
/** Base64 data URI suitable for wire protocol image_url. */
|
|
24
|
+
dataUri?: string;
|
|
25
|
+
/** Base64 raw (no prefix). */
|
|
26
|
+
base64?: string;
|
|
27
|
+
/** Detected extension: png, jpg, webp, gif. */
|
|
28
|
+
ext?: string;
|
|
29
|
+
/** Error message when ok=false. */
|
|
30
|
+
error?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function detectImageExt(buf: Buffer): string | null;
|
|
33
|
+
export declare function toDataUri(base64: string, ext: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Read an image from the system clipboard. Returns null if clipboard is empty
|
|
36
|
+
* or contains no image. Platform-specific: macOS (pngpaste/osascript), Linux
|
|
37
|
+
* (xclip/wl-paste), Windows (PowerShell).
|
|
38
|
+
*/
|
|
39
|
+
export declare function readClipboardImage(platform?: NodeJS.Platform): Buffer | null;
|
|
40
|
+
/**
|
|
41
|
+
* Read clipboard image, validate, save to .omk/screenshots/, and return
|
|
42
|
+
* both the file path and base64 data URI for wire protocol use.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pasteClipboardImage(projectRoot: string): ClipboardImage;
|
|
45
|
+
/**
|
|
46
|
+
* Read an image file from disk, validate, and return base64 data URI.
|
|
47
|
+
* Used for --image <file> flag support.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readImageFile(filePath: string): ClipboardImage;
|