bambu-studio-mcp 0.0.0-stage → 0.0.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 +105 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +132 -0
- package/dist/cli.js.map +1 -0
- package/dist/confirm.d.ts +7 -0
- package/dist/confirm.js +24 -0
- package/dist/confirm.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +10 -0
- package/dist/mcp.js +98 -0
- package/dist/mcp.js.map +1 -0
- package/dist/osa.d.ts +15 -0
- package/dist/osa.js +40 -0
- package/dist/osa.js.map +1 -0
- package/dist/parse.d.ts +15 -0
- package/dist/parse.js +241 -0
- package/dist/parse.js.map +1 -0
- package/dist/runner.d.ts +31 -0
- package/dist/runner.js +50 -0
- package/dist/runner.js.map +1 -0
- package/dist/screen.d.ts +26 -0
- package/dist/screen.js +61 -0
- package/dist/screen.js.map +1 -0
- package/dist/studio.d.ts +131 -0
- package/dist/studio.js +329 -0
- package/dist/studio.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/jxa/click.js +21 -0
- package/jxa/close-window.js +9 -0
- package/jxa/colour.js +27 -0
- package/jxa/instances.js +9 -0
- package/jxa/keystroke.js +14 -0
- package/jxa/ocr.js +25 -0
- package/jxa/permissions.js +11 -0
- package/jxa/prelude.js +114 -0
- package/jxa/wait-window.js +15 -0
- package/package.json +69 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alex Nodeland
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bambu-studio-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drive **Bambu Studio on macOS** from a CLI or an MCP client (Claude Code, Claude Desktop, any MCP host):
|
|
4
|
+
open a project, slice the plate, preview the print job, send it, and read the printer's status and camera.
|
|
5
|
+
|
|
6
|
+
It works the way you do, through Bambu Studio's own window. Your printer stays on Bambu Cloud, with no
|
|
7
|
+
LAN-only mode, no Developer Mode and no access code. Jobs go out through Bambu Studio's own channel.
|
|
8
|
+
|
|
9
|
+
> **Unofficial.** Not made by, affiliated with or endorsed by Bambu Lab. "Bambu Lab" and "Bambu Studio"
|
|
10
|
+
> are their trademarks.
|
|
11
|
+
|
|
12
|
+
## Why this way
|
|
13
|
+
|
|
14
|
+
Since Bambu Lab's 2025 authorization firmware, a third-party tool can only start a print over the LAN
|
|
15
|
+
with the printer in LAN-only mode and Developer Mode, which takes it off Bambu Cloud. This tool asks
|
|
16
|
+
for neither: it automates the app you already use.
|
|
17
|
+
|
|
18
|
+
- Bambu Studio has no scripting interface, and most of its window is drawn by the app itself, so
|
|
19
|
+
macOS accessibility can't read it.
|
|
20
|
+
- This tool presses Bambu Studio's own keyboard shortcuts (⌘R to slice, ⌘⇧G to print the plate). It
|
|
21
|
+
takes screenshots, reads them with macOS's built-in text recognition (Vision), and clicks only at
|
|
22
|
+
points it has just read and verified.
|
|
23
|
+
|
|
24
|
+
## Safety
|
|
25
|
+
|
|
26
|
+
Sending a job starts a real machine.
|
|
27
|
+
|
|
28
|
+
- **Preview, then send.** `preview` reads the Send print job dialog and returns a token. `send` reads
|
|
29
|
+
the dialog again and refuses if anything changed since: job, printer, plate, time, weight, or which
|
|
30
|
+
AMS slot feeds which filament. It also refuses if the dialog differs from what you said to `expect`,
|
|
31
|
+
if it shows a problem, or if Bambu Studio has disabled Send.
|
|
32
|
+
- **A person confirms.** Before it clicks, a native macOS dialog asks the person at the Mac ("Only if
|
|
33
|
+
the bed is clear"), with Cancel as the default. An MCP client can't skip it. Only a person can: the
|
|
34
|
+
CLI's `--yes`, or `BAMBU_STUDIO_MCP_ALLOW_UNCONFIRMED=1` in the server's environment.
|
|
35
|
+
- **One click, never retried.** It then confirms on the Device tab that the job started.
|
|
36
|
+
- **No other controls.** It doesn't pause, stop, home, move or load anything.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- macOS, with Bambu Studio installed in `/Applications`, logged in, and showing your printer.
|
|
41
|
+
- Bambu Studio in **English**. The tool reads its labels.
|
|
42
|
+
- The app that runs this (your terminal, or your MCP client) allowed in **System Settings > Privacy &
|
|
43
|
+
Security**:
|
|
44
|
+
- **Accessibility**, to press keys and click;
|
|
45
|
+
- **Screen & System Audio Recording**, to read the window.
|
|
46
|
+
- Node.js 20 or later.
|
|
47
|
+
|
|
48
|
+
Tested on Bambu Studio 02.09.02.62, macOS 27.2.1, with a Bambu Lab X2D. Other versions may work:
|
|
49
|
+
`bambu-studio-mcp doctor` tells you what it sees.
|
|
50
|
+
|
|
51
|
+
## Use it from an MCP client
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"bambu-studio": { "command": "npx", "args": ["-y", "bambu-studio-mcp", "serve"] }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
With Claude Code: `claude mcp add bambu-studio -- npx -y bambu-studio-mcp serve`.
|
|
62
|
+
|
|
63
|
+
| Tool | What it does |
|
|
64
|
+
| ----------------- | ----------------------------------------------------------------------------------- |
|
|
65
|
+
| `bambu_doctor` | Versions, permissions, instances and warnings. Read-only. |
|
|
66
|
+
| `bambu_instances` | Running Bambu Studio instances (one per open project) and their windows. Read-only. |
|
|
67
|
+
| `bambu_open` | Open a `.3mf` and wait for its window. |
|
|
68
|
+
| `bambu_slice` | Slice the plate and wait until it can be printed. Returns a screenshot. |
|
|
69
|
+
| `bambu_status` | State, job, progress, layer and finish time from the Device tab. Read-only. |
|
|
70
|
+
| `bambu_snapshot` | The printer camera's picture. It restarts the live view if Bambu Studio paused it. |
|
|
71
|
+
| `bambu_preview` | Open and read the Send print job dialog. Returns a token. Sends nothing. |
|
|
72
|
+
| `bambu_send` | Send the previewed job, after the checks and the native confirmation. |
|
|
73
|
+
| `bambu_cancel` | Close the Send print job dialog without sending. |
|
|
74
|
+
|
|
75
|
+
## Use it from the shell
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npx bambu-studio-mcp doctor
|
|
79
|
+
npx bambu-studio-mcp open ~/prints/plate.3mf
|
|
80
|
+
npx bambu-studio-mcp slice
|
|
81
|
+
npx bambu-studio-mcp preview # prints a token and the dialog's fields
|
|
82
|
+
npx bambu-studio-mcp send --token <t> --slot A2 --material PLA --plate PEI
|
|
83
|
+
npx bambu-studio-mcp status
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Answers are JSON on stdout, and screenshots are PNG paths in them. With more than one project open,
|
|
87
|
+
pass `--pid` or `--project`.
|
|
88
|
+
|
|
89
|
+
## Projects sliced elsewhere
|
|
90
|
+
|
|
91
|
+
If you slice with Bambu Studio's command-line slicer, Bambu Studio will load your project's settings
|
|
92
|
+
only if the file names them as changes from a stock preset (`different_settings_to_system`). The CLI
|
|
93
|
+
doesn't write that. Without it, the app opens the file on stock settings and quietly drops your
|
|
94
|
+
changes.
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). In short:
|
|
99
|
+
|
|
100
|
+
- `make install`, then `make check`: lint, strict types, tests with **100 % coverage**, knip, build,
|
|
101
|
+
and an MCP smoke test.
|
|
102
|
+
- `make live` runs read-only checks against your real Bambu Studio.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
[MIT](LICENSE)
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The process entry, and the only file the coverage gate leaves out: it is these two lines, and
|
|
3
|
+
// `make smoke` runs the built binary.
|
|
4
|
+
import { defaultDeps, main } from "./cli.js";
|
|
5
|
+
process.exitCode = await main(process.argv.slice(2), defaultDeps(process.argv.slice(2)));
|
|
6
|
+
//# 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,gGAAgG;AAChG,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ServerOptions } from "./mcp.js";
|
|
2
|
+
import { type StudioLike } from "./studio.js";
|
|
3
|
+
export declare const ALLOW_UNCONFIRMED_ENV = "BAMBU_STUDIO_MCP_ALLOW_UNCONFIRMED";
|
|
4
|
+
export declare const HELP: string;
|
|
5
|
+
export interface CliDeps {
|
|
6
|
+
studio: StudioLike;
|
|
7
|
+
out(text: string): void;
|
|
8
|
+
err(text: string): void;
|
|
9
|
+
serve(options: ServerOptions): Promise<unknown>;
|
|
10
|
+
/** A person allowed unconfirmed sends in the environment (BAMBU_STUDIO_MCP_ALLOW_UNCONFIRMED=1). */
|
|
11
|
+
envAllowsUnconfirmed: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function main(argv: readonly string[], deps: CliDeps): Promise<number>;
|
|
14
|
+
/** The real thing: a Studio on this Mac, stdout and stderr, and stdio for the MCP server. */
|
|
15
|
+
export declare function defaultDeps(argv: readonly string[], env?: Readonly<Record<string, string | undefined>>): CliDeps;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { BsmError } from "./errors.js";
|
|
3
|
+
import { serveStdio } from "./mcp.js";
|
|
4
|
+
import { Studio } from "./studio.js";
|
|
5
|
+
import { VERSION } from "./version.js";
|
|
6
|
+
export const ALLOW_UNCONFIRMED_ENV = "BAMBU_STUDIO_MCP_ALLOW_UNCONFIRMED";
|
|
7
|
+
export const HELP = `bambu-studio-mcp ${VERSION}: drive Bambu Studio on this Mac (unofficial).
|
|
8
|
+
|
|
9
|
+
Usage: bambu-studio-mcp <command> [options]
|
|
10
|
+
|
|
11
|
+
serve Run as an MCP server over stdio.
|
|
12
|
+
doctor Versions, permissions, instances and warnings.
|
|
13
|
+
instances Running Bambu Studio instances and their windows.
|
|
14
|
+
open <file.3mf> Open a project and wait for its window.
|
|
15
|
+
slice Slice the plate (⌘R) and wait until it can be printed.
|
|
16
|
+
status The printer's state from the Device tab.
|
|
17
|
+
snapshot The printer camera's picture from the Device tab.
|
|
18
|
+
preview Open the Send print job dialog and read it; prints a token.
|
|
19
|
+
send --token <t> Send the previewed job, after asking in a native dialog.
|
|
20
|
+
[--printer <name>] [--plate <name>] [--job <name>]
|
|
21
|
+
[--slot <A1> ...] [--material <PLA> ...] what the dialog must show
|
|
22
|
+
[--yes] skip the native dialog
|
|
23
|
+
cancel Close the Send print job dialog without sending.
|
|
24
|
+
|
|
25
|
+
--pid <n> | --project <title> which instance, when more than one is open.
|
|
26
|
+
|
|
27
|
+
Answers are JSON on stdout; screenshots are PNG paths in them. Errors are JSON on stderr,
|
|
28
|
+
exit 1 (2 for usage). Sending starts a real print: only with a clear bed.`;
|
|
29
|
+
const TARGET = { pid: { type: "string" }, project: { type: "string" } };
|
|
30
|
+
const SEND = {
|
|
31
|
+
...TARGET,
|
|
32
|
+
token: { type: "string" },
|
|
33
|
+
printer: { type: "string" },
|
|
34
|
+
plate: { type: "string" },
|
|
35
|
+
job: { type: "string" },
|
|
36
|
+
slot: { type: "string", multiple: true },
|
|
37
|
+
material: { type: "string", multiple: true },
|
|
38
|
+
yes: { type: "boolean" },
|
|
39
|
+
};
|
|
40
|
+
function usage(message) {
|
|
41
|
+
return new BsmError("USAGE", message, "bambu-studio-mcp help");
|
|
42
|
+
}
|
|
43
|
+
function parse(args, options) {
|
|
44
|
+
try {
|
|
45
|
+
return parseArgs({ args: [...args], options, allowPositionals: true, strict: true });
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
throw usage(e.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function toTarget(values) {
|
|
52
|
+
if (values.pid !== undefined && !/^\d+$/.test(values.pid))
|
|
53
|
+
throw usage(`--pid must be a number, not "${values.pid}"`);
|
|
54
|
+
return { pid: values.pid === undefined ? undefined : Number(values.pid), project: values.project };
|
|
55
|
+
}
|
|
56
|
+
export async function main(argv, deps) {
|
|
57
|
+
const [command = "help", ...rest] = argv;
|
|
58
|
+
const print = (value) => {
|
|
59
|
+
deps.out(JSON.stringify(value, null, 2));
|
|
60
|
+
return 0;
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
switch (command) {
|
|
64
|
+
case "help":
|
|
65
|
+
case "--help":
|
|
66
|
+
case "-h":
|
|
67
|
+
deps.out(HELP);
|
|
68
|
+
return 0;
|
|
69
|
+
case "version":
|
|
70
|
+
case "--version":
|
|
71
|
+
case "-v":
|
|
72
|
+
deps.out(VERSION);
|
|
73
|
+
return 0;
|
|
74
|
+
case "serve":
|
|
75
|
+
await deps.serve({ confirm: !deps.envAllowsUnconfirmed });
|
|
76
|
+
return 0;
|
|
77
|
+
case "doctor":
|
|
78
|
+
return print(await deps.studio.doctor());
|
|
79
|
+
case "instances":
|
|
80
|
+
return print(await deps.studio.instances());
|
|
81
|
+
case "open": {
|
|
82
|
+
const file = parse(rest, {}).positionals[0];
|
|
83
|
+
if (file === undefined)
|
|
84
|
+
throw usage("open needs the path of a .3mf");
|
|
85
|
+
return print(await deps.studio.open(file));
|
|
86
|
+
}
|
|
87
|
+
case "slice":
|
|
88
|
+
case "status":
|
|
89
|
+
case "snapshot":
|
|
90
|
+
case "preview":
|
|
91
|
+
case "cancel":
|
|
92
|
+
return print(await deps.studio[command](toTarget(parse(rest, TARGET).values)));
|
|
93
|
+
case "send": {
|
|
94
|
+
const { values } = parse(rest, SEND);
|
|
95
|
+
if (values.token === undefined)
|
|
96
|
+
throw usage("send needs --token, from preview");
|
|
97
|
+
return print(await deps.studio.send({
|
|
98
|
+
token: values.token,
|
|
99
|
+
expect: {
|
|
100
|
+
job: values.job,
|
|
101
|
+
printer: values.printer,
|
|
102
|
+
plate: values.plate,
|
|
103
|
+
slots: values.slot,
|
|
104
|
+
materials: values.material,
|
|
105
|
+
},
|
|
106
|
+
confirm: values.yes !== true,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
throw usage(`unknown command "${command}"`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
if (!(e instanceof BsmError))
|
|
115
|
+
throw e;
|
|
116
|
+
deps.err(JSON.stringify(e.toJSON(), null, 2));
|
|
117
|
+
return e.code === "USAGE" ? 2 : 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** The real thing: a Studio on this Mac, stdout and stderr, and stdio for the MCP server. */
|
|
121
|
+
export function defaultDeps(argv, env = process.env) {
|
|
122
|
+
const envAllowsUnconfirmed = env[ALLOW_UNCONFIRMED_ENV] === "1";
|
|
123
|
+
const studio = Studio.create({ allowUnconfirmed: envAllowsUnconfirmed || argv.includes("--yes") });
|
|
124
|
+
return {
|
|
125
|
+
studio,
|
|
126
|
+
out: (text) => process.stdout.write(`${text}\n`),
|
|
127
|
+
err: (text) => process.stderr.write(`${text}\n`),
|
|
128
|
+
serve: (options) => serveStdio(studio, options),
|
|
129
|
+
envAllowsUnconfirmed,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAsB,UAAU,EAAE,MAAM,UAAU,CA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AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Runner } from "./runner.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ask the person at the Mac, in a native dialog whose default is Cancel. A tool argument can't stand
|
|
4
|
+
* in for this: a model can pass any argument, so the question goes to the screen. It gives up, as a
|
|
5
|
+
* no, after `timeoutS` seconds.
|
|
6
|
+
*/
|
|
7
|
+
export declare function askToSend(runner: Runner, message: string, timeoutS?: number): Promise<boolean>;
|
package/dist/confirm.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExecError } from "./runner.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ask the person at the Mac, in a native dialog whose default is Cancel. A tool argument can't stand
|
|
4
|
+
* in for this: a model can pass any argument, so the question goes to the screen. It gives up, as a
|
|
5
|
+
* no, after `timeoutS` seconds.
|
|
6
|
+
*/
|
|
7
|
+
export async function askToSend(runner, message, timeoutS = 120) {
|
|
8
|
+
const script = [
|
|
9
|
+
"on run argv",
|
|
10
|
+
`display dialog (item 1 of argv) with title "bambu-studio-mcp" buttons {"Cancel", "Send"} default button "Cancel" cancel button "Cancel" with icon caution giving up after ${timeoutS}`,
|
|
11
|
+
"end run",
|
|
12
|
+
];
|
|
13
|
+
try {
|
|
14
|
+
const out = await runner.exec("osascript", [...script.flatMap((line) => ["-e", line]), message], (timeoutS + 10) * 1000);
|
|
15
|
+
return /button returned:Send/.test(out) && !/gave up:true/.test(out);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
// -128 is "User canceled".
|
|
19
|
+
if (e instanceof ExecError && /-128/.test(e.failure.stderr))
|
|
20
|
+
return false;
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,OAAe,EAAE,QAAQ,GAAG,GAAG;IAC7E,MAAM,MAAM,GAAG;QACb,aAAa;QACb,6KAA6K,QAAQ,EAAE;QACvL,SAAS;KACV,CAAC;IACF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAC3B,WAAW,EACX,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,EACpD,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,IAAI,CACvB,CAAC;QACF,OAAO,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,2BAA2B;QAC3B,IAAI,CAAC,YAAY,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QAC1E,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ErrorCode = "NO_PROCESS" | "WINDOWS" | "FOCUS" | "MOVED" | "OUTSIDE" | "OCR" | "IMAGE" | "PERMISSION_ACCESSIBILITY" | "PERMISSION_SCREEN" | "OSASCRIPT" | "EXEC" | "NO_INSTANCE" | "AMBIGUOUS" | "NOT_FOUND" | "TIMEOUT" | "NOT_READY" | "MISMATCH" | "STALE" | "DECLINED" | "DIALOG" | "USAGE";
|
|
2
|
+
export declare class BsmError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly hint?: string | undefined;
|
|
5
|
+
readonly name = "BsmError";
|
|
6
|
+
constructor(code: ErrorCode, message: string, hint?: string | undefined);
|
|
7
|
+
toJSON(): {
|
|
8
|
+
code: ErrorCode;
|
|
9
|
+
message: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Turn osascript's stderr into a BsmError: the scripts' own codes, missing permissions, or the first line as is. */
|
|
14
|
+
export declare function fromOsascript(stderr: string): BsmError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const SCRIPT_CODES = new Set([
|
|
2
|
+
"NO_PROCESS",
|
|
3
|
+
"WINDOWS",
|
|
4
|
+
"FOCUS",
|
|
5
|
+
"MOVED",
|
|
6
|
+
"OUTSIDE",
|
|
7
|
+
"OCR",
|
|
8
|
+
"IMAGE",
|
|
9
|
+
]);
|
|
10
|
+
export class BsmError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
hint;
|
|
13
|
+
name = "BsmError";
|
|
14
|
+
constructor(code, message, hint) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.hint = hint;
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
20
|
+
return this.hint === undefined
|
|
21
|
+
? { code: this.code, message: this.message }
|
|
22
|
+
: { code: this.code, message: this.message, hint: this.hint };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const ACCESSIBILITY_HINT = "System Settings > Privacy & Security > Accessibility: allow the app that runs this tool (your terminal, or your MCP client).";
|
|
26
|
+
/** Turn osascript's stderr into a BsmError: the scripts' own codes, missing permissions, or the first line as is. */
|
|
27
|
+
export function fromOsascript(stderr) {
|
|
28
|
+
const m = /BSM_([A-Z_]+): ([^\n(]*)/.exec(stderr);
|
|
29
|
+
if (m !== null && SCRIPT_CODES.has(m[1])) {
|
|
30
|
+
return new BsmError(m[1], m[2].trim());
|
|
31
|
+
}
|
|
32
|
+
if (/-1719|-25211|-1743|assistive access|not allowed to send keystrokes|not authorized/i.test(stderr)) {
|
|
33
|
+
return new BsmError("PERMISSION_ACCESSIBILITY", "macOS has not allowed this app to control other apps", ACCESSIBILITY_HINT);
|
|
34
|
+
}
|
|
35
|
+
const [first] = stderr.trim().split("\n");
|
|
36
|
+
return new BsmError("OSASCRIPT", first === "" ? "osascript failed" : first);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAyBA,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IAChD,YAAY;IACZ,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAItB,IAAI;IAEJ,IAAI;IALG,IAAI,GAAG,UAAU,CAAC;IAEpC,YACW,IAAe,EACxB,OAAe,EACN,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;oBAJN,IAAI;oBAEJ,IAAI;IAGf,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS;YAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YAC5C,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAClE,CAAC;CACF;AAED,MAAM,kBAAkB,GACtB,8HAA8H,CAAC;AAEjI,qHAAqH;AACrH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,CAAC,GAAG,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAc,EAAG,CAAC,CAAC,CAAC,CAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,oFAAoF,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtG,OAAO,IAAI,QAAQ,CACjB,0BAA0B,EAC1B,sDAAsD,EACtD,kBAAkB,CACnB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC;IACtD,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ALLOW_UNCONFIRMED_ENV, defaultDeps, HELP, main } from "./cli.js";
|
|
2
|
+
export { askToSend } from "./confirm.js";
|
|
3
|
+
export { BsmError, type ErrorCode } from "./errors.js";
|
|
4
|
+
export { createServer, type ServerOptions, serveStdio } from "./mcp.js";
|
|
5
|
+
export { JXA_DIR, Osa, type OsaLike } from "./osa.js";
|
|
6
|
+
export { clean, deriveState, diffDialogs, isReady, parseDevice, parseSendDialog, toSeconds, unmet, } from "./parse.js";
|
|
7
|
+
export { ExecError, nodeRunner, type Runner } from "./runner.js";
|
|
8
|
+
export { isGreen, type Rgb, Screen, type ScreenLike } from "./screen.js";
|
|
9
|
+
export { DEFAULTS, type Doctor, type Preview, SEND_DIALOG, type SendRequest, type SendResult, Studio, type StudioLike, type StudioOptions, TESTED, } from "./studio.js";
|
|
10
|
+
export type * from "./types.js";
|
|
11
|
+
export { VERSION } from "./version.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ALLOW_UNCONFIRMED_ENV, defaultDeps, HELP, main } from "./cli.js";
|
|
2
|
+
export { askToSend } from "./confirm.js";
|
|
3
|
+
export { BsmError } from "./errors.js";
|
|
4
|
+
export { createServer, serveStdio } from "./mcp.js";
|
|
5
|
+
export { JXA_DIR, Osa } from "./osa.js";
|
|
6
|
+
export { clean, deriveState, diffDialogs, isReady, parseDevice, parseSendDialog, toSeconds, unmet, } from "./parse.js";
|
|
7
|
+
export { ExecError, nodeRunner } from "./runner.js";
|
|
8
|
+
export { isGreen, Screen } from "./screen.js";
|
|
9
|
+
export { DEFAULTS, SEND_DIALOG, Studio, TESTED, } from "./studio.js";
|
|
10
|
+
export { VERSION } from "./version.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,YAAY,EAAsB,UAAU,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AACtD,OAAO,EACL,KAAK,EACL,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,EACX,eAAe,EACf,SAAS,EACT,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,OAAO,EAAY,MAAM,EAAmB,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,QAAQ,EAGR,WAAW,EAGX,MAAM,EAGN,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
+
import type { StudioLike } from "./studio.js";
|
|
4
|
+
export interface ServerOptions {
|
|
5
|
+
/** Ask the person at the Mac before each send. Turned off only by the server's own environment, never by a tool call. */
|
|
6
|
+
confirm: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createServer(studio: StudioLike, options?: ServerOptions): McpServer;
|
|
9
|
+
/** Serve over stdio, for an MCP client that launches this as a process. */
|
|
10
|
+
export declare function serveStdio(studio: StudioLike, options?: ServerOptions, transport?: Transport): Promise<McpServer>;
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BsmError } from "./errors.js";
|
|
5
|
+
import { VERSION } from "./version.js";
|
|
6
|
+
const target = {
|
|
7
|
+
pid: z.number().int().optional().describe("The Bambu Studio process, from bambu_instances."),
|
|
8
|
+
project: z.string().optional().describe("Or the project's window title, from bambu_instances."),
|
|
9
|
+
};
|
|
10
|
+
const SAFETY = "Sending starts a real print on a real machine. Only after bambu_preview, only what the person asked for, and only when they have said the bed is clear.";
|
|
11
|
+
/** Run one tool: its JSON as text, then its screenshot when it has one; errors as an error result. */
|
|
12
|
+
async function answer(studio, work) {
|
|
13
|
+
try {
|
|
14
|
+
const value = await work();
|
|
15
|
+
const content = [{ type: "text", text: JSON.stringify(value, null, 2) }];
|
|
16
|
+
if (typeof value.image === "string") {
|
|
17
|
+
content.push({ type: "image", data: await studio.base64(value.image), mimeType: "image/png" });
|
|
18
|
+
}
|
|
19
|
+
return { content };
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
const body = e instanceof BsmError ? e.toJSON() : { code: "UNEXPECTED", message: String(e) };
|
|
23
|
+
return { isError: true, content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function createServer(studio, options = { confirm: true }) {
|
|
27
|
+
const server = new McpServer({ name: "bambu-studio-mcp", version: VERSION }, {
|
|
28
|
+
instructions: `Drives Bambu Studio on this Mac through its own window: open, slice, preview and send a plate, and read the printer's status and camera. ${SAFETY}`,
|
|
29
|
+
});
|
|
30
|
+
server.registerTool("bambu_doctor", {
|
|
31
|
+
title: "Check the setup",
|
|
32
|
+
description: "macOS and Bambu Studio versions, the permissions this needs, open instances and warnings. Read-only.",
|
|
33
|
+
annotations: { readOnlyHint: true },
|
|
34
|
+
}, () => answer(studio, () => studio.doctor()));
|
|
35
|
+
server.registerTool("bambu_instances", {
|
|
36
|
+
title: "List Bambu Studio instances",
|
|
37
|
+
description: "Every running Bambu Studio process (one per open project) and its windows. Read-only.",
|
|
38
|
+
annotations: { readOnlyHint: true },
|
|
39
|
+
}, () => answer(studio, async () => ({ instances: await studio.instances() })));
|
|
40
|
+
server.registerTool("bambu_open", {
|
|
41
|
+
title: "Open a project",
|
|
42
|
+
description: "Open a .3mf in Bambu Studio and wait for its window. Bambu Studio opens each project in its own instance.",
|
|
43
|
+
inputSchema: { file: z.string().describe("Absolute path to a .3mf.") },
|
|
44
|
+
}, ({ file }) => answer(studio, () => studio.open(file)));
|
|
45
|
+
server.registerTool("bambu_slice", {
|
|
46
|
+
title: "Slice the plate",
|
|
47
|
+
description: "Slice the open plate (⌘R) and wait until it can be printed. Returns a screenshot of the window.",
|
|
48
|
+
inputSchema: target,
|
|
49
|
+
}, (args) => answer(studio, () => studio.slice(args)));
|
|
50
|
+
server.registerTool("bambu_status", {
|
|
51
|
+
title: "Printer status",
|
|
52
|
+
description: "The printer's state, job, progress, layer and finish time from Bambu Studio's Device tab (switching to it if needed), with a screenshot.",
|
|
53
|
+
inputSchema: target,
|
|
54
|
+
annotations: { readOnlyHint: true },
|
|
55
|
+
}, (args) => answer(studio, () => studio.status(args)));
|
|
56
|
+
server.registerTool("bambu_snapshot", {
|
|
57
|
+
title: "Camera snapshot",
|
|
58
|
+
description: "The printer camera's picture from the Device tab: look at it to see the bed. It may be an older still; capturedAt says when.",
|
|
59
|
+
inputSchema: target,
|
|
60
|
+
annotations: { readOnlyHint: true },
|
|
61
|
+
}, (args) => answer(studio, () => studio.snapshot(args)));
|
|
62
|
+
server.registerTool("bambu_preview", {
|
|
63
|
+
title: "Preview the print job",
|
|
64
|
+
description: "Open Bambu Studio's Send print job dialog for the sliced plate and read it: job, time, grams, printer, plate and which AMS slot feeds each filament. Returns a token for bambu_send. Sends nothing.",
|
|
65
|
+
inputSchema: target,
|
|
66
|
+
}, (args) => answer(studio, () => studio.preview(args)));
|
|
67
|
+
server.registerTool("bambu_send", {
|
|
68
|
+
title: "Send the print job",
|
|
69
|
+
description: `Press Send in the previewed dialog. It reads the dialog again first and refuses if anything changed since the preview, if it differs from \`expect\`, if the dialog shows a problem or if Send is disabled. Then it asks the person at the Mac in a native dialog. ${SAFETY}`,
|
|
70
|
+
inputSchema: {
|
|
71
|
+
token: z.string().describe("From bambu_preview."),
|
|
72
|
+
expect: z
|
|
73
|
+
.object({
|
|
74
|
+
job: z.string().optional(),
|
|
75
|
+
printer: z.string().optional(),
|
|
76
|
+
plate: z.string().optional(),
|
|
77
|
+
slots: z.array(z.string()).optional().describe('AMS slots, e.g. ["A2"].'),
|
|
78
|
+
materials: z.array(z.string()).optional().describe('e.g. ["PLA"].'),
|
|
79
|
+
})
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("What the dialog must show."),
|
|
82
|
+
},
|
|
83
|
+
annotations: { destructiveHint: true, openWorldHint: true },
|
|
84
|
+
}, ({ token, expect }) => answer(studio, () => studio.send({ token, expect, confirm: options.confirm })));
|
|
85
|
+
server.registerTool("bambu_cancel", {
|
|
86
|
+
title: "Close the send dialog",
|
|
87
|
+
description: "Close Bambu Studio's Send print job dialog without sending.",
|
|
88
|
+
inputSchema: target,
|
|
89
|
+
}, (args) => answer(studio, () => studio.cancel(args)));
|
|
90
|
+
return server;
|
|
91
|
+
}
|
|
92
|
+
/** Serve over stdio, for an MCP client that launches this as a process. */
|
|
93
|
+
export async function serveStdio(studio, options = { confirm: true }, transport = new StdioServerTransport()) {
|
|
94
|
+
const server = createServer(studio, options);
|
|
95
|
+
await server.connect(transport);
|
|
96
|
+
return server;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AASvC,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC5F,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;CAChG,CAAC;AAEF,MAAM,MAAM,GACV,yJAAyJ,CAAC;AAE5J,sGAAsG;AACtG,KAAK,UAAU,MAAM,CACnB,MAAkB,EAClB,IAAgD;IAEhD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAA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C,QAAQ,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;aACpE,CAAC;iBACD,QAAQ,EAAE;iBACV,QAAQ,CAAC,4BAA4B,CAAC;SAC1C;QACD,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;KAC5D,EACD,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CACtG,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,6DAA6D;QAC1E,WAAW,EAAE,MAAM;KACpB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CACpD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAkB,EAClB,OAAO,GAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,EAC1C,SAAS,GAAc,IAAI,oBAAoB,EAAE;IAEjD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/osa.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Runner } from "./runner.js";
|
|
2
|
+
/** jxa/ beside src/ and dist/ alike. */
|
|
3
|
+
export declare const JXA_DIR: string;
|
|
4
|
+
export interface OsaLike {
|
|
5
|
+
/** Run jxa/<name>.js (after jxa/prelude.js) with these arguments, and parse its JSON answer. */
|
|
6
|
+
call<T>(name: string, args?: ReadonlyArray<string | number>, timeoutMs?: number): Promise<T>;
|
|
7
|
+
}
|
|
8
|
+
export declare class Osa implements OsaLike {
|
|
9
|
+
private readonly runner;
|
|
10
|
+
private readonly dir;
|
|
11
|
+
private readonly sources;
|
|
12
|
+
constructor(runner: Runner, dir?: string);
|
|
13
|
+
private source;
|
|
14
|
+
call<T>(name: string, args?: ReadonlyArray<string | number>, timeoutMs?: number): Promise<T>;
|
|
15
|
+
}
|
package/dist/osa.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { fromOsascript } from "./errors.js";
|
|
4
|
+
import { ExecError } from "./runner.js";
|
|
5
|
+
/** jxa/ beside src/ and dist/ alike. */
|
|
6
|
+
export const JXA_DIR = fileURLToPath(new URL("../jxa/", import.meta.url));
|
|
7
|
+
export class Osa {
|
|
8
|
+
runner;
|
|
9
|
+
dir;
|
|
10
|
+
sources = new Map();
|
|
11
|
+
constructor(runner, dir = JXA_DIR) {
|
|
12
|
+
this.runner = runner;
|
|
13
|
+
this.dir = dir;
|
|
14
|
+
}
|
|
15
|
+
async source(name) {
|
|
16
|
+
const cached = this.sources.get(name);
|
|
17
|
+
if (cached !== undefined)
|
|
18
|
+
return cached;
|
|
19
|
+
const prelude = await this.runner.readText(join(this.dir, "prelude.js"));
|
|
20
|
+
const body = await this.runner.readText(join(this.dir, `${name}.js`));
|
|
21
|
+
const text = `${prelude}\n${body}`;
|
|
22
|
+
this.sources.set(name, text);
|
|
23
|
+
return text;
|
|
24
|
+
}
|
|
25
|
+
async call(name, args = [], timeoutMs) {
|
|
26
|
+
const source = await this.source(name);
|
|
27
|
+
let out;
|
|
28
|
+
try {
|
|
29
|
+
// Arguments go to the script's run(argv), never into its source.
|
|
30
|
+
out = await this.runner.exec("osascript", ["-l", "JavaScript", "-e", source, ...args.map(String)], timeoutMs);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (e instanceof ExecError)
|
|
34
|
+
throw fromOsascript(e.failure.stderr);
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
return JSON.parse(out);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=osa.js.map
|
package/dist/osa.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"osa.js","sourceRoot":"","sources":["../src/osa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAErD,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAO1E,MAAM,OAAO,GAAG;IAIK,MAAM;IACN,GAAG;IAJL,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD,YACmB,MAAc,EACd,GAAG,GAAW,OAAO;sBADrB,MAAM;mBACN,GAAG;IACnB,CAAC;IAEI,KAAK,CAAC,MAAM,CAAC,IAAY;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;QACzE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC;QACtE,MAAM,IAAI,GAAG,GAAG,OAAO,KAAK,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,IAAI,GAAmC,EAAE,EAAE,SAAkB;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,GAAW,CAAC;QAChB,IAAI,CAAC;YACH,iEAAiE;YACjE,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAC1B,WAAW,EACX,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EACvD,SAAS,CACV,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,SAAS;gBAAE,MAAM,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAClE,MAAM,CAAC,CAAC;QACV,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DeviceStatus, Expect, OcrItem, PrinterState, SendDialog } from "./types.js";
|
|
2
|
+
/** Drop the icons and bullets text recognition reads before a label ("• > Workshop" → "Workshop"), and
|
|
3
|
+
* turn look-alike letters back into Latin. */
|
|
4
|
+
export declare function clean(text: string): string;
|
|
5
|
+
/** "1h27m", "1h26min48s", "27m", "45s" → seconds; null if it isn't a duration. */
|
|
6
|
+
export declare function toSeconds(text: string): number | null;
|
|
7
|
+
export declare function parseSendDialog(items: readonly OcrItem[]): SendDialog;
|
|
8
|
+
export declare function deriveState(stage: string | null, percent: number | null): PrinterState;
|
|
9
|
+
export declare function parseDevice(items: readonly OcrItem[]): DeviceStatus;
|
|
10
|
+
/** A printer that is idle, has finished or had its job canceled takes a new one (once its bed is clear). */
|
|
11
|
+
export declare function isReady(state: PrinterState): boolean;
|
|
12
|
+
/** Every way two readings of the dialog differ, as human-readable lines. Empty when they match. */
|
|
13
|
+
export declare function diffDialogs(before: SendDialog, now: SendDialog): string[];
|
|
14
|
+
/** Every expectation the dialog fails, as human-readable lines. Empty when it meets them all. */
|
|
15
|
+
export declare function unmet(dialog: SendDialog, expect: Expect): string[];
|