ue-mcp-tripo 0.1.0 → 0.2.1
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 -21
- package/README.md +56 -18
- package/dist/index.d.ts +3 -6
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/shared/auth.d.ts +19 -0
- package/dist/shared/auth.js +32 -0
- package/dist/shared/auth.js.map +1 -0
- package/dist/shared/cli.d.ts +52 -0
- package/dist/shared/cli.js +174 -0
- package/dist/shared/cli.js.map +1 -0
- package/dist/shared/login.d.ts +13 -0
- package/dist/shared/login.js +47 -0
- package/dist/shared/login.js.map +1 -0
- package/dist/shared/secrets.d.ts +29 -0
- package/dist/shared/secrets.js +24 -0
- package/dist/shared/secrets.js.map +1 -0
- package/dist/tasks/AuthStatus.d.ts +10 -0
- package/dist/tasks/AuthStatus.js +14 -0
- package/dist/tasks/AuthStatus.js.map +1 -0
- package/dist/tasks/ClearKey.d.ts +11 -0
- package/dist/tasks/ClearKey.js +17 -0
- package/dist/tasks/ClearKey.js.map +1 -0
- package/dist/tasks/Cli.d.ts +18 -0
- package/dist/tasks/Cli.js +33 -0
- package/dist/tasks/Cli.js.map +1 -0
- package/dist/tasks/Generate.d.ts +47 -21
- package/dist/tasks/Generate.js +269 -50
- package/dist/tasks/Generate.js.map +1 -1
- package/dist/tasks/LoginPoll.d.ts +14 -0
- package/dist/tasks/LoginPoll.js +60 -0
- package/dist/tasks/LoginPoll.js.map +1 -0
- package/dist/tasks/LoginStart.d.ts +17 -0
- package/dist/tasks/LoginStart.js +43 -0
- package/dist/tasks/LoginStart.js.map +1 -0
- package/dist/tasks/SetKey.d.ts +15 -0
- package/dist/tasks/SetKey.js +20 -0
- package/dist/tasks/SetKey.js.map +1 -0
- package/dist/ui/settings.html +180 -0
- package/knowledge/tripo.md +128 -29
- package/package.json +11 -5
- package/skills/cli/SKILL.md +146 -0
- package/ue-mcp.plugin.yml +137 -124
- package/dist/shared/TripoClient.d.ts +0 -83
- package/dist/shared/TripoClient.js +0 -182
- package/dist/shared/TripoClient.js.map +0 -1
- package/dist/shared/pipeline.d.ts +0 -72
- package/dist/shared/pipeline.js +0 -278
- package/dist/shared/pipeline.js.map +0 -1
- package/dist/tasks/ImportModel.d.ts +0 -18
- package/dist/tasks/ImportModel.js +0 -23
- package/dist/tasks/ImportModel.js.map +0 -1
- package/dist/tasks/Setup.d.ts +0 -8
- package/dist/tasks/Setup.js +0 -24
- package/dist/tasks/Setup.js.map +0 -1
- package/dist/tasks/Status.d.ts +0 -12
- package/dist/tasks/Status.js +0 -29
- package/dist/tasks/Status.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 David Lyon
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Lyon
|
|
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,11 +1,13 @@
|
|
|
1
1
|
# ue-mcp-tripo
|
|
2
2
|
|
|
3
|
-
A [ue-mcp](https://github.com/db-lyon/ue-mcp) plugin that
|
|
3
|
+
A [ue-mcp](https://github.com/db-lyon/ue-mcp) plugin that brings [Tripo](https://www.tripo3d.ai) into Unreal Engine through Tripo's own command-line tool, [tripo-cli](https://www.npmjs.com/package/tripo-cli). One call turns a prompt or an image into a rigged, textured skeletal mesh with Unreal Mannequin bone names, and every other CLI command is available through a passthrough.
|
|
4
|
+
|
|
5
|
+
The plugin pins an exact tripo-cli version as a dependency and runs it from its own `node_modules`, so there is nothing else to install.
|
|
4
6
|
|
|
5
7
|
## Requirements
|
|
6
8
|
|
|
7
|
-
- ue-mcp 1.4.16-beta.
|
|
8
|
-
- A Tripo
|
|
9
|
+
- ue-mcp 1.4.16-beta.11 or later
|
|
10
|
+
- A Tripo account with credits
|
|
9
11
|
|
|
10
12
|
## Install
|
|
11
13
|
|
|
@@ -13,40 +15,76 @@ A [ue-mcp](https://github.com/db-lyon/ue-mcp) plugin that turns a prompt or an i
|
|
|
13
15
|
ue-mcp plugin install tripo
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
## Sign in
|
|
19
|
+
|
|
20
|
+
In Studio, open **Settings**, find Tripo Connector under the installed plugins, and select **Settings** on its row. Paste an API key from [Tripo's API keys page](https://developers.tripo3d.ai/en/keys), or select **Sign in with Tripo** and approve the one-time code in your browser. ue-mcp keeps a saved key for your user account only and passes it to the Tripo CLI. A `TRIPO_API_KEY` set in the ue-mcp server environment takes priority over a saved key.
|
|
21
|
+
|
|
22
|
+
Without Studio, sign in through the CLI's device login. It prints a URL and a one-time code; approve the code in the browser, then run the same call again to finish:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
tripo(action="cli", args=["login", "--region", "ov", "--no-wait"])
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `--region cn` for an account on the China site. Confirm the key, network and balance with:
|
|
17
29
|
|
|
18
30
|
```
|
|
19
|
-
tripo(action="
|
|
31
|
+
tripo(action="cli", args=["doctor"])
|
|
20
32
|
```
|
|
21
33
|
|
|
22
|
-
##
|
|
34
|
+
## Generate
|
|
23
35
|
|
|
24
36
|
```
|
|
25
37
|
tripo(action="generate", prompt="a stylized knight in plate armor", animation="idle")
|
|
26
38
|
```
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
This runs a single `tripo make` with Unreal defaults, writes its output to `<project>/Saved/Tripo/<name>`, and imports the model with ue-mcp's `asset(action="import_model")`. For the call above, the command is:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
tripo make "a stylized knight in plate armor" --for anim
|
|
44
|
+
--then "rig-check,rig:rig_type=biped,spec=unreal,retarget:animation=preset:idle,convert:fbx"
|
|
45
|
+
-p pbr=true -o <project>/Saved/Tripo/AStylizedKnightInPlateArmor --json --yes --no-open
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The result carries the Tripo task ids, the credits spent, the import result and the import's warnings.
|
|
29
49
|
|
|
30
|
-
|
|
|
50
|
+
| Option | Effect |
|
|
31
51
|
|---|---|
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
52
|
+
| `prompt`, `images` or `task` | The input: text, one image or 2 to 4 views (absolute paths or URLs), or an existing task id to continue from. |
|
|
53
|
+
| `rig=false` | Uses `--for game-pc` and imports a static mesh. |
|
|
54
|
+
| `rigType` | `biped` (default, with `spec=unreal`), another body type, or `auto` to let rig-check decide. |
|
|
55
|
+
| `animation` | One preset animation, such as `walk`. |
|
|
56
|
+
| `format=glb` | Skips the FBX conversion. |
|
|
57
|
+
| `params`, `model`, `then` | Extra `-p key=value` pairs, a generation model, or a replacement `--then` chain. |
|
|
58
|
+
| `dryRun=true` | Returns the plan and the credit estimate without spending anything. |
|
|
59
|
+
| `place`, `location`, `destination`, `name`, ... | Passed to `asset(import_model)`. |
|
|
60
|
+
|
|
61
|
+
A full run takes a few minutes. The call waits up to `waitSec` (default 300); `wait=false` returns at once. If `make` is still running, the result is `status=pending` with a `jobDir`, and `tripo(action="generate", resume="<jobDir>")` waits for it and imports the model. The CLI keeps running on its own in the meantime.
|
|
62
|
+
|
|
63
|
+
A model file already on disk does not need Tripo at all: import it with `asset(action="import_model", filePath="...", kind="skeletal")`.
|
|
64
|
+
|
|
65
|
+
## Any other CLI command
|
|
66
|
+
|
|
67
|
+
`tripo(action="cli", args=[...])` runs the pinned CLI with the given arguments plus `--json --yes --no-open`, and returns the parsed JSON result. A failed command returns the CLI's error message and the end of its stderr.
|
|
36
68
|
|
|
37
|
-
|
|
69
|
+
```
|
|
70
|
+
tripo(action="cli", args=["balance"])
|
|
71
|
+
tripo(action="cli", args=["task", "get", "<task id>"])
|
|
72
|
+
tripo(action="cli", args=["anim", "retarget", "<task id>", "-p", "animation=preset:run"])
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Commands stop after `timeoutSec` (default 300). For long jobs, pass `--no-wait` and follow up with `["task", "watch", "<id>", "--download"]`.
|
|
76
|
+
|
|
77
|
+
Tripo's agent guide, generated from `tripo docs` of the pinned version, ships as the plugin's knowledge file and as a `tripo-cli` skill.
|
|
38
78
|
|
|
39
79
|
## Development
|
|
40
80
|
|
|
41
81
|
```bash
|
|
42
82
|
npm install
|
|
43
|
-
npm run build
|
|
44
|
-
npm run check # manifest validates against the ue-mcp loader; every task resolves
|
|
45
|
-
npm test #
|
|
83
|
+
npm run build # compiles, then generates knowledge/ and skills/ from `tripo docs`
|
|
84
|
+
npm run check # the manifest validates against the ue-mcp loader; every task resolves
|
|
85
|
+
npm test # both actions against a fake CLI, plus offline dry runs of the real one
|
|
46
86
|
```
|
|
47
87
|
|
|
48
|
-
`TRIPO_BASE_URL` points the client at another Tripo host, such as `https://openapi.tripo3d.com` for the China region.
|
|
49
|
-
|
|
50
88
|
## License
|
|
51
89
|
|
|
52
90
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
* ue-mcp loads task classes by `class_path` from the manifest, so this file is
|
|
5
5
|
* not on the load path. It gives consumers a typed import surface.
|
|
6
6
|
*/
|
|
7
|
-
export { default as Generate } from "./tasks/Generate.js";
|
|
8
|
-
export { default as
|
|
9
|
-
export {
|
|
10
|
-
export { default as Setup } from "./tasks/Setup.js";
|
|
11
|
-
export { TripoClient, TripoError, API_KEY_ENV } from "./shared/TripoClient.js";
|
|
12
|
-
export { runChain, importFile } from "./shared/pipeline.js";
|
|
7
|
+
export { default as Generate, makeArgs, chainFor } from "./tasks/Generate.js";
|
|
8
|
+
export { default as Cli } from "./tasks/Cli.js";
|
|
9
|
+
export { cliPath, cliVersion, runCli, withAddedFlags, ADDED_FLAGS } from "./shared/cli.js";
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* ue-mcp loads task classes by `class_path` from the manifest, so this file is
|
|
5
5
|
* not on the load path. It gives consumers a typed import surface.
|
|
6
6
|
*/
|
|
7
|
-
export { default as Generate } from "./tasks/Generate.js";
|
|
8
|
-
export { default as
|
|
9
|
-
export {
|
|
10
|
-
export { default as Setup } from "./tasks/Setup.js";
|
|
11
|
-
export { TripoClient, TripoError, API_KEY_ENV } from "./shared/TripoClient.js";
|
|
12
|
-
export { runChain, importFile } from "./shared/pipeline.js";
|
|
7
|
+
export { default as Generate, makeArgs, chainFor } from "./tasks/Generate.js";
|
|
8
|
+
export { default as Cli } from "./tasks/Cli.js";
|
|
9
|
+
export { cliPath, cliVersion, runCli, withAddedFlags, ADDED_FLAGS } from "./shared/cli.js";
|
|
13
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** tripo-cli exit code for authentication failures (no key, rejected key). */
|
|
2
|
+
export declare const EXIT_AUTH = 3;
|
|
3
|
+
export interface AuthStatus {
|
|
4
|
+
/** The API key: set, and `env` (the user's own TRIPO_API_KEY) or `store` (saved through ue-mcp). */
|
|
5
|
+
key: {
|
|
6
|
+
set: boolean;
|
|
7
|
+
source: "env" | "store" | null;
|
|
8
|
+
};
|
|
9
|
+
/** Tripo calls authenticate, by the key or a `tripo login` profile. */
|
|
10
|
+
signedIn: boolean;
|
|
11
|
+
/** Where the working credential comes from, in words, when signed in. */
|
|
12
|
+
account?: string;
|
|
13
|
+
/** The site the account is on: ov (international) or cn (China mainland). */
|
|
14
|
+
region?: string;
|
|
15
|
+
/** Available credits, when whoami reports them. */
|
|
16
|
+
balance?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The current status, from the secret store and `tripo whoami --json`. */
|
|
19
|
+
export declare function authStatus(task: object, projectDir: string | null | undefined): Promise<AuthStatus>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the settings view shows about Tripo access: whether an API key is set
|
|
3
|
+
* and where it comes from, and the account `tripo whoami` reports. The key
|
|
4
|
+
* itself, and the masked key whoami prints, are never returned.
|
|
5
|
+
*/
|
|
6
|
+
import { failureMessage, runCli, withAddedFlags, workDir } from "./cli.js";
|
|
7
|
+
import { keyStatus } from "./secrets.js";
|
|
8
|
+
/** tripo-cli exit code for authentication failures (no key, rejected key). */
|
|
9
|
+
export const EXIT_AUTH = 3;
|
|
10
|
+
/** The current status, from the secret store and `tripo whoami --json`. */
|
|
11
|
+
export async function authStatus(task, projectDir) {
|
|
12
|
+
const key = keyStatus(task);
|
|
13
|
+
const args = withAddedFlags(["whoami"]);
|
|
14
|
+
const r = await runCli(args, { cwd: workDir(projectDir), timeoutMs: 60_000 });
|
|
15
|
+
if (r.exitCode === EXIT_AUTH && !r.timedOut)
|
|
16
|
+
return { key, signedIn: false };
|
|
17
|
+
if (r.exitCode !== 0 || r.timedOut)
|
|
18
|
+
throw new Error(failureMessage(args, r, 60_000));
|
|
19
|
+
const j = (r.json ?? {});
|
|
20
|
+
const fromEnv = j.source?.startsWith("env:") ?? false;
|
|
21
|
+
const account = fromEnv
|
|
22
|
+
? key.source === "store" ? "API key saved in ue-mcp" : "TRIPO_API_KEY environment variable"
|
|
23
|
+
: j.profile ? `Tripo sign-in (profile ${j.profile})` : "Tripo sign-in";
|
|
24
|
+
return {
|
|
25
|
+
key,
|
|
26
|
+
signedIn: true,
|
|
27
|
+
account,
|
|
28
|
+
...(j.region ? { region: j.region } : {}),
|
|
29
|
+
...(typeof j.balance === "number" ? { balance: j.balance } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/shared/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAsB3B,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,UAAqC;IAClF,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,QAAQ;QAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7E,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAErF,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAW,CAAC;IACnC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;IACtD,MAAM,OAAO,GAAG,OAAO;QACrB,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,oCAAoC;QAC3F,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;IACzE,OAAO;QACL,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,OAAO;QACP,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the tripo-cli binary this package pins.
|
|
3
|
+
*
|
|
4
|
+
* The binary is resolved from the plugin's own node_modules and started with
|
|
5
|
+
* the server's own Node (process.execPath): no global install, no npx, no
|
|
6
|
+
* shell. UE_MCP_TRIPO_CLI points at another script, which the tests use for a
|
|
7
|
+
* fake CLI.
|
|
8
|
+
*/
|
|
9
|
+
import { type ChildProcess } from "node:child_process";
|
|
10
|
+
/** Flags the plugin adds to every command unless the caller already passed them. */
|
|
11
|
+
export declare const ADDED_FLAGS: readonly ["--json", "--yes", "--no-open"];
|
|
12
|
+
export declare function cliPath(): string;
|
|
13
|
+
/** The pinned tripo-cli version, or null when it cannot be read (an override path). */
|
|
14
|
+
export declare function cliVersion(): string | null;
|
|
15
|
+
/** Append --json, --yes and --no-open, skipping any the caller already passed. */
|
|
16
|
+
export declare function withAddedFlags(args: string[]): string[];
|
|
17
|
+
export declare function refusal(args: string[]): string | null;
|
|
18
|
+
export interface CliResult {
|
|
19
|
+
exitCode: number | null;
|
|
20
|
+
stdout: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
/** stdout parsed as JSON, or undefined when it is not JSON (docs, completion). */
|
|
23
|
+
json?: unknown;
|
|
24
|
+
timedOut: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Parse the last non-empty stdout line as JSON; the CLI prints exactly one result line. */
|
|
27
|
+
export declare function parseJsonLine(stdout: string): unknown;
|
|
28
|
+
export declare function tail(text: string, lines?: number): string;
|
|
29
|
+
export declare function stripAnsi(text: string): string;
|
|
30
|
+
/** Run the CLI to completion (or until the timeout), capturing stdout and stderr. */
|
|
31
|
+
export declare function runCli(args: string[], opts?: {
|
|
32
|
+
cwd?: string;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}): Promise<CliResult>;
|
|
35
|
+
/** Message for a failed run: the CLI's own error JSON, its suggestion, and a stderr tail. */
|
|
36
|
+
export declare function failureMessage(args: string[], r: CliResult, timeoutMs?: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Start the CLI detached, with stdout and stderr going to files, so it keeps
|
|
39
|
+
* running when the MCP call (or the server) goes away.
|
|
40
|
+
*/
|
|
41
|
+
export declare function startDetached(args: string[], opts: {
|
|
42
|
+
cwd?: string;
|
|
43
|
+
stdoutFile: string;
|
|
44
|
+
stderrFile: string;
|
|
45
|
+
}): ChildProcess;
|
|
46
|
+
/**
|
|
47
|
+
* Where the CLI runs: <project>/Saved/Tripo, so its `.tripo` directory
|
|
48
|
+
* context and default output stay out of the project root and `@last`
|
|
49
|
+
* resolves the same way for every call. Without a project, a temp folder.
|
|
50
|
+
*/
|
|
51
|
+
export declare function workDir(projectDir: string | null | undefined): string;
|
|
52
|
+
export declare function isAlive(pid: number | undefined): boolean;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the tripo-cli binary this package pins.
|
|
3
|
+
*
|
|
4
|
+
* The binary is resolved from the plugin's own node_modules and started with
|
|
5
|
+
* the server's own Node (process.execPath): no global install, no npx, no
|
|
6
|
+
* shell. UE_MCP_TRIPO_CLI points at another script, which the tests use for a
|
|
7
|
+
* fake CLI.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { closeSync, mkdirSync, openSync } from "node:fs";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
/** Flags the plugin adds to every command unless the caller already passed them. */
|
|
15
|
+
export const ADDED_FLAGS = ["--json", "--yes", "--no-open"];
|
|
16
|
+
/** Commands the passthrough refuses, with the way to get the same result. */
|
|
17
|
+
const REFUSED = {
|
|
18
|
+
mcp: "`tripo mcp` starts a stdio server that never exits. Run the individual commands through tripo(action=\"cli\") instead.",
|
|
19
|
+
update: "`tripo update` installs tripo-cli globally, which this plugin does not use. Update the plugin instead: ue-mcp plugin update tripo.",
|
|
20
|
+
};
|
|
21
|
+
export function cliPath() {
|
|
22
|
+
const override = process.env.UE_MCP_TRIPO_CLI;
|
|
23
|
+
if (override)
|
|
24
|
+
return override;
|
|
25
|
+
const require = createRequire(import.meta.url);
|
|
26
|
+
const pkgPath = require.resolve("tripo-cli/package.json");
|
|
27
|
+
const pkg = require(pkgPath);
|
|
28
|
+
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.tripo;
|
|
29
|
+
if (!bin)
|
|
30
|
+
throw new Error(`tripo-cli at ${dirname(pkgPath)} declares no "tripo" bin.`);
|
|
31
|
+
return join(dirname(pkgPath), bin);
|
|
32
|
+
}
|
|
33
|
+
/** The pinned tripo-cli version, or null when it cannot be read (an override path). */
|
|
34
|
+
export function cliVersion() {
|
|
35
|
+
try {
|
|
36
|
+
const require = createRequire(import.meta.url);
|
|
37
|
+
return require("tripo-cli/package.json").version;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Append --json, --yes and --no-open, skipping any the caller already passed. */
|
|
44
|
+
export function withAddedFlags(args) {
|
|
45
|
+
const out = [...args];
|
|
46
|
+
for (const f of ADDED_FLAGS)
|
|
47
|
+
if (!out.includes(f))
|
|
48
|
+
out.push(f);
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
export function refusal(args) {
|
|
52
|
+
const command = args.find((a) => !a.startsWith("-"));
|
|
53
|
+
return command && REFUSED[command] ? REFUSED[command] : null;
|
|
54
|
+
}
|
|
55
|
+
/** Parse the last non-empty stdout line as JSON; the CLI prints exactly one result line. */
|
|
56
|
+
export function parseJsonLine(stdout) {
|
|
57
|
+
const text = stdout.trim();
|
|
58
|
+
if (!text)
|
|
59
|
+
return undefined;
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(text);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
const lines = text.split(/\r?\n/).filter((l) => l.trim());
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(lines[lines.length - 1]);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function tail(text, lines = 20) {
|
|
74
|
+
return text.split(/\r?\n/).filter((l) => l.trim()).slice(-lines).join("\n");
|
|
75
|
+
}
|
|
76
|
+
const ANSI = /\x1b\[[0-9;]*m/g;
|
|
77
|
+
export function stripAnsi(text) {
|
|
78
|
+
return text.replace(ANSI, "");
|
|
79
|
+
}
|
|
80
|
+
/** Run the CLI to completion (or until the timeout), capturing stdout and stderr. */
|
|
81
|
+
export function runCli(args, opts = {}) {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
const child = spawn(process.execPath, [cliPath(), ...args], {
|
|
84
|
+
cwd: opts.cwd,
|
|
85
|
+
env: process.env,
|
|
86
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
87
|
+
windowsHide: true,
|
|
88
|
+
});
|
|
89
|
+
let stdout = "";
|
|
90
|
+
let stderr = "";
|
|
91
|
+
let timedOut = false;
|
|
92
|
+
child.stdout.setEncoding("utf8").on("data", (d) => (stdout += d));
|
|
93
|
+
child.stderr.setEncoding("utf8").on("data", (d) => (stderr += d));
|
|
94
|
+
const timer = opts.timeoutMs
|
|
95
|
+
? setTimeout(() => {
|
|
96
|
+
timedOut = true;
|
|
97
|
+
child.kill();
|
|
98
|
+
}, opts.timeoutMs)
|
|
99
|
+
: undefined;
|
|
100
|
+
child.on("error", (e) => {
|
|
101
|
+
if (timer)
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
reject(e);
|
|
104
|
+
});
|
|
105
|
+
child.on("close", (code) => {
|
|
106
|
+
if (timer)
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
resolve({ exitCode: code, stdout, stderr: stripAnsi(stderr), json: parseJsonLine(stdout), timedOut });
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** Message for a failed run: the CLI's own error JSON, its suggestion, and a stderr tail. */
|
|
113
|
+
export function failureMessage(args, r, timeoutMs) {
|
|
114
|
+
const j = (r.json ?? {});
|
|
115
|
+
const head = r.timedOut
|
|
116
|
+
? `tripo ${args[0] ?? ""} did not finish within ${Math.round((timeoutMs ?? 0) / 1000)}s and was stopped. ` +
|
|
117
|
+
`A task it already submitted keeps running on Tripo's side: find it with tripo(action="cli", args=["history"]), ` +
|
|
118
|
+
`or pass --no-wait and follow up with ["task","watch","<id>"].`
|
|
119
|
+
: `tripo ${args[0] ?? ""} exited ${r.exitCode}: ${j.error ?? "no error message"}`;
|
|
120
|
+
const parts = [head];
|
|
121
|
+
if (j.suggestion)
|
|
122
|
+
parts.push(`Suggestion: ${j.suggestion}`);
|
|
123
|
+
if (j.task_id)
|
|
124
|
+
parts.push(`Task: ${j.task_id}`);
|
|
125
|
+
const err = tail(r.stderr);
|
|
126
|
+
if (err)
|
|
127
|
+
parts.push(`stderr:\n${err}`);
|
|
128
|
+
return parts.join("\n");
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Start the CLI detached, with stdout and stderr going to files, so it keeps
|
|
132
|
+
* running when the MCP call (or the server) goes away.
|
|
133
|
+
*/
|
|
134
|
+
export function startDetached(args, opts) {
|
|
135
|
+
const out = openSync(opts.stdoutFile, "w");
|
|
136
|
+
const err = openSync(opts.stderrFile, "w");
|
|
137
|
+
try {
|
|
138
|
+
const child = spawn(process.execPath, [cliPath(), ...args], {
|
|
139
|
+
cwd: opts.cwd,
|
|
140
|
+
env: process.env,
|
|
141
|
+
stdio: ["ignore", out, err],
|
|
142
|
+
detached: true,
|
|
143
|
+
windowsHide: true,
|
|
144
|
+
});
|
|
145
|
+
child.unref();
|
|
146
|
+
return child;
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
closeSync(out);
|
|
150
|
+
closeSync(err);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Where the CLI runs: <project>/Saved/Tripo, so its `.tripo` directory
|
|
155
|
+
* context and default output stay out of the project root and `@last`
|
|
156
|
+
* resolves the same way for every call. Without a project, a temp folder.
|
|
157
|
+
*/
|
|
158
|
+
export function workDir(projectDir) {
|
|
159
|
+
const dir = projectDir ? join(projectDir, "Saved", "Tripo") : join(tmpdir(), "ue-mcp-tripo");
|
|
160
|
+
mkdirSync(dir, { recursive: true });
|
|
161
|
+
return dir;
|
|
162
|
+
}
|
|
163
|
+
export function isAlive(pid) {
|
|
164
|
+
if (!pid)
|
|
165
|
+
return false;
|
|
166
|
+
try {
|
|
167
|
+
process.kill(pid, 0);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
return e.code === "EPERM";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/shared/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAU,CAAC;AAErE,6EAA6E;AAC7E,MAAM,OAAO,GAA2B;IACtC,GAAG,EAAE,wHAAwH;IAC7H,MAAM,EACJ,oIAAoI;CACvI,CAAC;AAEF,MAAM,UAAU,OAAO;IACrB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC9C,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,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,CAA2B,CAAC,IAAI,KAAK,OAAO,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Region = "ov" | "cn";
|
|
2
|
+
export interface LoginState {
|
|
3
|
+
region: Region;
|
|
4
|
+
userCode: string;
|
|
5
|
+
/** Epoch ms. */
|
|
6
|
+
expiresAt: number;
|
|
7
|
+
/** login_start found the sign-in already approved. */
|
|
8
|
+
completed?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseRegion(value: unknown): Region;
|
|
11
|
+
export declare function readLoginState(workDir: string): LoginState | null;
|
|
12
|
+
export declare function writeLoginState(workDir: string, state: LoginState): void;
|
|
13
|
+
export declare function clearLoginState(workDir: string): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pieces of the non-blocking device sign-in (login_start, login_poll,
|
|
3
|
+
* login_status).
|
|
4
|
+
*
|
|
5
|
+
* The CLI parks the pending grant itself (~/.tripo/pending-login.json), so
|
|
6
|
+
* `tripo login --region <r> --no-wait` run again finishes the sign-in once the
|
|
7
|
+
* human approved. The only state kept here is what the CLI does not expose:
|
|
8
|
+
* the region and code login_start returned and when it expires, so login_poll
|
|
9
|
+
* can tell "still pending" from "that code lapsed and the CLI issued a new one".
|
|
10
|
+
* It holds no key or device code.
|
|
11
|
+
*/
|
|
12
|
+
import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
export function parseRegion(value) {
|
|
15
|
+
if (value === undefined || value === null || value === "")
|
|
16
|
+
return "ov";
|
|
17
|
+
const v = String(value).toLowerCase();
|
|
18
|
+
if (v === "ov" || v === "cn")
|
|
19
|
+
return v;
|
|
20
|
+
throw new Error(`region must be "ov" (international) or "cn" (China mainland), got "${String(value)}".`);
|
|
21
|
+
}
|
|
22
|
+
function stateFile(workDir) {
|
|
23
|
+
return join(workDir, "login-state.json");
|
|
24
|
+
}
|
|
25
|
+
export function readLoginState(workDir) {
|
|
26
|
+
try {
|
|
27
|
+
const s = JSON.parse(readFileSync(stateFile(workDir), "utf8"));
|
|
28
|
+
return s && typeof s.region === "string" ? s : null;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function writeLoginState(workDir, state) {
|
|
35
|
+
const file = stateFile(workDir);
|
|
36
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
37
|
+
writeFileSync(file, JSON.stringify(state) + "\n");
|
|
38
|
+
}
|
|
39
|
+
export function clearLoginState(workDir) {
|
|
40
|
+
try {
|
|
41
|
+
unlinkSync(stateFile(workDir));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// already gone
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/shared/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAa1C,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACvE,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACvC,MAAM,IAAI,KAAK,CAAC,sEAAsE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAe,CAAC;QAC7E,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,KAAiB;IAChE,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,CAAC;QACH,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tripo API key as ue-mcp's plugin secret store holds it.
|
|
3
|
+
*
|
|
4
|
+
* The manifest declares TRIPO_API_KEY under `secrets:`, so ue-mcp keeps the
|
|
5
|
+
* value per user and puts it in the server's environment, where the pinned
|
|
6
|
+
* tripo-cli reads it. Task code reaches the store through `this.secrets`,
|
|
7
|
+
* which ue-mcp sets on the plugin's task classes. A value never leaves this
|
|
8
|
+
* module: callers see only whether a key is set and where it comes from.
|
|
9
|
+
*/
|
|
10
|
+
export declare const KEY_NAME = "TRIPO_API_KEY";
|
|
11
|
+
export interface SecretStatus {
|
|
12
|
+
name: string;
|
|
13
|
+
set: boolean;
|
|
14
|
+
/** `env` when the user's own environment variable holds it, `store` when ue-mcp does. */
|
|
15
|
+
source: "env" | "store" | null;
|
|
16
|
+
}
|
|
17
|
+
/** The part of ue-mcp's `this.secrets` the plugin uses. */
|
|
18
|
+
export interface SecretStore {
|
|
19
|
+
set(name: string, value: string): Promise<void>;
|
|
20
|
+
clear(name: string): Promise<void>;
|
|
21
|
+
status(name: string): SecretStatus;
|
|
22
|
+
}
|
|
23
|
+
/** The task's secret store, or a clear error on a ue-mcp too old to have one. */
|
|
24
|
+
export declare function secretsOf(task: object): SecretStore;
|
|
25
|
+
/** The key's status: whether it is set and from where, never the value. */
|
|
26
|
+
export declare function keyStatus(task: object): {
|
|
27
|
+
set: boolean;
|
|
28
|
+
source: "env" | "store" | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tripo API key as ue-mcp's plugin secret store holds it.
|
|
3
|
+
*
|
|
4
|
+
* The manifest declares TRIPO_API_KEY under `secrets:`, so ue-mcp keeps the
|
|
5
|
+
* value per user and puts it in the server's environment, where the pinned
|
|
6
|
+
* tripo-cli reads it. Task code reaches the store through `this.secrets`,
|
|
7
|
+
* which ue-mcp sets on the plugin's task classes. A value never leaves this
|
|
8
|
+
* module: callers see only whether a key is set and where it comes from.
|
|
9
|
+
*/
|
|
10
|
+
export const KEY_NAME = "TRIPO_API_KEY";
|
|
11
|
+
/** The task's secret store, or a clear error on a ue-mcp too old to have one. */
|
|
12
|
+
export function secretsOf(task) {
|
|
13
|
+
const store = task.secrets;
|
|
14
|
+
if (!store) {
|
|
15
|
+
throw new Error("This ue-mcp has no plugin secret store. Update ue-mcp with `npx ue-mcp update`, or set TRIPO_API_KEY in the server environment.");
|
|
16
|
+
}
|
|
17
|
+
return store;
|
|
18
|
+
}
|
|
19
|
+
/** The key's status: whether it is set and from where, never the value. */
|
|
20
|
+
export function keyStatus(task) {
|
|
21
|
+
const s = secretsOf(task).status(KEY_NAME);
|
|
22
|
+
return { set: s.set, source: s.source };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/shared/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;AAgBxC,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAI,IAAkC,CAAC,OAAO,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,iIAAiI,CAAC,CAAC;IACrJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tripo.auth_status - whether a Tripo API key is set (and from where) and the
|
|
3
|
+
* account Tripo calls use. Signed out is a result, not an error. App-only:
|
|
4
|
+
* the settings view calls it.
|
|
5
|
+
*/
|
|
6
|
+
import { UeMcpTask, type TaskResult } from "ue-mcp/task";
|
|
7
|
+
export default class AuthStatus extends UeMcpTask<Record<string, never>> {
|
|
8
|
+
get taskName(): string;
|
|
9
|
+
execute(): Promise<TaskResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tripo.auth_status - whether a Tripo API key is set (and from where) and the
|
|
3
|
+
* account Tripo calls use. Signed out is a result, not an error. App-only:
|
|
4
|
+
* the settings view calls it.
|
|
5
|
+
*/
|
|
6
|
+
import { UeMcpTask } from "ue-mcp/task";
|
|
7
|
+
import { authStatus } from "../shared/auth.js";
|
|
8
|
+
export default class AuthStatus extends UeMcpTask {
|
|
9
|
+
get taskName() { return "tripo.auth_status"; }
|
|
10
|
+
async execute() {
|
|
11
|
+
return { success: true, data: { ...(await authStatus(this, this.ctx?.project?.projectDir)) } };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=AuthStatus.js.map
|