@bevel-software/platform-mcp-core 0.11.2 → 0.12.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/meta-tools.d.ts.map +1 -1
- package/dist/meta-tools.js +8 -2
- package/dist/meta-tools.js.map +1 -1
- package/dist/results.d.ts +74 -0
- package/dist/results.d.ts.map +1 -1
- package/dist/results.js +514 -0
- package/dist/results.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +5 -0
- package/src/meta-tools.ts +8 -2
- package/src/results.ts +549 -0
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* policy (see `registerManual`).
|
|
25
25
|
*/
|
|
26
26
|
export { type ProxiedTool, toListedTool, sanitizeInputSchema, flattenManualTool, flattenDiscoveredTool, } from './proxied-tool.js';
|
|
27
|
-
export { describeToolFailure, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, } from './results.js';
|
|
27
|
+
export { describeToolFailure, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, type McpImageResult, mcpImageResult, isMcpImageResult, omitImagePayloads, } from './results.js';
|
|
28
28
|
export { CODE_MODE_META_TOOLS, META_TOOL_NAMES, CALL_TOOL_CHAIN_MAX_OUTPUT, type SpillPort, dispatchMetaTool, } from './meta-tools.js';
|
|
29
29
|
export { registerManual, dispatchToolCall } from './dispatch.js';
|
|
30
30
|
export { type SkillSummary, type LoadedSkill, skillPromptText, } from './skills.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,cAAc,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,0BAA0B,EAC1B,KAAK,SAAS,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* policy (see `registerManual`).
|
|
25
25
|
*/
|
|
26
26
|
export { toListedTool, sanitizeInputSchema, flattenManualTool, flattenDiscoveredTool, } from './proxied-tool.js';
|
|
27
|
-
export { describeToolFailure, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, } from './results.js';
|
|
27
|
+
export { describeToolFailure, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, mcpImageResult, isMcpImageResult, omitImagePayloads, } from './results.js';
|
|
28
28
|
export { CODE_MODE_META_TOOLS, META_TOOL_NAMES, CALL_TOOL_CHAIN_MAX_OUTPUT, dispatchMetaTool, } from './meta-tools.js';
|
|
29
29
|
export { registerManual, dispatchToolCall } from './dispatch.js';
|
|
30
30
|
export { skillPromptText, } from './skills.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EAErB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,0BAA0B,EAE1B,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAGL,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
package/dist/meta-tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-tools.d.ts","sourceRoot":"","sources":["../src/meta-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"meta-tools.d.ts","sourceRoot":"","sources":["../src/meta-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA6B1D,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAkCzC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAAoD,CAAC;AAErG,qFAAqF;AACrF,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAgBlD;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,OAAO,CAAC,cAAc,CAAC,CAoFzB"}
|
package/dist/meta-tools.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { utcpNameToTsInterfaceName, findToolsByNames } from './code-mode-names.js';
|
|
2
|
-
import { toCallToolResult, toolError, describeToolFailure } from './results.js';
|
|
2
|
+
import { toCallToolResult, toolError, describeToolFailure, omitImagePayloads } from './results.js';
|
|
3
3
|
/**
|
|
4
4
|
* Code-mode meta-tools exposed ALONGSIDE the direct tools. They let an external
|
|
5
5
|
* agent batch many Bevel calls into one isolated-vm run (`call_tool_chain`)
|
|
@@ -22,6 +22,7 @@ const CALL_TOOL_CHAIN_DESCRIPTION = [
|
|
|
22
22
|
'Execute a short JavaScript program with direct access to every registered UTCP tool as a synchronous function. Call tools as `KNOWLEDGE_BASE.<tool>({ body: { ...args } })` with NO `await` (results are already resolved), and `return` the final value. The runtime is plain JavaScript (no type annotations / no TypeScript-only syntax).',
|
|
23
23
|
'Discover first: `list_tools` lists every tool in callable form (e.g. `KNOWLEDGE_BASE.read_file`); `tools_info` returns their exact argument + return shapes — do not guess. Batch multiple tool calls into one chain to avoid a round-trip per call. The chain runs with your own connection key, so it can only reach the tools you can already call directly.',
|
|
24
24
|
'Large results: if the combined result+logs exceed `max_output_size` (default 200000 chars) the full JSON is spilled to a shared store and you get back a `__tool_chain_spill__/…` ref instead. Read it with `read_file` (pass that ref as `path` — `branch` is ignored — plus `offset`/`limit` to slice it), or better, re-run a narrower chain that returns only what you need.',
|
|
25
|
+
'Images: image files are returned as native MCP image content on a DIRECT `read_file` call only — a chained `read_file` of an image yields `{ image_omitted: true, note }` instead of the picture, so call it outside the chain to actually see the image.',
|
|
25
26
|
].join('\n\n');
|
|
26
27
|
export const CODE_MODE_META_TOOLS = [
|
|
27
28
|
{
|
|
@@ -125,7 +126,12 @@ export async function dispatchMetaTool(client, name, args, spill) {
|
|
|
125
126
|
const maxOutputSize = typeof args.max_output_size === 'number' && Number.isFinite(args.max_output_size)
|
|
126
127
|
? Math.min(1_000_000, Math.max(1_000, Math.trunc(args.max_output_size)))
|
|
127
128
|
: CALL_TOOL_CHAIN_MAX_OUTPUT;
|
|
128
|
-
const { result, logs } = await client.callToolChain(code, timeout);
|
|
129
|
+
const { result: rawResult, logs } = await client.callToolChain(code, timeout);
|
|
130
|
+
// Images never ride a chain result: the chain's value is stringified JSON,
|
|
131
|
+
// where base64 is context flood, not a picture. A chained `read_file` of an
|
|
132
|
+
// image comes back as an omitted-image note instead (see omitImagePayloads);
|
|
133
|
+
// the direct tool call is the sanctioned way to SEE an image.
|
|
134
|
+
const result = omitImagePayloads(rawResult, 'result');
|
|
129
135
|
// Bound the payload: an external session has no ambient workspace, so an
|
|
130
136
|
// oversized result spills to the shared store and we return only a ref —
|
|
131
137
|
// parity with the in-process agent's `call_tool_chain`.
|
package/dist/meta-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-tools.js","sourceRoot":"","sources":["../src/meta-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"meta-tools.js","sourceRoot":"","sources":["../src/meta-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEnG;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,2BAA2B,GAAG;IAClC,8UAA8U;IAC9U,iWAAiW;IACjW,kXAAkX;IAClX,2PAA2P;CAC5P,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEf,MAAM,CAAC,MAAM,oBAAoB,GAAc;IAC7C;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,8IAA8I;QAChJ,WAAW,EAAE,E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AAK;oBACxG,uGAAuG;oBACvG,iCAAiC;aACpC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,gBAAgB,CAAC;YACtB,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,KAAK;YACnB,OAAO,EAAE,2BAA2B,QAAQ,CAAC,MAAM,4CAA4C,aAAa,qDAAqD,GAAG,sLAAsL;SAC3V,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,SAAS,CAAC,QAAQ,IAAI,kBAAkB,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
package/dist/results.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Discriminator for {@link McpImageResult}. The slash + version suffix make it
|
|
4
|
+
* a value no ordinary tool result carries by accident — a domain object with a
|
|
5
|
+
* `kind` field holds things like `'image'` or `'file'`, never this string —
|
|
6
|
+
* so the result shaping below can act on the shape without ever mistaking
|
|
7
|
+
* caller data for it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MCP_IMAGE_RESULT_KIND = "bevel/mcp-image@v1";
|
|
10
|
+
/**
|
|
11
|
+
* The sentinel a tool HANDLER returns when its result is a picture, not JSON.
|
|
12
|
+
*
|
|
13
|
+
* Handlers normally return domain JSON that `toCallToolResult` stringifies
|
|
14
|
+
* into one text block. An image cannot ride that path — a multimodal client
|
|
15
|
+
* only SEES a picture delivered as a native MCP image content block — so a
|
|
16
|
+
* handler that wants the caller to see one returns this shape instead, and
|
|
17
|
+
* the MCP result shaping turns it into
|
|
18
|
+
* `content: [{type:'image', data, mimeType}, {type:'text', text: note}]`.
|
|
19
|
+
* The `note` keeps the transcript self-describing (path, size, dimensions);
|
|
20
|
+
* without it the result is the bare image block.
|
|
21
|
+
*
|
|
22
|
+
* The shape intentionally travels as plain JSON: it crosses the UTCP http hop
|
|
23
|
+
* (loopback REST → hosted proxy) unchanged, and only the final MCP surface
|
|
24
|
+
* turns it into content blocks.
|
|
25
|
+
*/
|
|
26
|
+
export interface McpImageResult {
|
|
27
|
+
kind: typeof MCP_IMAGE_RESULT_KIND;
|
|
28
|
+
/** Base64-encoded image bytes (no data-URI prefix). */
|
|
29
|
+
data: string;
|
|
30
|
+
/** e.g. `image/png` — what the MCP image block advertises. */
|
|
31
|
+
mimeType: string;
|
|
32
|
+
/** One-line description (path + size/dimensions) emitted as a text block beside the image. */
|
|
33
|
+
note?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Build a {@link McpImageResult} for a handler to return. */
|
|
36
|
+
export declare function mcpImageResult(data: string, mimeType: string, note?: string): McpImageResult;
|
|
37
|
+
export declare function isMcpImageResult(value: unknown): value is McpImageResult;
|
|
2
38
|
/**
|
|
3
39
|
* Extract a human-meaningful failure message from a tool-call error. UTCP's
|
|
4
40
|
* HTTP protocol surfaces a non-2xx as an axios-style error whose `.response.data`
|
|
@@ -7,6 +43,44 @@ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
|
7
43
|
*/
|
|
8
44
|
export declare function describeToolFailure(err: unknown): string;
|
|
9
45
|
export declare function toCallToolResult(value: unknown): CallToolResult;
|
|
46
|
+
/**
|
|
47
|
+
* Replace image payloads inside a `call_tool_chain` result with a short note.
|
|
48
|
+
*
|
|
49
|
+
* A chain's return value is JSON that gets STRINGIFIED into the transcript
|
|
50
|
+
* (or spilled), so an image result reaching it would either flood the context
|
|
51
|
+
* with base64 or burn a spill for bytes no one can see — a chain has no way to
|
|
52
|
+
* deliver a native image block. Policy (v1): images are returned directly,
|
|
53
|
+
* never through tool chains. This walk swaps every image sentinel — and every
|
|
54
|
+
* spec-shaped image content block, which is what the local server's remote
|
|
55
|
+
* MCP hop hands a chain (see `toCallToolResult`) — for
|
|
56
|
+
* `{ image_omitted: true, note }`, keeping whatever structure the chain built
|
|
57
|
+
* around it. The walk is ITERATIVE (explicit stack) and cycle-safe with no
|
|
58
|
+
* depth cutoff — nesting depth can never smuggle a payload past the scrub.
|
|
59
|
+
* Arrays and plain records are rebuilt; a NON-plain object (class instance,
|
|
60
|
+
* Map-like with enumerable props) is judged by its JSON shape — `toJSON()`
|
|
61
|
+
* output when it defines one, enumerable own properties otherwise — because
|
|
62
|
+
* that is exactly what `JSON.stringify` will emit downstream: when that shape
|
|
63
|
+
* holds an image the object is rebuilt as a plain sanitized copy, and when it
|
|
64
|
+
* does not the original reference is preserved untouched (RegExp, Map, Date
|
|
65
|
+
* and friends are never mangled).
|
|
66
|
+
*
|
|
67
|
+
* The one thing never preserved by reference is a USER `toJSON`. The scrubbed
|
|
68
|
+
* result is stringified into the transcript AFTER this returns, so a hook left
|
|
69
|
+
* live in it fires a second time there, unscrubbed: an impure one — clean when
|
|
70
|
+
* probed, an image payload on the next call — would slip base64 straight past
|
|
71
|
+
* the walk. Every object carrying one is therefore rebuilt from the single
|
|
72
|
+
* view this scrub cached for it, and nothing reachable in the returned value
|
|
73
|
+
* carries a hook the walk did not already resolve. Best-effort by design:
|
|
74
|
+
* chain code that EXTRACTS the base64 string itself escapes the walk, and then
|
|
75
|
+
* the ordinary max_output_size spill bounds the damage.
|
|
76
|
+
*
|
|
77
|
+
* `rootKey` is the JSON property name the SCRUBBED value will be serialized
|
|
78
|
+
* under afterwards — '' (the default) when it is stringified standalone, the
|
|
79
|
+
* envelope key (e.g. `call_tool_chain`'s 'result') when a caller embeds it —
|
|
80
|
+
* so a key-sensitive root `toJSON` answers this scrub with the same view the
|
|
81
|
+
* transcript serializer will ask it for.
|
|
82
|
+
*/
|
|
83
|
+
export declare function omitImagePayloads(value: unknown, rootKey?: string): unknown;
|
|
10
84
|
export declare function renderProgress(chunk: unknown): string;
|
|
11
85
|
export declare function toolError(message: string): CallToolResult;
|
|
12
86
|
/**
|
package/dist/results.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAgBxD;
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,qBAAqB,CAAC;IACnC,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAE5F;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAoBxE;AAiBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAgBxD;AA+FD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAwD/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,SAAK,GAAG,O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