@shield-agent/kya 0.22.0 → 0.23.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.
- package/.mcp.json +1 -1
- package/README.md +72 -30
- package/amp/settings.example.json +1 -1
- package/claude/claude_desktop_config.example.json +1 -1
- package/cline/cline_mcp_settings.example.json +1 -1
- package/copilot/mcp-config.example.json +1 -1
- package/dist/certify/attest.js +5 -5
- package/dist/certify/catalog.d.ts +1 -1
- package/dist/certify/catalog.js +3 -3
- package/dist/certify/context.js +1 -1
- package/dist/certify/evaluate.d.ts +2 -2
- package/dist/certify/evaluate.js +12 -12
- package/dist/certify/live.js +2 -2
- package/dist/certify/render.d.ts +1 -1
- package/dist/certify/render.js +10 -10
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +49 -16
- package/dist/cli.js.map +1 -1
- package/dist/commands/certify.d.ts +1 -1
- package/dist/commands/certify.js +3 -3
- package/dist/commands/connect.d.ts +2 -2
- package/dist/commands/connect.js +22 -22
- package/dist/commands/dash.js +4 -4
- package/dist/commands/gate-serve.js +3 -3
- package/dist/commands/gate.d.ts +1 -1
- package/dist/commands/gate.js +16 -16
- package/dist/commands/hook.d.ts +1 -1
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +55 -18
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/import-traces.d.ts +16 -0
- package/dist/commands/import-traces.d.ts.map +1 -0
- package/dist/commands/import-traces.js +18 -0
- package/dist/commands/import-traces.js.map +1 -0
- package/dist/commands/init.js +1 -1
- package/dist/commands/investigate.d.ts +13 -0
- package/dist/commands/investigate.d.ts.map +1 -0
- package/dist/commands/investigate.js +22 -0
- package/dist/commands/investigate.js.map +1 -0
- package/dist/commands/notify-flush.d.ts +2 -0
- package/dist/commands/notify-flush.d.ts.map +1 -0
- package/dist/commands/notify-flush.js +47 -0
- package/dist/commands/notify-flush.js.map +1 -0
- package/dist/commands/orr.d.ts +3 -3
- package/dist/commands/orr.js +5 -5
- package/dist/commands/receipt-serve.d.ts +1 -1
- package/dist/commands/receipt-serve.js +1 -1
- package/dist/commands/serve-mcp.js +1 -1
- package/dist/commands/start.d.ts +2 -2
- package/dist/commands/start.js +20 -20
- package/dist/commands/stop.d.ts +1 -1
- package/dist/commands/stop.js +6 -6
- package/dist/commands/update.d.ts +19 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +96 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/wire-hooks.d.ts +1 -1
- package/dist/commands/wire-hooks.js +14 -14
- package/dist/commands/wrap.d.ts.map +1 -1
- package/dist/commands/wrap.js +12 -7
- package/dist/commands/wrap.js.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +5 -5
- package/dist/dash/dash.d.ts +1 -1
- package/dist/dash/dash.js +3 -3
- package/dist/dash/entitlement.d.ts +1 -1
- package/dist/dash/entitlement.js +1 -1
- package/dist/dash/render.js +2 -2
- package/dist/dash/screens/enterprise.js +9 -9
- package/dist/dash/screens/free.js +5 -5
- package/dist/diff-preview.d.ts +1 -1
- package/dist/diff-preview.js +2 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/fs-atomic.d.ts +1 -1
- package/dist/fs-atomic.js +2 -2
- package/dist/gate/binary.js +4 -4
- package/dist/gate/config-gen.d.ts +1 -1
- package/dist/gate/config-gen.js +7 -7
- package/dist/gate/config.d.ts +2 -2
- package/dist/gate/config.js +6 -6
- package/dist/gate/daemon.js +1 -1
- package/dist/gate/discover.d.ts +2 -2
- package/dist/gate/discover.js +7 -7
- package/dist/gate/hosted-sync.js +1 -1
- package/dist/gate/otlp-decode.d.ts +2 -2
- package/dist/gate/otlp-decode.js +2 -2
- package/dist/gate/otlp-receiver.d.ts +1 -1
- package/dist/gate/otlp-receiver.js +3 -3
- package/dist/host-reload.js +11 -11
- package/dist/host-tools.d.ts +1 -1
- package/dist/host-tools.js +1 -1
- package/dist/importers/formats.d.ts +26 -0
- package/dist/importers/formats.d.ts.map +1 -0
- package/dist/importers/formats.js +281 -0
- package/dist/importers/formats.js.map +1 -0
- package/dist/importers/index.d.ts +26 -0
- package/dist/importers/index.d.ts.map +1 -0
- package/dist/importers/index.js +122 -0
- package/dist/importers/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/investigate/detectors.d.ts +35 -0
- package/dist/investigate/detectors.d.ts.map +1 -0
- package/dist/investigate/detectors.js +277 -0
- package/dist/investigate/detectors.js.map +1 -0
- package/dist/investigate/fix-brief.d.ts +3 -0
- package/dist/investigate/fix-brief.d.ts.map +1 -0
- package/dist/investigate/fix-brief.js +88 -0
- package/dist/investigate/fix-brief.js.map +1 -0
- package/dist/investigate/incidents.d.ts +19 -0
- package/dist/investigate/incidents.d.ts.map +1 -0
- package/dist/investigate/incidents.js +84 -0
- package/dist/investigate/incidents.js.map +1 -0
- package/dist/investigate/index.d.ts +25 -0
- package/dist/investigate/index.d.ts.map +1 -0
- package/dist/investigate/index.js +46 -0
- package/dist/investigate/index.js.map +1 -0
- package/dist/mcp/protocol.d.ts +2 -2
- package/dist/mcp/protocol.d.ts.map +1 -1
- package/dist/mcp/protocol.js +39 -8
- package/dist/mcp/protocol.js.map +1 -1
- package/dist/mcp/stdio.d.ts +1 -1
- package/dist/mcp/stdio.js +2 -2
- package/dist/mcp-servers.d.ts +2 -2
- package/dist/mcp-servers.js +2 -2
- package/dist/node-upgrade.d.ts +2 -2
- package/dist/node-upgrade.js +9 -9
- package/dist/notify/dispatch.d.ts +20 -0
- package/dist/notify/dispatch.d.ts.map +1 -0
- package/dist/notify/dispatch.js +52 -0
- package/dist/notify/dispatch.js.map +1 -0
- package/dist/notify/index.d.ts +39 -0
- package/dist/notify/index.d.ts.map +1 -0
- package/dist/notify/index.js +119 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/sender.d.ts +56 -0
- package/dist/notify/sender.d.ts.map +1 -0
- package/dist/notify/sender.js +139 -0
- package/dist/notify/sender.js.map +1 -0
- package/dist/notify/templates.d.ts +33 -0
- package/dist/notify/templates.d.ts.map +1 -0
- package/dist/notify/templates.js +119 -0
- package/dist/notify/templates.js.map +1 -0
- package/dist/offline-evaluate.d.ts +2 -2
- package/dist/offline-evaluate.js +3 -3
- package/dist/orr/agentshield.d.ts +2 -2
- package/dist/orr/agentshield.js +4 -4
- package/dist/orr/scorecard.d.ts +1 -1
- package/dist/orr/scorecard.js +3 -3
- package/dist/otel/exporter.d.ts +64 -0
- package/dist/otel/exporter.d.ts.map +1 -0
- package/dist/otel/exporter.js +243 -0
- package/dist/otel/exporter.js.map +1 -0
- package/dist/parse-args.d.ts +1 -1
- package/dist/parse-args.js +1 -1
- package/dist/receipt/auto-open.d.ts +1 -1
- package/dist/receipt/auto-open.js +1 -1
- package/dist/receipt/daemon.d.ts +6 -6
- package/dist/receipt/daemon.js +15 -15
- package/dist/receipt/dashboard.d.ts +1 -1
- package/dist/receipt/dashboard.js +2 -2
- package/dist/receipt/embeddings.d.ts +15 -4
- package/dist/receipt/embeddings.d.ts.map +1 -1
- package/dist/receipt/embeddings.js +116 -35
- package/dist/receipt/embeddings.js.map +1 -1
- package/dist/receipt/enrich.d.ts +2 -2
- package/dist/receipt/enrich.js +5 -5
- package/dist/receipt/gate-card.d.ts +2 -2
- package/dist/receipt/gate-card.d.ts.map +1 -1
- package/dist/receipt/gate-card.js +3 -3
- package/dist/receipt/live-server.d.ts.map +1 -1
- package/dist/receipt/live-server.js +22 -8
- package/dist/receipt/live-server.js.map +1 -1
- package/dist/receipt/receipt-css.d.ts +1 -1
- package/dist/receipt/receipt-css.d.ts.map +1 -1
- package/dist/receipt/receipt-css.js +72 -11
- package/dist/receipt/receipt-css.js.map +1 -1
- package/dist/receipt/render-receipt.d.ts +1 -1
- package/dist/receipt/render-receipt.d.ts.map +1 -1
- package/dist/receipt/render-receipt.js +138 -87
- package/dist/receipt/render-receipt.js.map +1 -1
- package/dist/receipt/share.d.ts +2 -2
- package/dist/receipt/share.js +5 -5
- package/dist/sample-tools.d.ts +1 -1
- package/dist/sample-tools.js +1 -1
- package/dist/sandbox/mock-driver.d.ts +1 -1
- package/dist/sandbox/mock-driver.js +1 -1
- package/dist/sdk/a2a.d.ts +2 -2
- package/dist/sdk/a2a.js +1 -1
- package/dist/sdk/adapters/claude-agent.d.ts +1 -1
- package/dist/sdk/adapters/claude-agent.js +1 -1
- package/dist/sdk/adapters/langgraph.d.ts +1 -1
- package/dist/sdk/adapters/langgraph.js +1 -1
- package/dist/sdk/adapters/mastra.d.ts +1 -1
- package/dist/sdk/adapters/mastra.js +1 -1
- package/dist/sdk/adapters/openai-agents.d.ts +1 -1
- package/dist/sdk/adapters/openai-agents.js +1 -1
- package/dist/sdk/adapters/vercel-ai.d.ts +2 -2
- package/dist/sdk/adapters/vercel-ai.js +1 -1
- package/dist/sdk/govern.d.ts +2 -2
- package/dist/sdk/govern.js +3 -3
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/showback/trail-usage.d.ts +30 -0
- package/dist/showback/trail-usage.d.ts.map +1 -0
- package/dist/showback/trail-usage.js +50 -0
- package/dist/showback/trail-usage.js.map +1 -0
- package/dist/sign/evidence-bundle.d.ts +6 -6
- package/dist/sign/evidence-bundle.js +5 -5
- package/dist/star-cta.d.ts +1 -1
- package/dist/star-cta.d.ts.map +1 -1
- package/dist/star-cta.js +3 -3
- package/dist/trail-summary.d.ts +1 -1
- package/dist/trail-summary.js +3 -3
- package/dist/trail.d.ts +8 -2
- package/dist/trail.d.ts.map +1 -1
- package/dist/trail.js +18 -5
- package/dist/trail.js.map +1 -1
- package/dist/update-check.d.ts +17 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +134 -0
- package/dist/update-check.js.map +1 -0
- package/droid/README.md +1 -1
- package/droid/mcp.example.json +1 -1
- package/gemini/settings.example.json +1 -1
- package/grok/README.md +1 -1
- package/kilo/kilo.example.json +1 -1
- package/kimi/mcp.example.json +1 -1
- package/kiro/mcp.example.json +1 -1
- package/manifest.json +1 -1
- package/mastracode/mcp.example.json +1 -1
- package/mcp.json +1 -1
- package/openai/codex.config.example.toml +1 -1
- package/opencode/opencode.example.json +1 -1
- package/package.json +2 -2
- package/qwen/settings.example.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trail-usage showback (observe only). Aggregates per-event usage captured on
|
|
3
|
+
* the trail: real token counts when the host reported them, a static
|
|
4
|
+
* per-event estimate when it did not. Not a billing meter. Not a PEP -
|
|
5
|
+
* spend must never influence verdicts, so nothing here feeds the gate.
|
|
6
|
+
*/
|
|
7
|
+
import type { TrailEvent } from "../trail.js";
|
|
8
|
+
/** Static fallback estimate for one gated tool call without reported usage. */
|
|
9
|
+
export declare const STATIC_ESTIMATE_TOKENS_IN = 2000;
|
|
10
|
+
export declare const STATIC_ESTIMATE_TOKENS_OUT = 500;
|
|
11
|
+
export interface TrailUsageSummary {
|
|
12
|
+
readonly events: number;
|
|
13
|
+
/** Events whose token counts came from the host, not the estimate. */
|
|
14
|
+
readonly realUsageEvents: number;
|
|
15
|
+
/** events - realUsageEvents (rows priced at the static estimate). */
|
|
16
|
+
readonly estimatedEvents: number;
|
|
17
|
+
/** real + estimated, what the panel totals display. */
|
|
18
|
+
readonly tokensIn: number;
|
|
19
|
+
readonly tokensOut: number;
|
|
20
|
+
readonly realTokensIn: number;
|
|
21
|
+
readonly realTokensOut: number;
|
|
22
|
+
readonly estimatedTokensIn: number;
|
|
23
|
+
readonly estimatedTokensOut: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Per event: prefer reported tokensIn/tokensOut; fall back to the static
|
|
27
|
+
* estimate only when the event carries no real usage at all.
|
|
28
|
+
*/
|
|
29
|
+
export declare function summarizeTrailUsage(events: readonly TrailEvent[]): TrailUsageSummary;
|
|
30
|
+
//# sourceMappingURL=trail-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trail-usage.d.ts","sourceRoot":"","sources":["../../src/showback/trail-usage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAQD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,UAAU,EAAE,GAC5B,iBAAiB,CA6BnB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trail-usage showback (observe only). Aggregates per-event usage captured on
|
|
3
|
+
* the trail: real token counts when the host reported them, a static
|
|
4
|
+
* per-event estimate when it did not. Not a billing meter. Not a PEP -
|
|
5
|
+
* spend must never influence verdicts, so nothing here feeds the gate.
|
|
6
|
+
*/
|
|
7
|
+
/** Static fallback estimate for one gated tool call without reported usage. */
|
|
8
|
+
export const STATIC_ESTIMATE_TOKENS_IN = 2000;
|
|
9
|
+
export const STATIC_ESTIMATE_TOKENS_OUT = 500;
|
|
10
|
+
function realTokens(n) {
|
|
11
|
+
return typeof n === "number" && Number.isFinite(n) && n >= 0
|
|
12
|
+
? Math.floor(n)
|
|
13
|
+
: undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per event: prefer reported tokensIn/tokensOut; fall back to the static
|
|
17
|
+
* estimate only when the event carries no real usage at all.
|
|
18
|
+
*/
|
|
19
|
+
export function summarizeTrailUsage(events) {
|
|
20
|
+
let realUsageEvents = 0;
|
|
21
|
+
let realIn = 0;
|
|
22
|
+
let realOut = 0;
|
|
23
|
+
let estimatedEvents = 0;
|
|
24
|
+
for (const e of events) {
|
|
25
|
+
const tin = realTokens(e.tokensIn);
|
|
26
|
+
const tout = realTokens(e.tokensOut);
|
|
27
|
+
if (tin !== undefined || tout !== undefined) {
|
|
28
|
+
realUsageEvents += 1;
|
|
29
|
+
realIn += tin ?? 0;
|
|
30
|
+
realOut += tout ?? 0;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
estimatedEvents += 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const estimatedTokensIn = estimatedEvents * STATIC_ESTIMATE_TOKENS_IN;
|
|
37
|
+
const estimatedTokensOut = estimatedEvents * STATIC_ESTIMATE_TOKENS_OUT;
|
|
38
|
+
return {
|
|
39
|
+
events: events.length,
|
|
40
|
+
realUsageEvents,
|
|
41
|
+
estimatedEvents,
|
|
42
|
+
tokensIn: realIn + estimatedTokensIn,
|
|
43
|
+
tokensOut: realOut + estimatedTokensOut,
|
|
44
|
+
realTokensIn: realIn,
|
|
45
|
+
realTokensOut: realOut,
|
|
46
|
+
estimatedTokensIn,
|
|
47
|
+
estimatedTokensOut,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=trail-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trail-usage.js","sourceRoot":"","sources":["../../src/showback/trail-usage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG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kBAAkB;QACvC,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,OAAO;QACtB,iBAAiB;QACjB,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signed evidence bundles (v1)
|
|
2
|
+
* Signed evidence bundles (v1) - the OSS half of hosted verification.
|
|
3
3
|
* Self-signed by a locally generated ed25519 key: proves bundle integrity and
|
|
4
4
|
* continuity of a key, NOT identity. Identity binding is a hosted claim.
|
|
5
|
-
* node:crypto only
|
|
5
|
+
* node:crypto only - the package dependency list is locked.
|
|
6
6
|
*/
|
|
7
7
|
import { type KeyObject } from "node:crypto";
|
|
8
8
|
import type { CertifyReport } from "../certify/evaluate.js";
|
|
@@ -12,7 +12,7 @@ export declare const EVIDENCE_BUNDLE_VERSION = 1;
|
|
|
12
12
|
export interface EvidenceKey {
|
|
13
13
|
readonly publicKey: KeyObject;
|
|
14
14
|
readonly privateKey: KeyObject;
|
|
15
|
-
/** base64url(SPKI DER)
|
|
15
|
+
/** base64url(SPKI DER) - the `pubkey` field of every bundle. */
|
|
16
16
|
readonly pubkeyB64u: string;
|
|
17
17
|
/** First 16 hex chars of sha256(SPKI DER). */
|
|
18
18
|
readonly fingerprint: string;
|
|
@@ -33,7 +33,7 @@ export declare function fingerprintSpki(spkiDer: Buffer): string;
|
|
|
33
33
|
export declare function evidenceKeyFromSerialized(raw: unknown): EvidenceKey;
|
|
34
34
|
/** Load the evidence signing key, generating one (mode 0600) on first use. */
|
|
35
35
|
export declare function loadOrCreateEvidenceKey(env?: NodeJS.ProcessEnv): EvidenceKey;
|
|
36
|
-
/** sig = base64url( ed25519_sign( canonicalJson(body) ) )
|
|
36
|
+
/** sig = base64url( ed25519_sign( canonicalJson(body) ) ) - canonicalJson from src/hash.ts. */
|
|
37
37
|
export declare function signCanonicalPayload(body: unknown, privateKey: KeyObject): string;
|
|
38
38
|
/** Verify `sig` over canonicalJson(bundle without the `sig` and `pubkey` fields) using the embedded `pubkey`. */
|
|
39
39
|
export declare function verifyBundleSignature(bundle: Record<string, unknown>): boolean;
|
|
@@ -45,12 +45,12 @@ export interface BundleAgent {
|
|
|
45
45
|
}
|
|
46
46
|
export interface EvidenceBundleInput {
|
|
47
47
|
readonly report: CertifyReport;
|
|
48
|
-
/** Events inside report.window
|
|
48
|
+
/** Events inside report.window - the digest binds the bundle to the tape. */
|
|
49
49
|
readonly windowEvents: readonly TrailEvent[];
|
|
50
50
|
readonly agent?: BundleAgent;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Build a signed evidence bundle v1 (hard cross-repo contract
|
|
53
|
+
* Build a signed evidence bundle v1 (hard cross-repo contract - see
|
|
54
54
|
* docs/certify.md). sig = base64url(ed25519_sign(canonicalJson(body))) where
|
|
55
55
|
* body is the bundle without the sig and pubkey fields (same stripping as
|
|
56
56
|
* verifyBundleSignature). Self-signed: integrity + key continuity, NOT identity.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signed evidence bundles (v1)
|
|
2
|
+
* Signed evidence bundles (v1) - the OSS half of hosted verification.
|
|
3
3
|
* Self-signed by a locally generated ed25519 key: proves bundle integrity and
|
|
4
4
|
* continuity of a key, NOT identity. Identity binding is a hosted claim.
|
|
5
|
-
* node:crypto only
|
|
5
|
+
* node:crypto only - the package dependency list is locked.
|
|
6
6
|
*/
|
|
7
7
|
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify, } from "node:crypto";
|
|
8
8
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
|
|
@@ -58,7 +58,7 @@ export function evidenceKeyFromSerialized(raw) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
catch {
|
|
61
|
-
throw new UsageError("evidence key file is corrupt
|
|
61
|
+
throw new UsageError("evidence key file is corrupt - regenerating (old bundles stay verifiable only with the old pubkey)");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
/** Load the evidence signing key, generating one (mode 0600) on first use. */
|
|
@@ -103,7 +103,7 @@ export function loadOrCreateEvidenceKey(env = process.env) {
|
|
|
103
103
|
regenerated: existed,
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
/** sig = base64url( ed25519_sign( canonicalJson(body) ) )
|
|
106
|
+
/** sig = base64url( ed25519_sign( canonicalJson(body) ) ) - canonicalJson from src/hash.ts. */
|
|
107
107
|
export function signCanonicalPayload(body, privateKey) {
|
|
108
108
|
const payload = Buffer.from(canonicalJson(body), "utf8");
|
|
109
109
|
return sign(null, payload, privateKey).toString("base64url");
|
|
@@ -141,7 +141,7 @@ function clipBundleEvidence(evidence) {
|
|
|
141
141
|
: evidence;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
|
-
* Build a signed evidence bundle v1 (hard cross-repo contract
|
|
144
|
+
* Build a signed evidence bundle v1 (hard cross-repo contract - see
|
|
145
145
|
* docs/certify.md). sig = base64url(ed25519_sign(canonicalJson(body))) where
|
|
146
146
|
* body is the bundle without the sig and pubkey fields (same stripping as
|
|
147
147
|
* verifyBundleSignature). Self-signed: integrity + key continuity, NOT identity.
|
package/dist/star-cta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const STAR_REPO_URL = "https://github.com/The-Pixel-Boys/shield-agent";
|
|
2
|
-
export declare const STAR_CTA_LINE = "Loving KYA? Star the repo
|
|
2
|
+
export declare const STAR_CTA_LINE = "Loving KYA? Star the repo - it keeps the OSS report free: https://github.com/The-Pixel-Boys/shield-agent";
|
|
3
3
|
/** The CTA only fires once the trail has meaningful activity to report. */
|
|
4
4
|
export declare const STAR_CTA_MIN_EVENTS = 10;
|
|
5
5
|
export declare function starCtaFlagPath(cwd: string): string;
|
package/dist/star-cta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"star-cta.d.ts","sourceRoot":"","sources":["../src/star-cta.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,mDAAmD,CAAC;AAC9E,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"star-cta.d.ts","sourceRoot":"","sources":["../src/star-cta.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,mDAAmD,CAAC;AAC9E,eAAO,MAAM,aAAa,6GAA+E,CAAC;AAC1G,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAkB,GACvC,OAAO,CAkBT"}
|
package/dist/star-cta.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* One-time "star the repo" CTA, printed after `kya start` / `kya receipt`
|
|
3
3
|
* surface a live report URL and the trail has real activity in the window.
|
|
4
4
|
* The flag lives in the project `.kya/` dir, so the CTA prints at most once
|
|
5
|
-
* per project
|
|
5
|
+
* per project - it never gates or delays the report itself.
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync, mkdirSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
@@ -10,7 +10,7 @@ import { configDir } from "./config.js";
|
|
|
10
10
|
import { atomicWriteSync } from "./fs-atomic.js";
|
|
11
11
|
import { readTrailSince } from "./trail.js";
|
|
12
12
|
export const STAR_REPO_URL = "https://github.com/The-Pixel-Boys/shield-agent";
|
|
13
|
-
export const STAR_CTA_LINE = `Loving KYA? Star the repo
|
|
13
|
+
export const STAR_CTA_LINE = `Loving KYA? Star the repo - it keeps the OSS report free: ${STAR_REPO_URL}`;
|
|
14
14
|
/** The CTA only fires once the trail has meaningful activity to report. */
|
|
15
15
|
export const STAR_CTA_MIN_EVENTS = 10;
|
|
16
16
|
export function starCtaFlagPath(cwd) {
|
|
@@ -40,7 +40,7 @@ export function maybePrintStarCta(cwd, days, log = console.log) {
|
|
|
40
40
|
atomicWriteSync(starCtaFlagPath(cwd), `${new Date().toISOString()}\n`);
|
|
41
41
|
}
|
|
42
42
|
catch {
|
|
43
|
-
/* flag persistence is best-effort
|
|
43
|
+
/* flag persistence is best-effort - worst case the CTA prints again */
|
|
44
44
|
}
|
|
45
45
|
return true;
|
|
46
46
|
}
|
package/dist/trail-summary.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Strip query/fragment from URLs before they enter the summary. */
|
|
2
2
|
export declare function scrubUrl(value: string): string;
|
|
3
3
|
/**
|
|
4
|
-
* Shell lines: keep bin + arg count only
|
|
4
|
+
* Shell lines: keep bin + arg count only - never the full command
|
|
5
5
|
* (env assignments, -p passwords, Basic auth headers).
|
|
6
6
|
*/
|
|
7
7
|
export declare function summarizeShellCommand(cmd: string): string;
|
package/dist/trail-summary.js
CHANGED
|
@@ -124,14 +124,14 @@ export function scrubUrl(value) {
|
|
|
124
124
|
return value.replace(/([?&#][^=\s]*=)[^&\s#]+/g, "$1[redacted]");
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
|
-
* Shell lines: keep bin + arg count only
|
|
127
|
+
* Shell lines: keep bin + arg count only - never the full command
|
|
128
128
|
* (env assignments, -p passwords, Basic auth headers).
|
|
129
129
|
*/
|
|
130
130
|
export function summarizeShellCommand(cmd) {
|
|
131
131
|
const trimmed = cmd.trim();
|
|
132
132
|
if (!trimmed)
|
|
133
133
|
return "shell";
|
|
134
|
-
// Space-free URL masquerading as a "command"
|
|
134
|
+
// Space-free URL masquerading as a "command" - scrub query before binning.
|
|
135
135
|
if (!/\s/.test(trimmed) && (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || /[?&#].*=/.test(trimmed))) {
|
|
136
136
|
return finalize([`shell`, pathLike(trimmed)]) ?? "shell";
|
|
137
137
|
}
|
|
@@ -223,7 +223,7 @@ export function deriveTrailSummary(toolId, args) {
|
|
|
223
223
|
return undefined;
|
|
224
224
|
}
|
|
225
225
|
if (typeof args === "string") {
|
|
226
|
-
// Treat bare strings as opaque
|
|
226
|
+
// Treat bare strings as opaque - only length, avoid dumping secrets.
|
|
227
227
|
return finalize([verb || "args", `(${args.length} chars)`]);
|
|
228
228
|
}
|
|
229
229
|
if (typeof args === "number" || typeof args === "boolean") {
|
package/dist/trail.d.ts
CHANGED
|
@@ -20,11 +20,17 @@ export interface TrailEvent {
|
|
|
20
20
|
readonly diffPreview?: string;
|
|
21
21
|
/** Clipped redacted target file path (never raw args). */
|
|
22
22
|
readonly targetPath?: string;
|
|
23
|
+
/** Wall latency of the evaluate call in ms. Observe-only; never a verdict input. */
|
|
24
|
+
readonly latencyMs?: number;
|
|
25
|
+
/** Real input tokens reported by the host. Observe-only showback. */
|
|
26
|
+
readonly tokensIn?: number;
|
|
27
|
+
/** Real output tokens reported by the host. Observe-only showback. */
|
|
28
|
+
readonly tokensOut?: number;
|
|
23
29
|
}
|
|
24
30
|
export declare function globalTrailPath(env?: NodeJS.ProcessEnv): string;
|
|
25
31
|
/** Pre-0.3.0 per-project trail location, still merged on read. */
|
|
26
32
|
export declare function legacyTrailPath(cwd: string): string;
|
|
27
|
-
/** The trail is global since 0.3.0
|
|
33
|
+
/** The trail is global since 0.3.0 - one file for all projects. */
|
|
28
34
|
export declare function trailPath(_cwd: string, env?: NodeJS.ProcessEnv): string;
|
|
29
35
|
export declare function receiptsDir(cwd: string): string;
|
|
30
36
|
/** Detect Cursor / Claude Code / Codex / Grok / host from env. */
|
|
@@ -33,7 +39,7 @@ export declare function productLabel(p: TrailProduct | undefined): string;
|
|
|
33
39
|
/** Map a hook --host id to the trail product (explicit beats env sniffing). */
|
|
34
40
|
export declare function hostToProduct(host: string): TrailProduct;
|
|
35
41
|
export declare function appendTrail(cwd: string, event: TrailEvent, env?: NodeJS.ProcessEnv): void;
|
|
36
|
-
/** trail.jsonl read cap
|
|
42
|
+
/** trail.jsonl read cap - oversized files are tail-read (recent events win). */
|
|
37
43
|
export declare const MAX_TRAIL_BYTES: number;
|
|
38
44
|
/**
|
|
39
45
|
* Global trail + legacy per-cwd trail (pre-0.3.0 installs), merged and sorted
|
package/dist/trail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,GACN,KAAK,GACL,SAAS,GACT,OAAO,CAAC;AAEZ,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,QA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|
2
|
-
* Local session trail (JSONL). Observe path
|
|
2
|
+
* Local session trail (JSONL). Observe path - not a second PEP.
|
|
3
3
|
*/
|
|
4
4
|
import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, statSync, } from "node:fs";
|
|
5
5
|
import { basename, join } from "node:path";
|
|
@@ -11,7 +11,7 @@ export function globalTrailPath(env = process.env) {
|
|
|
11
11
|
export function legacyTrailPath(cwd) {
|
|
12
12
|
return join(configDir(cwd), "trail.jsonl");
|
|
13
13
|
}
|
|
14
|
-
/** The trail is global since 0.3.0
|
|
14
|
+
/** The trail is global since 0.3.0 - one file for all projects. */
|
|
15
15
|
export function trailPath(_cwd, env = process.env) {
|
|
16
16
|
return globalTrailPath(env);
|
|
17
17
|
}
|
|
@@ -97,7 +97,7 @@ const TRAIL_PRODUCTS = new Set([
|
|
|
97
97
|
]);
|
|
98
98
|
/**
|
|
99
99
|
* Validate one parsed JSONL line against the TrailEvent shape. Untrusted
|
|
100
|
-
* fields (wrong type, unknown mode/product) drop the line or the field
|
|
100
|
+
* fields (wrong type, unknown mode/product) drop the line or the field -
|
|
101
101
|
* a single malformed line must never brick the report render.
|
|
102
102
|
*/
|
|
103
103
|
function parseTrailEvent(raw) {
|
|
@@ -131,9 +131,22 @@ function parseTrailEvent(raw) {
|
|
|
131
131
|
...(typeof e.summary === "string" ? { summary: e.summary } : {}),
|
|
132
132
|
...(typeof e.diffPreview === "string" ? { diffPreview: e.diffPreview } : {}),
|
|
133
133
|
...(typeof e.targetPath === "string" ? { targetPath: e.targetPath } : {}),
|
|
134
|
+
...(nonNegNumber(e.latencyMs) !== undefined
|
|
135
|
+
? { latencyMs: nonNegNumber(e.latencyMs) }
|
|
136
|
+
: {}),
|
|
137
|
+
...(nonNegNumber(e.tokensIn) !== undefined
|
|
138
|
+
? { tokensIn: nonNegNumber(e.tokensIn) }
|
|
139
|
+
: {}),
|
|
140
|
+
...(nonNegNumber(e.tokensOut) !== undefined
|
|
141
|
+
? { tokensOut: nonNegNumber(e.tokensOut) }
|
|
142
|
+
: {}),
|
|
134
143
|
};
|
|
135
144
|
}
|
|
136
|
-
/**
|
|
145
|
+
/** Usage/latency fields pass only as finite non-negative numbers. */
|
|
146
|
+
function nonNegNumber(v) {
|
|
147
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : undefined;
|
|
148
|
+
}
|
|
149
|
+
/** trail.jsonl read cap - oversized files are tail-read (recent events win). */
|
|
137
150
|
export const MAX_TRAIL_BYTES = 1024 * 1024;
|
|
138
151
|
function readTrailText(path) {
|
|
139
152
|
const size = statSync(path).size;
|
|
@@ -151,7 +164,7 @@ function readTrailText(path) {
|
|
|
151
164
|
finally {
|
|
152
165
|
closeSync(fd);
|
|
153
166
|
}
|
|
154
|
-
// First line is partial (possibly mid-multibyte)
|
|
167
|
+
// First line is partial (possibly mid-multibyte) - drop it.
|
|
155
168
|
const nl = tail.indexOf("\n");
|
|
156
169
|
return nl === -1 ? "" : tail.slice(nl + 1);
|
|
157
170
|
}
|
package/dist/trail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trail.js","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"trail.js","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EA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A6E;AAC7E,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,KAAW,EACX,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACjC,OAAO,CAAC,IAAI,OAAO,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACnE,OAAO,CACL,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE;QAC1B,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE;QAC7B,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE;QAC7B,SAAS,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface UpdateCheckResult {
|
|
2
|
+
readonly current: string;
|
|
3
|
+
readonly latest: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function shouldSkipUpdateCheck(command: string | undefined, flags: Readonly<Record<string, string | boolean>>, env: NodeJS.ProcessEnv): boolean;
|
|
6
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
7
|
+
export interface UpdateCheckDeps {
|
|
8
|
+
readonly fetch?: typeof fetch;
|
|
9
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns { current, latest } when a newer version is available on npm,
|
|
13
|
+
* undefined when already up-to-date, offline, or the check failed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function checkForUpdate(deps?: UpdateCheckDeps): Promise<UpdateCheckResult | undefined>;
|
|
16
|
+
export declare function formatUpdateBanner(result: UpdateCheckResult): string;
|
|
17
|
+
//# sourceMappingURL=update-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAmBD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EACjD,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAQT;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAU5D;AA6DD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAcvG;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight "new KYA version available" check.
|
|
3
|
+
*
|
|
4
|
+
* - Queries npm registry at most once per 24 h and caches the result in
|
|
5
|
+
* ~/.kya/update-check.json.
|
|
6
|
+
* - Never fails a command: network/cache problems return undefined.
|
|
7
|
+
* - Honors KYA_UPDATE_CHECK=0 and --no-update-check.
|
|
8
|
+
* - Skips machine-readable/integrated subcommands so hosts aren't confused.
|
|
9
|
+
*/
|
|
10
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { globalConfigDir } from "./config.js";
|
|
12
|
+
import { CLI_VERSION } from "./version.js";
|
|
13
|
+
const NPM_REGISTRY_URL = "https://registry.npmjs.org/@shield-agent%2Fkya";
|
|
14
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
15
|
+
const FETCH_TIMEOUT_MS = 5000;
|
|
16
|
+
/** Commands whose output is consumed by hosts, scripts, or pipes. */
|
|
17
|
+
const SKIP_COMMANDS = new Set([
|
|
18
|
+
"serve-mcp",
|
|
19
|
+
"receipt-serve",
|
|
20
|
+
"hook",
|
|
21
|
+
"wrap",
|
|
22
|
+
"eval-tool",
|
|
23
|
+
"invoke",
|
|
24
|
+
"approve",
|
|
25
|
+
"reject",
|
|
26
|
+
]);
|
|
27
|
+
export function shouldSkipUpdateCheck(command, flags, env) {
|
|
28
|
+
if (!command)
|
|
29
|
+
return true;
|
|
30
|
+
if (SKIP_COMMANDS.has(command))
|
|
31
|
+
return true;
|
|
32
|
+
if (flags["no-update-check"] === true || flags["no-update-check"] === "true")
|
|
33
|
+
return true;
|
|
34
|
+
if (env.KYA_UPDATE_CHECK === "0" || env.KYA_UPDATE_CHECK === "false")
|
|
35
|
+
return true;
|
|
36
|
+
if (env.CI === "true" || env.GITHUB_ACTIONS === "true")
|
|
37
|
+
return true;
|
|
38
|
+
if (flags["json"] === true || flags["json"] === "true")
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
export function compareVersions(a, b) {
|
|
43
|
+
const parse = (v) => v.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
|
|
44
|
+
const av = parse(a);
|
|
45
|
+
const bv = parse(b);
|
|
46
|
+
for (let i = 0; i < 3; i++) {
|
|
47
|
+
const an = Number.isFinite(av[i]) ? av[i] : 0;
|
|
48
|
+
const bn = Number.isFinite(bv[i]) ? bv[i] : 0;
|
|
49
|
+
if (an !== bn)
|
|
50
|
+
return an - bn;
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
function cachePath(env) {
|
|
55
|
+
return `${globalConfigDir(env)}/update-check.json`;
|
|
56
|
+
}
|
|
57
|
+
function readCache(env) {
|
|
58
|
+
try {
|
|
59
|
+
const raw = readFileSync(cachePath(env), "utf8");
|
|
60
|
+
const parsed = JSON.parse(raw);
|
|
61
|
+
if (parsed && typeof parsed.latest === "string" && typeof parsed.checkedAt === "string") {
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* ignore corrupt/missing cache */
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function writeCache(latest, env) {
|
|
71
|
+
try {
|
|
72
|
+
const dir = globalConfigDir(env);
|
|
73
|
+
mkdirSync(dir, { recursive: true });
|
|
74
|
+
const cache = { latest, checkedAt: new Date().toISOString() };
|
|
75
|
+
writeFileSync(cachePath(env), `${JSON.stringify(cache, null, 2)}\n`, "utf8");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* ignore write failures */
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function cacheFresh(cache) {
|
|
82
|
+
try {
|
|
83
|
+
const checked = new Date(cache.checkedAt).getTime();
|
|
84
|
+
return Number.isFinite(checked) && Date.now() - checked < CACHE_TTL_MS;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function fetchLatestVersion(env, fetchImpl = fetch) {
|
|
91
|
+
if (env.KYA_OFFLINE === "1" || env.KYA_OFFLINE === "true")
|
|
92
|
+
return undefined;
|
|
93
|
+
try {
|
|
94
|
+
const controller = new AbortController();
|
|
95
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
96
|
+
const res = await fetchImpl(NPM_REGISTRY_URL, {
|
|
97
|
+
signal: controller.signal,
|
|
98
|
+
headers: { Accept: "application/json" },
|
|
99
|
+
});
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
if (!res.ok)
|
|
102
|
+
return undefined;
|
|
103
|
+
const data = (await res.json());
|
|
104
|
+
const latest = data?.["dist-tags"]?.latest;
|
|
105
|
+
return typeof latest === "string" && latest ? latest : undefined;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns { current, latest } when a newer version is available on npm,
|
|
113
|
+
* undefined when already up-to-date, offline, or the check failed.
|
|
114
|
+
*/
|
|
115
|
+
export async function checkForUpdate(deps = {}) {
|
|
116
|
+
const env = deps.env ?? process.env;
|
|
117
|
+
const cache = readCache(env);
|
|
118
|
+
let latest = cache && cacheFresh(cache) ? cache.latest : undefined;
|
|
119
|
+
if (!latest) {
|
|
120
|
+
latest = await fetchLatestVersion(env, deps.fetch);
|
|
121
|
+
if (latest)
|
|
122
|
+
writeCache(latest, env);
|
|
123
|
+
}
|
|
124
|
+
if (!latest)
|
|
125
|
+
return undefined;
|
|
126
|
+
const current = CLI_VERSION;
|
|
127
|
+
if (compareVersions(latest, current) <= 0)
|
|
128
|
+
return undefined;
|
|
129
|
+
return { current, latest };
|
|
130
|
+
}
|
|
131
|
+
export function formatUpdateBanner(result) {
|
|
132
|
+
return `A new version of KYA is available: ${result.latest} (you have ${result.current}).\nRun: kya update\nOr: npm i -g @shield-agent/kya@latest`;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=update-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-check.js","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SA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C;IAC5B,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAyB;IAC1D,OAAO,sCAAsC,MAAM,CAAC,MAAM,cAAc,MAAM,CAAC,OAAO,6DAA6D,CAAC;AACtJ,CAAC"}
|
package/droid/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Droid (Factory) + Shield KYA
|
|
2
2
|
|
|
3
|
-
Preferred path is Droid's own CLI: `droid mcp add shield-kya "npx --no-install @shield-agent/kya@0.
|
|
3
|
+
Preferred path is Droid's own CLI: `droid mcp add shield-kya "npx --no-install @shield-agent/kya@0.23.0 serve-mcp --stdio" --env KYA_BASE_URL=https://shield-agent.com --env KYA_API_KEY=$KYA_API_KEY --env KYA_HOST=ide`.
|
|
4
4
|
|
|
5
5
|
`mcp.example.json` shows the expected on-disk shape (`~/.factory/mcp.json`) — **schema not yet verified against a live Droid install**; treat as a starting point and prefer `droid mcp add`.
|
|
6
6
|
|
package/droid/mcp.example.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"shield-kya": {
|
|
4
4
|
"command": "npx",
|
|
5
|
-
"args": ["--no-install", "@shield-agent/kya@0.
|
|
5
|
+
"args": ["--no-install", "@shield-agent/kya@0.23.0", "serve-mcp", "--stdio"],
|
|
6
6
|
"env": {
|
|
7
7
|
"KYA_BASE_URL": "https://shield-agent.com",
|
|
8
8
|
"KYA_API_KEY": "${KYA_API_KEY}",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"shield-kya": {
|
|
4
4
|
"command": "npx",
|
|
5
|
-
"args": ["--no-install", "@shield-agent/kya@0.
|
|
5
|
+
"args": ["--no-install", "@shield-agent/kya@0.23.0", "serve-mcp", "--stdio"],
|
|
6
6
|
"env": {
|
|
7
7
|
"KYA_BASE_URL": "https://shield-agent.com",
|
|
8
8
|
"KYA_API_KEY": "${KYA_API_KEY}",
|
package/grok/README.md
CHANGED
|
@@ -40,7 +40,7 @@ chat = client.chat.create(
|
|
|
40
40
|
There is no grok.com stdio path. For a local agent host use the same stdio launch as Claude:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npx --no-install @shield-agent/kya@0.
|
|
43
|
+
npx --no-install @shield-agent/kya@0.23.0 serve-mcp --stdio
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Env: `KYA_BASE_URL`, `KYA_API_KEY`, `KYA_HOST`. Codex and Gemini example configs in this package show the full snippets.
|
package/kilo/kilo.example.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcp": {
|
|
3
3
|
"shield-kya": {
|
|
4
4
|
"type": "local",
|
|
5
|
-
"command": ["npx", "--no-install", "@shield-agent/kya@0.
|
|
5
|
+
"command": ["npx", "--no-install", "@shield-agent/kya@0.23.0", "serve-mcp", "--stdio"],
|
|
6
6
|
"enabled": true,
|
|
7
7
|
"environment": {
|
|
8
8
|
"KYA_BASE_URL": "https://shield-agent.com",
|
package/kimi/mcp.example.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"shield-kya": {
|
|
4
4
|
"command": "npx",
|
|
5
|
-
"args": ["--no-install", "@shield-agent/kya@0.
|
|
5
|
+
"args": ["--no-install", "@shield-agent/kya@0.23.0", "serve-mcp", "--stdio"],
|
|
6
6
|
"env": {
|
|
7
7
|
"KYA_BASE_URL": "https://shield-agent.com",
|
|
8
8
|
"KYA_API_KEY": "${KYA_API_KEY}",
|
package/kiro/mcp.example.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"shield-kya": {
|
|
4
4
|
"command": "npx",
|
|
5
|
-
"args": ["--no-install", "@shield-agent/kya@0.
|
|
5
|
+
"args": ["--no-install", "@shield-agent/kya@0.23.0", "serve-mcp", "--stdio"],
|
|
6
6
|
"env": {
|
|
7
7
|
"KYA_BASE_URL": "https://shield-agent.com",
|
|
8
8
|
"KYA_API_KEY": "${KYA_API_KEY}",
|