@kya-os/consent 0.1.47 → 0.1.48
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/README.md +89 -0
- package/dist/bundle/index.d.ts +2 -0
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/capabilities/registry.d.ts.map +1 -1
- package/dist/capabilities/registry.js +5 -1
- package/dist/capabilities/registry.js.map +1 -1
- package/dist/cedar/compile.d.ts +67 -2
- package/dist/cedar/compile.d.ts.map +1 -1
- package/dist/cedar/compile.js +34 -5
- package/dist/cedar/compile.js.map +1 -1
- package/dist/cedar/index.d.ts +1 -0
- package/dist/cedar/index.d.ts.map +1 -1
- package/dist/cedar/index.js.map +1 -1
- package/dist/cjs/bundle/index.js +3 -1
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/capabilities/registry.js +5 -1
- package/dist/cjs/capabilities/registry.js.map +1 -1
- package/dist/cjs/cedar/compile.js +34 -5
- package/dist/cjs/cedar/compile.js.map +1 -1
- package/dist/cjs/cedar/index.js.map +1 -1
- package/dist/cjs/components/consent-action-bar.js +16 -5
- package/dist/cjs/components/consent-action-bar.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +92 -37
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-capability-card.js +35 -4
- package/dist/cjs/components/consent-capability-card.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +37 -27
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/constants/capabilities.js +10 -0
- package/dist/cjs/constants/capabilities.js.map +1 -0
- package/dist/cjs/constants/index.js +3 -1
- package/dist/cjs/constants/index.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/resolution/credential-capabilities.js.map +1 -1
- package/dist/cjs/resolution/selected-capabilities.js +73 -0
- package/dist/cjs/resolution/selected-capabilities.js.map +1 -0
- package/dist/cjs/schemas/capabilities.schemas.js +14 -2
- package/dist/cjs/schemas/capabilities.schemas.js.map +1 -1
- package/dist/cjs/types/capabilities.types.js +55 -0
- package/dist/cjs/types/capabilities.types.js.map +1 -1
- package/dist/components/consent-action-bar.d.ts +2 -0
- package/dist/components/consent-action-bar.d.ts.map +1 -1
- package/dist/components/consent-action-bar.js +16 -5
- package/dist/components/consent-action-bar.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +18 -5
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +92 -37
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-capability-card.d.ts +2 -0
- package/dist/components/consent-capability-card.d.ts.map +1 -1
- package/dist/components/consent-capability-card.js +35 -4
- package/dist/components/consent-capability-card.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +3 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +37 -27
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +221 -46
- package/dist/consent.min.js +193 -146
- package/dist/constants/capabilities.d.ts +7 -0
- package/dist/constants/capabilities.d.ts.map +1 -0
- package/dist/constants/capabilities.js +7 -0
- package/dist/constants/capabilities.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/resolution/credential-capabilities.d.ts +2 -2
- package/dist/resolution/credential-capabilities.d.ts.map +1 -1
- package/dist/resolution/credential-capabilities.js.map +1 -1
- package/dist/resolution/selected-capabilities.d.ts +26 -0
- package/dist/resolution/selected-capabilities.d.ts.map +1 -0
- package/dist/resolution/selected-capabilities.js +69 -0
- package/dist/resolution/selected-capabilities.js.map +1 -0
- package/dist/schemas/api.schemas.d.ts +88 -68
- package/dist/schemas/api.schemas.d.ts.map +1 -1
- package/dist/schemas/branding.schemas.d.ts +2 -2
- package/dist/schemas/capabilities.schemas.d.ts +58 -12
- package/dist/schemas/capabilities.schemas.d.ts.map +1 -1
- package/dist/schemas/capabilities.schemas.js +14 -2
- package/dist/schemas/capabilities.schemas.js.map +1 -1
- package/dist/schemas/config.schemas.d.ts +140 -100
- package/dist/schemas/config.schemas.d.ts.map +1 -1
- package/dist/types/capabilities.types.d.ts +69 -0
- package/dist/types/capabilities.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.js +53 -1
- package/dist/types/capabilities.types.js.map +1 -1
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/config.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAgB9D;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa1B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAQ7B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAC;AAEH,M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C,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAEvE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAE9D"}
|
|
@@ -10,8 +10,69 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Risk classification for a capability. Used to surface the amber `HIGHER RISK`
|
|
12
12
|
* chip on capability rows when riskLevel is `high` or `critical`.
|
|
13
|
+
*
|
|
14
|
+
* Name collision, not a shared type: `kya-os-mcp`'s agent-reputation gate
|
|
15
|
+
* (`kya-os-mcp/src/auth/handshake.ts`, `AgentReputation.riskLevel`) has its
|
|
16
|
+
* own field of the same name for a different question, "how risky is this
|
|
17
|
+
* agent's reputation" rather than "how risky is this capability grant", and
|
|
18
|
+
* its members don't match this union:
|
|
19
|
+
*
|
|
20
|
+
* value | this RiskLevel (capability) | kya-os-mcp riskLevel (reputation)
|
|
21
|
+
* ----------- | ---------------------------- | ----------------------------------
|
|
22
|
+
* "low" | yes | yes
|
|
23
|
+
* "medium" | yes | yes
|
|
24
|
+
* "high" | yes | yes
|
|
25
|
+
* "critical" | yes | no
|
|
26
|
+
* "unknown" | no | yes
|
|
27
|
+
*
|
|
28
|
+
* TypeScript's structural union check catches a straight mismatch at a
|
|
29
|
+
* typed call site, but that protection disappears the moment either value
|
|
30
|
+
* passes through a plain `string` (a DB column, a JSON payload logged and
|
|
31
|
+
* re-parsed, a query param). Treat the two as unrelated concepts that
|
|
32
|
+
* happen to share a name, not as one enum reused across packages.
|
|
13
33
|
*/
|
|
14
34
|
export type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
35
|
+
/**
|
|
36
|
+
* Whether a capability at this risk level may be probed, that is granted to
|
|
37
|
+
* a relationship that has not cleared the First-Contact Scope Cap (design
|
|
38
|
+
* doc "First-Contact Scope Cap, Consent-Phishing Defense (RFC-4 companion)",
|
|
39
|
+
* section 3). `high` and `critical` capabilities are never probe-eligible:
|
|
40
|
+
* they are structurally unmintable at first contact regardless of operator
|
|
41
|
+
* configuration (rule 2) and can never ship pre-checked (rule 1).
|
|
42
|
+
*
|
|
43
|
+
* Deliberately an allowlist (`riskLevel` must be exactly `"low"` or
|
|
44
|
+
* `"medium"`), not a denylist. `riskLevel`'s type is `RiskLevel`, but the
|
|
45
|
+
* caller in `compileCapabilitiesToCedar` does no runtime re-validation, so a
|
|
46
|
+
* value that started as unchecked data (a DB column, a JSON payload, a
|
|
47
|
+
* legacy/typo string like `"High"` or `"severe"`) reaches this function as
|
|
48
|
+
* raw data despite the type annotation. A denylist (`riskLevel !== "high" &&
|
|
49
|
+
* riskLevel !== "critical"`) fails OPEN on any such non-canonical value,
|
|
50
|
+
* treating it as probe-eligible and emitting it to a first-contact or
|
|
51
|
+
* unverified agent, the exact escalation this gate exists to prevent. The
|
|
52
|
+
* allowlist form is strictly more defensive and behaves identically on
|
|
53
|
+
* schema-validated input, where `riskLevel` is already constrained to this
|
|
54
|
+
* union.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isProbeEligible(riskLevel: RiskLevel): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Minimum agent-relationship facts needed to decide whether a capability
|
|
59
|
+
* grant may rise above `probe`. Mirrors `AgentMetadata.verified` /
|
|
60
|
+
* `connectedAt`; deliberately a subset so callers can pass either the full
|
|
61
|
+
* agent tile or just the two fields that matter here.
|
|
62
|
+
*/
|
|
63
|
+
export type RelationshipContext = Pick<AgentMetadata, "verified" | "connectedAt">;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the requesting agent is capped at `probe`: it presented no valid,
|
|
66
|
+
* verified Entity Card (rule 3), or the relationship is first contact, that
|
|
67
|
+
* is `connectedAt` is absent or unparseable (rule 2). Per the design doc,
|
|
68
|
+
* neither condition is ever raised by assurance vector, relationship age, or
|
|
69
|
+
* click count.
|
|
70
|
+
*
|
|
71
|
+
* `agent` itself may be absent: real stored configs exist with no agent
|
|
72
|
+
* metadata at all, not merely `verified: false`. That counts as unverified
|
|
73
|
+
* too, so this fails closed rather than throwing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isCappedAtProbe(agent: RelationshipContext | undefined): boolean;
|
|
15
76
|
/**
|
|
16
77
|
* Allowlist of icon tokens recognized by `<consent-capability-card>`. Operators
|
|
17
78
|
* pick from this list in the WYSIWYG editor; unknown tokens fall back to a
|
|
@@ -54,6 +115,14 @@ export interface Capability {
|
|
|
54
115
|
/** Optional grouping label shown above a cluster of related capabilities. */
|
|
55
116
|
category?: string;
|
|
56
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Presentation data for a host that authorizes literal scopes without Cedar.
|
|
120
|
+
* This does not change the authored Capability schema or Cedar compilation.
|
|
121
|
+
* The host remains responsible for enforcing the reviewed scopes and limits.
|
|
122
|
+
*/
|
|
123
|
+
export type ConsentScopeCapability = Omit<Capability, "cedar"> & {
|
|
124
|
+
cedar?: string;
|
|
125
|
+
};
|
|
57
126
|
/**
|
|
58
127
|
* Optional grouping wrapper, e.g. group several capabilities under
|
|
59
128
|
* "Browse + cart" vs "Checkout".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.types.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH
|
|
1
|
+
{"version":3,"file":"capabilities.types.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,UA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IAC7C,GAAG,EAAE,MAAM,CAAC;IAEZ,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qFAAqF;IACrF,QAAQ,EAAE,OAAO,CAAC;IAElB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IAEjB,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IAEZ,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IAEjB,kEAAkE;IAClE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -7,5 +7,57 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @kya-os/consent/types/capabilities
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Whether a capability at this risk level may be probed, that is granted to
|
|
12
|
+
* a relationship that has not cleared the First-Contact Scope Cap (design
|
|
13
|
+
* doc "First-Contact Scope Cap, Consent-Phishing Defense (RFC-4 companion)",
|
|
14
|
+
* section 3). `high` and `critical` capabilities are never probe-eligible:
|
|
15
|
+
* they are structurally unmintable at first contact regardless of operator
|
|
16
|
+
* configuration (rule 2) and can never ship pre-checked (rule 1).
|
|
17
|
+
*
|
|
18
|
+
* Deliberately an allowlist (`riskLevel` must be exactly `"low"` or
|
|
19
|
+
* `"medium"`), not a denylist. `riskLevel`'s type is `RiskLevel`, but the
|
|
20
|
+
* caller in `compileCapabilitiesToCedar` does no runtime re-validation, so a
|
|
21
|
+
* value that started as unchecked data (a DB column, a JSON payload, a
|
|
22
|
+
* legacy/typo string like `"High"` or `"severe"`) reaches this function as
|
|
23
|
+
* raw data despite the type annotation. A denylist (`riskLevel !== "high" &&
|
|
24
|
+
* riskLevel !== "critical"`) fails OPEN on any such non-canonical value,
|
|
25
|
+
* treating it as probe-eligible and emitting it to a first-contact or
|
|
26
|
+
* unverified agent, the exact escalation this gate exists to prevent. The
|
|
27
|
+
* allowlist form is strictly more defensive and behaves identically on
|
|
28
|
+
* schema-validated input, where `riskLevel` is already constrained to this
|
|
29
|
+
* union.
|
|
30
|
+
*/
|
|
31
|
+
export function isProbeEligible(riskLevel) {
|
|
32
|
+
return riskLevel === "low" || riskLevel === "medium";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether `value` parses as a real point in time in the past. Guards
|
|
36
|
+
* `connectedAt`, which reaches `isCappedAtProbe` as a plain string (the
|
|
37
|
+
* `z.string().datetime()` schema check applies at the `AgentMetadata`
|
|
38
|
+
* ingestion boundary, not necessarily on every `RelationshipContext` this
|
|
39
|
+
* function receives) — a truthy-but-malformed value like `"not-a-date"`
|
|
40
|
+
* must not read as an established relationship.
|
|
41
|
+
*/
|
|
42
|
+
function isValidPastTimestamp(value) {
|
|
43
|
+
const parsed = Date.parse(value);
|
|
44
|
+
return Number.isFinite(parsed) && parsed <= Date.now();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether the requesting agent is capped at `probe`: it presented no valid,
|
|
48
|
+
* verified Entity Card (rule 3), or the relationship is first contact, that
|
|
49
|
+
* is `connectedAt` is absent or unparseable (rule 2). Per the design doc,
|
|
50
|
+
* neither condition is ever raised by assurance vector, relationship age, or
|
|
51
|
+
* click count.
|
|
52
|
+
*
|
|
53
|
+
* `agent` itself may be absent: real stored configs exist with no agent
|
|
54
|
+
* metadata at all, not merely `verified: false`. That counts as unverified
|
|
55
|
+
* too, so this fails closed rather than throwing.
|
|
56
|
+
*/
|
|
57
|
+
export function isCappedAtProbe(agent) {
|
|
58
|
+
return (!agent ||
|
|
59
|
+
!agent.verified ||
|
|
60
|
+
!agent.connectedAt ||
|
|
61
|
+
!isValidPastTimestamp(agent.connectedAt));
|
|
62
|
+
}
|
|
11
63
|
//# sourceMappingURL=capabilities.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.types.js","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
1
|
+
{"version":3,"file":"capabilities.types.js","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4BH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,QAAQ,CAAC;AACvD,CAAC;AAUD;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsC;IACpE,OAAO,CACL,CAAC,KAAK;QACN,CAAC,KAAK,CAAC,QAAQ;QACf,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/consent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "Canonical consent page types, styles, and utilities for MCP-I and AgentShield",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"./consent.min.js": "./dist/consent.min.js"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
|
-
"build": "tsc -p tsconfig.build.json && npm run build:
|
|
84
|
-
"build:cjs": "tsc -p tsconfig.cjs.json &&
|
|
83
|
+
"build": "tsc -p tsconfig.build.json && npm run build:bundle && npm run build:inline && npm run build:mcp-app && npm run build:cjs && npm run verify:bundles",
|
|
84
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && node scripts/write-cjs-package.js",
|
|
85
85
|
"build:bundle": "esbuild src/bundle/index.ts --bundle --format=esm --target=es2020 --outfile=dist/consent.js && esbuild src/bundle/index.ts --bundle --format=esm --target=es2020 --minify --outfile=dist/consent.min.js",
|
|
86
86
|
"build:inline": "node scripts/generate-inline-bundle.js && tsc src/bundle/inline.ts --declaration --outDir dist/bundle --module esnext --moduleResolution bundler --target es2020",
|
|
87
87
|
"build:mcp-app": "node scripts/generate-mcp-app-bundle.js && tsc src/mcp-app/inline.ts src/mcp-app/index.ts src/mcp-app/types.ts --declaration --outDir dist/mcp-app --module esnext --moduleResolution bundler --target es2020",
|
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
"lint": "eslint .",
|
|
93
93
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
94
94
|
"clean": "rm -rf dist .turbo node_modules",
|
|
95
|
-
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
95
|
+
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js",
|
|
96
|
+
"test:browser": "python3 scripts/test-capabilities-browser.py && python3 scripts/test-mcp-consent-selection.py",
|
|
97
|
+
"verify:bundles": "node scripts/verify-bundles.js"
|
|
96
98
|
},
|
|
97
99
|
"sideEffects": [
|
|
98
100
|
"./src/components/*.ts",
|