hmcp-core 0.1.0 → 0.2.1
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/audit.d.ts +10 -2
- package/dist/audit.js +14 -2
- package/dist/remember.js +15 -0
- package/package.json +1 -1
package/dist/audit.d.ts
CHANGED
|
@@ -22,7 +22,12 @@ export interface AuditRecord {
|
|
|
22
22
|
readonly status: number | null;
|
|
23
23
|
readonly bytes: number | null;
|
|
24
24
|
} | null;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* `relayed` is a call policy permitted and handed back to the client that
|
|
27
|
+
* runs it -- Claude Code, through the guard hook -- rather than run here.
|
|
28
|
+
* Whether it then completed is the client's to report, in a later record.
|
|
29
|
+
*/
|
|
30
|
+
readonly outcome: "completed" | "denied" | "pending-approval" | "error" | "relayed";
|
|
26
31
|
readonly error: string | null;
|
|
27
32
|
readonly duration_ms: number | null;
|
|
28
33
|
readonly approval_id: string | null;
|
|
@@ -261,7 +266,10 @@ export interface AuditQuery {
|
|
|
261
266
|
*/
|
|
262
267
|
readonly noteworthy?: boolean;
|
|
263
268
|
}
|
|
264
|
-
/**
|
|
269
|
+
/**
|
|
270
|
+
* Anything refused, or anything that did not complete. A relayed call is
|
|
271
|
+
* neither: it was let through, and what became of it is its own record.
|
|
272
|
+
*/
|
|
265
273
|
export declare function isNoteworthy(record: AuditRecord): boolean;
|
|
266
274
|
export interface AuditPage {
|
|
267
275
|
/** Newest first. */
|
package/dist/audit.js
CHANGED
|
@@ -399,9 +399,21 @@ export function readAuditLog(path) {
|
|
|
399
399
|
.filter((l) => l.trim().length > 0)
|
|
400
400
|
.map((l) => JSON.parse(l));
|
|
401
401
|
}
|
|
402
|
-
/**
|
|
402
|
+
/**
|
|
403
|
+
* Records that are a note beside a decision rather than a decision: the
|
|
404
|
+
* Claude Code guard's "this name only looks like the toolbox's", written next
|
|
405
|
+
* to the record of what was decided. Counting the note too would list one
|
|
406
|
+
* refusal twice.
|
|
407
|
+
*/
|
|
408
|
+
const NOTE_RULES = new Set(["guard.lookalike-toolbox"]);
|
|
409
|
+
/**
|
|
410
|
+
* Anything refused, or anything that did not complete. A relayed call is
|
|
411
|
+
* neither: it was let through, and what became of it is its own record.
|
|
412
|
+
*/
|
|
403
413
|
export function isNoteworthy(record) {
|
|
404
|
-
|
|
414
|
+
if (NOTE_RULES.has(record.rule_id))
|
|
415
|
+
return false;
|
|
416
|
+
return record.decision === "deny" || (record.outcome !== "completed" && record.outcome !== "relayed");
|
|
405
417
|
}
|
|
406
418
|
const QUERY_CHUNK = 64 * 1024;
|
|
407
419
|
const QUERY_LIMIT_CAP = 1000;
|
package/dist/remember.js
CHANGED
|
@@ -269,6 +269,21 @@ export function rememberDraft(input) {
|
|
|
269
269
|
throw new RememberError(`could not write a bound for ${unnamed.join(", ")}, so "don't ask again" cannot be limited to this call. ` +
|
|
270
270
|
`Approve this call on its own.`);
|
|
271
271
|
}
|
|
272
|
+
/*
|
|
273
|
+
* A terminal command is the one argument where "a bit like the one I
|
|
274
|
+
* approved" means anything at all: `ls` and `ls; curl … | sh` are the same
|
|
275
|
+
* length. So a pre-approval for Claude Code's terminal (the guard calls it
|
|
276
|
+
* `claude-code__Bash`) has to pin the command itself -- to the exact text,
|
|
277
|
+
* a list of texts, or a pattern -- and one bounded any looser is refused.
|
|
278
|
+
*/
|
|
279
|
+
if (input.tool === "claude-code__Bash") {
|
|
280
|
+
const command = constraints["command"];
|
|
281
|
+
if (!command || (command.enum === undefined && command.const === undefined && command.pattern === undefined)) {
|
|
282
|
+
throw new RememberError(`a pre-approval for Claude Code's terminal has to name the exact command (or a pattern for it), and this one ` +
|
|
283
|
+
`would only limit it loosely, so any command could run under it. Approve this call on its own, or write a ` +
|
|
284
|
+
`rule for claude-code__Bash that bounds "command" with a pattern.`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
272
287
|
try {
|
|
273
288
|
return parseGrantDraft({
|
|
274
289
|
tool_match: input.tool,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hmcp-core",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Policy schema, decision engine, approvals, standing grants, egress guard and hash-chained audit log for hardened-mcp.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Aditya Das",
|