open-multi-agent-kit 0.78.1 → 0.78.3
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 +37 -0
- package/MATURITY.md +4 -0
- package/README.md +70 -1
- package/dist/benchmark/contracts.d.ts +116 -0
- package/dist/benchmark/contracts.js +6 -0
- package/dist/benchmark/fixtures.d.ts +11 -0
- package/dist/benchmark/fixtures.js +121 -0
- package/dist/benchmark/harness.d.ts +13 -0
- package/dist/benchmark/harness.js +191 -0
- package/dist/benchmark/shadow-mode.d.ts +17 -0
- package/dist/benchmark/shadow-mode.js +96 -0
- 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/commands/merge.js +102 -56
- package/dist/contracts/interview.d.ts +106 -0
- package/dist/contracts/interview.js +9 -0
- package/dist/contracts/provider-health.d.ts +37 -0
- package/dist/contracts/provider-health.js +49 -1
- package/dist/evidence/evidence-trust-score.d.ts +101 -0
- package/dist/evidence/evidence-trust-score.js +408 -0
- package/dist/evidence/index.d.ts +6 -0
- package/dist/evidence/index.js +3 -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/orchestration/merge-arbiter.d.ts +91 -0
- package/dist/orchestration/merge-arbiter.js +376 -0
- package/dist/providers/health.d.ts +3 -0
- package/dist/providers/health.js +46 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/provider-health.d.ts +8 -1
- package/dist/providers/provider-health.js +39 -0
- package/dist/providers/provider-task-runner.js +31 -0
- package/dist/providers/provider.d.ts +2 -0
- package/dist/providers/router.js +87 -3
- package/dist/providers/types.d.ts +4 -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 +43 -0
- package/dist/runtime/provider-maturity-gate.js +129 -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/tool-dispatch-contracts.d.ts +24 -3
- package/dist/runtime/tool-dispatch-contracts.js +42 -2
- package/dist/runtime/weakness-remediation-index.d.ts +27 -0
- package/dist/runtime/weakness-remediation-index.js +37 -0
- package/dist/safety/enforcement-engine.d.ts +89 -0
- package/dist/safety/enforcement-engine.js +279 -0
- package/dist/safety/tool-authority-gate.d.ts +40 -0
- package/dist/safety/tool-authority-gate.js +92 -0
- package/dist/schema/evidence.schema.d.ts +2 -2
- package/dist/schema/proof-bundle.schema.d.ts +28 -28
- 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/benchmark-design.md +122 -0
- package/docs/github-organic-promotion.md +127 -0
- package/docs/native-root-runtime-algorithms.md +301 -0
- package/package.json +8 -4
- 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,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy / Sandbox Enforcement Engine v2
|
|
3
|
+
*
|
|
4
|
+
* Capability lattice with conservative policy combination.
|
|
5
|
+
* effectivePolicy = minByAuthority(userPolicy, repoPolicy, providerPolicy, adapterPolicy, riskPolicy)
|
|
6
|
+
*
|
|
7
|
+
* Conservative by default. Any ambiguity → block.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
export const ALL_CAPABILITIES = [
|
|
11
|
+
"read",
|
|
12
|
+
"write",
|
|
13
|
+
"shell",
|
|
14
|
+
"network",
|
|
15
|
+
"secret_read",
|
|
16
|
+
"secret_write",
|
|
17
|
+
"merge",
|
|
18
|
+
"publish",
|
|
19
|
+
];
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Authority ranking (higher = more permissive)
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
const AUTHORITY_RANK = {
|
|
24
|
+
none: 0,
|
|
25
|
+
advisory: 1,
|
|
26
|
+
direct: 2,
|
|
27
|
+
full: 3,
|
|
28
|
+
};
|
|
29
|
+
export function rankOf(level) {
|
|
30
|
+
return AUTHORITY_RANK[level];
|
|
31
|
+
}
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Defaults
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
const DEFAULT_CAPABILITY_LEVEL = "full";
|
|
36
|
+
const DEFAULT_SANDBOX_MODE = "unrestricted";
|
|
37
|
+
const DEFAULT_APPROVAL_POLICY = "yolo";
|
|
38
|
+
export function defaultLattice() {
|
|
39
|
+
return {
|
|
40
|
+
read: DEFAULT_CAPABILITY_LEVEL,
|
|
41
|
+
write: DEFAULT_CAPABILITY_LEVEL,
|
|
42
|
+
shell: DEFAULT_CAPABILITY_LEVEL,
|
|
43
|
+
network: DEFAULT_CAPABILITY_LEVEL,
|
|
44
|
+
secret_read: DEFAULT_CAPABILITY_LEVEL,
|
|
45
|
+
secret_write: DEFAULT_CAPABILITY_LEVEL,
|
|
46
|
+
merge: DEFAULT_CAPABILITY_LEVEL,
|
|
47
|
+
publish: DEFAULT_CAPABILITY_LEVEL,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// minByAuthority — conservative combination
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
/**
|
|
54
|
+
* Combine multiple policy layers by taking the **most restrictive**
|
|
55
|
+
* (minimum) authority level for each capability.
|
|
56
|
+
*
|
|
57
|
+
* If no layer expresses an opinion on a capability, it defaults to "full".
|
|
58
|
+
* If any layer expresses a sandbox mode, the most restrictive mode wins.
|
|
59
|
+
* If any layer expresses an approval policy, the most restrictive wins.
|
|
60
|
+
*/
|
|
61
|
+
export function combinePoliciesByMinAuthority(layers) {
|
|
62
|
+
const base = defaultLattice();
|
|
63
|
+
const activeSources = [];
|
|
64
|
+
// Track the most restrictive values seen so far.
|
|
65
|
+
const lattice = { ...base };
|
|
66
|
+
let sandboxMode = DEFAULT_SANDBOX_MODE;
|
|
67
|
+
let approvalPolicy = DEFAULT_APPROVAL_POLICY;
|
|
68
|
+
for (const layer of layers) {
|
|
69
|
+
activeSources.push(layer.source);
|
|
70
|
+
for (const cap of ALL_CAPABILITIES) {
|
|
71
|
+
const level = layer.lattice[cap];
|
|
72
|
+
if (level !== undefined) {
|
|
73
|
+
if (AUTHORITY_RANK[level] < AUTHORITY_RANK[lattice[cap]]) {
|
|
74
|
+
lattice[cap] = level;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (layer.sandboxMode !== undefined) {
|
|
79
|
+
if (sandboxModeRank(layer.sandboxMode) < sandboxModeRank(sandboxMode)) {
|
|
80
|
+
sandboxMode = layer.sandboxMode;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (layer.approvalPolicy !== undefined) {
|
|
84
|
+
if (approvalPolicyRank(layer.approvalPolicy) < approvalPolicyRank(approvalPolicy)) {
|
|
85
|
+
approvalPolicy = layer.approvalPolicy;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
lattice: lattice,
|
|
91
|
+
sandboxMode,
|
|
92
|
+
approvalPolicy,
|
|
93
|
+
sources: activeSources,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Ranking helpers for sandbox mode and approval policy
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
function sandboxModeRank(mode) {
|
|
100
|
+
switch (mode) {
|
|
101
|
+
case "read-only":
|
|
102
|
+
return 0;
|
|
103
|
+
case "network-isolated":
|
|
104
|
+
return 1;
|
|
105
|
+
case "workspace-write":
|
|
106
|
+
return 2;
|
|
107
|
+
case "unrestricted":
|
|
108
|
+
return 3;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function approvalPolicyRank(policy) {
|
|
112
|
+
switch (policy) {
|
|
113
|
+
case "block":
|
|
114
|
+
return 0;
|
|
115
|
+
case "interactive":
|
|
116
|
+
return 1;
|
|
117
|
+
case "auto":
|
|
118
|
+
return 2;
|
|
119
|
+
case "yolo":
|
|
120
|
+
return 3;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Derive blocked / approval-required capabilities from combined policy
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* Compute the enforcement proof from a combined policy.
|
|
128
|
+
*
|
|
129
|
+
* Rules:
|
|
130
|
+
* 1. read-only sandbox blocks write, shell, network, merge, publish.
|
|
131
|
+
* 2. network-isolated sandbox blocks network.
|
|
132
|
+
* 3. Any capability with level "none" is blocked.
|
|
133
|
+
* 4. Any capability with level "advisory" requires approval.
|
|
134
|
+
* 5. interactive policy requires approval for non-read capabilities.
|
|
135
|
+
* 6. block policy blocks everything except read.
|
|
136
|
+
*/
|
|
137
|
+
export function computeEnforcementProof(combined) {
|
|
138
|
+
const blocked = new Set();
|
|
139
|
+
const approvalRequired = new Set();
|
|
140
|
+
const { lattice, sandboxMode, approvalPolicy, sources } = combined;
|
|
141
|
+
// Sandbox hard floors
|
|
142
|
+
if (sandboxMode === "read-only") {
|
|
143
|
+
for (const cap of ["write", "shell", "network", "merge", "publish", "secret_write"]) {
|
|
144
|
+
blocked.add(cap);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (sandboxMode === "network-isolated") {
|
|
148
|
+
blocked.add("network");
|
|
149
|
+
}
|
|
150
|
+
// Per-capability levels
|
|
151
|
+
for (const cap of ALL_CAPABILITIES) {
|
|
152
|
+
const level = lattice[cap];
|
|
153
|
+
if (level === "none") {
|
|
154
|
+
blocked.add(cap);
|
|
155
|
+
}
|
|
156
|
+
else if (level === "advisory") {
|
|
157
|
+
approvalRequired.add(cap);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Approval policy overrides
|
|
161
|
+
if (approvalPolicy === "block") {
|
|
162
|
+
for (const cap of ALL_CAPABILITIES) {
|
|
163
|
+
if (cap !== "read")
|
|
164
|
+
blocked.add(cap);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else if (approvalPolicy === "interactive") {
|
|
168
|
+
for (const cap of ALL_CAPABILITIES) {
|
|
169
|
+
if (cap !== "read" && !blocked.has(cap)) {
|
|
170
|
+
approvalRequired.add(cap);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else if (approvalPolicy === "yolo") {
|
|
175
|
+
// yolo removes approval requirements (but keeps blocks)
|
|
176
|
+
for (const cap of ALL_CAPABILITIES) {
|
|
177
|
+
approvalRequired.delete(cap);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// auto: advisory-level capabilities still need approval; full = allow
|
|
181
|
+
// (approvalRequired already contains advisory-level caps)
|
|
182
|
+
const blockedCapabilities = ALL_CAPABILITIES.filter((c) => blocked.has(c));
|
|
183
|
+
const approvalRequiredCapabilities = ALL_CAPABILITIES.filter((c) => approvalRequired.has(c) && !blocked.has(c));
|
|
184
|
+
return {
|
|
185
|
+
sandboxMode,
|
|
186
|
+
enforcedBy: [...sources],
|
|
187
|
+
blockedCapabilities,
|
|
188
|
+
approvalRequired: approvalRequiredCapabilities,
|
|
189
|
+
policyHash: hashCombinedPolicy(combined),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
// Policy hash (deterministic, no secrets)
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
function hashCombinedPolicy(combined) {
|
|
196
|
+
const payload = JSON.stringify({
|
|
197
|
+
lattice: combined.lattice,
|
|
198
|
+
sandboxMode: combined.sandboxMode,
|
|
199
|
+
approvalPolicy: combined.approvalPolicy,
|
|
200
|
+
sources: combined.sources,
|
|
201
|
+
});
|
|
202
|
+
return createHash("sha256").update(payload).digest("hex").slice(0, 16);
|
|
203
|
+
}
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Adapter enforcement check
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
/**
|
|
208
|
+
* Returns true when the runtime/adapter has provided a valid enforcement proof.
|
|
209
|
+
* Runtimes without enforcement proof cannot enter authority lanes.
|
|
210
|
+
*/
|
|
211
|
+
export function hasValidEnforcementProof(proof) {
|
|
212
|
+
if (typeof proof !== "object" || proof === null)
|
|
213
|
+
return false;
|
|
214
|
+
const p = proof;
|
|
215
|
+
if (typeof p.policyHash !== "string" || p.policyHash.length === 0)
|
|
216
|
+
return false;
|
|
217
|
+
if (!Array.isArray(p.enforcedBy) || p.enforcedBy.length === 0)
|
|
218
|
+
return false;
|
|
219
|
+
if (!Array.isArray(p.blockedCapabilities))
|
|
220
|
+
return false;
|
|
221
|
+
if (!Array.isArray(p.approvalRequired))
|
|
222
|
+
return false;
|
|
223
|
+
if (!isSandboxMode(p.sandboxMode))
|
|
224
|
+
return false;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function isSandboxMode(v) {
|
|
228
|
+
return v === "read-only" || v === "workspace-write" || v === "network-isolated" || v === "unrestricted";
|
|
229
|
+
}
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
// Convenience: build a PolicyLayer from legacy authority levels
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
export function policyLayerFromLegacyAuthorities(source, options) {
|
|
234
|
+
const lattice = {};
|
|
235
|
+
if (options.writeAuthority) {
|
|
236
|
+
lattice.write = options.writeAuthority;
|
|
237
|
+
lattice.merge = options.writeAuthority;
|
|
238
|
+
lattice.publish = options.writeAuthority;
|
|
239
|
+
}
|
|
240
|
+
if (options.shellAuthority) {
|
|
241
|
+
lattice.shell = options.shellAuthority;
|
|
242
|
+
lattice.merge = minLevel(lattice.merge, options.shellAuthority);
|
|
243
|
+
lattice.publish = minLevel(lattice.publish, options.shellAuthority);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
source,
|
|
247
|
+
lattice,
|
|
248
|
+
sandboxMode: options.sandboxMode,
|
|
249
|
+
approvalPolicy: options.approvalPolicy,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function minLevel(a, b) {
|
|
253
|
+
if (a === undefined)
|
|
254
|
+
return b;
|
|
255
|
+
return AUTHORITY_RANK[a] <= AUTHORITY_RANK[b] ? a : b;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Map a capability-lattice capability to the coarse ToolOp used by the gate.
|
|
259
|
+
* This preserves backward compatibility with the existing 4-class gate while
|
|
260
|
+
* allowing the new lattice to express finer-grained restrictions.
|
|
261
|
+
*/
|
|
262
|
+
export function capabilityToToolOp(cap) {
|
|
263
|
+
switch (cap) {
|
|
264
|
+
case "read":
|
|
265
|
+
return "read";
|
|
266
|
+
case "write":
|
|
267
|
+
case "publish":
|
|
268
|
+
return "write";
|
|
269
|
+
case "shell":
|
|
270
|
+
return "shell";
|
|
271
|
+
case "merge":
|
|
272
|
+
return "merge";
|
|
273
|
+
case "network":
|
|
274
|
+
return "network";
|
|
275
|
+
case "secret_read":
|
|
276
|
+
case "secret_write":
|
|
277
|
+
return "secret";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -60,3 +60,43 @@ export declare function mapToolNameToOp(toolName: string): ToolOp;
|
|
|
60
60
|
* @see ToolAuthorityContext for the decision inputs and ordering rules.
|
|
61
61
|
*/
|
|
62
62
|
export declare function decideToolAuthority(ctx: ToolAuthorityContext): ToolAuthorityDecision;
|
|
63
|
+
import type { CapabilityLattice, CapabilityLevel, EnforcementProof, SandboxCapability } from "./enforcement-engine.js";
|
|
64
|
+
/**
|
|
65
|
+
* Extended operation class for v2 gate.
|
|
66
|
+
* Adds "network" and "secret" ops so the lattice can express finer
|
|
67
|
+
* restrictions without weakening the existing 4-class gate.
|
|
68
|
+
*/
|
|
69
|
+
export type ToolOpV2 = ToolOp | "network" | "secret";
|
|
70
|
+
/** Authority context enriched with enforcement proof. */
|
|
71
|
+
export interface ToolAuthorityContextV2 extends ToolAuthorityContext {
|
|
72
|
+
/** v2 enforcement proof — required for authority lanes. */
|
|
73
|
+
readonly enforcementProof?: EnforcementProof;
|
|
74
|
+
/** Full capability lattice when available. */
|
|
75
|
+
readonly lattice?: Readonly<CapabilityLattice>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Derive the effective capability level for a tool operation from the lattice.
|
|
79
|
+
*/
|
|
80
|
+
export declare function toolOpToCapability(op: ToolOpV2): SandboxCapability;
|
|
81
|
+
/**
|
|
82
|
+
* Build a ToolAuthorityContext from an enforcement proof.
|
|
83
|
+
* Bridges the v2 lattice into the legacy gate.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildToolAuthorityContextFromProof(op: ToolOpV2, proof: EnforcementProof, tty: boolean): ToolAuthorityContext;
|
|
86
|
+
/**
|
|
87
|
+
* Decide using v2 enforcement proof when available, else fall back to legacy.
|
|
88
|
+
*/
|
|
89
|
+
export declare function decideToolAuthorityV2(ctx: ToolAuthorityContextV2): ToolAuthorityDecision;
|
|
90
|
+
/**
|
|
91
|
+
* Pure v2 capability check.
|
|
92
|
+
*/
|
|
93
|
+
export declare function effectiveCapabilityLevel(cap: SandboxCapability, lattice?: Readonly<CapabilityLattice>): CapabilityLevel;
|
|
94
|
+
/**
|
|
95
|
+
* Adapter-enforced capability resolution.
|
|
96
|
+
* Runtimes without enforcement proof cannot enter authority lanes.
|
|
97
|
+
*/
|
|
98
|
+
export declare function isOperationAllowedByProof(op: ToolOpV2, proof: EnforcementProof | undefined): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Returns true when the operation requires explicit approval per the proof.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isOperationApprovalRequiredByProof(op: ToolOpV2, proof: EnforcementProof | undefined): boolean;
|
|
@@ -106,3 +106,95 @@ export function decideToolAuthority(ctx) {
|
|
|
106
106
|
// interactive: ask only when a TTY is attached; non-TTY ask = deny-by-default.
|
|
107
107
|
return ctx.tty ? "ask" : "block";
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Derive the effective capability level for a tool operation from the lattice.
|
|
111
|
+
*/
|
|
112
|
+
export function toolOpToCapability(op) {
|
|
113
|
+
switch (op) {
|
|
114
|
+
case "read":
|
|
115
|
+
return "read";
|
|
116
|
+
case "write":
|
|
117
|
+
return "write";
|
|
118
|
+
case "shell":
|
|
119
|
+
return "shell";
|
|
120
|
+
case "merge":
|
|
121
|
+
return "merge";
|
|
122
|
+
case "network":
|
|
123
|
+
return "network";
|
|
124
|
+
case "secret":
|
|
125
|
+
return "secret_write";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a ToolAuthorityContext from an enforcement proof.
|
|
130
|
+
* Bridges the v2 lattice into the legacy gate.
|
|
131
|
+
*/
|
|
132
|
+
export function buildToolAuthorityContextFromProof(op, proof, tty) {
|
|
133
|
+
const cap = toolOpToCapability(op);
|
|
134
|
+
const blocked = proof.blockedCapabilities.includes(cap);
|
|
135
|
+
const approvalPolicy = blocked
|
|
136
|
+
? "block"
|
|
137
|
+
: proof.approvalRequired.includes(cap)
|
|
138
|
+
? "interactive"
|
|
139
|
+
: "auto";
|
|
140
|
+
const writeBlocked = proof.blockedCapabilities.includes("write") || proof.blockedCapabilities.includes("publish");
|
|
141
|
+
const shellBlocked = proof.blockedCapabilities.includes("shell");
|
|
142
|
+
const writeApproval = proof.approvalRequired.includes("write") || proof.approvalRequired.includes("publish");
|
|
143
|
+
const shellApproval = proof.approvalRequired.includes("shell");
|
|
144
|
+
const writeAuthority = writeBlocked
|
|
145
|
+
? "none"
|
|
146
|
+
: writeApproval
|
|
147
|
+
? "advisory"
|
|
148
|
+
: "full";
|
|
149
|
+
const shellAuthority = shellBlocked
|
|
150
|
+
? "none"
|
|
151
|
+
: shellApproval
|
|
152
|
+
? "advisory"
|
|
153
|
+
: "full";
|
|
154
|
+
const sandboxMode = proof.sandboxMode === "read-only" ? "read-only" : "workspace-write";
|
|
155
|
+
return {
|
|
156
|
+
op: op === "network" || op === "secret" ? "shell" : op,
|
|
157
|
+
writeAuthority,
|
|
158
|
+
shellAuthority,
|
|
159
|
+
approvalPolicy,
|
|
160
|
+
sandboxMode,
|
|
161
|
+
tty,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Decide using v2 enforcement proof when available, else fall back to legacy.
|
|
166
|
+
*/
|
|
167
|
+
export function decideToolAuthorityV2(ctx) {
|
|
168
|
+
if (ctx.enforcementProof) {
|
|
169
|
+
const legacyCtx = buildToolAuthorityContextFromProof(ctx.op, ctx.enforcementProof, ctx.tty);
|
|
170
|
+
return decideToolAuthority(legacyCtx);
|
|
171
|
+
}
|
|
172
|
+
return decideToolAuthority(ctx);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Pure v2 capability check.
|
|
176
|
+
*/
|
|
177
|
+
export function effectiveCapabilityLevel(cap, lattice) {
|
|
178
|
+
if (!lattice)
|
|
179
|
+
return "full";
|
|
180
|
+
return lattice[cap] ?? "full";
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Adapter-enforced capability resolution.
|
|
184
|
+
* Runtimes without enforcement proof cannot enter authority lanes.
|
|
185
|
+
*/
|
|
186
|
+
export function isOperationAllowedByProof(op, proof) {
|
|
187
|
+
if (!proof)
|
|
188
|
+
return false;
|
|
189
|
+
const cap = toolOpToCapability(op);
|
|
190
|
+
return !proof.blockedCapabilities.includes(cap);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns true when the operation requires explicit approval per the proof.
|
|
194
|
+
*/
|
|
195
|
+
export function isOperationApprovalRequiredByProof(op, proof) {
|
|
196
|
+
if (!proof)
|
|
197
|
+
return true;
|
|
198
|
+
const cap = toolOpToCapability(op);
|
|
199
|
+
return proof.approvalRequired.includes(cap);
|
|
200
|
+
}
|
|
@@ -14,7 +14,7 @@ export declare const EvidenceRecordSchema: z.ZodObject<{
|
|
|
14
14
|
observedAt: z.ZodString;
|
|
15
15
|
message: z.ZodOptional<z.ZodString>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
status: "failed" | "skipped" | "
|
|
17
|
+
status: "failed" | "skipped" | "missing" | "blocked" | "passed";
|
|
18
18
|
kind: "file-exists" | "custom" | "summary-present" | "command-passes" | "git-diff-non-empty" | "marker-present" | "screenshot-present";
|
|
19
19
|
required: boolean;
|
|
20
20
|
runId: string;
|
|
@@ -27,7 +27,7 @@ export declare const EvidenceRecordSchema: z.ZodObject<{
|
|
|
27
27
|
path?: string | undefined;
|
|
28
28
|
nodeId?: string | undefined;
|
|
29
29
|
}, {
|
|
30
|
-
status: "failed" | "skipped" | "
|
|
30
|
+
status: "failed" | "skipped" | "missing" | "blocked" | "passed";
|
|
31
31
|
kind: "file-exists" | "custom" | "summary-present" | "command-passes" | "git-diff-non-empty" | "marker-present" | "screenshot-present";
|
|
32
32
|
required: boolean;
|
|
33
33
|
runId: string;
|
|
@@ -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,23 +101,23 @@ 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
|
-
|
|
117
|
+
verdict: "failed" | "partial" | "passed";
|
|
118
118
|
proofId: string;
|
|
119
|
+
runtimeVersion: "v1.2";
|
|
119
120
|
scenario: "no-kimi-smoke" | "evidence-block" | "fallback-route" | "dag-dependent-block" | "replay-inspect" | "example-generation" | "doctor-provider" | "native-safety" | "contract-version-smoke";
|
|
120
|
-
verdict: "failed" | "partial" | "passed";
|
|
121
121
|
knownLimitations: string[];
|
|
122
122
|
checksums: Record<string, string>;
|
|
123
123
|
}, {
|
|
@@ -128,23 +128,23 @@ 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
|
-
|
|
144
|
+
verdict: "failed" | "partial" | "passed";
|
|
145
145
|
proofId: string;
|
|
146
|
+
runtimeVersion: "v1.2";
|
|
146
147
|
scenario: "no-kimi-smoke" | "evidence-block" | "fallback-route" | "dag-dependent-block" | "replay-inspect" | "example-generation" | "doctor-provider" | "native-safety" | "contract-version-smoke";
|
|
147
|
-
verdict: "failed" | "partial" | "passed";
|
|
148
148
|
knownLimitations: string[];
|
|
149
149
|
checksums: Record<string, string>;
|
|
150
150
|
}>;
|
|
@@ -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;
|