@shield-agent/kya 0.21.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/LIMITATIONS.md +1 -0
- package/README.md +90 -31
- 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 +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +110 -37
- 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.d.ts.map +1 -1
- package/dist/commands/gate-serve.js +19 -5
- package/dist/commands/gate-serve.js.map +1 -1
- 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/receipt.d.ts +5 -2
- package/dist/commands/receipt.d.ts.map +1 -1
- package/dist/commands/receipt.js +7 -4
- package/dist/commands/receipt.js.map +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 +21 -2
- package/dist/receipt/share.d.ts.map +1 -1
- package/dist/receipt/share.js +68 -5
- package/dist/receipt/share.js.map +1 -1
- 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/telemetry.d.ts +135 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +427 -0
- package/dist/telemetry.js.map +1 -0
- 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 +4 -3
- package/qwen/settings.example.json +1 -1
- package/server.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangGraph.js-style tool adapter. Structural only
|
|
2
|
+
* LangGraph.js-style tool adapter. Structural only - no @langgraph imports.
|
|
3
3
|
* Matches the `{ name, description, schema, func }` tool shape; returns the
|
|
4
4
|
* same shape with a governed func.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mastra-style tool adapter. Structural only
|
|
2
|
+
* Mastra-style tool adapter. Structural only - no @mastra imports. Matches
|
|
3
3
|
* the `{ id, description, inputSchema, execute }` tool shape; returns the
|
|
4
4
|
* same shape with a governed execute.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mastra-style tool adapter. Structural only
|
|
2
|
+
* Mastra-style tool adapter. Structural only - no @mastra imports. Matches
|
|
3
3
|
* the `{ id, description, inputSchema, execute }` tool shape; returns the
|
|
4
4
|
* same shape with a governed execute.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI Agents TS function-tool adapter. Structural only
|
|
2
|
+
* OpenAI Agents TS function-tool adapter. Structural only - no
|
|
3
3
|
* @openai/agents import. Matches the `{ name, description, parameters,
|
|
4
4
|
* invoke }` function-tool shape where invoke receives the run context and a
|
|
5
5
|
* JSON string input; returns the same shape with a governed invoke. The
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI Agents TS function-tool adapter. Structural only
|
|
2
|
+
* OpenAI Agents TS function-tool adapter. Structural only - no
|
|
3
3
|
* @openai/agents import. Matches the `{ name, description, parameters,
|
|
4
4
|
* invoke }` function-tool shape where invoke receives the run context and a
|
|
5
5
|
* JSON string input; returns the same shape with a governed invoke. The
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vercel AI SDK tool adapter. Structural only
|
|
2
|
+
* Vercel AI SDK tool adapter. Structural only - no `ai` import. Matches the
|
|
3
3
|
* `{ description, parameters, execute }` tool shape; returns the same shape
|
|
4
4
|
* with a governed execute. AI SDK tools are keyed by name in the tools
|
|
5
5
|
* record, so the name is an explicit adapter option.
|
|
@@ -11,7 +11,7 @@ export interface VercelAiToolLike<TArgs = unknown, TResult = unknown> {
|
|
|
11
11
|
readonly execute: (args: TArgs) => Promise<TResult> | TResult;
|
|
12
12
|
}
|
|
13
13
|
export interface GovernVercelAiOptions extends GovernanceOptions {
|
|
14
|
-
/** Tool name
|
|
14
|
+
/** Tool name - the key this definition is registered under. */
|
|
15
15
|
readonly name: string;
|
|
16
16
|
}
|
|
17
17
|
export declare function governVercelAiTool<TArgs, TResult>(tool: VercelAiToolLike<TArgs, TResult>, options: GovernVercelAiOptions): VercelAiToolLike<TArgs, TResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vercel AI SDK tool adapter. Structural only
|
|
2
|
+
* Vercel AI SDK tool adapter. Structural only - no `ai` import. Matches the
|
|
3
3
|
* `{ description, parameters, execute }` tool shape; returns the same shape
|
|
4
4
|
* with a governed execute. AI SDK tools are keyed by name in the tools
|
|
5
5
|
* record, so the name is an explicit adapter option.
|
package/dist/sdk/govern.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In-process governance shim: evaluate a tool call through the same path
|
|
3
|
-
* `kya wrap` uses (offline sample evaluate by default
|
|
3
|
+
* `kya wrap` uses (offline sample evaluate by default - no network, no hosted
|
|
4
4
|
* plane required), record the trail event, then ALLOW/REQUIRE_APPROVE run the
|
|
5
5
|
* function while DENY throws KyaDeniedError without running it.
|
|
6
6
|
*
|
|
7
7
|
* Importing this module starts nothing: config resolves lazily on first call.
|
|
8
8
|
*
|
|
9
|
-
* Deliberate coupling: the trail write is fail-closed
|
|
9
|
+
* Deliberate coupling: the trail write is fail-closed - a governance shim
|
|
10
10
|
* where the audit record cannot be written does not run the action.
|
|
11
11
|
*/
|
|
12
12
|
import type { ResolvedConfig } from "../config.js";
|
package/dist/sdk/govern.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In-process governance shim: evaluate a tool call through the same path
|
|
3
|
-
* `kya wrap` uses (offline sample evaluate by default
|
|
3
|
+
* `kya wrap` uses (offline sample evaluate by default - no network, no hosted
|
|
4
4
|
* plane required), record the trail event, then ALLOW/REQUIRE_APPROVE run the
|
|
5
5
|
* function while DENY throws KyaDeniedError without running it.
|
|
6
6
|
*
|
|
7
7
|
* Importing this module starts nothing: config resolves lazily on first call.
|
|
8
8
|
*
|
|
9
|
-
* Deliberate coupling: the trail write is fail-closed
|
|
9
|
+
* Deliberate coupling: the trail write is fail-closed - a governance shim
|
|
10
10
|
* where the audit record cannot be written does not run the action.
|
|
11
11
|
*/
|
|
12
12
|
import { resolveConfig } from "../config.js";
|
|
@@ -19,7 +19,7 @@ export class KyaDeniedError extends KyaError {
|
|
|
19
19
|
reasonCode;
|
|
20
20
|
toolId;
|
|
21
21
|
constructor(input) {
|
|
22
|
-
super(`kya ${input.verdict}: ${input.toolId} (${input.reasonCode || "no reason"})
|
|
22
|
+
super(`kya ${input.verdict}: ${input.toolId} (${input.reasonCode || "no reason"}) - function not executed`, "KYA_DENIED", 1);
|
|
23
23
|
this.name = "KyaDeniedError";
|
|
24
24
|
this.verdict = input.verdict;
|
|
25
25
|
this.reasonCode = input.reasonCode;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @shield-agent/kya/sdk
|
|
2
|
+
* @shield-agent/kya/sdk - in-process governance shims for agent frameworks.
|
|
3
3
|
* Importing this surface starts no daemons, telemetry, or network clients;
|
|
4
4
|
* evaluation defaults to the offline sample path.
|
|
5
5
|
*/
|
package/dist/sdk/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @shield-agent/kya/sdk
|
|
2
|
+
* @shield-agent/kya/sdk - in-process governance shims for agent frameworks.
|
|
3
3
|
* Importing this surface starts no daemons, telemetry, or network clients;
|
|
4
4
|
* evaluation defaults to the offline sample path.
|
|
5
5
|
*/
|
|
@@ -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;AAIH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAiB9C,SAAS,UAAU,CAAC,CAAqB;IACvC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA6B;IAE7B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5C,eAAe,IAAI,CAAC,CAAC;YACrB,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC;YACnB,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,eAAe,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,MAAM,iBAAiB,GAAG,eAAe,GAAG,yBAAyB,CAAC;IACtE,MAAM,kBAAkB,GAAG,eAAe,GAAG,0BAA0B,CAAC;IACxE,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,eAAe;QACf,eAAe;QACf,QAAQ,EAAE,MAAM,GAAG,iBAAiB;QACpC,SAAS,EAAE,OAAO,GAAG,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
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export type TelemetrySurface = "mcp-stdio" | "mcp-http" | "report" | "gateway" | "hook";
|
|
2
|
+
export type TelemetryEventKind = "start" | "heartbeat" | "end" | "ping";
|
|
3
|
+
export interface TelemetryState {
|
|
4
|
+
/** true = opted in, false = opted out, undefined = never answered. */
|
|
5
|
+
readonly enabled?: boolean;
|
|
6
|
+
/** Random UUID, created only when the user opts in. Never derived from the machine or user. */
|
|
7
|
+
readonly installId?: string;
|
|
8
|
+
/** When the question was answered; its presence means "do not ask again". */
|
|
9
|
+
readonly askedAt?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TelemetryPayload {
|
|
12
|
+
readonly schema: 1;
|
|
13
|
+
readonly installId: string;
|
|
14
|
+
readonly sessionId: string;
|
|
15
|
+
readonly event: TelemetryEventKind;
|
|
16
|
+
readonly surface: TelemetrySurface;
|
|
17
|
+
readonly cliVersion: string;
|
|
18
|
+
readonly os: string;
|
|
19
|
+
readonly arch: string;
|
|
20
|
+
readonly nodeMajor: number;
|
|
21
|
+
readonly hostId: string;
|
|
22
|
+
readonly gateMode: string;
|
|
23
|
+
readonly hostedLinked: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Pick<Response, "ok" | "status">>;
|
|
26
|
+
export declare const DEFAULT_TELEMETRY_ENDPOINT = "https://shield-agent.com/api/v1/telemetry/kya";
|
|
27
|
+
export declare function telemetryStatePath(env: NodeJS.ProcessEnv): string;
|
|
28
|
+
/** Tolerant read: a missing, corrupt or hand-edited file is "never asked", never an error. */
|
|
29
|
+
export declare function readTelemetryState(env: NodeJS.ProcessEnv): TelemetryState;
|
|
30
|
+
export declare function writeTelemetryState(env: NodeJS.ProcessEnv, state: TelemetryState): void;
|
|
31
|
+
/** Why telemetry is forced off for THIS process regardless of the saved answer, or undefined. */
|
|
32
|
+
export declare function telemetryDisabledReason(env: NodeJS.ProcessEnv): string | undefined;
|
|
33
|
+
/** True only when the user opted in AND nothing overrides it for this process. */
|
|
34
|
+
export declare function isTelemetryEnabled(env: NodeJS.ProcessEnv): boolean;
|
|
35
|
+
/** https, or http on a loopback host (tests, self-hosting). Anything else falls back to the default. */
|
|
36
|
+
export declare function telemetryEndpoint(env: NodeJS.ProcessEnv): string;
|
|
37
|
+
/** Host registry slug from the session id `kya connect` writes (`mcp:<host>`), else "unknown". */
|
|
38
|
+
export declare function telemetryHostId(env: NodeJS.ProcessEnv): string;
|
|
39
|
+
/**
|
|
40
|
+
* The ONLY fields that ever leave the machine. A test pins this exact key set; adding a field here
|
|
41
|
+
* is a privacy change that needs the server validator, docs/telemetry.md and the privacy page updated.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildPayload(input: {
|
|
44
|
+
readonly installId: string;
|
|
45
|
+
readonly sessionId: string;
|
|
46
|
+
readonly event: TelemetryEventKind;
|
|
47
|
+
readonly surface: TelemetrySurface;
|
|
48
|
+
readonly env: NodeJS.ProcessEnv;
|
|
49
|
+
readonly cwd: string;
|
|
50
|
+
}): TelemetryPayload;
|
|
51
|
+
/**
|
|
52
|
+
* POST one JSON body. Returns whether the server accepted it. Never throws: telemetry must not be
|
|
53
|
+
* able to change what the CLI does, so every failure (network, timeout, redirect, non-2xx) is just
|
|
54
|
+
* `false`. The deliberate swallow is the whole point of this function.
|
|
55
|
+
*/
|
|
56
|
+
export declare function postTelemetry(url: string, body: unknown, fetchImpl?: FetchLike): Promise<boolean>;
|
|
57
|
+
export interface SessionBeacon {
|
|
58
|
+
/** Sends `end` (bounded by the send timeout) and stops the heartbeat. Idempotent. */
|
|
59
|
+
stop(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Start reporting for one long-lived process. A no-op unless the user opted in and nothing overrides
|
|
63
|
+
* it. Writes NOTHING to stdout or stderr (an MCP stdio process owns stdout as its protocol channel).
|
|
64
|
+
*/
|
|
65
|
+
export declare function startSessionBeacon(surface: TelemetrySurface, deps: {
|
|
66
|
+
readonly env: NodeJS.ProcessEnv;
|
|
67
|
+
readonly cwd: string;
|
|
68
|
+
readonly fetchImpl?: FetchLike;
|
|
69
|
+
readonly intervalMs?: number;
|
|
70
|
+
}): SessionBeacon;
|
|
71
|
+
/** At most one ping per this window, however many tool calls fire the hook. */
|
|
72
|
+
export declare const HOOK_PING_INTERVAL_MS: number;
|
|
73
|
+
/** Its mtime is the time of the last ping attempt. Content is empty: nothing to leak or corrupt. */
|
|
74
|
+
export declare function hookPingStampPath(env: NodeJS.ProcessEnv): string;
|
|
75
|
+
type SpawnLike = (command: string, args: readonly string[], options: {
|
|
76
|
+
detached: boolean;
|
|
77
|
+
stdio: "ignore";
|
|
78
|
+
env: NodeJS.ProcessEnv;
|
|
79
|
+
cwd: string;
|
|
80
|
+
windowsHide: boolean;
|
|
81
|
+
}) => {
|
|
82
|
+
unref(): void;
|
|
83
|
+
on(event: "error", listener: () => void): unknown;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Claims today's ping slot: true for exactly one caller per interval. A fresh stamp means someone
|
|
87
|
+
* already did; a stale one is removed and re-created with an exclusive create (`wx`), so of several
|
|
88
|
+
* hooks racing on a stale stamp only the one whose create succeeds gets the slot.
|
|
89
|
+
*/
|
|
90
|
+
export declare function claimHookPingSlot(env: NodeJS.ProcessEnv, nowMs?: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Called by `kya hook` after it has produced its answer. Cheap on the hot path: when telemetry is off
|
|
93
|
+
* or a ping already went out today this is one file read and one stat. Otherwise it claims the day's
|
|
94
|
+
* slot (see {@link claimHookPingSlot}) and starts the helper detached with ignored stdio, so the
|
|
95
|
+
* hook's stdout, stderr and exit code are untouched and it never waits. `host` is the hook's `--host`
|
|
96
|
+
* (claude, grok, ...), handed to the helper so the host mix stays meaningful for hook-only installs.
|
|
97
|
+
* A failed ping is not retried until tomorrow: a spawn storm while offline would be worse than a gap.
|
|
98
|
+
* Never throws. Returns whether a helper was started.
|
|
99
|
+
*/
|
|
100
|
+
export declare function maybeSpawnHookPing(deps: {
|
|
101
|
+
readonly env: NodeJS.ProcessEnv;
|
|
102
|
+
readonly cwd: string;
|
|
103
|
+
readonly host?: string;
|
|
104
|
+
readonly entry?: string;
|
|
105
|
+
readonly spawnImpl?: SpawnLike;
|
|
106
|
+
readonly nowMs?: number;
|
|
107
|
+
}): boolean;
|
|
108
|
+
/** The helper's job (`kya telemetry ping`): one `ping` as surface `hook`, same gates as every beacon. */
|
|
109
|
+
export declare function sendHookPing(env: NodeJS.ProcessEnv, cwd: string, fetchImpl?: FetchLike): Promise<boolean>;
|
|
110
|
+
export interface ConsentIo {
|
|
111
|
+
readonly error: (msg: string) => void;
|
|
112
|
+
/** Test seam: force interactive / non-interactive. Defaults to "stdin and stderr are TTYs". */
|
|
113
|
+
readonly isTty?: boolean;
|
|
114
|
+
/** Test seam: returns the raw answer line. Defaults to a readline prompt on stdin/stderr. */
|
|
115
|
+
readonly ask?: (question: string) => Promise<string>;
|
|
116
|
+
}
|
|
117
|
+
export declare const CONSENT_NOTICE: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Ask once, on an interactive terminal, in the setup commands (`start`, `init`, `connect`). Strict
|
|
120
|
+
* opt-in: only an explicit `y` / `yes` enables; empty input, anything else, or closing the prompt is No.
|
|
121
|
+
* Skipped when already answered, when an override forces telemetry off, and when not interactive
|
|
122
|
+
* (nothing is saved then, so the next interactive run can ask).
|
|
123
|
+
*/
|
|
124
|
+
export declare function maybePromptConsent(io: ConsentIo, env: NodeJS.ProcessEnv): Promise<"yes" | "no" | "skipped">;
|
|
125
|
+
export interface TelemetryCommandIo {
|
|
126
|
+
readonly log: (msg: string) => void;
|
|
127
|
+
readonly error: (msg: string) => void;
|
|
128
|
+
}
|
|
129
|
+
export declare function runTelemetryCommand(input: {
|
|
130
|
+
readonly sub: string | undefined;
|
|
131
|
+
readonly purge: boolean;
|
|
132
|
+
readonly json: boolean;
|
|
133
|
+
}, io: TelemetryCommandIo, env: NodeJS.ProcessEnv, cwd: string, fetchImpl?: FetchLike): Promise<number>;
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAiCA,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AACxF,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC;AAExE,MAAM,WAAW,cAAc;IA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