@musicpal/pianopal-upload 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/README.md +69 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/cli-command.type.d.ts +10 -0
- package/dist/cli/cli-command.type.js +3 -0
- package/dist/cli/cli-command.type.js.map +1 -0
- package/dist/cli/format-upload-summary.d.ts +2 -0
- package/dist/cli/format-upload-summary.js +15 -0
- package/dist/cli/format-upload-summary.js.map +1 -0
- package/dist/cli/parse-cli-args.d.ts +2 -0
- package/dist/cli/parse-cli-args.js +52 -0
- package/dist/cli/parse-cli-args.js.map +1 -0
- package/dist/cli/run-cli.d.ts +7 -0
- package/dist/cli/run-cli.js +46 -0
- package/dist/cli/run-cli.js.map +1 -0
- package/dist/cli/usage-text.d.ts +1 -0
- package/dist/cli/usage-text.js +30 -0
- package/dist/cli/usage-text.js.map +1 -0
- package/dist/client/parse-tool-result.d.ts +1 -0
- package/dist/client/parse-tool-result.js +28 -0
- package/dist/client/parse-tool-result.js.map +1 -0
- package/dist/client/pianopal-mcp-client.d.ts +11 -0
- package/dist/client/pianopal-mcp-client.js +42 -0
- package/dist/client/pianopal-mcp-client.js.map +1 -0
- package/dist/client/pianopal-tool-error.d.ts +4 -0
- package/dist/client/pianopal-tool-error.js +12 -0
- package/dist/client/pianopal-tool-error.js.map +1 -0
- package/dist/config/load-uploader-config.d.ts +7 -0
- package/dist/config/load-uploader-config.js +22 -0
- package/dist/config/load-uploader-config.js.map +1 -0
- package/dist/config/uploader-config.interface.d.ts +5 -0
- package/dist/config/uploader-config.interface.js +3 -0
- package/dist/config/uploader-config.interface.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/run-mcp-server.d.ts +1 -0
- package/dist/mcp/run-mcp-server.js +58 -0
- package/dist/mcp/run-mcp-server.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/upload/asset-type.d.ts +4 -0
- package/dist/upload/asset-type.js +17 -0
- package/dist/upload/asset-type.js.map +1 -0
- package/dist/upload/confirmed-asset.interface.d.ts +7 -0
- package/dist/upload/confirmed-asset.interface.js +3 -0
- package/dist/upload/confirmed-asset.interface.js.map +1 -0
- package/dist/upload/infer-mime-type.d.ts +1 -0
- package/dist/upload/infer-mime-type.js +23 -0
- package/dist/upload/infer-mime-type.js.map +1 -0
- package/dist/upload/transfer-input.interface.d.ts +9 -0
- package/dist/upload/transfer-input.interface.js +3 -0
- package/dist/upload/transfer-input.interface.js.map +1 -0
- package/dist/upload/transfer-via-put.d.ts +2 -0
- package/dist/upload/transfer-via-put.js +20 -0
- package/dist/upload/transfer-via-put.js.map +1 -0
- package/dist/upload/transfer-via-tus.d.ts +4 -0
- package/dist/upload/transfer-via-tus.js +20 -0
- package/dist/upload/transfer-via-tus.js.map +1 -0
- package/dist/upload/upload-dependencies.interface.d.ts +12 -0
- package/dist/upload/upload-dependencies.interface.js +3 -0
- package/dist/upload/upload-dependencies.interface.js.map +1 -0
- package/dist/upload/upload-local-file.d.ts +4 -0
- package/dist/upload/upload-local-file.js +62 -0
- package/dist/upload/upload-local-file.js.map +1 -0
- package/dist/upload/upload-progress.interface.d.ts +4 -0
- package/dist/upload/upload-progress.interface.js +3 -0
- package/dist/upload/upload-progress.interface.js.map +1 -0
- package/dist/upload/upload-request.interface.d.ts +8 -0
- package/dist/upload/upload-request.interface.js +3 -0
- package/dist/upload/upload-request.interface.js.map +1 -0
- package/dist/upload/upload-result.interface.d.ts +8 -0
- package/dist/upload/upload-result.interface.js +3 -0
- package/dist/upload/upload-result.interface.js.map +1 -0
- package/dist/upload/upload-session.interface.d.ts +7 -0
- package/dist/upload/upload-session.interface.js +3 -0
- package/dist/upload/upload-session.interface.js.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @musicpal/pianopal-upload
|
|
2
|
+
|
|
3
|
+
Puts a media file into the PianoPal library from the machine that holds it, for
|
|
4
|
+
partners who author courses over the PianoPal MCP.
|
|
5
|
+
|
|
6
|
+
An AI assistant can start and confirm an upload through the MCP, but the bytes
|
|
7
|
+
never pass through a tool call — something on the machine has to send them. This
|
|
8
|
+
package is that something, in two forms:
|
|
9
|
+
|
|
10
|
+
- a **command line**, for assistants that can run commands (Claude Code, Cursor,
|
|
11
|
+
Codex);
|
|
12
|
+
- a **local MCP server**, for assistants that cannot (Claude Desktop): it exposes
|
|
13
|
+
one tool, `upload_local_file`, and does the upload itself.
|
|
14
|
+
|
|
15
|
+
Video is uploaded with the resumable protocol Cloudflare Stream requires; every
|
|
16
|
+
other type by a single `PUT`. Which one applies is decided by the server per file.
|
|
17
|
+
|
|
18
|
+
## Setup
|
|
19
|
+
|
|
20
|
+
Node.js 18 or newer. Export your partner API key — it is read from the
|
|
21
|
+
environment and never accepted as a flag:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export PIANOPAL_API_KEY="mp_live_XXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYY"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Optional: `PIANOPAL_APP_ID` (default `com.musicpal.partner.mcp`) and
|
|
28
|
+
`PIANOPAL_MCP_URL` (default production) when PianoPal has pointed you at a test
|
|
29
|
+
server.
|
|
30
|
+
|
|
31
|
+
## Command line
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx @musicpal/pianopal-upload ./intro.mp4 --type video --title "Course intro"
|
|
35
|
+
npx @musicpal/pianopal-upload ./cover.png --type image --unique-name course-cover --json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Types: `image`, `thumbnail_image`, `audio_mp3`, `audio_wav`, `audio_aac`,
|
|
39
|
+
`static_voice`, `musicxml`, `video`. The content type is inferred from the
|
|
40
|
+
extension; pass `--mime-type` when it cannot be.
|
|
41
|
+
|
|
42
|
+
The result names the `assetId` to reference from a step. A video is confirmed
|
|
43
|
+
before it is playable: poll `asset_get` over the MCP until `ready` is true.
|
|
44
|
+
|
|
45
|
+
## Local MCP server (Claude Desktop)
|
|
46
|
+
|
|
47
|
+
Add it next to the PianoPal connector in `claude_desktop_config.json`:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"pianopal-upload": {
|
|
53
|
+
"command": "npx",
|
|
54
|
+
"args": ["-y", "@musicpal/pianopal-upload", "--mcp"],
|
|
55
|
+
"env": {
|
|
56
|
+
"PIANOPAL_API_KEY": "mp_live_XXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYY"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The assistant then has `upload_local_file({ path, type, title?, uniqueName?,
|
|
64
|
+
mimeType? })`, which starts, transfers and confirms the upload in one call.
|
|
65
|
+
|
|
66
|
+
## Exit codes
|
|
67
|
+
|
|
68
|
+
`0` done, `1` the command line did not form a command, `2` the upload did not
|
|
69
|
+
complete (the message names the step and the server's reason).
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const run_cli_1 = require("./cli/run-cli");
|
|
5
|
+
void (0, run_cli_1.runCli)(process.argv.slice(2), {
|
|
6
|
+
stdout: (text) => process.stdout.write(`${text}\n`),
|
|
7
|
+
stderr: (text) => process.stderr.write(`${text}\n`),
|
|
8
|
+
}).then((code) => {
|
|
9
|
+
if (code !== 0 || !process.argv.includes('--mcp')) {
|
|
10
|
+
process.exitCode = code;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AACA,2CAAsC;AAEtC,KAAK,IAAA,gBAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACjC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IACnD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;CACpD,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;IAEf,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAA;IACzB,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command.type.js","sourceRoot":"","sources":["../../src/cli/cli-command.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatUploadSummary = void 0;
|
|
4
|
+
const formatUploadSummary = (result) => [
|
|
5
|
+
`Uploaded ${result.fileSizeBytes} bytes by ${result.method}.`,
|
|
6
|
+
`assetId: ${result.assetId}`,
|
|
7
|
+
`type: ${result.asset.type}`,
|
|
8
|
+
`ready: ${result.asset.ready ? 'yes' : 'no'}` +
|
|
9
|
+
(result.asset.videoProcessingStatus === null
|
|
10
|
+
? ''
|
|
11
|
+
: ` (encoding: ${result.asset.videoProcessingStatus})`),
|
|
12
|
+
result.nextStep,
|
|
13
|
+
].join('\n');
|
|
14
|
+
exports.formatUploadSummary = formatUploadSummary;
|
|
15
|
+
//# sourceMappingURL=format-upload-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-upload-summary.js","sourceRoot":"","sources":["../../src/cli/format-upload-summary.ts"],"names":[],"mappings":";;;AAQO,MAAM,mBAAmB,GAAG,CAAC,MAAoB,EAAU,EAAE,CAClE;IACE,YAAY,MAAM,CAAC,aAAa,aAAa,MAAM,CAAC,MAAM,GAAG;IAC7D,YAAY,MAAM,CAAC,OAAO,EAAE;IAC5B,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;IAC5B,UAAU,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QAC3C,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,IAAI;YAC1C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,eAAe,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,CAAC;IAC3D,MAAM,CAAC,QAAQ;CAChB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAVD,QAAA,mBAAmB,uBAUlB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCliArgs = void 0;
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
|
+
const asset_type_1 = require("../upload/asset-type");
|
|
6
|
+
const parseCliArgs = (argv) => {
|
|
7
|
+
const { values, positionals } = (0, node_util_1.parseArgs)({
|
|
8
|
+
args: [...argv],
|
|
9
|
+
allowPositionals: true,
|
|
10
|
+
options: {
|
|
11
|
+
type: { type: 'string' },
|
|
12
|
+
title: { type: 'string' },
|
|
13
|
+
'unique-name': { type: 'string' },
|
|
14
|
+
'mime-type': { type: 'string' },
|
|
15
|
+
json: { type: 'boolean', default: false },
|
|
16
|
+
mcp: { type: 'boolean', default: false },
|
|
17
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (values.help) {
|
|
21
|
+
return { kind: 'help' };
|
|
22
|
+
}
|
|
23
|
+
if (values.mcp) {
|
|
24
|
+
return { kind: 'mcp' };
|
|
25
|
+
}
|
|
26
|
+
const [filePath, ...rest] = positionals;
|
|
27
|
+
if (filePath === undefined) {
|
|
28
|
+
throw new Error('Name the file to upload, or pass --mcp to run as an MCP server.');
|
|
29
|
+
}
|
|
30
|
+
if (rest.length > 0) {
|
|
31
|
+
throw new Error(`One file per run; unexpected: ${rest.join(' ')}`);
|
|
32
|
+
}
|
|
33
|
+
if (values.type === undefined) {
|
|
34
|
+
throw new Error(`--type is required; one of ${asset_type_1.ASSET_TYPES.join(', ')}.`);
|
|
35
|
+
}
|
|
36
|
+
if (!(0, asset_type_1.isAssetType)(values.type)) {
|
|
37
|
+
throw new Error(`Unknown --type "${values.type}"; one of ${asset_type_1.ASSET_TYPES.join(', ')}.`);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
kind: 'upload',
|
|
41
|
+
json: values.json,
|
|
42
|
+
request: {
|
|
43
|
+
filePath,
|
|
44
|
+
type: values.type,
|
|
45
|
+
mimeType: values['mime-type'],
|
|
46
|
+
title: values.title,
|
|
47
|
+
uniqueName: values['unique-name'],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.parseCliArgs = parseCliArgs;
|
|
52
|
+
//# sourceMappingURL=parse-cli-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-cli-args.js","sourceRoot":"","sources":["../../src/cli/parse-cli-args.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAA+D;AAcxD,MAAM,YAAY,GAAG,CAAC,IAAuB,EAAc,EAAE;IAClE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,qBAAS,EAAC;QACxC,IAAI,EAA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AI,CAAC,IAAA,wBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,IAAI,aAAa,wBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvF,CAAC;IAED,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE;YACP,QAAQ;YACR,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC;YAC7B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;SAClC;KACF,CAAA;AACH,CAAC,CAAA;AAhDY,QAAA,YAAY,gBAgDxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const EXIT_USAGE = 1;
|
|
2
|
+
export declare const EXIT_FAILED = 2;
|
|
3
|
+
export interface CliIo {
|
|
4
|
+
readonly stdout: (text: string) => void;
|
|
5
|
+
readonly stderr: (text: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const runCli: (argv: readonly string[], io: CliIo) => Promise<number>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCli = exports.EXIT_FAILED = exports.EXIT_USAGE = void 0;
|
|
4
|
+
const pianopal_mcp_client_1 = require("../client/pianopal-mcp-client");
|
|
5
|
+
const load_uploader_config_1 = require("../config/load-uploader-config");
|
|
6
|
+
const run_mcp_server_1 = require("../mcp/run-mcp-server");
|
|
7
|
+
const upload_local_file_1 = require("../upload/upload-local-file");
|
|
8
|
+
const format_upload_summary_1 = require("./format-upload-summary");
|
|
9
|
+
const parse_cli_args_1 = require("./parse-cli-args");
|
|
10
|
+
const usage_text_1 = require("./usage-text");
|
|
11
|
+
exports.EXIT_USAGE = 1;
|
|
12
|
+
exports.EXIT_FAILED = 2;
|
|
13
|
+
const runCli = async (argv, io) => {
|
|
14
|
+
let command;
|
|
15
|
+
try {
|
|
16
|
+
command = (0, parse_cli_args_1.parseCliArgs)(argv);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
io.stderr(`${messageOf(error)}\n\n${usage_text_1.USAGE_TEXT}`);
|
|
20
|
+
return exports.EXIT_USAGE;
|
|
21
|
+
}
|
|
22
|
+
if (command.kind === 'help') {
|
|
23
|
+
io.stdout(usage_text_1.USAGE_TEXT);
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
if (command.kind === 'mcp') {
|
|
27
|
+
await (0, run_mcp_server_1.runMcpServer)();
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const config = (0, load_uploader_config_1.loadUploaderConfig)();
|
|
32
|
+
const result = await (0, upload_local_file_1.uploadLocalFile)(command.request, {
|
|
33
|
+
openSession: () => pianopal_mcp_client_1.PianopalMcpClient.connect(config),
|
|
34
|
+
onProgress: (sent, total) => io.stderr(`${Math.floor((sent / total) * 100)}% (${sent}/${total} bytes)`),
|
|
35
|
+
});
|
|
36
|
+
io.stdout(command.json ? JSON.stringify(result, null, 2) : (0, format_upload_summary_1.formatUploadSummary)(result));
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
io.stderr(`Upload failed: ${messageOf(error)}`);
|
|
41
|
+
return exports.EXIT_FAILED;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.runCli = runCli;
|
|
45
|
+
const messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
46
|
+
//# sourceMappingURL=run-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cli.js","sourceRoot":"","sources":["../../src/cli/run-cli.ts"],"names":[],"mappings":";;;AAAA,uEAAiE;AACjE,yEAAmE;AACnE,0D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CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,2CAAmB,EAAC,MAAM,CAAC,CAAC,CAAA;QACvF,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,EAAE,CAAC,MAAM,CAAC,kBAAkB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC/C,OAAO,mBAAW,CAAA;IACpB,CAAC;AACH,CAAC,CAAA;AAhCY,QAAA,MAAM,UAgClB;AAED,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE,CAC3C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const USAGE_TEXT: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USAGE_TEXT = void 0;
|
|
4
|
+
const asset_type_1 = require("../upload/asset-type");
|
|
5
|
+
const load_uploader_config_1 = require("../config/load-uploader-config");
|
|
6
|
+
exports.USAGE_TEXT = `pianopal-upload — put a media file into the PianoPal library
|
|
7
|
+
|
|
8
|
+
Usage
|
|
9
|
+
pianopal-upload <file> --type <type> [--title <text>] [--unique-name <key>]
|
|
10
|
+
[--mime-type <type>] [--json]
|
|
11
|
+
pianopal-upload --mcp
|
|
12
|
+
pianopal-upload --help
|
|
13
|
+
|
|
14
|
+
Types
|
|
15
|
+
${asset_type_1.ASSET_TYPES.join(', ')}
|
|
16
|
+
|
|
17
|
+
Options
|
|
18
|
+
--type The library category to file it under (required)
|
|
19
|
+
--title Human-readable name shown in the library
|
|
20
|
+
--unique-name Stable key to look the asset up by later
|
|
21
|
+
--mime-type Content type, when it cannot be inferred from the extension
|
|
22
|
+
--json Print the result as JSON instead of a summary
|
|
23
|
+
--mcp Run as a local MCP server over stdio, exposing upload_local_file
|
|
24
|
+
|
|
25
|
+
Environment
|
|
26
|
+
${load_uploader_config_1.API_KEY_ENV} Your PianoPal partner API key (required; never a flag)
|
|
27
|
+
${load_uploader_config_1.APP_ID_ENV} Tenant id (default: com.musicpal.partner.mcp)
|
|
28
|
+
${load_uploader_config_1.MCP_URL_ENV} MCP endpoint (default: production)
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=usage-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-text.js","sourceRoot":"","sources":["../../src/cli/usage-text.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,yEAAqF;AAGxE,QAAA,UAAU,GAAG;;;;;;;;;IAStB,wBAAW,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;IAWtB,kCAAW;IACX,iCAAU;IACV,kCAAW;CACd,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseToolResult: <T>(tool: string, result: unknown) => T;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseToolResult = void 0;
|
|
4
|
+
const pianopal_tool_error_1 = require("./pianopal-tool-error");
|
|
5
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
6
|
+
const isTextPart = (part) => typeof part === 'object' &&
|
|
7
|
+
part !== null &&
|
|
8
|
+
part.type === 'text' &&
|
|
9
|
+
typeof part.text === 'string';
|
|
10
|
+
const parseToolResult = (tool, result) => {
|
|
11
|
+
const shape = isRecord(result) ? result : {};
|
|
12
|
+
const parts = Array.isArray(shape.content) ? shape.content.filter(isTextPart) : [];
|
|
13
|
+
const first = parts[0];
|
|
14
|
+
if (shape.isError === true) {
|
|
15
|
+
throw new pianopal_tool_error_1.PianopalToolError(tool, first?.text ?? 'refused without a message');
|
|
16
|
+
}
|
|
17
|
+
if (first === undefined) {
|
|
18
|
+
throw new pianopal_tool_error_1.PianopalToolError(tool, 'answered without a text part');
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(first.text);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
throw new pianopal_tool_error_1.PianopalToolError(tool, `answered with something other than JSON: ${first.text}`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.parseToolResult = parseToolResult;
|
|
28
|
+
//# sourceMappingURL=parse-tool-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-tool-result.js","sourceRoot":"","sources":["../../src/client/parse-tool-result.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AAQzD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AAE7C,MAAM,UAAU,GAAG,CAAC,IAAa,EAAoB,EAAE,CACrD,OAAO,IAAI,KAAK,QAAQ;IACxB,IAAI,KAAK,IAAI;IACZ,IAA2B,CAAC,IAAI,KAAK,MAAM;IAC5C,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,CAAA;AAgBhD,MAAM,eAAe,GAAG,CAAI,IAAY,EAAE,MAAe,EAAK,EAAE;IACrE,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAClF,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAEtB,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,uCAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,2BAA2B,CAAC,CAAA;IAC/E,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,uCAAiB,CAAC,IAAI,EAAE,8BAA8B,CAAC,CAAA;IACnE,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAM,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,uCAAiB,CAAC,IAAI,EAAE,4CAA4C,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7F,CAAC;AACH,CAAC,CAAA;AAlBY,QAAA,eAAe,mBAkB3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UploaderConfig } from '../config/uploader-config.interface';
|
|
2
|
+
export interface PianopalToolCaller {
|
|
3
|
+
callTool<T>(name: string, args: Record<string, unknown>): Promise<T>;
|
|
4
|
+
}
|
|
5
|
+
export declare class PianopalMcpClient implements PianopalToolCaller {
|
|
6
|
+
private readonly client;
|
|
7
|
+
private constructor();
|
|
8
|
+
static connect(config: UploaderConfig): Promise<PianopalMcpClient>;
|
|
9
|
+
callTool<T>(name: string, args: Record<string, unknown>): Promise<T>;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PianopalMcpClient = void 0;
|
|
4
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
5
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
6
|
+
const load_uploader_config_1 = require("../config/load-uploader-config");
|
|
7
|
+
const parse_tool_result_1 = require("./parse-tool-result");
|
|
8
|
+
const CLIENT_NAME = 'pianopal-upload';
|
|
9
|
+
const CLIENT_VERSION = '0.1.0';
|
|
10
|
+
class PianopalMcpClient {
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
static async connect(config) {
|
|
15
|
+
const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(config.mcpUrl), {
|
|
16
|
+
requestInit: {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
19
|
+
'X-App-Id': config.appId,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const client = new index_js_1.Client({ name: CLIENT_NAME, version: CLIENT_VERSION });
|
|
24
|
+
try {
|
|
25
|
+
await client.connect(transport);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Could not connect to the PianoPal MCP at ${config.mcpUrl}. Check ${load_uploader_config_1.API_KEY_ENV} and ` +
|
|
29
|
+
`${load_uploader_config_1.APP_ID_ENV}. ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
return new PianopalMcpClient(client);
|
|
32
|
+
}
|
|
33
|
+
async callTool(name, args) {
|
|
34
|
+
const result = await this.client.callTool({ name, arguments: args });
|
|
35
|
+
return (0, parse_tool_result_1.parseToolResult)(name, result);
|
|
36
|
+
}
|
|
37
|
+
async close() {
|
|
38
|
+
await this.client.close();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.PianopalMcpClient = PianopalMcpClient;
|
|
42
|
+
//# sourceMappingURL=pianopal-mcp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pianopal-mcp-client.js","sourceRoot":"","sources":["../../src/client/pianopal-mcp-client.ts"],"names":[],"mappings":";;;AAAA,wEAAkE;AAClE,0FAAkG;AAElG,yEAAwE;AAExE,2DAAqD;AAGrD,MAAM,WAAW,GAAG,iBAAiB,CAAA;AAGrC,MAAM,cAAc,GAAG,OAAO,CAAA;AA0B9B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CD,8CA+CC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PianopalToolError = void 0;
|
|
4
|
+
class PianopalToolError extends Error {
|
|
5
|
+
constructor(tool, message) {
|
|
6
|
+
super(`${tool}: ${message}`);
|
|
7
|
+
this.tool = tool;
|
|
8
|
+
this.name = 'PianopalToolError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.PianopalToolError = PianopalToolError;
|
|
12
|
+
//# sourceMappingURL=pianopal-tool-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pianopal-tool-error.js","sourceRoot":"","sources":["../../src/client/pianopal-tool-error.ts"],"names":[],"mappings":";;;AAOA,MAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAEW,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAA;QAHnB,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF;AATD,8CASC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UploaderConfig } from './uploader-config.interface';
|
|
2
|
+
export declare const API_KEY_ENV = "PIANOPAL_API_KEY";
|
|
3
|
+
export declare const APP_ID_ENV = "PIANOPAL_APP_ID";
|
|
4
|
+
export declare const MCP_URL_ENV = "PIANOPAL_MCP_URL";
|
|
5
|
+
export declare const DEFAULT_APP_ID = "com.musicpal.partner.mcp";
|
|
6
|
+
export declare const DEFAULT_MCP_URL = "https://api.pianopal.ai/api/v1/mcp";
|
|
7
|
+
export declare const loadUploaderConfig: (env?: NodeJS.ProcessEnv) => UploaderConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadUploaderConfig = exports.DEFAULT_MCP_URL = exports.DEFAULT_APP_ID = exports.MCP_URL_ENV = exports.APP_ID_ENV = exports.API_KEY_ENV = void 0;
|
|
4
|
+
exports.API_KEY_ENV = 'PIANOPAL_API_KEY';
|
|
5
|
+
exports.APP_ID_ENV = 'PIANOPAL_APP_ID';
|
|
6
|
+
exports.MCP_URL_ENV = 'PIANOPAL_MCP_URL';
|
|
7
|
+
exports.DEFAULT_APP_ID = 'com.musicpal.partner.mcp';
|
|
8
|
+
exports.DEFAULT_MCP_URL = 'https://api.pianopal.ai/api/v1/mcp';
|
|
9
|
+
const loadUploaderConfig = (env = process.env) => {
|
|
10
|
+
const apiKey = env[exports.API_KEY_ENV]?.trim();
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
throw new Error(`${exports.API_KEY_ENV} is not set. Export your PianoPal partner API key in that variable; ` +
|
|
13
|
+
'it is never accepted as a command-line argument.');
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
mcpUrl: env[exports.MCP_URL_ENV]?.trim() || exports.DEFAULT_MCP_URL,
|
|
17
|
+
apiKey,
|
|
18
|
+
appId: env[exports.APP_ID_ENV]?.trim() || exports.DEFAULT_APP_ID,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.loadUploaderConfig = loadUploaderConfig;
|
|
22
|
+
//# sourceMappingURL=load-uploader-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-uploader-config.js","sourceRoot":"","sources":["../../src/config/load-uploader-config.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAG,kBAAkB,CAAA;AAGhC,QAAA,UAAU,GAAG,iBAAiB,CAAA;AAG9B,QAAA,WAAW,GAAG,kBAAkB,CAAA;AAGhC,QAAA,cAAc,GAAG,0BAA0B,CAAA;AAG3C,QAAA,eAAe,GAAG,oCAAoC,CAAA;AAa5D,MAAM,kBAAkB,GAAG,CAChC,MAAyB,OAAO,CAAC,GAAG,EACpB,EAAE;IAClB,MAAM,MAAM,GAAG,GAAG,CAAC,mBAAW,CAAC,EAAE,IAAI,EAAE,CAAA;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,GAAG,mBAAW,sEAAsE;YAClF,kDAAkD,CACrD,CAAA;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,mBAAW,CAAC,EAAE,IAAI,EAAE,IAAI,uBAAe;QACnD,MAAM;QACN,KAAK,EAAE,GAAG,CAAC,kBAAU,CAAC,EAAE,IAAI,EAAE,IAAI,sBAAc;KACjD,CAAA;AACH,CAAC,CAAA;AAhBY,QAAA,kBAAkB,sBAgB9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploader-config.interface.js","sourceRoot":"","sources":["../../src/config/uploader-config.interface.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PianopalMcpClient } from './client/pianopal-mcp-client';
|
|
2
|
+
export type { PianopalToolCaller } from './client/pianopal-mcp-client';
|
|
3
|
+
export { PianopalToolError } from './client/pianopal-tool-error';
|
|
4
|
+
export { loadUploaderConfig } from './config/load-uploader-config';
|
|
5
|
+
export type { UploaderConfig } from './config/uploader-config.interface';
|
|
6
|
+
export { ASSET_TYPES } from './upload/asset-type';
|
|
7
|
+
export type { AssetType } from './upload/asset-type';
|
|
8
|
+
export { uploadLocalFile } from './upload/upload-local-file';
|
|
9
|
+
export type { UploadRequest } from './upload/upload-request.interface';
|
|
10
|
+
export type { UploadResult } from './upload/upload-result.interface';
|
|
11
|
+
export { runMcpServer } from './mcp/run-mcp-server';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMcpServer = exports.uploadLocalFile = exports.ASSET_TYPES = exports.loadUploaderConfig = exports.PianopalToolError = exports.PianopalMcpClient = void 0;
|
|
4
|
+
var pianopal_mcp_client_1 = require("./client/pianopal-mcp-client");
|
|
5
|
+
Object.defineProperty(exports, "PianopalMcpClient", { enumerable: true, get: function () { return pianopal_mcp_client_1.PianopalMcpClient; } });
|
|
6
|
+
var pianopal_tool_error_1 = require("./client/pianopal-tool-error");
|
|
7
|
+
Object.defineProperty(exports, "PianopalToolError", { enumerable: true, get: function () { return pianopal_tool_error_1.PianopalToolError; } });
|
|
8
|
+
var load_uploader_config_1 = require("./config/load-uploader-config");
|
|
9
|
+
Object.defineProperty(exports, "loadUploaderConfig", { enumerable: true, get: function () { return load_uploader_config_1.loadUploaderConfig; } });
|
|
10
|
+
var asset_type_1 = require("./upload/asset-type");
|
|
11
|
+
Object.defineProperty(exports, "ASSET_TYPES", { enumerable: true, get: function () { return asset_type_1.ASSET_TYPES; } });
|
|
12
|
+
var upload_local_file_1 = require("./upload/upload-local-file");
|
|
13
|
+
Object.defineProperty(exports, "uploadLocalFile", { enumerable: true, get: function () { return upload_local_file_1.uploadLocalFile; } });
|
|
14
|
+
var run_mcp_server_1 = require("./mcp/run-mcp-server");
|
|
15
|
+
Object.defineProperty(exports, "runMcpServer", { enumerable: true, get: function () { return run_mcp_server_1.runMcpServer; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oEAAgE;AAAvD,wHAAA,iBAAiB,OAAA;AAE1B,oEAAgE;AAAvD,wHAAA,iBAAiB,OAAA;AAC1B,sEAAkE;AAAzD,0HAAA,kBAAkB,OAAA;AAE3B,kDAAiD;AAAxC,yGAAA,WAAW,OAAA;AAEpB,gEAA4D;AAAnD,oHAAA,eAAe,OAAA;AAGxB,uDAAmD;AAA1C,8GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runMcpServer: () => Promise<void>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMcpServer = void 0;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const pianopal_mcp_client_1 = require("../client/pianopal-mcp-client");
|
|
8
|
+
const load_uploader_config_1 = require("../config/load-uploader-config");
|
|
9
|
+
const asset_type_1 = require("../upload/asset-type");
|
|
10
|
+
const upload_local_file_1 = require("../upload/upload-local-file");
|
|
11
|
+
const SERVER_NAME = 'pianopal-upload';
|
|
12
|
+
const SERVER_VERSION = '0.1.0';
|
|
13
|
+
const INSTRUCTIONS = 'Local uploader for the PianoPal library. Use upload_local_file for a file on this ' +
|
|
14
|
+
'machine instead of asset_upload_start: it starts, transfers and confirms the upload ' +
|
|
15
|
+
'in one call, including video. Search the library with asset_search first. A video ' +
|
|
16
|
+
'is confirmed before it is ready; poll asset_get until ready is true.';
|
|
17
|
+
const runMcpServer = async () => {
|
|
18
|
+
const config = (0, load_uploader_config_1.loadUploaderConfig)();
|
|
19
|
+
const server = new mcp_js_1.McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, {
|
|
20
|
+
instructions: INSTRUCTIONS,
|
|
21
|
+
});
|
|
22
|
+
server.registerTool('upload_local_file', {
|
|
23
|
+
description: 'Upload a file from this machine into the PianoPal library and confirm it. ' +
|
|
24
|
+
'Returns the assetId to reference from a step. Handles every type, including ' +
|
|
25
|
+
'video. Search asset_search before uploading something the library may hold.',
|
|
26
|
+
inputSchema: {
|
|
27
|
+
path: zod_1.z.string().min(1).describe('Absolute path of the file on this machine'),
|
|
28
|
+
type: zod_1.z.enum(asset_type_1.ASSET_TYPES).describe('The library category to file it under'),
|
|
29
|
+
title: zod_1.z.string().max(2000).optional().describe('Human-readable name for the library'),
|
|
30
|
+
uniqueName: zod_1.z.string().max(500).optional().describe('Stable key to look it up by later'),
|
|
31
|
+
mimeType: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.max(255)
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Content type, when it cannot be inferred from the extension'),
|
|
36
|
+
},
|
|
37
|
+
}, async (input) => {
|
|
38
|
+
try {
|
|
39
|
+
const result = await (0, upload_local_file_1.uploadLocalFile)({
|
|
40
|
+
filePath: input.path,
|
|
41
|
+
type: input.type,
|
|
42
|
+
title: input.title,
|
|
43
|
+
uniqueName: input.uniqueName,
|
|
44
|
+
mimeType: input.mimeType,
|
|
45
|
+
}, { openSession: () => pianopal_mcp_client_1.PianopalMcpClient.connect(config) });
|
|
46
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
isError: true,
|
|
51
|
+
content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
await server.connect(new stdio_js_1.StdioServerTransport());
|
|
56
|
+
};
|
|
57
|
+
exports.runMcpServer = runMcpServer;
|
|
58
|
+
//# sourceMappingURL=run-mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-mcp-server.js","sourceRoot":"","sources":["../../src/mcp/run-mcp-server.ts"],"names":[],"mappings":";;;AAAA,oEAAmE;AACnE,wEAAgF;AAChF,6BAAuB;AACvB,uEAAiE;AACjE,yEAAmE;AACnE,qDAAkD;AAClD,mEAA6D;AAG7D,MAAM,WAAW,GAAG,iBAAiB,CAAA;AAGrC,MAAM,cAAc,GAAG,OAAO,CAAA;AAG9B,MAAM,YAAY,GAChB,oFAAoF;IACpF,sFAAsF;IACtF,oFAAoF;IACpF,sEAAsE,CAAA;AAgBjE,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;IACpD,M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