yenop 0.0.0 → 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.md +105 -0
- package/README.md +243 -3
- package/dist/adapters/claude-code/hook.d.ts +43 -0
- package/dist/adapters/claude-code/hook.js +101 -0
- package/dist/adapters/claude-code/hook.js.map +1 -0
- package/dist/adapters/claude-code/install.d.ts +23 -0
- package/dist/adapters/claude-code/install.js +86 -0
- package/dist/adapters/claude-code/install.js.map +1 -0
- package/dist/adapters/codex/hook.d.ts +7 -0
- package/dist/adapters/codex/hook.js +134 -0
- package/dist/adapters/codex/hook.js.map +1 -0
- package/dist/adapters/codex/install.d.ts +18 -0
- package/dist/adapters/codex/install.js +66 -0
- package/dist/adapters/codex/install.js.map +1 -0
- package/dist/adapters/cursor/hook.d.ts +25 -0
- package/dist/adapters/cursor/hook.js +228 -0
- package/dist/adapters/cursor/hook.js.map +1 -0
- package/dist/adapters/cursor/install.d.ts +10 -0
- package/dist/adapters/cursor/install.js +57 -0
- package/dist/adapters/cursor/install.js.map +1 -0
- package/dist/adapters/gemini/hook.d.ts +20 -0
- package/dist/adapters/gemini/hook.js +232 -0
- package/dist/adapters/gemini/hook.js.map +1 -0
- package/dist/adapters/gemini/install.d.ts +21 -0
- package/dist/adapters/gemini/install.js +101 -0
- package/dist/adapters/gemini/install.js.map +1 -0
- package/dist/adapters/hooks/pipeline.d.ts +69 -0
- package/dist/adapters/hooks/pipeline.js +131 -0
- package/dist/adapters/hooks/pipeline.js.map +1 -0
- package/dist/adapters/hooks/registry.d.ts +8 -0
- package/dist/adapters/hooks/registry.js +14 -0
- package/dist/adapters/hooks/registry.js.map +1 -0
- package/dist/adapters/mcp/gateway.d.ts +64 -0
- package/dist/adapters/mcp/gateway.js +205 -0
- package/dist/adapters/mcp/gateway.js.map +1 -0
- package/dist/adapters/mcp/run.d.ts +12 -0
- package/dist/adapters/mcp/run.js +86 -0
- package/dist/adapters/mcp/run.js.map +1 -0
- package/dist/adapters/openai-agents/index.d.ts +74 -0
- package/dist/adapters/openai-agents/index.js +139 -0
- package/dist/adapters/openai-agents/index.js.map +1 -0
- package/dist/cli/demo.d.ts +5 -0
- package/dist/cli/demo.js +130 -0
- package/dist/cli/demo.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +746 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/core/config.d.ts +50 -0
- package/dist/core/config.js +93 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/engine.d.ts +31 -0
- package/dist/core/engine.js +301 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/ids.d.ts +5 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.js +73 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/policy.d.ts +41 -0
- package/dist/core/policy.js +205 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/receipts.d.ts +47 -0
- package/dist/core/receipts.js +137 -0
- package/dist/core/receipts.js.map +1 -0
- package/dist/core/report.d.ts +51 -0
- package/dist/core/report.js +125 -0
- package/dist/core/report.js.map +1 -0
- package/dist/core/shell.d.ts +105 -0
- package/dist/core/shell.js +921 -0
- package/dist/core/shell.js.map +1 -0
- package/dist/core/state.d.ts +52 -0
- package/dist/core/state.js +269 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/telemetry.d.ts +52 -0
- package/dist/core/telemetry.js +150 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/tools.d.ts +5 -0
- package/dist/core/tools.js +59 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/types.d.ts +213 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/daemon/client.d.ts +34 -0
- package/dist/daemon/client.js +138 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/fast.d.ts +9 -0
- package/dist/daemon/fast.js +43 -0
- package/dist/daemon/fast.js.map +1 -0
- package/dist/daemon/server.d.ts +38 -0
- package/dist/daemon/server.js +321 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/service.d.ts +26 -0
- package/dist/daemon/service.js +171 -0
- package/dist/daemon/service.js.map +1 -0
- package/dist/viewer/server.d.ts +52 -0
- package/dist/viewer/server.js +184 -0
- package/dist/viewer/server.js.map +1 -0
- package/package.json +59 -7
- package/policies/README.md +58 -0
- package/policies/approve/default.cedar +72 -0
- package/policies/permit/default.cedar +48 -0
- package/policies/schema.cedarschema +104 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Yenop } from "../../core/index.js";
|
|
2
|
+
type JsonId = number | string;
|
|
3
|
+
export type OnAsk = "elicit" | "block" | "allow";
|
|
4
|
+
/** What one message makes the gateway send, and where. */
|
|
5
|
+
export type Effect = {
|
|
6
|
+
to: "server" | "client";
|
|
7
|
+
line: string;
|
|
8
|
+
};
|
|
9
|
+
interface Held {
|
|
10
|
+
line: string;
|
|
11
|
+
id: JsonId;
|
|
12
|
+
callId: string;
|
|
13
|
+
tool: string;
|
|
14
|
+
}
|
|
15
|
+
interface Pending {
|
|
16
|
+
fingerprint: string;
|
|
17
|
+
callId: string;
|
|
18
|
+
tool: string;
|
|
19
|
+
exp: number;
|
|
20
|
+
}
|
|
21
|
+
export interface GatewayState {
|
|
22
|
+
/** The client said it can show elicitation forms, in the 2025 handshake. */
|
|
23
|
+
legacyElicitation: boolean;
|
|
24
|
+
seq: number;
|
|
25
|
+
/** 2025 flow: our elicitation id -> the call waiting on the answer. */
|
|
26
|
+
held: Map<string, Held>;
|
|
27
|
+
/** 2026 flow: requestState nonce -> the call it belongs to. */
|
|
28
|
+
pending: Map<string, Pending>;
|
|
29
|
+
/** Asks that were forwarded: the server's response id -> the ask, so the outcome gets recorded. */
|
|
30
|
+
awaiting: Map<string, {
|
|
31
|
+
callId: string;
|
|
32
|
+
tool: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export declare function newGatewayState(): GatewayState;
|
|
36
|
+
export interface GatewayContext {
|
|
37
|
+
yenop: Yenop;
|
|
38
|
+
/** One run per gateway process: one client session with one server. */
|
|
39
|
+
runId: string;
|
|
40
|
+
/** The server alias, used to build the tool reference and to name the tool for receipts. */
|
|
41
|
+
server: string;
|
|
42
|
+
user: string;
|
|
43
|
+
client: string;
|
|
44
|
+
onAsk: OnAsk;
|
|
45
|
+
state: GatewayState;
|
|
46
|
+
}
|
|
47
|
+
export { mcpToolRef } from "../../core/tools.js";
|
|
48
|
+
/** Decide what one client message causes. Only tools/call is gated; parse failures and other methods pass through. */
|
|
49
|
+
export declare function gateClientMessage(ctx: GatewayContext, line: string): Effect[];
|
|
50
|
+
/** A server message always reaches the client. If it answers a forwarded ask, the outcome is recorded on the way. */
|
|
51
|
+
export declare function gateServerMessage(ctx: GatewayContext, line: string): Effect[];
|
|
52
|
+
/** A newline-delimited-JSON splitter that holds a partial trailing line between chunks. */
|
|
53
|
+
export declare function makeLineSplitter(onLine: (line: string) => void): (chunk: Buffer | string) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Wire a running gateway: client stdin -> (gate) -> server stdin, and server stdout -> (outcomes) -> client stdout.
|
|
56
|
+
* Streams are injectable so tests drive it without a subprocess.
|
|
57
|
+
*/
|
|
58
|
+
export interface GatewayStreams {
|
|
59
|
+
clientIn: NodeJS.ReadableStream;
|
|
60
|
+
clientOut: NodeJS.WritableStream;
|
|
61
|
+
serverIn: NodeJS.WritableStream;
|
|
62
|
+
serverOut: NodeJS.ReadableStream;
|
|
63
|
+
}
|
|
64
|
+
export declare function pumpGateway(ctx: GatewayContext, s: GatewayStreams): void;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP gateway: Yenop between an MCP client and an MCP server.
|
|
3
|
+
*
|
|
4
|
+
* An MCP client (Cursor, Claude Desktop, an OpenAI or custom agent) launches a tool server and calls its
|
|
5
|
+
* tools. Point the client at Yenop instead of at the server; Yenop launches the real server, forwards every
|
|
6
|
+
* message, and runs a decision on each `tools/call`. Allowed calls go through untouched. Blocked calls never
|
|
7
|
+
* reach the server: the client gets a tool error carrying the reason. This is the same policy engine, run
|
|
8
|
+
* state and receipts as the Claude Code hook, so a rule written once covers every MCP-speaking agent.
|
|
9
|
+
*
|
|
10
|
+
* This is where the trusted-backend attacks land: an injected instruction telling the agent to dump a
|
|
11
|
+
* database through a Supabase MCP server, or exfiltrate a repo through a GitHub MCP server. The server would
|
|
12
|
+
* obey. The gateway does not.
|
|
13
|
+
*
|
|
14
|
+
* When a call needs a person, the gateway asks the person through the client, using MCP elicitation. Two
|
|
15
|
+
* protocol generations exist and the gateway speaks both:
|
|
16
|
+
* - 2025-06-18 / 2025-11-25: the client declares `capabilities.elicitation` in `initialize`; the server sends
|
|
17
|
+
* an `elicitation/create` request and the client answers it. The gateway holds the call meanwhile.
|
|
18
|
+
* - 2026-07-28 (multi round-trip requests): servers no longer send requests. The gateway answers the call
|
|
19
|
+
* with `resultType: "input_required"` plus an opaque `requestState`; the client shows the form and retries
|
|
20
|
+
* the call with `inputResponses` and the same `requestState`. Nothing is held; the state is one nonce.
|
|
21
|
+
* A client that supports neither gets the `onAsk` fallback: block (default) or allow.
|
|
22
|
+
*
|
|
23
|
+
* stdio transport: newline-delimited JSON-RPC, one message per line. Only `tools/call` is gated; every other
|
|
24
|
+
* message passes. A blocked call is never written to the server.
|
|
25
|
+
*/
|
|
26
|
+
import { randomBytes } from "node:crypto";
|
|
27
|
+
import { mcpToolRef } from "../../core/tools.js";
|
|
28
|
+
export function newGatewayState() {
|
|
29
|
+
return { legacyElicitation: false, seq: 0, held: new Map(), pending: new Map(), awaiting: new Map() };
|
|
30
|
+
}
|
|
31
|
+
const ELICIT_KEY = "yenop-approval";
|
|
32
|
+
const ELICIT_PREFIX = "yenop:";
|
|
33
|
+
const PENDING_TTL_MS = 10 * 60 * 1000;
|
|
34
|
+
const CAPS_META = "io.modelcontextprotocol/clientCapabilities";
|
|
35
|
+
export { mcpToolRef } from "../../core/tools.js";
|
|
36
|
+
function canon(v) {
|
|
37
|
+
if (Array.isArray(v))
|
|
38
|
+
return `[${v.map(canon).join(",")}]`;
|
|
39
|
+
if (v && typeof v === "object") {
|
|
40
|
+
const o = v;
|
|
41
|
+
return `{${Object.keys(o).sort().map((k) => `${JSON.stringify(k)}:${canon(o[k])}`).join(",")}}`;
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(v);
|
|
44
|
+
}
|
|
45
|
+
function fingerprint(tool, args) {
|
|
46
|
+
return `${tool} ${canon(args ?? {})}`;
|
|
47
|
+
}
|
|
48
|
+
function toolError(id, text) {
|
|
49
|
+
return { to: "client", line: JSON.stringify({ jsonrpc: "2.0", id, result: { content: [{ type: "text", text }], isError: true } }) };
|
|
50
|
+
}
|
|
51
|
+
function short(args) {
|
|
52
|
+
const s = canon(args ?? {});
|
|
53
|
+
return s.length > 80 ? s.slice(0, 79) + "…" : s;
|
|
54
|
+
}
|
|
55
|
+
/** The question a person sees. One flat enum, no mode field: readable by every client generation. */
|
|
56
|
+
function approvalRequest(ctx, tool, args, reason) {
|
|
57
|
+
return {
|
|
58
|
+
method: "elicitation/create",
|
|
59
|
+
params: {
|
|
60
|
+
message: `Yenop: ${reason} Allow ${ctx.server}/${tool} ${short(args)}?`,
|
|
61
|
+
requestedSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: { decision: { type: "string", title: "Decision", description: "Allow this call once, or deny it", enum: ["allow", "deny"] } },
|
|
64
|
+
required: ["decision"],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function answered(r) {
|
|
70
|
+
return r?.action === "accept" && r.content?.["decision"] === "allow" ? "allow" : "deny";
|
|
71
|
+
}
|
|
72
|
+
function refuse(ctx, id, callId, tool, why, detail) {
|
|
73
|
+
ctx.yenop.recordOutcome(ctx.runId, callId, tool, "denied", detail);
|
|
74
|
+
return toolError(id, `Yenop: ${why} (tool ${ctx.server}/${tool}).`);
|
|
75
|
+
}
|
|
76
|
+
function stripMrtr(msg) {
|
|
77
|
+
const params = { ...msg.params };
|
|
78
|
+
delete params.inputResponses;
|
|
79
|
+
delete params.requestState;
|
|
80
|
+
return JSON.stringify({ ...msg, params });
|
|
81
|
+
}
|
|
82
|
+
/** Decide what one client message causes. Only tools/call is gated; parse failures and other methods pass through. */
|
|
83
|
+
export function gateClientMessage(ctx, line) {
|
|
84
|
+
let msg;
|
|
85
|
+
try {
|
|
86
|
+
msg = JSON.parse(line);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return [{ to: "server", line }]; // never break the stream on a parse error
|
|
90
|
+
}
|
|
91
|
+
const st = ctx.state;
|
|
92
|
+
// 2025 flow: the client is answering a question the gateway asked. The server never asked, so it never sees this.
|
|
93
|
+
if (msg.method === undefined && typeof msg.id === "string" && msg.id.startsWith(ELICIT_PREFIX)) {
|
|
94
|
+
const h = st.held.get(msg.id);
|
|
95
|
+
st.held.delete(msg.id);
|
|
96
|
+
if (!h)
|
|
97
|
+
return [];
|
|
98
|
+
if (msg.error === undefined && answered(msg.result) === "allow") {
|
|
99
|
+
st.awaiting.set(String(h.id), { callId: h.callId, tool: h.tool });
|
|
100
|
+
return [{ to: "server", line: h.line }];
|
|
101
|
+
}
|
|
102
|
+
return [refuse(ctx, h.id, h.callId, h.tool, "the person said no", "declined in the client")];
|
|
103
|
+
}
|
|
104
|
+
if (msg.method === "initialize") {
|
|
105
|
+
st.legacyElicitation = !!msg.params?.capabilities?.["elicitation"];
|
|
106
|
+
return [{ to: "server", line }];
|
|
107
|
+
}
|
|
108
|
+
if (msg.method === "notifications/cancelled") {
|
|
109
|
+
const rid = String(msg.params?.requestId);
|
|
110
|
+
for (const [k, h] of st.held)
|
|
111
|
+
if (String(h.id) === rid)
|
|
112
|
+
st.held.delete(k);
|
|
113
|
+
return [{ to: "server", line }];
|
|
114
|
+
}
|
|
115
|
+
if (msg.method !== "tools/call" || !msg.params || typeof msg.params.name !== "string")
|
|
116
|
+
return [{ to: "server", line }];
|
|
117
|
+
const tool = msg.params.name;
|
|
118
|
+
const args = msg.params.arguments ?? {};
|
|
119
|
+
// 2026 flow: a retry carrying the person's answer to a question the gateway asked.
|
|
120
|
+
const rs = msg.params.requestState;
|
|
121
|
+
if (rs !== undefined && st.pending.has(rs)) {
|
|
122
|
+
const p = st.pending.get(rs);
|
|
123
|
+
st.pending.delete(rs); // single use
|
|
124
|
+
if (p.exp < Date.now() || p.fingerprint !== fingerprint(tool, args)) {
|
|
125
|
+
return [refuse(ctx, msg.id, p.callId, p.tool, "the approval did not match this call or had expired; ask again", "approval expired or mismatched")];
|
|
126
|
+
}
|
|
127
|
+
if (answered(msg.params.inputResponses?.[ELICIT_KEY]) === "allow") {
|
|
128
|
+
if (msg.id !== undefined)
|
|
129
|
+
st.awaiting.set(String(msg.id), { callId: p.callId, tool: p.tool });
|
|
130
|
+
return [{ to: "server", line: stripMrtr(msg) }]; // the real server never asked for these fields
|
|
131
|
+
}
|
|
132
|
+
return [refuse(ctx, msg.id, p.callId, p.tool, "the person said no", "declined in the client")];
|
|
133
|
+
}
|
|
134
|
+
const req = { runId: ctx.runId, principal: { runtime: "mcp", agent: ctx.client, user: ctx.user }, tool: mcpToolRef(ctx.server, tool), args };
|
|
135
|
+
if (msg.id !== undefined)
|
|
136
|
+
req.callId = `mcp:${msg.id}`;
|
|
137
|
+
const callId = req.callId ?? "";
|
|
138
|
+
const d = ctx.yenop.decide(req);
|
|
139
|
+
if (d.mode === "observe" || d.effect === "allow")
|
|
140
|
+
return [{ to: "server", line }];
|
|
141
|
+
if (d.effect === "deny")
|
|
142
|
+
return [toolError(msg.id, `Yenop blocked this: ${d.message} (tool ${ctx.server}/${tool}); receipt ${d.receiptId}.`)];
|
|
143
|
+
// ask
|
|
144
|
+
if (ctx.onAsk === "allow") {
|
|
145
|
+
if (msg.id !== undefined)
|
|
146
|
+
st.awaiting.set(String(msg.id), { callId, tool });
|
|
147
|
+
return [{ to: "server", line }];
|
|
148
|
+
}
|
|
149
|
+
if (ctx.onAsk === "elicit") {
|
|
150
|
+
const caps = msg.params._meta?.[CAPS_META];
|
|
151
|
+
if (caps?.elicitation !== undefined) {
|
|
152
|
+
const nonce = randomBytes(16).toString("hex");
|
|
153
|
+
st.pending.set(nonce, { fingerprint: fingerprint(tool, args), callId, tool, exp: Date.now() + PENDING_TTL_MS });
|
|
154
|
+
const result = { resultType: "input_required", inputRequests: { [ELICIT_KEY]: approvalRequest(ctx, tool, args, d.message) }, requestState: nonce };
|
|
155
|
+
return [{ to: "client", line: JSON.stringify({ jsonrpc: "2.0", id: msg.id, result }) }];
|
|
156
|
+
}
|
|
157
|
+
if (st.legacyElicitation && msg.id !== undefined) {
|
|
158
|
+
const eid = `${ELICIT_PREFIX}${++st.seq}`;
|
|
159
|
+
st.held.set(eid, { line, id: msg.id, callId, tool });
|
|
160
|
+
return [{ to: "client", line: JSON.stringify({ jsonrpc: "2.0", id: eid, ...approvalRequest(ctx, tool, args, d.message) }) }];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return [refuse(ctx, msg.id, callId, tool, `needs a person, and this client cannot ask one: ${d.message} Adjust policy or run it yourself; receipt ${d.receiptId}`, "blocked at the MCP gateway: client cannot elicit")];
|
|
164
|
+
}
|
|
165
|
+
/** A server message always reaches the client. If it answers a forwarded ask, the outcome is recorded on the way. */
|
|
166
|
+
export function gateServerMessage(ctx, line) {
|
|
167
|
+
try {
|
|
168
|
+
const msg = JSON.parse(line);
|
|
169
|
+
if (msg.id !== undefined && msg.method === undefined) {
|
|
170
|
+
const a = ctx.state.awaiting.get(String(msg.id));
|
|
171
|
+
if (a) {
|
|
172
|
+
ctx.state.awaiting.delete(String(msg.id));
|
|
173
|
+
const failed = msg.error !== undefined || msg.result?.isError === true;
|
|
174
|
+
ctx.yenop.recordOutcome(ctx.runId, a.callId, a.tool, failed ? "failed" : "ran", failed ? "the server reported an error" : undefined);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
/* not JSON: pass it through */
|
|
180
|
+
}
|
|
181
|
+
return [{ to: "client", line }];
|
|
182
|
+
}
|
|
183
|
+
/** A newline-delimited-JSON splitter that holds a partial trailing line between chunks. */
|
|
184
|
+
export function makeLineSplitter(onLine) {
|
|
185
|
+
let buf = "";
|
|
186
|
+
return (chunk) => {
|
|
187
|
+
buf += chunk.toString("utf8");
|
|
188
|
+
let nl;
|
|
189
|
+
while ((nl = buf.indexOf("\n")) !== -1) {
|
|
190
|
+
const line = buf.slice(0, nl);
|
|
191
|
+
buf = buf.slice(nl + 1);
|
|
192
|
+
if (line.trim().length > 0)
|
|
193
|
+
onLine(line);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function pumpGateway(ctx, s) {
|
|
198
|
+
const apply = (effects) => {
|
|
199
|
+
for (const e of effects)
|
|
200
|
+
(e.to === "server" ? s.serverIn : s.clientOut).write(e.line + "\n");
|
|
201
|
+
};
|
|
202
|
+
s.clientIn.on("data", makeLineSplitter((line) => apply(gateClientMessage(ctx, line))));
|
|
203
|
+
s.serverOut.on("data", makeLineSplitter((line) => apply(gateServerMessage(ctx, line))));
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../../src/adapters/mcp/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgDjD,MAAM,UAAU,eAAe;IAC7B,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,GA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AAC,IAAI,OAAO;YAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC/F,CAAC,CAAC;IACF,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type OnAsk } from "./gateway.js";
|
|
2
|
+
export interface McpOptions {
|
|
3
|
+
server?: string;
|
|
4
|
+
command: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
onAsk?: OnAsk;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
home?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Split `["--server","github","--","npx","-y","pkg"]` into options and the upstream command after `--`. */
|
|
11
|
+
export declare function parseMcpArgs(argv: string[]): McpOptions;
|
|
12
|
+
export declare function runMcpGateway(opts: McpOptions): Promise<number>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `yenop mcp --server NAME -- <command> <args...>`
|
|
3
|
+
* Launch the real MCP server and proxy stdio through the gateway.
|
|
4
|
+
*/
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { basename } from "node:path";
|
|
7
|
+
import { userInfo } from "node:os";
|
|
8
|
+
import { openYenop } from "../../core/index.js";
|
|
9
|
+
import { uuidv7 } from "../../core/index.js";
|
|
10
|
+
import { pumpGateway, newGatewayState } from "./gateway.js";
|
|
11
|
+
/** Split `["--server","github","--","npx","-y","pkg"]` into options and the upstream command after `--`. */
|
|
12
|
+
export function parseMcpArgs(argv) {
|
|
13
|
+
let server;
|
|
14
|
+
let onAsk;
|
|
15
|
+
let i = 0;
|
|
16
|
+
for (; i < argv.length; i++) {
|
|
17
|
+
const a = argv[i];
|
|
18
|
+
if (a === "--") {
|
|
19
|
+
i++;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (a === "--server")
|
|
23
|
+
server = argv[++i];
|
|
24
|
+
else if (a === "--on-ask") {
|
|
25
|
+
const v = argv[++i];
|
|
26
|
+
if (v !== "elicit" && v !== "block" && v !== "allow")
|
|
27
|
+
throw new Error(`yenop mcp: --on-ask must be elicit, block or allow (got ${v})`);
|
|
28
|
+
onAsk = v;
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
const rest = argv.slice(i);
|
|
34
|
+
if (rest.length === 0)
|
|
35
|
+
throw new Error('yenop mcp: nothing to launch. Usage: yenop mcp --server NAME -- <command> [args...]');
|
|
36
|
+
const opts = { command: rest[0], args: rest.slice(1), server: server ?? basename(rest[0]).replace(/\.[^.]+$/, "") };
|
|
37
|
+
if (onAsk)
|
|
38
|
+
opts.onAsk = onAsk;
|
|
39
|
+
return opts;
|
|
40
|
+
}
|
|
41
|
+
export async function runMcpGateway(opts) {
|
|
42
|
+
const openArgs = {};
|
|
43
|
+
if (opts.cwd !== undefined)
|
|
44
|
+
openArgs.cwd = opts.cwd;
|
|
45
|
+
if (opts.home !== undefined)
|
|
46
|
+
openArgs.home = opts.home;
|
|
47
|
+
const yenop = openYenop(openArgs);
|
|
48
|
+
const child = spawn(opts.command, opts.args, { stdio: ["pipe", "pipe", "inherit"] });
|
|
49
|
+
const ctx = {
|
|
50
|
+
yenop,
|
|
51
|
+
runId: `mcp:${opts.server}:${uuidv7()}`,
|
|
52
|
+
server: opts.server ?? "mcp",
|
|
53
|
+
user: safeUser(),
|
|
54
|
+
client: "mcp-client",
|
|
55
|
+
onAsk: opts.onAsk ?? "elicit",
|
|
56
|
+
state: newGatewayState(),
|
|
57
|
+
};
|
|
58
|
+
pumpGateway(ctx, {
|
|
59
|
+
clientIn: process.stdin,
|
|
60
|
+
clientOut: process.stdout,
|
|
61
|
+
serverIn: child.stdin,
|
|
62
|
+
serverOut: child.stdout,
|
|
63
|
+
});
|
|
64
|
+
// The gateway's lifetime is the server's. When either end closes, tear down cleanly.
|
|
65
|
+
return await new Promise((resolve) => {
|
|
66
|
+
const done = (code) => {
|
|
67
|
+
yenop.close();
|
|
68
|
+
resolve(code);
|
|
69
|
+
};
|
|
70
|
+
child.on("exit", (code) => done(code ?? 0));
|
|
71
|
+
child.on("error", (e) => {
|
|
72
|
+
process.stderr.write(`yenop mcp: cannot launch ${opts.command}: ${e.message}\n`);
|
|
73
|
+
done(127);
|
|
74
|
+
});
|
|
75
|
+
process.stdin.on("end", () => child.stdin?.end());
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function safeUser() {
|
|
79
|
+
try {
|
|
80
|
+
return userInfo().username;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return "unknown";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/mcp/run.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CA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EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5C,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,OAAO,KAAM,CAAW,CAAC,OAAO,IAAI,CAAC,CAAC;YAC5F,IAAI,CAAC,GAAG,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ;IACf,IAAI,CAAC;QACH,OAAO,QAAQ,EAAE,CAAC,QAAQ,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type OpenOptions, type Yenop } from "../../core/index.js";
|
|
2
|
+
import type { Decision, ToolRef } from "../../core/types.js";
|
|
3
|
+
/** `protocol.FunctionCallItem`, the part a guardrail reads. */
|
|
4
|
+
export interface ToolCallLike {
|
|
5
|
+
name: string;
|
|
6
|
+
/** The model's arguments, as a JSON string. */
|
|
7
|
+
arguments: string;
|
|
8
|
+
callId: string;
|
|
9
|
+
}
|
|
10
|
+
/** `ToolInputGuardrailData`: the SDK's run context (one per `run()`), the agent, and the call. */
|
|
11
|
+
export interface GuardrailDataLike {
|
|
12
|
+
context: object;
|
|
13
|
+
agent: {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
toolCall: ToolCallLike;
|
|
17
|
+
}
|
|
18
|
+
export interface OutputGuardrailDataLike extends GuardrailDataLike {
|
|
19
|
+
output: unknown;
|
|
20
|
+
}
|
|
21
|
+
export type GuardrailBehavior = {
|
|
22
|
+
type: "allow";
|
|
23
|
+
} | {
|
|
24
|
+
type: "rejectContent";
|
|
25
|
+
message: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "throwException";
|
|
28
|
+
};
|
|
29
|
+
export interface GuardrailOutput {
|
|
30
|
+
behavior: GuardrailBehavior;
|
|
31
|
+
outputInfo?: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface ToolInputGuardrail {
|
|
34
|
+
type: "tool_input";
|
|
35
|
+
name: string;
|
|
36
|
+
run: (data: GuardrailDataLike) => Promise<GuardrailOutput>;
|
|
37
|
+
}
|
|
38
|
+
export interface ToolOutputGuardrail {
|
|
39
|
+
type: "tool_output";
|
|
40
|
+
name: string;
|
|
41
|
+
run: (data: OutputGuardrailDataLike) => Promise<GuardrailOutput>;
|
|
42
|
+
}
|
|
43
|
+
/** What one of the agent's tools can do. */
|
|
44
|
+
export interface ToolSpec {
|
|
45
|
+
kind: ToolRef["kind"];
|
|
46
|
+
/** Only reads; default false, the safe direction. */
|
|
47
|
+
readOnly?: boolean;
|
|
48
|
+
/** For kind "mcp": the server, so trustedServers/sensitiveServers in config apply. */
|
|
49
|
+
server?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface YenopGuardrailOptions extends OpenOptions {
|
|
52
|
+
/** What each tool can do, by name. Unlisted tools are judged as unknown, not read-only. */
|
|
53
|
+
tools?: Record<string, ToolSpec>;
|
|
54
|
+
/** Rename or reshape a tool's arguments into what the engine reads (command, file_path, paths, url). */
|
|
55
|
+
mapArgs?: (name: string, args: Record<string, unknown>) => Record<string, unknown>;
|
|
56
|
+
/** Route an ask to a person. Resolve true to let the call run. Absent: every ask is refused. */
|
|
57
|
+
onAsk?: (decision: Decision, data: GuardrailDataLike) => Promise<boolean> | boolean;
|
|
58
|
+
/** How a deny reaches the agent. "reject" (default) tells it why; "throw" trips the SDK's exception. */
|
|
59
|
+
onDeny?: "reject" | "throw";
|
|
60
|
+
/** The runtime name in receipts. Default "openai-agents". */
|
|
61
|
+
runtime?: string;
|
|
62
|
+
/** The person the agent acts for, in receipts. Default: the OS user. */
|
|
63
|
+
user?: string;
|
|
64
|
+
/** Share an already-open Yenop instead of opening one. */
|
|
65
|
+
yenop?: Yenop;
|
|
66
|
+
}
|
|
67
|
+
export interface YenopGuardrails {
|
|
68
|
+
inputGuardrails: ToolInputGuardrail[];
|
|
69
|
+
outputGuardrails: ToolOutputGuardrail[];
|
|
70
|
+
/** The run id Yenop is using for an SDK run context, once the first call has been judged. */
|
|
71
|
+
runIdFor(context: object): string | undefined;
|
|
72
|
+
close(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare function yenopGuardrails(opts?: YenopGuardrailOptions): YenopGuardrails;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Agents SDK adapter: Yenop as tool guardrails, in process.
|
|
3
|
+
*
|
|
4
|
+
* The SDK (`@openai/agents`) runs an agent loop in the developer's own process and lets a tool carry
|
|
5
|
+
* `inputGuardrails`, run before the tool executes, and `outputGuardrails`, run after. Yenop plugs in as one of
|
|
6
|
+
* each: the input guardrail is the decision, the output guardrail records the outcome. The shapes below are
|
|
7
|
+
* structural copies of `@openai/agents-core` 0.18.0 (`toolGuardrail.d.ts`); Yenop does not import the SDK,
|
|
8
|
+
* so the developer's SDK version and Yenop's never have to agree, and the tests need no SDK at all.
|
|
9
|
+
*
|
|
10
|
+
* import { tool } from "@openai/agents";
|
|
11
|
+
* import { yenopGuardrails } from "yenop/openai-agents";
|
|
12
|
+
* const guard = yenopGuardrails({ tools: { run_shell: { kind: "shell" }, write_file: { kind: "write" } } });
|
|
13
|
+
* const runShell = tool({ name: "run_shell", ..., inputGuardrails: guard.inputGuardrails, outputGuardrails: guard.outputGuardrails });
|
|
14
|
+
*
|
|
15
|
+
* What the developer must know:
|
|
16
|
+
* - Tools here are the developer's own functions, so Yenop cannot know what "run_shell" does by name. `tools`
|
|
17
|
+
* says what each tool can do; a tool not listed is judged as unknown and not read-only, which the baseline
|
|
18
|
+
* holds for a person. For a shell tool the argument must be named `command`, for file tools `file_path`
|
|
19
|
+
* (or several in `paths`), for web tools `url`; `mapArgs` renames anything else.
|
|
20
|
+
* - A guardrail cannot ask a person. `onAsk` is where the developer routes an ask (a terminal prompt, a
|
|
21
|
+
* Slack message, their approval UI) and answers true or false. Without `onAsk`, an ask is refused, never
|
|
22
|
+
* let through: Yenop only ever tightens.
|
|
23
|
+
* - A deny becomes `rejectContent` with the reason by default, so the agent learns why and can do something
|
|
24
|
+
* else; `onDeny: "throw"` escalates to the SDK's tripwire exception instead.
|
|
25
|
+
* - One SDK run is one Yenop run: the run id is bound to the SDK's RunContext object, so run-level facts
|
|
26
|
+
* (untrusted content taken in, sensitive data touched) follow the agent across its tool calls.
|
|
27
|
+
* - Yenop's own failure is a rejection, not an allow.
|
|
28
|
+
*/
|
|
29
|
+
import { randomUUID } from "node:crypto";
|
|
30
|
+
import { openYenop } from "../../core/index.js";
|
|
31
|
+
import { classifyTool } from "../../core/tools.js";
|
|
32
|
+
import { safeUser } from "../hooks/pipeline.js";
|
|
33
|
+
function parseArgs(text) {
|
|
34
|
+
if (text === "" || text === undefined)
|
|
35
|
+
return {};
|
|
36
|
+
try {
|
|
37
|
+
const v = JSON.parse(text);
|
|
38
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : undefined;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function yenopGuardrails(opts = {}) {
|
|
45
|
+
const { tools, mapArgs, onAsk, onDeny, runtime, user, yenop: shared, ...open } = opts;
|
|
46
|
+
// The project the agent works in decides the tenant and the policy layers; without an explicit cwd it is the
|
|
47
|
+
// current directory, the same rule the CLI hooks follow. (Found live: decisions had landed under "local".)
|
|
48
|
+
const cwd = open.cwd ?? process.cwd();
|
|
49
|
+
const y = shared ?? openYenop({ ...open, cwd });
|
|
50
|
+
const owned = shared === undefined;
|
|
51
|
+
const rt = runtime ?? "openai-agents";
|
|
52
|
+
const who = user ?? safeUser();
|
|
53
|
+
const runs = new WeakMap();
|
|
54
|
+
const runIdOf = (context) => {
|
|
55
|
+
let id = runs.get(context);
|
|
56
|
+
if (!id) {
|
|
57
|
+
id = `${rt}:${randomUUID()}`;
|
|
58
|
+
runs.set(context, id);
|
|
59
|
+
}
|
|
60
|
+
return id;
|
|
61
|
+
};
|
|
62
|
+
const toolRef = (name) => {
|
|
63
|
+
const spec = tools?.[name];
|
|
64
|
+
if (!spec)
|
|
65
|
+
return { ...classifyTool(name), kind: "unknown", readOnly: false };
|
|
66
|
+
const ref = { name, kind: spec.kind, readOnly: spec.readOnly ?? false };
|
|
67
|
+
if (spec.server !== undefined)
|
|
68
|
+
ref.server = spec.server;
|
|
69
|
+
return ref;
|
|
70
|
+
};
|
|
71
|
+
const reject = (message) => ({ behavior: { type: "rejectContent", message } });
|
|
72
|
+
const input = {
|
|
73
|
+
type: "tool_input",
|
|
74
|
+
name: "yenop",
|
|
75
|
+
async run(data) {
|
|
76
|
+
const { name, callId } = data.toolCall;
|
|
77
|
+
let request;
|
|
78
|
+
let d;
|
|
79
|
+
try {
|
|
80
|
+
const raw = parseArgs(data.toolCall.arguments);
|
|
81
|
+
if (raw === undefined)
|
|
82
|
+
return reject(`Yenop: the arguments for ${name} are not a JSON object; the call is refused.`);
|
|
83
|
+
const args = mapArgs ? mapArgs(name, raw) : raw;
|
|
84
|
+
request = { runId: runIdOf(data.context), principal: { runtime: rt, agent: data.agent.name, user: who }, tool: toolRef(name), args, cwd, callId };
|
|
85
|
+
d = y.decide(request);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
return reject(`Yenop failed and refuses by default: ${e.message}. Run "yenop status".`);
|
|
89
|
+
}
|
|
90
|
+
const info = { receiptId: d.receiptId, effect: d.effect, reasons: d.reasons, mode: d.mode };
|
|
91
|
+
if (d.mode === "observe" || d.effect === "allow")
|
|
92
|
+
return { behavior: { type: "allow" }, outputInfo: info };
|
|
93
|
+
if (d.effect === "deny")
|
|
94
|
+
return onDeny === "throw" ? { behavior: { type: "throwException" }, outputInfo: info } : { ...reject(`Yenop: ${d.message}`), outputInfo: info };
|
|
95
|
+
// ask
|
|
96
|
+
if (!onAsk) {
|
|
97
|
+
y.recordOutcome(request.runId, callId, name, "denied", "no onAsk handler: the agent cannot ask a person");
|
|
98
|
+
return { ...reject(`Yenop: ${d.message} This agent has no way to ask a person, so the call is refused; give yenopGuardrails an onAsk handler to route approvals.`), outputInfo: info };
|
|
99
|
+
}
|
|
100
|
+
let ok = false;
|
|
101
|
+
try {
|
|
102
|
+
ok = (await onAsk(d, data)) === true;
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
y.recordOutcome(request.runId, callId, name, "denied", `onAsk failed: ${e.message}`);
|
|
106
|
+
return { ...reject(`Yenop: the approval handler failed (${e.message}); the call is refused.`), outputInfo: info };
|
|
107
|
+
}
|
|
108
|
+
if (ok)
|
|
109
|
+
return { behavior: { type: "allow" }, outputInfo: { ...info, approvedBy: "person" } };
|
|
110
|
+
y.recordOutcome(request.runId, callId, name, "denied", "declined by the person");
|
|
111
|
+
return { ...reject(`Yenop: a person declined this call. ${d.message}`), outputInfo: info };
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
const output = {
|
|
115
|
+
type: "tool_output",
|
|
116
|
+
name: "yenop-outcome",
|
|
117
|
+
async run(data) {
|
|
118
|
+
try {
|
|
119
|
+
const runId = runs.get(data.context);
|
|
120
|
+
if (runId)
|
|
121
|
+
y.recordOutcome(runId, data.toolCall.callId, data.toolCall.name, "ran");
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
/* recording never blocks the output */
|
|
125
|
+
}
|
|
126
|
+
return { behavior: { type: "allow" } };
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
inputGuardrails: [input],
|
|
131
|
+
outputGuardrails: [output],
|
|
132
|
+
runIdFor: (context) => runs.get(context),
|
|
133
|
+
close: () => {
|
|
134
|
+
if (owned)
|
|
135
|
+
y.close();
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/openai-agents/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAgC,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAoEhD,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;QACtC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAA6B,CAAC,CAAC,CAAC,SAAS,CAAC;IACtG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAA8B,EAAE;IAC9D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACtF,6GAA6G;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