@shield-agent/kya 0.1.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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +207 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +111 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +143 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/eval-tool.d.ts +27 -0
- package/dist/commands/eval-tool.d.ts.map +1 -0
- package/dist/commands/eval-tool.js +87 -0
- package/dist/commands/eval-tool.js.map +1 -0
- package/dist/commands/init.d.ts +19 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +69 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/orr.d.ts +81 -0
- package/dist/commands/orr.d.ts.map +1 -0
- package/dist/commands/orr.js +468 -0
- package/dist/commands/orr.js.map +1 -0
- package/dist/commands/register-agent.d.ts +17 -0
- package/dist/commands/register-agent.d.ts.map +1 -0
- package/dist/commands/register-agent.js +39 -0
- package/dist/commands/register-agent.js.map +1 -0
- package/dist/commands/serve-mcp.d.ts +19 -0
- package/dist/commands/serve-mcp.d.ts.map +1 -0
- package/dist/commands/serve-mcp.js +40 -0
- package/dist/commands/serve-mcp.js.map +1 -0
- package/dist/config.d.ts +45 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +34 -0
- package/dist/errors.js.map +1 -0
- package/dist/hash.d.ts +5 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +25 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/http.d.ts +26 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/http.js +118 -0
- package/dist/mcp/http.js.map +1 -0
- package/dist/mcp/protocol.d.ts +53 -0
- package/dist/mcp/protocol.d.ts.map +1 -0
- package/dist/mcp/protocol.js +282 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/stdio.d.ts +22 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +67 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/offline-evaluate.d.ts +23 -0
- package/dist/offline-evaluate.d.ts.map +1 -0
- package/dist/offline-evaluate.js +68 -0
- package/dist/offline-evaluate.js.map +1 -0
- package/dist/parse-args.d.ts +14 -0
- package/dist/parse-args.d.ts.map +1 -0
- package/dist/parse-args.js +86 -0
- package/dist/parse-args.js.map +1 -0
- package/dist/sample-tools.d.ts +19 -0
- package/dist/sample-tools.d.ts.map +1 -0
- package/dist/sample-tools.js +37 -0
- package/dist/sample-tools.js.map +1 -0
- package/package.json +65 -0
- package/server.json +59 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool surface for local gate — proxies to Shield KYA (sole PEP).
|
|
3
|
+
* Does not execute irreversible side effects; only evaluate / ingest / request approval.
|
|
4
|
+
* Host-agnostic: stdio or HTTP transport.
|
|
5
|
+
*/
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { computeArgsHash } from "../hash.js";
|
|
8
|
+
import { findSampleTool } from "../sample-tools.js";
|
|
9
|
+
export const MCP_SERVER_INFO = {
|
|
10
|
+
name: "shield-kya",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
title: "Shield Agent AI (KYA)",
|
|
13
|
+
description: "Know Your Agent control plane: policy evaluate, session observe, and high-stakes gates. Standard MCP tools; no proprietary client protocol.",
|
|
14
|
+
};
|
|
15
|
+
export const MCP_TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
name: "kya.policy_evaluate",
|
|
18
|
+
description: "Evaluate ALLOW | DENY | REQUIRE_APPROVE for an agent action at the tool boundary. Sole PEP is Shield KYA; missing APPROVED means no irreversible side effect.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
action: { type: "string", description: "Action or toolId" },
|
|
23
|
+
toolId: { type: "string", description: "Stable tool id (preferred)" },
|
|
24
|
+
agentId: { type: "string" },
|
|
25
|
+
irreversible: { type: "boolean" },
|
|
26
|
+
sessionRisk: { type: "string", enum: ["LOW", "MEDIUM", "HIGH"] },
|
|
27
|
+
approvalStatus: {
|
|
28
|
+
type: "string",
|
|
29
|
+
enum: ["NONE", "PENDING", "APPROVED", "REJECTED"],
|
|
30
|
+
},
|
|
31
|
+
args: { type: "object", description: "Tool args (hashed, not logged raw)" },
|
|
32
|
+
argsHash: { type: "string" },
|
|
33
|
+
host: { type: "string", enum: ["ide", "runtime"] },
|
|
34
|
+
context: { type: "object" },
|
|
35
|
+
},
|
|
36
|
+
required: [],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "kya.session_ingest",
|
|
41
|
+
description: "Ingest an AgentEvent-compatible session observation for raise-only risk. Risk may only raise severity, never auto-ALLOW.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
session: { type: "object" },
|
|
46
|
+
sessionId: { type: "string" },
|
|
47
|
+
host: { type: "string", enum: ["ide", "runtime"] },
|
|
48
|
+
riskLevel: { type: "string", enum: ["LOW", "MEDIUM", "HIGH"] },
|
|
49
|
+
hitCodes: { type: "array", items: { type: "string" } },
|
|
50
|
+
source: { type: "string" },
|
|
51
|
+
model: { type: "string" },
|
|
52
|
+
payload: { type: "object" },
|
|
53
|
+
},
|
|
54
|
+
required: [],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "kya.request_approval",
|
|
59
|
+
description: "Open a human approval request for a high-stakes side effect. Does not execute the side effect.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
action: { type: "string" },
|
|
64
|
+
toolId: { type: "string" },
|
|
65
|
+
agentId: { type: "string" },
|
|
66
|
+
resourceId: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Work-item / correlation UUID (mapped to disputeId binding)",
|
|
69
|
+
},
|
|
70
|
+
summary: { type: "string" },
|
|
71
|
+
packVersion: { type: "string" },
|
|
72
|
+
},
|
|
73
|
+
required: ["action"],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
export async function handleMcpToolCall(name, args, ctx) {
|
|
78
|
+
const a = args ?? {};
|
|
79
|
+
try {
|
|
80
|
+
switch (name) {
|
|
81
|
+
case "kya.policy_evaluate":
|
|
82
|
+
return await callPolicyEvaluate(a, ctx);
|
|
83
|
+
case "kya.session_ingest":
|
|
84
|
+
return await callSessionIngest(a, ctx);
|
|
85
|
+
case "kya.request_approval":
|
|
86
|
+
return await callRequestApproval(a, ctx);
|
|
87
|
+
default:
|
|
88
|
+
return textResult({ error: `unknown tool: ${name}` }, true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
93
|
+
return textResult({ error: message }, true);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function callPolicyEvaluate(a, ctx) {
|
|
97
|
+
const toolId = str(a.toolId) ?? str(a.action);
|
|
98
|
+
if (!toolId) {
|
|
99
|
+
return textResult({ error: "action or toolId required" }, true);
|
|
100
|
+
}
|
|
101
|
+
const sample = findSampleTool(toolId);
|
|
102
|
+
const host = parseHost(str(a.host), ctx.host);
|
|
103
|
+
const argsObj = a.args && typeof a.args === "object" && !Array.isArray(a.args)
|
|
104
|
+
? a.args
|
|
105
|
+
: {};
|
|
106
|
+
const argsHash = str(a.argsHash) ?? computeArgsHash(argsObj);
|
|
107
|
+
const irreversible = typeof a.irreversible === "boolean"
|
|
108
|
+
? a.irreversible
|
|
109
|
+
: (sample?.irreversible ?? false);
|
|
110
|
+
const response = await ctx.client.evaluatePolicy({
|
|
111
|
+
toolId,
|
|
112
|
+
action: toolId,
|
|
113
|
+
argsHash,
|
|
114
|
+
irreversible,
|
|
115
|
+
actionClass: sample?.actionClass,
|
|
116
|
+
dataClass: sample?.dataClass,
|
|
117
|
+
sessionRisk: str(a.sessionRisk) ?? "LOW",
|
|
118
|
+
approvalStatus: str(a.approvalStatus) ?? "NONE",
|
|
119
|
+
env: {
|
|
120
|
+
host,
|
|
121
|
+
agentId: str(a.agentId) ?? ctx.agentId,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
return textResult(response);
|
|
125
|
+
}
|
|
126
|
+
async function callSessionIngest(a, ctx) {
|
|
127
|
+
const session = a.session && typeof a.session === "object" && !Array.isArray(a.session)
|
|
128
|
+
? a.session
|
|
129
|
+
: {};
|
|
130
|
+
const sessionId = str(a.sessionId) ??
|
|
131
|
+
str(session.sessionId) ??
|
|
132
|
+
str(session.id) ??
|
|
133
|
+
randomUUID();
|
|
134
|
+
const host = parseHost(str(a.host) ?? str(session.host), ctx.host);
|
|
135
|
+
const riskLevel = str(a.riskLevel) ??
|
|
136
|
+
str(session.riskLevel) ??
|
|
137
|
+
str(session.riskHint) ??
|
|
138
|
+
"LOW";
|
|
139
|
+
const hitCodes = Array.isArray(a.hitCodes)
|
|
140
|
+
? a.hitCodes
|
|
141
|
+
: Array.isArray(session.hitCodes)
|
|
142
|
+
? session.hitCodes
|
|
143
|
+
: undefined;
|
|
144
|
+
const payload = a.payload ??
|
|
145
|
+
session.payload ??
|
|
146
|
+
(session.tools
|
|
147
|
+
? { tools: session.tools }
|
|
148
|
+
: undefined);
|
|
149
|
+
const response = await ctx.client.ingestSession({
|
|
150
|
+
sessionId,
|
|
151
|
+
source: str(a.source) ?? str(session.source) ?? "mcp-gate",
|
|
152
|
+
model: str(a.model) ?? str(session.model),
|
|
153
|
+
riskLevel,
|
|
154
|
+
hitCodes,
|
|
155
|
+
payload,
|
|
156
|
+
host,
|
|
157
|
+
});
|
|
158
|
+
return textResult(response);
|
|
159
|
+
}
|
|
160
|
+
async function callRequestApproval(a, ctx) {
|
|
161
|
+
const action = str(a.action) ?? str(a.toolId);
|
|
162
|
+
if (!action) {
|
|
163
|
+
return textResult({ error: "action required" }, true);
|
|
164
|
+
}
|
|
165
|
+
const agentId = str(a.agentId) ?? ctx.agentId;
|
|
166
|
+
if (!agentId) {
|
|
167
|
+
return textResult({
|
|
168
|
+
error: "agentId required (set KYA_AGENT_ID or pass agentId; run register-agent first)",
|
|
169
|
+
}, true);
|
|
170
|
+
}
|
|
171
|
+
const resourceId = str(a.resourceId) ?? randomUUID();
|
|
172
|
+
// Server expects UUID for disputeId work-item binding
|
|
173
|
+
const disputeId = isUuid(resourceId) ? resourceId : randomUUID();
|
|
174
|
+
const response = await ctx.client.requestApproval({
|
|
175
|
+
agentId,
|
|
176
|
+
disputeId,
|
|
177
|
+
toolId: str(a.toolId) ?? action,
|
|
178
|
+
action,
|
|
179
|
+
packVersion: str(a.packVersion) ?? "generic",
|
|
180
|
+
});
|
|
181
|
+
return textResult({
|
|
182
|
+
...response,
|
|
183
|
+
note: "Approval opened only — no side effect executed (fail closed until APPROVED)",
|
|
184
|
+
summary: str(a.summary),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function textResult(data, isError = false) {
|
|
188
|
+
return {
|
|
189
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
190
|
+
isError,
|
|
191
|
+
structuredContent: data,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function str(v) {
|
|
195
|
+
if (typeof v === "string" && v.length > 0)
|
|
196
|
+
return v;
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
function parseHost(raw, fallback) {
|
|
200
|
+
if (raw === "ide" || raw === "runtime")
|
|
201
|
+
return raw;
|
|
202
|
+
return fallback;
|
|
203
|
+
}
|
|
204
|
+
function isUuid(s) {
|
|
205
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s);
|
|
206
|
+
}
|
|
207
|
+
export async function handleJsonRpc(msg, ctx) {
|
|
208
|
+
const id = msg.id ?? null;
|
|
209
|
+
// notifications (no id) — process but no response for some
|
|
210
|
+
try {
|
|
211
|
+
switch (msg.method) {
|
|
212
|
+
case "initialize":
|
|
213
|
+
return {
|
|
214
|
+
jsonrpc: "2.0",
|
|
215
|
+
id,
|
|
216
|
+
result: {
|
|
217
|
+
protocolVersion: "2024-11-05",
|
|
218
|
+
capabilities: { tools: {} },
|
|
219
|
+
serverInfo: {
|
|
220
|
+
name: MCP_SERVER_INFO.name,
|
|
221
|
+
version: MCP_SERVER_INFO.version,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
case "notifications/initialized":
|
|
226
|
+
case "initialized":
|
|
227
|
+
return null;
|
|
228
|
+
case "ping":
|
|
229
|
+
return { jsonrpc: "2.0", id, result: {} };
|
|
230
|
+
case "tools/list":
|
|
231
|
+
return {
|
|
232
|
+
jsonrpc: "2.0",
|
|
233
|
+
id,
|
|
234
|
+
result: {
|
|
235
|
+
tools: MCP_TOOLS.map((t) => ({
|
|
236
|
+
name: t.name,
|
|
237
|
+
description: t.description,
|
|
238
|
+
inputSchema: t.inputSchema,
|
|
239
|
+
})),
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
case "tools/call": {
|
|
243
|
+
const params = (msg.params ?? {});
|
|
244
|
+
if (!params.name) {
|
|
245
|
+
return {
|
|
246
|
+
jsonrpc: "2.0",
|
|
247
|
+
id,
|
|
248
|
+
error: { code: -32602, message: "tools/call requires name" },
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const result = await handleMcpToolCall(params.name, params.arguments, ctx);
|
|
252
|
+
return {
|
|
253
|
+
jsonrpc: "2.0",
|
|
254
|
+
id,
|
|
255
|
+
result: {
|
|
256
|
+
content: result.content,
|
|
257
|
+
isError: result.isError ?? false,
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
default:
|
|
262
|
+
if (msg.id === undefined)
|
|
263
|
+
return null;
|
|
264
|
+
return {
|
|
265
|
+
jsonrpc: "2.0",
|
|
266
|
+
id,
|
|
267
|
+
error: { code: -32601, message: `Method not found: ${msg.method}` },
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
273
|
+
if (msg.id === undefined)
|
|
274
|
+
return null;
|
|
275
|
+
return {
|
|
276
|
+
jsonrpc: "2.0",
|
|
277
|
+
id,
|
|
278
|
+
error: { code: -32000, message },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/mcp/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,6IAA6I;CACvI,CAAC;AAQX,MAAM,CAAC,MAAM,SAAS,GAA0B;IAC9C;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,+JAA+J;QACjK,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAA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CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { KyaHttpClient } from "../client.js";
|
|
2
|
+
import type { Host } from "../config.js";
|
|
3
|
+
export interface StdioMcpOptions {
|
|
4
|
+
readonly client: KyaHttpClient;
|
|
5
|
+
readonly kyaHost: Host;
|
|
6
|
+
readonly agentId?: string;
|
|
7
|
+
readonly input?: NodeJS.ReadableStream;
|
|
8
|
+
readonly output?: NodeJS.WritableStream;
|
|
9
|
+
/** When true, do not attach process signal handlers (tests). */
|
|
10
|
+
readonly bare?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface StdioMcpHandle {
|
|
13
|
+
/** Resolve when stream ends. */
|
|
14
|
+
readonly done: Promise<void>;
|
|
15
|
+
close(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MCP over stdio — newline-delimited JSON-RPC 2.0 (common host shape).
|
|
19
|
+
* Also accepts Content-Length framed messages (LSP-style) when headers present.
|
|
20
|
+
*/
|
|
21
|
+
export declare function startStdioMcp(options: StdioMcpOptions): StdioMcpHandle;
|
|
22
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/mcp/stdio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAOzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IACxC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CA4BtE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as readline from "node:readline";
|
|
2
|
+
import { handleJsonRpc, } from "./protocol.js";
|
|
3
|
+
/**
|
|
4
|
+
* MCP over stdio — newline-delimited JSON-RPC 2.0 (common host shape).
|
|
5
|
+
* Also accepts Content-Length framed messages (LSP-style) when headers present.
|
|
6
|
+
*/
|
|
7
|
+
export function startStdioMcp(options) {
|
|
8
|
+
const input = options.input ?? process.stdin;
|
|
9
|
+
const output = options.output ?? process.stdout;
|
|
10
|
+
const ctx = {
|
|
11
|
+
client: options.client,
|
|
12
|
+
host: options.kyaHost,
|
|
13
|
+
agentId: options.agentId,
|
|
14
|
+
};
|
|
15
|
+
let closed = false;
|
|
16
|
+
const rl = readline.createInterface({ input, crlfDelay: Infinity });
|
|
17
|
+
const done = new Promise((resolve) => {
|
|
18
|
+
rl.on("line", (line) => {
|
|
19
|
+
void onLine(line.trim(), ctx, output);
|
|
20
|
+
});
|
|
21
|
+
rl.on("close", () => {
|
|
22
|
+
closed = true;
|
|
23
|
+
resolve();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
done,
|
|
28
|
+
close() {
|
|
29
|
+
if (!closed)
|
|
30
|
+
rl.close();
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function onLine(line, ctx, output) {
|
|
35
|
+
if (!line || line.startsWith("Content-Length:")) {
|
|
36
|
+
// Content-Length framing without body on same line — skip header-only lines
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let msg;
|
|
40
|
+
try {
|
|
41
|
+
msg = JSON.parse(line);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
writeJson(output, {
|
|
45
|
+
jsonrpc: "2.0",
|
|
46
|
+
id: null,
|
|
47
|
+
error: { code: -32700, message: "Parse error" },
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!msg.method) {
|
|
52
|
+
writeJson(output, {
|
|
53
|
+
jsonrpc: "2.0",
|
|
54
|
+
id: msg.id ?? null,
|
|
55
|
+
error: { code: -32600, message: "Invalid Request" },
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const response = await handleJsonRpc(msg, ctx);
|
|
60
|
+
if (response !== null) {
|
|
61
|
+
writeJson(output, response);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeJson(output, value) {
|
|
65
|
+
output.write(`${JSON.stringify(value)}\n`);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/mcp/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAG1C,OAAO,EACL,aAAa,GAGd,MAAM,eAAe,CAAC;AAkBvB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAChD,MAAM,GAAG,GAAsB;QAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,OAAO;QACrB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;IAEF,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,EAA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E,EAAE,GAAG,CAAC,EAAE,IAAI,IAAI;YAClB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE;SACpD,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/C,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,MAA6B,EAAE,KAAc;IAC9D,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline sample policy evaluate for light-install demos.
|
|
3
|
+
* Not a second production PEP — production injects HTTP evaluate against Shield.
|
|
4
|
+
* Same sample tools as docs/dev/kya-custom-tools-sample.md (R8: packs off).
|
|
5
|
+
*/
|
|
6
|
+
import type { Host } from "./config.js";
|
|
7
|
+
import type { PolicyEvaluateRequest, PolicyEvaluateResponse } from "./client.js";
|
|
8
|
+
import { type PolicyVerdict } from "./sample-tools.js";
|
|
9
|
+
export type SessionRisk = "LOW" | "MEDIUM" | "HIGH";
|
|
10
|
+
/** Raise-only: risk may bump ALLOW → REQUIRE_APPROVE; never lowers DENY/REQUIRE_APPROVE. */
|
|
11
|
+
export declare function applySessionRisk(base: {
|
|
12
|
+
verdict: PolicyVerdict;
|
|
13
|
+
reasonCode: string;
|
|
14
|
+
}, risk: SessionRisk | undefined): {
|
|
15
|
+
verdict: PolicyVerdict;
|
|
16
|
+
reasonCode: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Local fixture evaluate — day-1 offline demo without paid cloud or full console.
|
|
20
|
+
* Doctrine: sole production PEP remains Shield HTTP; this is demo/CT only.
|
|
21
|
+
*/
|
|
22
|
+
export declare function evaluateOffline(req: PolicyEvaluateRequest, host?: Host): PolicyEvaluateResponse;
|
|
23
|
+
//# sourceMappingURL=offline-evaluate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offline-evaluate.d.ts","sourceRoot":"","sources":["../src/offline-evaluate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvF,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAoCpD,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACpD,IAAI,EAAE,WAAW,GAAG,SAAS,GAC5B;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAWhD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,qBAAqB,EAC1B,IAAI,GAAE,IAAY,GACjB,sBAAsB,CAkBxB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline sample policy evaluate for light-install demos.
|
|
3
|
+
* Not a second production PEP — production injects HTTP evaluate against Shield.
|
|
4
|
+
* Same sample tools as docs/dev/kya-custom-tools-sample.md (R8: packs off).
|
|
5
|
+
*/
|
|
6
|
+
import { SAMPLE_TOOLS } from "./sample-tools.js";
|
|
7
|
+
function baseTier(toolId, irreversible, actionClass) {
|
|
8
|
+
if (!toolId || toolId.trim() === "") {
|
|
9
|
+
return { verdict: "DENY", reasonCode: "EMPTY_TOOL" };
|
|
10
|
+
}
|
|
11
|
+
const known = SAMPLE_TOOLS.find((t) => t.toolId === toolId);
|
|
12
|
+
if (known?.policyTier) {
|
|
13
|
+
if (known.policyTier === "DENY") {
|
|
14
|
+
return { verdict: "DENY", reasonCode: "NEVER_EVENT" };
|
|
15
|
+
}
|
|
16
|
+
if (known.policyTier === "REQUIRE_APPROVE") {
|
|
17
|
+
return { verdict: "REQUIRE_APPROVE", reasonCode: "HIGH_STAKES_WRITE" };
|
|
18
|
+
}
|
|
19
|
+
return { verdict: "ALLOW", reasonCode: "ALLOW" };
|
|
20
|
+
}
|
|
21
|
+
const ac = (actionClass ?? "");
|
|
22
|
+
if (ac === "EXTERNAL_SIDE_EFFECT") {
|
|
23
|
+
return { verdict: "DENY", reasonCode: "UNKNOWN_EXTERNAL_SIDE_EFFECT" };
|
|
24
|
+
}
|
|
25
|
+
if (ac === "EXPORT") {
|
|
26
|
+
return { verdict: "REQUIRE_APPROVE", reasonCode: "UNKNOWN_EXPORT" };
|
|
27
|
+
}
|
|
28
|
+
if (irreversible || ac === "WRITE") {
|
|
29
|
+
return { verdict: "REQUIRE_APPROVE", reasonCode: "UNKNOWN_IRREVERSIBLE" };
|
|
30
|
+
}
|
|
31
|
+
return { verdict: "ALLOW", reasonCode: "ALLOW" };
|
|
32
|
+
}
|
|
33
|
+
/** Raise-only: risk may bump ALLOW → REQUIRE_APPROVE; never lowers DENY/REQUIRE_APPROVE. */
|
|
34
|
+
export function applySessionRisk(base, risk) {
|
|
35
|
+
if (base.verdict === "DENY" || base.verdict === "REQUIRE_APPROVE") {
|
|
36
|
+
return base;
|
|
37
|
+
}
|
|
38
|
+
if (risk === "HIGH") {
|
|
39
|
+
return { verdict: "REQUIRE_APPROVE", reasonCode: "SESSION_RISK_HIGH" };
|
|
40
|
+
}
|
|
41
|
+
if (risk === "MEDIUM") {
|
|
42
|
+
return { verdict: "REQUIRE_APPROVE", reasonCode: "SESSION_RISK_MEDIUM" };
|
|
43
|
+
}
|
|
44
|
+
return base;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Local fixture evaluate — day-1 offline demo without paid cloud or full console.
|
|
48
|
+
* Doctrine: sole production PEP remains Shield HTTP; this is demo/CT only.
|
|
49
|
+
*/
|
|
50
|
+
export function evaluateOffline(req, host = "ide") {
|
|
51
|
+
const irreversible = req.irreversible ?? false;
|
|
52
|
+
const base = baseTier(req.toolId, irreversible, req.actionClass);
|
|
53
|
+
const risk = req.sessionRisk ?? "LOW";
|
|
54
|
+
const final = applySessionRisk(base, risk);
|
|
55
|
+
const resolvedHost = req.env?.host ?? host;
|
|
56
|
+
return {
|
|
57
|
+
verdict: final.verdict,
|
|
58
|
+
reasonCode: final.reasonCode,
|
|
59
|
+
toolId: req.toolId,
|
|
60
|
+
argsHash: req.argsHash,
|
|
61
|
+
localVerdict: base.verdict,
|
|
62
|
+
sessionRisk: risk,
|
|
63
|
+
host: resolvedHost,
|
|
64
|
+
opaAllow: true,
|
|
65
|
+
opaReason: "OFFLINE_SAMPLE",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=offline-evaluate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offline-evaluate.js","sourceRoot":"","sources":["../src/offline-evaluate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,YAAY,EAAwC,MAAM,mBAAmB,CAAC;AAIvF,SAAS,QAAQ,CACf,MAAc,EACd,YAAqB,EACrB,WAAoB;IAEpB,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACpC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACvD,CAAC;IAED,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IAC5D,IAAI,K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,EAAE,mBAAmB,EAAE,CAAC;IACzE,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,GAA0B,EAC1B,OAAa,KAAK;IAElB,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC;IAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACjE,MAAM,IAAI,GAAI,GAAG,CAAC,WAAuC,IAAI,KAAK,CAAC;IACnE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC;IAE3C,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,YAAY,EAAE,IAAI,CAAC,OAAO;QAC1B,WAAW,EAAE,IAAI;QACjB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,gBAAgB;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal argv parser — no external CLI framework.
|
|
3
|
+
* Supports: flags (--foo), values (--foo bar | --foo=bar), boolean (--stdio), positionals.
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedArgs {
|
|
6
|
+
readonly command: string | undefined;
|
|
7
|
+
readonly positionals: readonly string[];
|
|
8
|
+
readonly flags: Readonly<Record<string, string | boolean>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
11
|
+
export declare function flagString(flags: Readonly<Record<string, string | boolean>>, ...names: string[]): string | undefined;
|
|
12
|
+
export declare function flagBool(flags: Readonly<Record<string, string | boolean>>, ...names: string[]): boolean;
|
|
13
|
+
export declare function flagInt(flags: Readonly<Record<string, string | boolean>>, name: string, fallback: number): number;
|
|
14
|
+
//# sourceMappingURL=parse-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../src/parse-args.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAC5D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAoD7D;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EACjD,GAAG,KAAK,EAAE,MAAM,EAAE,GACjB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,QAAQ,CACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EACjD,GAAG,KAAK,EAAE,MAAM,EAAE,GACjB,OAAO,CAOT;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EACjD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM,CAOR"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal argv parser — no external CLI framework.
|
|
3
|
+
* Supports: flags (--foo), values (--foo bar | --foo=bar), boolean (--stdio), positionals.
|
|
4
|
+
*/
|
|
5
|
+
export function parseArgs(argv) {
|
|
6
|
+
const args = [...argv];
|
|
7
|
+
// drop node + script path when present (cli entry strips itself; tests pass raw)
|
|
8
|
+
const flags = {};
|
|
9
|
+
const positionals = [];
|
|
10
|
+
let command;
|
|
11
|
+
for (let i = 0; i < args.length; i++) {
|
|
12
|
+
const token = args[i];
|
|
13
|
+
if (token === "--") {
|
|
14
|
+
positionals.push(...args.slice(i + 1));
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
if (token.startsWith("--")) {
|
|
18
|
+
const eq = token.indexOf("=");
|
|
19
|
+
if (eq !== -1) {
|
|
20
|
+
const key = token.slice(2, eq);
|
|
21
|
+
const value = token.slice(eq + 1);
|
|
22
|
+
flags[key] = value;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const key = token.slice(2);
|
|
26
|
+
const next = args[i + 1];
|
|
27
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
28
|
+
// boolean-looking flags stay boolean when next is another command-like word
|
|
29
|
+
// only consume next if it looks like a value (not a known pattern of pure flag)
|
|
30
|
+
flags[key] = next;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
flags[key] = true;
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (token.startsWith("-") && token.length === 2) {
|
|
39
|
+
const key = token.slice(1);
|
|
40
|
+
const next = args[i + 1];
|
|
41
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
42
|
+
flags[key] = next;
|
|
43
|
+
i++;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
flags[key] = true;
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (command === undefined) {
|
|
51
|
+
command = token;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
positionals.push(token);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { command, positionals, flags };
|
|
58
|
+
}
|
|
59
|
+
export function flagString(flags, ...names) {
|
|
60
|
+
for (const name of names) {
|
|
61
|
+
const v = flags[name];
|
|
62
|
+
if (typeof v === "string" && v.length > 0)
|
|
63
|
+
return v;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
export function flagBool(flags, ...names) {
|
|
68
|
+
for (const name of names) {
|
|
69
|
+
const v = flags[name];
|
|
70
|
+
if (v === true || v === "true" || v === "1")
|
|
71
|
+
return true;
|
|
72
|
+
if (v === false || v === "false" || v === "0")
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
export function flagInt(flags, name, fallback) {
|
|
78
|
+
const v = flags[name];
|
|
79
|
+
if (typeof v === "string" && v.length > 0) {
|
|
80
|
+
const n = Number.parseInt(v, 10);
|
|
81
|
+
if (Number.isFinite(n))
|
|
82
|
+
return n;
|
|
83
|
+
}
|
|
84
|
+
return fallback;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=parse-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.js","sourceRoot":"","sources":["../src/parse-args.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,iFAAiF;IACjF,MAAM,KAAK,GAAqC,EAAE,CAAC;IACnD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,OAA2B,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAA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AO,KAAK,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAAiD,EACjD,IAAY,EACZ,QAAgB;IAEhB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample custom tools for light install — zero vertical packs (R8).
|
|
3
|
+
* Same descriptors as docs/dev/kya-custom-tools-sample.md.
|
|
4
|
+
*/
|
|
5
|
+
export type ActionClass = "READ" | "WRITE" | "EXTERNAL_SIDE_EFFECT" | "EXPORT";
|
|
6
|
+
export type PolicyVerdict = "ALLOW" | "DENY" | "REQUIRE_APPROVE";
|
|
7
|
+
export type DataClass = "PUBLIC" | "INTERNAL" | "CONFIDENTIAL" | "RESTRICTED";
|
|
8
|
+
export interface SampleToolDescriptor {
|
|
9
|
+
readonly toolId: string;
|
|
10
|
+
readonly displayName: string;
|
|
11
|
+
readonly actionClass: ActionClass;
|
|
12
|
+
readonly policyTier: PolicyVerdict;
|
|
13
|
+
readonly irreversible: boolean;
|
|
14
|
+
readonly dataClass: DataClass;
|
|
15
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
16
|
+
}
|
|
17
|
+
export declare const SAMPLE_TOOLS: readonly SampleToolDescriptor[];
|
|
18
|
+
export declare function findSampleTool(toolId: string): SampleToolDescriptor | undefined;
|
|
19
|
+
//# sourceMappingURL=sample-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-tools.d.ts","sourceRoot":"","sources":["../src/sample-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,sBAAsB,GAAG,QAAQ,CAAC;AAC/E,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,iBAAiB,CAAC;AACjE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACtD;AAED,eAAO,MAAM,YAAY,EAAE,SAAS,oBAAoB,EA4B9C,CAAC;AAEX,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAE/E"}
|