@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
package/dist/commands/connect.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* kya connect <host>
|
|
2
|
+
* kya connect <host> - wire Shield KYA MCP into a coding host's config file.
|
|
3
3
|
* Idempotent create/merge/skip. Global (home) scope by default; --project for
|
|
4
4
|
* hosts with project-level config. Hosts without a verified MCP config stay
|
|
5
5
|
* copy-paste recipes (recipeOnly).
|
|
6
6
|
*
|
|
7
7
|
* Home-config writes are merge-only and symlink-safe: an existing target is
|
|
8
8
|
* resolved with realpath and must be a regular file (dotfile setups symlink
|
|
9
|
-
* ~/.claude.json & co.
|
|
9
|
+
* ~/.claude.json & co. - writing the resolved regular file is supported).
|
|
10
10
|
*/
|
|
11
11
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, statSync, } from "node:fs";
|
|
12
12
|
import { homedir } from "node:os";
|
|
@@ -184,17 +184,17 @@ export function writeTarget(path) {
|
|
|
184
184
|
real = realpathSync(path);
|
|
185
185
|
}
|
|
186
186
|
catch {
|
|
187
|
-
throw new UsageError(`${path} cannot be resolved
|
|
187
|
+
throw new UsageError(`${path} cannot be resolved - refusing to write`);
|
|
188
188
|
}
|
|
189
189
|
if (!statSync(real).isFile()) {
|
|
190
|
-
throw new UsageError(`${path} does not resolve to a regular file
|
|
190
|
+
throw new UsageError(`${path} does not resolve to a regular file - refusing to write`);
|
|
191
191
|
}
|
|
192
192
|
return real;
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
195
|
* Where a create should land. A dangling symlink (dotfiles target not yet
|
|
196
|
-
* materialized) resolves to its link target
|
|
197
|
-
* the link's directory
|
|
196
|
+
* materialized) resolves to its link target - relative links resolve against
|
|
197
|
+
* the link's directory - so the rename completes the link instead of
|
|
198
198
|
* replacing it with a regular file.
|
|
199
199
|
*/
|
|
200
200
|
export function createTarget(path) {
|
|
@@ -206,7 +206,7 @@ export function createTarget(path) {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
catch {
|
|
209
|
-
/* not a symlink or unreadable link
|
|
209
|
+
/* not a symlink or unreadable link - plain create below */
|
|
210
210
|
}
|
|
211
211
|
mkdirSync(dirname(path), { recursive: true });
|
|
212
212
|
return path;
|
|
@@ -223,15 +223,15 @@ export function mergeJsonHostConfig(path, rootKey, block, force, serverKey = "sh
|
|
|
223
223
|
raw = JSON.parse(readFileSync(target, "utf8"));
|
|
224
224
|
}
|
|
225
225
|
catch {
|
|
226
|
-
// Never rewrite a host's real config we cannot parse
|
|
227
|
-
throw new UsageError(`${path} is not valid JSON
|
|
226
|
+
// Never rewrite a host's real config we cannot parse - that destroys settings.
|
|
227
|
+
throw new UsageError(`${path} is not valid JSON - fix it by hand or back it up and delete it, then re-run connect`);
|
|
228
228
|
}
|
|
229
229
|
const existing = raw[rootKey];
|
|
230
230
|
if (existing !== undefined && (typeof existing !== "object" || existing === null || Array.isArray(existing))) {
|
|
231
|
-
throw new UsageError(`${path} has "${rootKey}" but it is not an object
|
|
231
|
+
throw new UsageError(`${path} has "${rootKey}" but it is not an object - refusing to clobber it`);
|
|
232
232
|
}
|
|
233
233
|
const servers = (existing ?? {});
|
|
234
|
-
// Presence of the key
|
|
234
|
+
// Presence of the key - even a null value - counts as wired: never touch it
|
|
235
235
|
// without --force.
|
|
236
236
|
if (Object.prototype.hasOwnProperty.call(servers, serverKey) && !force) {
|
|
237
237
|
return "skipped";
|
|
@@ -276,7 +276,7 @@ function tomlGateTableBlock(url, dialect) {
|
|
|
276
276
|
* Minimal TOML wiring for Grok/Codex: append the [mcp_servers.<key>] table at
|
|
277
277
|
* EOF, skip when present, --force replaces the existing table block. An inline
|
|
278
278
|
* `<key> = …` definition under [mcp_servers] cannot be merged safely as
|
|
279
|
-
* text
|
|
279
|
+
* text - refuse it with a clear error.
|
|
280
280
|
*/
|
|
281
281
|
function mergeTomlHostConfig(path, hostId, force, dialect, serverKey = "shield-kya", gateUrl) {
|
|
282
282
|
const re = grokRegexes(serverKey);
|
|
@@ -294,10 +294,10 @@ function mergeTomlHostConfig(path, hostId, force, dialect, serverKey = "shield-k
|
|
|
294
294
|
return "skipped";
|
|
295
295
|
if (!header) {
|
|
296
296
|
if (re.quotedTable.test(text)) {
|
|
297
|
-
throw new UsageError(`${path} has a quoted [mcp_servers."${serverKey}"] table
|
|
297
|
+
throw new UsageError(`${path} has a quoted [mcp_servers."${serverKey}"] table - appending an unquoted one would duplicate it; fix the header by hand, then re-run connect`);
|
|
298
298
|
}
|
|
299
299
|
if (re.inline.test(text)) {
|
|
300
|
-
throw new UsageError(`${path} defines ${serverKey} inline under [mcp_servers]
|
|
300
|
+
throw new UsageError(`${path} defines ${serverKey} inline under [mcp_servers] - remove that line by hand, then re-run connect`);
|
|
301
301
|
}
|
|
302
302
|
const sep = text.length === 0 || text.endsWith("\n") ? "" : "\n";
|
|
303
303
|
atomicWriteSync(target, `${text}${sep}${block}`);
|
|
@@ -330,24 +330,24 @@ export function wireHost(input) {
|
|
|
330
330
|
const key = input.host.trim().toLowerCase();
|
|
331
331
|
const spec = CONNECT_REGISTRY[key];
|
|
332
332
|
if (!spec) {
|
|
333
|
-
throw new UsageError(`unknown host "${input.host}"
|
|
333
|
+
throw new UsageError(`unknown host "${input.host}" - supported: ${knownHosts().join(", ")}`);
|
|
334
334
|
}
|
|
335
335
|
if (spec.recipeOnly) {
|
|
336
|
-
throw new UsageError(`${spec.label} has no safe auto-wire
|
|
336
|
+
throw new UsageError(`${spec.label} has no safe auto-wire - follow the copy-paste recipe in ${spec.recipeOnly}`);
|
|
337
337
|
}
|
|
338
338
|
const scope = input.scope ?? "global";
|
|
339
339
|
const path = scope === "project"
|
|
340
340
|
? spec.projectPath?.(input.cwd)
|
|
341
341
|
: spec.globalPath?.(input.home);
|
|
342
342
|
if (!path) {
|
|
343
|
-
throw new UsageError(`${spec.label} has no ${scope}-scope config
|
|
343
|
+
throw new UsageError(`${spec.label} has no ${scope}-scope config - try --${scope === "project" ? "global" : "project"}`);
|
|
344
344
|
}
|
|
345
345
|
const status = mergeHostConfig(path, key, spec, Boolean(input.force), input.gateUrl ? "shield-kya-gate" : "shield-kya", input.gateUrl);
|
|
346
346
|
return { host: key, label: spec.label, path, status, scope };
|
|
347
347
|
}
|
|
348
348
|
/** Per-host next-step line after wiring (accurate about restarts). */
|
|
349
349
|
export function wireNextMessage(hostId, label, procs) {
|
|
350
|
-
const verify = "Verify: ask the agent to list its MCP tools
|
|
350
|
+
const verify = "Verify: ask the agent to list its MCP tools - kya.policy_evaluate, kya.session_ingest, kya.request_approval should appear.";
|
|
351
351
|
const reload = hostReload(hostId);
|
|
352
352
|
return reload
|
|
353
353
|
? `${reloadMessage(reload, label, hostRunning(reload, procs))} ${verify}`
|
|
@@ -356,7 +356,7 @@ export function wireNextMessage(hostId, label, procs) {
|
|
|
356
356
|
export async function runConnect(config, input, env = process.env) {
|
|
357
357
|
const home = env.KYA_HOME?.trim() || homedir();
|
|
358
358
|
if (input.hooks && !hookSupported(input.host)) {
|
|
359
|
-
throw new UsageError(`no hook wiring for ${input.host}
|
|
359
|
+
throw new UsageError(`no hook wiring for ${input.host} - supported: claude, grok, kimi`);
|
|
360
360
|
}
|
|
361
361
|
const wired = wireHost({
|
|
362
362
|
host: input.host,
|
|
@@ -374,7 +374,7 @@ export async function runConnect(config, input, env = process.env) {
|
|
|
374
374
|
r = wireHook({ host: wired.host, home, force: input.force });
|
|
375
375
|
}
|
|
376
376
|
catch (err) {
|
|
377
|
-
// The MCP write already landed
|
|
377
|
+
// The MCP write already landed - say so, so the user knows the state.
|
|
378
378
|
if (err instanceof UsageError) {
|
|
379
379
|
throw new UsageError(`${err.message} (note: MCP config was already wired at ${wired.path})`);
|
|
380
380
|
}
|
|
@@ -397,14 +397,14 @@ export function formatConnectHuman(r) {
|
|
|
397
397
|
? "created"
|
|
398
398
|
: r.status === "wired"
|
|
399
399
|
? "wired"
|
|
400
|
-
: "already wired (skipped
|
|
400
|
+
: "already wired (skipped - use --force to overwrite)";
|
|
401
401
|
const hooksVerb = r.hooksStatus === undefined
|
|
402
402
|
? undefined
|
|
403
403
|
: r.hooksStatus === "created"
|
|
404
404
|
? "hooks created"
|
|
405
405
|
: r.hooksStatus === "wired"
|
|
406
406
|
? "hooks wired"
|
|
407
|
-
: "hooks already wired (skipped
|
|
407
|
+
: "hooks already wired (skipped - use --force to overwrite)";
|
|
408
408
|
return [
|
|
409
409
|
`KYA connect ${r.host}`,
|
|
410
410
|
`${verb}: ${r.path}`,
|
package/dist/commands/dash.js
CHANGED
|
@@ -12,7 +12,7 @@ import { runInvoke } from "./invoke.js";
|
|
|
12
12
|
import { runKillAgent, runShrinkSession } from "./ops.js";
|
|
13
13
|
import { runOrr } from "./orr.js";
|
|
14
14
|
const AUTO_REFRESH_MS = 5_000;
|
|
15
|
-
/** TUI ORR stays first_party only
|
|
15
|
+
/** TUI ORR stays first_party only - Scorecard spawn is CLI-explicit (no env leak / stdin race). */
|
|
16
16
|
function deskOrr(cwd) {
|
|
17
17
|
return runOrr({
|
|
18
18
|
path: cwd,
|
|
@@ -200,7 +200,7 @@ export async function runDash(config, parsed, io, env) {
|
|
|
200
200
|
pasteBuf = "";
|
|
201
201
|
if (pending) {
|
|
202
202
|
pending = undefined;
|
|
203
|
-
io.log("paste ignored
|
|
203
|
+
io.log("paste ignored - confirm cancelled");
|
|
204
204
|
void paint({ clear: false });
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -226,7 +226,7 @@ export async function runDash(config, parsed, io, env) {
|
|
|
226
226
|
void (async () => {
|
|
227
227
|
try {
|
|
228
228
|
if (!stillLive()) {
|
|
229
|
-
io.log("offline mid-flight
|
|
229
|
+
io.log("offline mid-flight - aborted");
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
if (job.kind === "kill") {
|
|
@@ -242,7 +242,7 @@ export async function runDash(config, parsed, io, env) {
|
|
|
242
242
|
io.log(`clearance ${sh.from} → ${sh.to}`);
|
|
243
243
|
}
|
|
244
244
|
else if (job.kind === "decide") {
|
|
245
|
-
// Machine sk_* keys must not decide
|
|
245
|
+
// Machine sk_* keys must not decide - JWT / kya.approve only.
|
|
246
246
|
if (isMachineApiKey(config.apiKey ?? "")) {
|
|
247
247
|
io.log(`Machine API keys cannot ${job.decision} from the TUI. Run: kya ${job.decision} --id ${job.id}`);
|
|
248
248
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-serve.d.ts","sourceRoot":"","sources":["../../src/commands/gate-serve.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,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/**
|
|
2
2
|
* Hidden supervisor: runs the OTLP receiver and the gateway binary as its
|
|
3
3
|
* child in the foreground, publishing `<global .kya>/gate-server.json` once
|
|
4
|
-
* up. Spawned detached by `kya gate run`
|
|
4
|
+
* up. Spawned detached by `kya gate run` - never invoked by users directly.
|
|
5
5
|
* SIGTERM/SIGINT (or a dead binary child) shuts both down.
|
|
6
6
|
*/
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
@@ -32,7 +32,7 @@ export async function startGateSupervisor(input) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
catch (err) {
|
|
35
|
-
throw new UsageError(`gate OTLP receiver could not bind 127.0.0.1:${otlpPort}
|
|
35
|
+
throw new UsageError(`gate OTLP receiver could not bind 127.0.0.1:${otlpPort} - ${err instanceof Error ? err.message : String(err)}`);
|
|
36
36
|
}
|
|
37
37
|
const child = spawn(binary, ["-f", gateYamlPath(env)], {
|
|
38
38
|
stdio: ["ignore", "inherit", "inherit"],
|
|
@@ -68,7 +68,7 @@ export async function startGateSupervisor(input) {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
catch {
|
|
71
|
-
/* sync is best-effort
|
|
71
|
+
/* sync is best-effort - never crash the supervisor */
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
// Initial running sync + 60s heartbeat (only when credentials are configured).
|
|
@@ -77,7 +77,11 @@ export async function startGateSupervisor(input) {
|
|
|
77
77
|
? setInterval(() => doHostedSync("running", true), 60_000)
|
|
78
78
|
: undefined;
|
|
79
79
|
let shutdownFn = () => { };
|
|
80
|
-
|
|
80
|
+
// A binary that cannot be started (missing, not executable) is reported on the ChildProcess 'error'
|
|
81
|
+
// event, which would be an uncaught exception with no listener and kill the supervisor before any
|
|
82
|
+
// cleanup (state file, telemetry `end`). Treat it as a failed start: shut down, then reject.
|
|
83
|
+
let startError;
|
|
84
|
+
const waitUntilClosed = new Promise((resolve, reject) => {
|
|
81
85
|
let closing = false;
|
|
82
86
|
const shutdown = () => {
|
|
83
87
|
if (closing)
|
|
@@ -102,14 +106,24 @@ export async function startGateSupervisor(input) {
|
|
|
102
106
|
.catch(() => undefined)
|
|
103
107
|
.finally(() => {
|
|
104
108
|
clearGateState(env, process.pid);
|
|
105
|
-
|
|
109
|
+
if (startError)
|
|
110
|
+
reject(startError);
|
|
111
|
+
else
|
|
112
|
+
resolve();
|
|
106
113
|
});
|
|
107
114
|
};
|
|
108
115
|
shutdownFn = shutdown;
|
|
109
116
|
process.once("SIGINT", shutdown);
|
|
110
117
|
process.once("SIGTERM", shutdown);
|
|
111
118
|
child.once("exit", () => shutdown());
|
|
119
|
+
child.once("error", (err) => {
|
|
120
|
+
startError = new UsageError(`gate binary could not be started (${binary}): ${err instanceof Error ? err.message : String(err)}`);
|
|
121
|
+
shutdown();
|
|
122
|
+
});
|
|
112
123
|
});
|
|
124
|
+
// The rejection is for whoever awaits waitUntilClosed; without this a start failure that lands before
|
|
125
|
+
// the caller attaches its handler would be reported as an unhandled rejection and kill the process.
|
|
126
|
+
waitUntilClosed.catch(() => undefined);
|
|
113
127
|
return {
|
|
114
128
|
pid: process.pid,
|
|
115
129
|
childPid: child.pid ?? undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-serve.js","sourceRoot":"","sources":["../../src/commands/gate-serve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,mBAAmB,GAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC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;IACpG,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS;QAChC,GAAG;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,eAAe;QACf,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,CAAC,eAAe,CAAC;AAC/B,CAAC"}
|
package/dist/commands/gate.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export interface GateRunResult {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Generate the gateway YAML from gateways.json, then spawn the detached
|
|
70
|
-
* supervisor (OTLP receiver + gateway binary child). Requires the binary
|
|
70
|
+
* supervisor (OTLP receiver + gateway binary child). Requires the binary -
|
|
71
71
|
* never downloads; `kya gate setup` is the only downloader. Success is
|
|
72
72
|
* reported only after the listener actually answers.
|
|
73
73
|
*/
|
package/dist/commands/gate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `kya gate`
|
|
2
|
+
* `kya gate` - local MCP gateway: govern + audit tool calls to any MCP server.
|
|
3
3
|
*
|
|
4
4
|
* init scaffold .kya/gateways.json (recipes for the well-known servers)
|
|
5
5
|
* setup install the pinned gateway binary to .kya/bin (only downloader)
|
|
@@ -36,7 +36,7 @@ export function runGateInit(env = process.env) {
|
|
|
36
36
|
created: r.created,
|
|
37
37
|
next: r.created
|
|
38
38
|
? "move a recipe into \"servers\" and fill its placeholders, then `kya gate setup && kya gate run`"
|
|
39
|
-
: "gateways.json already exists
|
|
39
|
+
: "gateways.json already exists - edit it, then `kya gate run`",
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
export async function runGateSetup(env = process.env) {
|
|
@@ -54,7 +54,7 @@ export function bindScopeFromYaml(env) {
|
|
|
54
54
|
yaml = readFileSync(gateYamlPath(env), "utf8");
|
|
55
55
|
}
|
|
56
56
|
catch {
|
|
57
|
-
return { loopbackOnly: false, detail: "no generated config yet
|
|
57
|
+
return { loopbackOnly: false, detail: "no generated config yet - `kya gate run` generates one" };
|
|
58
58
|
}
|
|
59
59
|
const hasRule = yaml.includes("networkAuthorization:") && yaml.includes("127.0.0.0/8") && yaml.includes("::1");
|
|
60
60
|
const listenersOff = yaml.includes('statsAddr: "off"') && yaml.includes('readinessAddr: "off"');
|
|
@@ -63,7 +63,7 @@ export function bindScopeFromYaml(env) {
|
|
|
63
63
|
loopbackOnly,
|
|
64
64
|
detail: loopbackOnly
|
|
65
65
|
? "loopback-only (L4 allowlist 127.0.0.0/8 + ::1; stats/readiness/admin listeners off)"
|
|
66
|
-
: "WARNING: generated config is missing the loopback allowlist or listener offs
|
|
66
|
+
: "WARNING: generated config is missing the loopback allowlist or listener offs - re-run `kya gate run`",
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
async function probeListener(state) {
|
|
@@ -102,7 +102,7 @@ export async function runGateDoctor(env = process.env) {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Generate the gateway YAML from gateways.json, then spawn the detached
|
|
105
|
-
* supervisor (OTLP receiver + gateway binary child). Requires the binary
|
|
105
|
+
* supervisor (OTLP receiver + gateway binary child). Requires the binary -
|
|
106
106
|
* never downloads; `kya gate setup` is the only downloader. Success is
|
|
107
107
|
* reported only after the listener actually answers.
|
|
108
108
|
*/
|
|
@@ -110,7 +110,7 @@ export async function runGateRun(config, input = {}) {
|
|
|
110
110
|
const env = input.env ?? process.env;
|
|
111
111
|
const bin = inspectGateBinary(env);
|
|
112
112
|
if (!bin.present) {
|
|
113
|
-
throw new KyaError(`gateway binary not installed
|
|
113
|
+
throw new KyaError(`gateway binary not installed - run \`kya gate setup\` first (expected at ${gateBinaryPath(env)})`, "GATE_BINARY_MISSING");
|
|
114
114
|
}
|
|
115
115
|
const gateways = readGateways(env);
|
|
116
116
|
const yaml = generateGatewayYaml(gateways);
|
|
@@ -127,7 +127,7 @@ export async function runGateRun(config, input = {}) {
|
|
|
127
127
|
};
|
|
128
128
|
const existing = readGateState(env);
|
|
129
129
|
if (existing && pidAlive(existing.pid) && isGateDaemonProcess(existing.pid)) {
|
|
130
|
-
// Never rewrite gate.yaml under a live process
|
|
130
|
+
// Never rewrite gate.yaml under a live process - the gateway watches the
|
|
131
131
|
// file. Compare and report drift instead.
|
|
132
132
|
let drift = false;
|
|
133
133
|
try {
|
|
@@ -153,8 +153,8 @@ export async function runGateRun(config, input = {}) {
|
|
|
153
153
|
reused: true,
|
|
154
154
|
...(drift ? { drift } : {}),
|
|
155
155
|
next: drift
|
|
156
|
-
? "config changed since gateway started
|
|
157
|
-
: "gateway already running
|
|
156
|
+
? "config changed since gateway started - `kya gate stop && kya gate run` to apply"
|
|
157
|
+
: "gateway already running - `kya gate stop` first to reload config",
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
clearGateState(env);
|
|
@@ -174,7 +174,7 @@ export async function runGateRun(config, input = {}) {
|
|
|
174
174
|
const fail = async () => {
|
|
175
175
|
await killGateProcessTree(pid, readGateState(env)?.childPid);
|
|
176
176
|
clearGateState(env);
|
|
177
|
-
throw new KyaError(`gateway failed to start
|
|
177
|
+
throw new KyaError(`gateway failed to start - see ${logPath}`, "GATE_START_FAILED");
|
|
178
178
|
};
|
|
179
179
|
let probingSince = -1;
|
|
180
180
|
for (let waited = 0; waited < 10_000; waited += 100) {
|
|
@@ -204,7 +204,7 @@ export async function runGateRun(config, input = {}) {
|
|
|
204
204
|
configPath: gateYamlPath(env),
|
|
205
205
|
logPath,
|
|
206
206
|
reused: false,
|
|
207
|
-
next: `point your host at ${state.url}/mcp (server key shield-kya-gate)
|
|
207
|
+
next: `point your host at ${state.url}/mcp (server key shield-kya-gate) - ` +
|
|
208
208
|
"`kya connect <host> --gate` wires it; `kya gate stop` stops everything.",
|
|
209
209
|
};
|
|
210
210
|
}
|
|
@@ -259,7 +259,7 @@ export async function runGateStop(env = process.env, input = {}) {
|
|
|
259
259
|
return { stopped: false };
|
|
260
260
|
}
|
|
261
261
|
if (pidAlive(state.pid) && !isGateDaemonProcess(state.pid)) {
|
|
262
|
-
// Planted or recycled pid
|
|
262
|
+
// Planted or recycled pid - never signal a foreign process.
|
|
263
263
|
clearGateState(env);
|
|
264
264
|
triggerHostedSyncFromEnv({ cwd: input.cwd ?? process.cwd(), env, state: "configured-stopped" });
|
|
265
265
|
return { stopped: false, pid: state.pid, stale: true };
|
|
@@ -287,12 +287,12 @@ export function formatGateDoctorHuman(r) {
|
|
|
287
287
|
"KYA gate doctor",
|
|
288
288
|
r.binary.present
|
|
289
289
|
? `binary: ${r.binary.path}${r.binary.version ? ` (${r.binary.version})` : ""}`
|
|
290
|
-
: `binary: missing
|
|
290
|
+
: `binary: missing - run \`kya gate setup\``,
|
|
291
291
|
`config: ${r.config.path} (${r.config.servers} server${r.config.servers === 1 ? "" : "s"})`,
|
|
292
292
|
`bind scope: ${r.bindScope.detail}`,
|
|
293
293
|
r.listener.running
|
|
294
294
|
? `listener: ${r.listener.url} (${r.listener.healthy ? "healthy" : "not answering"})`
|
|
295
|
-
: "listener: not running
|
|
295
|
+
: "listener: not running - `kya gate run`",
|
|
296
296
|
syncLine,
|
|
297
297
|
].join("\n");
|
|
298
298
|
}
|
|
@@ -300,13 +300,13 @@ function formatLastSync(last) {
|
|
|
300
300
|
if (!last)
|
|
301
301
|
return "";
|
|
302
302
|
const status = last.ok ? "ok" : "failed";
|
|
303
|
-
const detail = last.error ? `
|
|
303
|
+
const detail = last.error ? ` - ${last.error}` : "";
|
|
304
304
|
return ` (last sync: ${status}${detail})`;
|
|
305
305
|
}
|
|
306
306
|
export function gateSubcommand(parsed) {
|
|
307
307
|
const sub = parsed.positionals[0];
|
|
308
308
|
if (sub === "init" || sub === "setup" || sub === "doctor" || sub === "status" || sub === "run" || sub === "stop") {
|
|
309
|
-
// `status` is an alias for `doctor`
|
|
309
|
+
// `status` is an alias for `doctor` - same output, hosted sync line included.
|
|
310
310
|
return sub === "status" ? "doctor" : sub;
|
|
311
311
|
}
|
|
312
312
|
throw new UsageError("Usage: kya gate <init|setup|doctor|status|run|stop>");
|
package/dist/commands/hook.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface HookInput {
|
|
|
5
5
|
readonly stdinText: string;
|
|
6
6
|
readonly env: NodeJS.ProcessEnv;
|
|
7
7
|
readonly cwd: string;
|
|
8
|
-
/** Test seam
|
|
8
|
+
/** Test seam - defaults to the offline runEvalTool path. */
|
|
9
9
|
readonly evaluate?: (toolId: string, args: unknown) => Promise<PolicyEvaluateResponse>;
|
|
10
10
|
}
|
|
11
11
|
export interface HookResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAM3D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACxF;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAwFD,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAqEnE"}
|
package/dist/commands/hook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* kya hook
|
|
2
|
+
* kya hook - PreToolUse interception for hosts with native hooks
|
|
3
3
|
* (Claude Code, Grok, Kimi Code). Offline local evaluate only: no network,
|
|
4
4
|
* sub-second, fail-open on any internal error. DENY (local never-list)
|
|
5
5
|
* blocks; REQUIRE_APPROVE records advisory unless --strict.
|
|
@@ -7,7 +7,27 @@
|
|
|
7
7
|
import { resolveConfig } from "../config.js";
|
|
8
8
|
import { runEvalTool } from "./eval-tool.js";
|
|
9
9
|
import { appendTrail, defaultSessionId, hostToProduct } from "../trail.js";
|
|
10
|
-
import {
|
|
10
|
+
import { deriveWireChangeFields } from "../diff-preview.js";
|
|
11
|
+
import { maybeSpawnNotifyFlush } from "../notify/dispatch.js";
|
|
12
|
+
function tokenCount(v) {
|
|
13
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0
|
|
14
|
+
? Math.floor(v)
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Accept input_tokens/output_tokens (Claude/Kimi) and inputTokens/outputTokens. */
|
|
18
|
+
function readUsageShape(raw) {
|
|
19
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
20
|
+
return undefined;
|
|
21
|
+
const u = raw;
|
|
22
|
+
const tokensIn = tokenCount(u.input_tokens ?? u.inputTokens);
|
|
23
|
+
const tokensOut = tokenCount(u.output_tokens ?? u.outputTokens);
|
|
24
|
+
if (tokensIn === undefined && tokensOut === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
return {
|
|
27
|
+
...(tokensIn !== undefined ? { tokensIn } : {}),
|
|
28
|
+
...(tokensOut !== undefined ? { tokensOut } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
11
31
|
/** Accept snake_case (Claude/Kimi) and camelCase (Grok) envelopes. */
|
|
12
32
|
function parsePayload(stdinText) {
|
|
13
33
|
let raw;
|
|
@@ -23,6 +43,11 @@ function parsePayload(stdinText) {
|
|
|
23
43
|
const event = (typeof p.hook_event_name === "string" && p.hook_event_name) ||
|
|
24
44
|
(typeof p.hookEventName === "string" && p.hookEventName) ||
|
|
25
45
|
undefined;
|
|
46
|
+
const toolResponse = p.tool_response && typeof p.tool_response === "object" && !Array.isArray(p.tool_response)
|
|
47
|
+
? p.tool_response
|
|
48
|
+
: p.toolResponse && typeof p.toolResponse === "object" && !Array.isArray(p.toolResponse)
|
|
49
|
+
? p.toolResponse
|
|
50
|
+
: undefined;
|
|
26
51
|
return {
|
|
27
52
|
event,
|
|
28
53
|
sessionId: (typeof p.session_id === "string" && p.session_id) ||
|
|
@@ -33,6 +58,7 @@ function parsePayload(stdinText) {
|
|
|
33
58
|
(typeof p.toolName === "string" && p.toolName) ||
|
|
34
59
|
undefined,
|
|
35
60
|
toolInput: p.tool_input ?? p.toolInput,
|
|
61
|
+
usage: readUsageShape(p.usage) ?? readUsageShape(toolResponse?.usage),
|
|
36
62
|
};
|
|
37
63
|
}
|
|
38
64
|
const ALLOW = { exitCode: 0, stdout: "", stderr: "" };
|
|
@@ -70,28 +96,39 @@ export async function runHook(input) {
|
|
|
70
96
|
(async (toolId, args) => (await runEvalTool(config, { toolId, args, offline: true })).response);
|
|
71
97
|
const response = await evaluate(payload.toolName, payload.toolInput ?? {});
|
|
72
98
|
// payload.cwd is host-supplied and only feeds the project-basename stamp;
|
|
73
|
-
// the trail path itself comes from env/KYA_HOME
|
|
99
|
+
// the trail path itself comes from env/KYA_HOME - no traversal risk.
|
|
74
100
|
const trailCwd = payload.cwd?.trim() || input.cwd;
|
|
75
|
-
|
|
101
|
+
// Wire change fields (summary, diffPreview, targetPath) feed the receipt's
|
|
102
|
+
// Changes tab; redaction + opt-out live inside deriveWireChangeFields.
|
|
103
|
+
const changeFields = deriveWireChangeFields(payload.toolName, payload.toolInput ?? {}, input.env);
|
|
104
|
+
const trailEvent = {
|
|
105
|
+
ts: new Date().toISOString(),
|
|
106
|
+
sessionId: payload.sessionId ?? defaultSessionId(input.env),
|
|
107
|
+
host: config.host,
|
|
108
|
+
product: hostToProduct(input.host),
|
|
109
|
+
toolId: response.toolId ?? payload.toolName,
|
|
110
|
+
verdict: response.verdict,
|
|
111
|
+
reasonCode: response.reasonCode ?? "",
|
|
112
|
+
mode: "offline",
|
|
113
|
+
neverEvent: response.reasonCode === "NEVER_EVENT",
|
|
114
|
+
argsHash: response.argsHash,
|
|
115
|
+
...(changeFields ?? {}),
|
|
116
|
+
...(payload.usage?.tokensIn !== undefined
|
|
117
|
+
? { tokensIn: payload.usage.tokensIn }
|
|
118
|
+
: {}),
|
|
119
|
+
...(payload.usage?.tokensOut !== undefined
|
|
120
|
+
? { tokensOut: payload.usage.tokensOut }
|
|
121
|
+
: {}),
|
|
122
|
+
};
|
|
76
123
|
try {
|
|
77
|
-
appendTrail(trailCwd,
|
|
78
|
-
ts: new Date().toISOString(),
|
|
79
|
-
sessionId: payload.sessionId ?? defaultSessionId(input.env),
|
|
80
|
-
host: config.host,
|
|
81
|
-
product: hostToProduct(input.host),
|
|
82
|
-
toolId: response.toolId ?? payload.toolName,
|
|
83
|
-
verdict: response.verdict,
|
|
84
|
-
reasonCode: response.reasonCode ?? "",
|
|
85
|
-
mode: "offline",
|
|
86
|
-
neverEvent: response.reasonCode === "NEVER_EVENT",
|
|
87
|
-
argsHash: response.argsHash,
|
|
88
|
-
summary: deriveTrailSummary(payload.toolName, payload.toolInput ?? {}),
|
|
89
|
-
...(targetPath ? { targetPath } : {}),
|
|
90
|
-
}, input.env);
|
|
124
|
+
appendTrail(trailCwd, trailEvent, input.env);
|
|
91
125
|
}
|
|
92
126
|
catch {
|
|
93
127
|
/* observe path never breaks the gate */
|
|
94
128
|
}
|
|
129
|
+
// Webhooks + OTLP export ride a detached helper; the hook never waits on
|
|
130
|
+
// the network. No-op unless a sink is configured.
|
|
131
|
+
maybeSpawnNotifyFlush({ env: input.env, cwd: trailCwd, event: trailEvent });
|
|
95
132
|
if (response.verdict === "DENY") {
|
|
96
133
|
return deny(`KYA denied ${payload.toolName}: ${response.reasonCode}`);
|
|
97
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAiC9D,SAAS,UAAU,CAAC,CAAU;IAC5B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,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AAC,SAAS,EAAE;gBACxC,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACF,IAAI,CAAC;YACH,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,wCAAwC;QAC1C,CAAC;QACD,yEAAyE;QACzE,kDAAkD;QAClD,qBAAqB,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QAE5E,IAAI,QAAQ,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,cAAc,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,OAAO,KAAK,iBAAiB,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC,oBAAoB,OAAO,CAAC,QAAQ,uBAAuB,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC;QACjG,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,CAAC,2DAA2D;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kya import - convert foreign trace exports (LangSmith, Langfuse, Phoenix,
|
|
3
|
+
* OTel JSON) into local trail events so the receipt/certify sees them.
|
|
4
|
+
*/
|
|
5
|
+
import type { ParsedArgs } from "../parse-args.js";
|
|
6
|
+
import { type ImportSource } from "../importers/index.js";
|
|
7
|
+
export interface ImportCliOptions {
|
|
8
|
+
readonly from: ImportSource | undefined;
|
|
9
|
+
readonly file: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function importOptionsFromArgs(parsed: ParsedArgs): ImportCliOptions;
|
|
12
|
+
export declare function runImport(opts: ImportCliOptions, io: {
|
|
13
|
+
log: (s: string) => void;
|
|
14
|
+
error: (s: string) => void;
|
|
15
|
+
}, cwd: string, env: NodeJS.ProcessEnv): Promise<number>;
|
|
16
|
+
//# sourceMappingURL=import-traces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-traces.d.ts","sourceRoot":"","sources":["../../src/commands/import-traces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAI1E;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,gBAAgB,EACtB,EAAE,EAAE;IAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,EAC5D,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flagString } from "../parse-args.js";
|
|
2
|
+
import { importTraces, renderImportSummary, } from "../importers/index.js";
|
|
3
|
+
const SOURCES = ["langsmith", "langfuse", "phoenix", "otel"];
|
|
4
|
+
export function importOptionsFromArgs(parsed) {
|
|
5
|
+
const rawFrom = flagString(parsed.flags, "from")?.toLowerCase();
|
|
6
|
+
const from = SOURCES.find((s) => s === rawFrom);
|
|
7
|
+
return { from, file: parsed.positionals[0] };
|
|
8
|
+
}
|
|
9
|
+
export async function runImport(opts, io, cwd, env) {
|
|
10
|
+
if (!opts.from || !opts.file) {
|
|
11
|
+
io.error("Usage: kya import --from <langsmith|langfuse|phoenix|otel> <file>");
|
|
12
|
+
return 2;
|
|
13
|
+
}
|
|
14
|
+
const result = await importTraces({ from: opts.from, file: opts.file, cwd, env });
|
|
15
|
+
io.log(renderImportSummary(result));
|
|
16
|
+
return result.imported === 0 && result.errors.length > 0 ? 1 : 0;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=import-traces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-traces.js","sourceRoot":"","sources":["../../src/commands/import-traces.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,OAAO,GAA4B,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAOtF,MAAM,UAAU,qBAAqB,CAAC,MAAkB;IACtD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;IAChD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAsB,EACtB,EAA4D,EAC5D,GAAW,EACX,GAAsB;IAEtB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7B,EAAE,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC9E,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAClF,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -45,7 +45,7 @@ export function initFromArgs(parsed, cwd = process.cwd()) {
|
|
|
45
45
|
const force = parsed.flags["force"] === true || parsed.flags["force"] === "true";
|
|
46
46
|
return runInit({ cwd, baseUrl, host, force });
|
|
47
47
|
}
|
|
48
|
-
const ENV_EXAMPLE = `# Shield KYA light install
|
|
48
|
+
const ENV_EXAMPLE = `# Shield KYA light install - copy to .env (never commit secrets)
|
|
49
49
|
# Docs: docs/guides/kya-light-install.md
|
|
50
50
|
|
|
51
51
|
# Control plane origin (hosted or local free console)
|