@shield-agent/kya 0.22.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +247 -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/search.d.ts +11 -0
- package/dist/receipt/search.d.ts.map +1 -1
- package/dist/receipt/search.js +70 -3
- package/dist/receipt/search.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 +5 -3
- package/qwen/settings.example.json +1 -1
- package/server.json +2 -2
package/dist/receipt/share.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `kya receipt --share`
|
|
2
|
+
* `kya receipt --share` - publish a redacted summary of the current report
|
|
3
3
|
* window to the hosted platform and get back a public URL.
|
|
4
4
|
*
|
|
5
5
|
* The payload is built FROM THE RECEIPT MODEL, never from the raw trail:
|
|
6
6
|
* aggregate counts and public labels only. No absolute paths, no session ids,
|
|
7
|
-
* no tool arguments, no identity (baseUrl/IP)
|
|
7
|
+
* no tool arguments, no identity (baseUrl/IP) - anything that could identify
|
|
8
8
|
* a machine, project, or person stays local. Dependency-free: global fetch.
|
|
9
9
|
*/
|
|
10
10
|
import { CLI_VERSION } from "../version.js";
|
|
@@ -94,7 +94,7 @@ export function clampShareRetries(raw) {
|
|
|
94
94
|
return 0;
|
|
95
95
|
return Math.min(n, SHARE_MAX_RETRIES);
|
|
96
96
|
}
|
|
97
|
-
/** POST the payload; 15s timeout. Never throws
|
|
97
|
+
/** POST the payload; 15s timeout. Never throws - failures come back as {ok:false}. */
|
|
98
98
|
export async function shareReceiptPayload(payload, opts) {
|
|
99
99
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
100
100
|
const controller = new AbortController();
|
|
@@ -124,8 +124,8 @@ export async function shareReceiptPayload(payload, opts) {
|
|
|
124
124
|
status: 429,
|
|
125
125
|
retryAfterSeconds,
|
|
126
126
|
error: retryAfterSeconds != null
|
|
127
|
-
? `share failed: rate limited
|
|
128
|
-
: "share failed: rate limited
|
|
127
|
+
? `share failed: rate limited - retry in ~${retryAfterSeconds}s`
|
|
128
|
+
: "share failed: rate limited - retry later",
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
return { ok: false, status: res.status, error: `share failed: HTTP ${res.status}` };
|
package/dist/sample-tools.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sample custom tools for light install
|
|
2
|
+
* Sample custom tools for light install - zero vertical packs (R8).
|
|
3
3
|
* Same descriptors as docs/dev/kya-custom-tools-sample.md.
|
|
4
4
|
*/
|
|
5
5
|
export type ActionClass = "READ" | "WRITE" | "EXTERNAL_SIDE_EFFECT" | "EXPORT";
|
package/dist/sample-tools.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SandboxDriver } from "./types.js";
|
|
2
|
-
/** In-memory driver for unit tests
|
|
2
|
+
/** In-memory driver for unit tests - never talks to a real VMM. */
|
|
3
3
|
export declare function createMockDriver(): SandboxDriver & {
|
|
4
4
|
readonly live: Set<string>;
|
|
5
5
|
};
|
package/dist/sdk/a2a.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* performs the send. `a2a` is a registry-unknown server, so offline evaluate
|
|
5
5
|
* lands on the safe REQUIRE_APPROVE/UNKNOWN path unless the action is
|
|
6
6
|
* declared irreversible. Fleet-level A2A governance (mTLS identity, org
|
|
7
|
-
* policy between runtimes) is the kya gateway's job
|
|
7
|
+
* policy between runtimes) is the kya gateway's job - this is the
|
|
8
8
|
* single-process complement.
|
|
9
9
|
*/
|
|
10
10
|
import type { ResolvedConfig } from "../config.js";
|
|
@@ -12,7 +12,7 @@ export interface GovernA2aSendOptions {
|
|
|
12
12
|
readonly peerId: string;
|
|
13
13
|
readonly peerUrl?: string;
|
|
14
14
|
readonly action: string;
|
|
15
|
-
/** Short human description of the payload
|
|
15
|
+
/** Short human description of the payload - trail summary only, never the body. */
|
|
16
16
|
readonly payloadSummary?: string;
|
|
17
17
|
readonly irreversible?: boolean;
|
|
18
18
|
readonly config?: ResolvedConfig;
|
package/dist/sdk/a2a.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* performs the send. `a2a` is a registry-unknown server, so offline evaluate
|
|
5
5
|
* lands on the safe REQUIRE_APPROVE/UNKNOWN path unless the action is
|
|
6
6
|
* declared irreversible. Fleet-level A2A governance (mTLS identity, org
|
|
7
|
-
* policy between runtimes) is the kya gateway's job
|
|
7
|
+
* policy between runtimes) is the kya gateway's job - this is the
|
|
8
8
|
* single-process complement.
|
|
9
9
|
*/
|
|
10
10
|
import { runEvalTool } from "../commands/eval-tool.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic Agent SDK tool adapter. Structural only
|
|
2
|
+
* Anthropic Agent SDK tool adapter. Structural only - no
|
|
3
3
|
* @anthropic-ai/claude-agent-sdk import. Matches the
|
|
4
4
|
* `{ name, description, inputSchema, handler }` in-process tool shape where
|
|
5
5
|
* handler receives parsed args plus SDK extras; returns the same shape with
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic Agent SDK tool adapter. Structural only
|
|
2
|
+
* Anthropic Agent SDK tool adapter. Structural only - no
|
|
3
3
|
* @anthropic-ai/claude-agent-sdk import. Matches the
|
|
4
4
|
* `{ name, description, inputSchema, handler }` in-process tool shape where
|
|
5
5
|
* handler receives parsed args plus SDK extras; returns the same shape with
|
|
@@ -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
|
-
* 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
|
}
|
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,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
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,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE5E;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAEpF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAC3B,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,CAAC,EAAE,MAAM,GACZ,YAAY,CAed;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAmBhE;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAexD;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,IAAI,CAQN;AAoED,gFAAgF;AAChF,eAAO,MAAM,eAAe,QAAc,CAAC;AAqC3C;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,UAAU,EAAE,CAazF;AAED,6EAA6E;AAC7E,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,IAAI,EACX,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,UAAU,EAAE,CAOd;AAED,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAO7E"}
|
package/dist/trail.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
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
|
}
|