meshy-dsh 0.2.1 → 0.3.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/README.md CHANGED
@@ -21,19 +21,23 @@ profile: install into each one you use (`web`, `tui`, `desktop`). Then ask for a
21
21
  low-poly treasure chest and export FBX". The agent checks the CLI, asks you to sign in if needed,
22
22
  shows the cost and waits for your confirmation before it spends credits.
23
23
 
24
- Requires Node.js 22.12 or newer. The agent installs the Meshy CLI (`npm install -g meshy-cli@0.7`)
25
- when it is missing and signs you in with `meshy auth login`; in mainland China it uses
26
- `meshy auth login --region cn`, which signs in at meshy.cn with the same account and keeps later
27
- calls on the China site. dsh removes credential-shaped variables from the agent's shell, so an
28
- exported `MESHY_API_KEY` does not reach the CLI; the browser login does.
24
+ The plugin ships the Meshy CLI and keeps your sign-in itself: dsh runs the agent's shell in a
25
+ sandbox that cannot save a login, so the plugin signs in, refreshes the session on its side and
26
+ hands it to every shell call. Sign in once — from **Settings → Meshy**, or in a chat, where the
27
+ agent shows you a link and a code (the `meshy_sign_in` tool) — and every session, new or old, is
28
+ signed in; nothing is installed or downloaded per session. Choose the China site to sign in at
29
+ meshy.cn with the same account and the same credits, and keep calls there. The sign-in is the CLI's own (encrypted under
30
+ a key your OS keeps), so `meshy` in your terminal shares it. dsh keeps an exported `MESHY_API_KEY`
31
+ out of the agent's shell, and the plugin does not pass it on either.
29
32
 
30
33
  ## Settings page and 3D preview
31
34
 
32
35
  In Web and Desktop, a **Meshy** entry appears in the left sidebar. It opens a Meshy page with your
33
36
  account and a few example requests: pick one and a new session opens with it filled in, ready to
34
37
  edit and send. **Settings → Meshy** (also the plugin's page under **Plugins**) shows the
35
- Meshy CLI version, whether and how you are signed in (browser or API key), which site (meshy.ai
36
- or meshy.cn) and your credits. **Sign in to Meshy** shows the approval link with a QR code for your phone and the code
38
+ Meshy CLI version, whether and how you are signed in (browser or API key), the account, which
39
+ site (meshy.ai or meshy.cn) and your credits. The account (name and email) appears once you sign
40
+ in with this version; the China site does not report it yet. **Sign in to Meshy** shows the approval link with a QR code for your phone and the code
37
41
  to check; the page picks up the approval by itself. Clicking a `.glb` file in the right sidebar, or
38
42
  the card of a model the agent delivers, opens an interactive 3D preview (drag to orbit, scroll to
39
43
  zoom, reset the view or let it turn) with its file size and triangle count. Models up to 256 MB
@@ -45,8 +49,12 @@ neither; the skills work the same everywhere.
45
49
 
46
50
  [`cordis.patch.yml`](cordis.patch.yml) mounts one more instance of dsh's built-in filesystem
47
51
  skill provider over this package's `skills/` directory, so the skills load like any local skill,
48
- and loads the package itself for the settings page: `lib/index.js` serves four authenticated
49
- routes that run the Meshy CLI with fixed arguments, and `lib/client.js` (built from `src/client/`)
52
+ and loads the package itself: `lib/index.js` keeps the sign-in fresh and gives every shell call
53
+ the CLI this package depends on (`DSH_MESHY_NODE`, `DSH_MESHY_CLI`), the session
54
+ (`DSH_MESHY_CREDENTIAL`, `DSH_MESHY_REGION`, `DSH_MESHY_SUBJECT`, never the refresh token) and a
55
+ `.meshy` directory in the session's workspace for the CLI's operation journal
56
+ (`DSH_MESHY_STATE_DIR`); it registers the `meshy_sign_in` tool, and in Web and Desktop serves four
57
+ authenticated routes that run the CLI with fixed arguments. `lib/client.js` (built from `src/client/`)
50
58
  is the browser half, with three.js in a separate `lib/client.viewer.js` loaded on first use. A skill of the same name in
51
59
  your project's `.dsh/skills` or `.agents/skills` takes precedence. `locale/` and `icon.svg` are
52
60
  what dsh's Plugin Manager shows.
package/README.zh.md CHANGED
@@ -14,15 +14,15 @@ dsh plugin --profile web add github:meshy-dev/meshy-dsh
14
14
 
15
15
  装好后,`dsh --profile web --dump-config` 里会出现 `# == meshy-dsh` 一层;在 `dsh web` 的输入框里输入 `/`,能看到 `meshy-3d-generation` 和 `meshy-3d-printing`(装完要新开会话)。插件按 profile 安装,你用哪个 profile(`web`、`tui`、`desktop`)就要往哪个里装。然后直接提需求,比如"做一个低多边形的宝箱,导出 FBX"。agent 会先检查 CLI,需要时引导你登录,说明消耗的积分,等你确认后才开始生成。
16
16
 
17
- 需要 Node.js 22.12 或更新版本。没有 Meshy CLI 时 agent 会自动安装(`npm install -g meshy-cli@0.7`),并用 `meshy auth login` 帮你登录;在中国大陆请用 `meshy auth login --region cn`,在 meshy.cn 登录,账号和国际站相同,之后的调用都会走中国站。dsh 会从 agent 的 shell 里去掉带凭据特征的环境变量,所以你 export 的 `MESHY_API_KEY` 传不到 CLI,请使用浏览器登录。
17
+ 插件自带 Meshy CLI,登录也由插件保管:dsh 让 agent 的 shell 跑在沙箱里,没法保存登录,所以由插件登录、在自己这边刷新登录态,再交给每一次 shell 调用。在**设置 → Meshy** 里登录一次,或者在聊天里由 agent 给你发链接和验证码(`meshy_sign_in` 工具),之后所有会话,不管新开还是已有,都是已登录状态,每个会话也不用再安装或下载任何东西。选中国站会在 meshy.cn 用同一个账号登录,额度也和国际站通用,之后的调用都走中国站。这份登录就是 CLI 自己的登录(用系统保管的密钥加密),所以终端里的 `meshy` 也共用它。dsh 不会把你 export 的 `MESHY_API_KEY` 带进 agent 的 shell,插件也不会转交它。
18
18
 
19
19
  ## 设置页与 3D 预览
20
20
 
21
- 在 Web 和 Desktop 里,左侧栏会出现 **Meshy** 入口,打开后是 Meshy 页面:显示账号,并给出几个示例需求,点一个就会新开会话并填好需求,改一改再发送。**设置 → Meshy**(插件页里也有)会显示 Meshy CLI 版本、是否已登录及登录方式(浏览器或 API key)、所在站点(meshy.ai 或 meshy.cn)和积分。点**登录 Meshy**会显示批准链接、二维码和核对用的验证码,可以用手机扫码批准,页面会自动发现批准完成。在右侧栏点一个 `.glb` 文件,或点 agent 交付的模型卡片,会打开可交互的 3D 预览(拖动旋转,滚轮缩放,可复位视角或自动旋转),并显示文件大小和三角面数。预览会按 2 MB 分块读取模型,所以不受 dsh 整文件预览 32 MB 的上限限制,最大可预览 256 MB。tui 和 headless 没有这些界面,skill 在任何界面都一样能用。
21
+ 在 Web 和 Desktop 里,左侧栏会出现 **Meshy** 入口,打开后是 Meshy 页面:显示账号,并给出几个示例需求,点一个就会新开会话并填好需求,改一改再发送。**设置 → Meshy**(插件页里也有)会显示 Meshy CLI 版本、是否已登录及登录方式(浏览器或 API key)、登录的账号、所在站点(meshy.ai 或 meshy.cn)和积分。账号(名字和邮箱)要用这个版本登录后才会显示,中国站暂时还不提供。点**登录 Meshy**会显示批准链接、二维码和核对用的验证码,可以用手机扫码批准,页面会自动发现批准完成。在右侧栏点一个 `.glb` 文件,或点 agent 交付的模型卡片,会打开可交互的 3D 预览(拖动旋转,滚轮缩放,可复位视角或自动旋转),并显示文件大小和三角面数。预览会按 2 MB 分块读取模型,所以不受 dsh 整文件预览 32 MB 的上限限制,最大可预览 256 MB。tui 和 headless 没有这些界面,skill 在任何界面都一样能用。
22
22
 
23
23
  ## 工作方式
24
24
 
25
- [`cordis.patch.yml`](cordis.patch.yml) 再挂一个 dsh 内置的文件系统 skill provider,只扫描本包的 `skills/` 目录,所以这些 skill 和本地 skill 的加载方式完全一样;同时加载本包自身来提供设置页:`lib/index.js` 提供四个需要鉴权的接口,用固定参数调用 Meshy CLI;`lib/client.js`(由 `src/client/` 构建)是浏览器端,three.js 单独放在首次使用时才加载的 `lib/client.viewer.js` 里。项目里 `.dsh/skills` 或 `.agents/skills` 下的同名 skill 优先。`locale/` 和 `icon.svg` 是 dsh 插件管理页显示的名称、简介和图标。
25
+ [`cordis.patch.yml`](cordis.patch.yml) 再挂一个 dsh 内置的文件系统 skill provider,只扫描本包的 `skills/` 目录,所以这些 skill 和本地 skill 的加载方式完全一样;同时加载本包自身:`lib/index.js` 负责刷新登录态,并给每次 shell 调用提供本包依赖的 CLI(`DSH_MESHY_NODE`、`DSH_MESHY_CLI`)、登录态(`DSH_MESHY_CREDENTIAL`、`DSH_MESHY_REGION`、`DSH_MESHY_SUBJECT`,从不包含 refresh token),以及会话 workspace 里给 CLI 操作日志用的 `.meshy` 目录(`DSH_MESHY_STATE_DIR`);它还注册 `meshy_sign_in` 工具,并在 Web 和 Desktop 里提供四个需要鉴权的接口,用固定参数调用 Meshy CLI;`lib/client.js`(由 `src/client/` 构建)是浏览器端,three.js 单独放在首次使用时才加载的 `lib/client.viewer.js` 里。项目里 `.dsh/skills` 或 `.agents/skills` 下的同名 skill 优先。`locale/` 和 `icon.svg` 是 dsh 插件管理页显示的名称、简介和图标。
26
26
 
27
27
  `skills/` 是 [meshy-3d-agent](https://github.com/meshy-dev/meshy-3d-agent) 里 CLI skill 的副本;那个仓库负责维护,也服务其他所有 agent 宿主。修改请提到那边。
28
28
 
package/lib/client.js CHANGED
@@ -2616,6 +2616,7 @@ const en = {
2616
2616
  site: "Site",
2617
2617
  "site.global": "Global",
2618
2618
  "site.cn": "China",
2619
+ account: "Account",
2619
2620
  credits: "Credits",
2620
2621
  "credits.get": "Get credits",
2621
2622
  method: "Signed in with",
@@ -2639,9 +2640,8 @@ const en = {
2639
2640
  "signOut.body": "The Meshy skills in DeepSeek Harness will ask you to sign in again before they generate.",
2640
2641
  close: "Close",
2641
2642
  cli: "Meshy CLI {version}",
2642
- "cli.temporary": "run through npm exec",
2643
2643
  "error.cli": "Meshy CLI not found",
2644
- "error.cliHint": "Install Node.js 22.12 or newer, then run this and refresh:",
2644
+ "error.cliHint": "Reinstall the Meshy plugin under Plugins, then refresh.",
2645
2645
  "error.expired": "The code expired. Start again for a new one.",
2646
2646
  "error.generic": "Something went wrong: {message}",
2647
2647
  "viewer.title": "3D model",
@@ -2681,6 +2681,7 @@ const zh = {
2681
2681
  site: "站点",
2682
2682
  "site.global": "国际站",
2683
2683
  "site.cn": "中国站",
2684
+ account: "账号",
2684
2685
  credits: "积分",
2685
2686
  "credits.get": "获取积分",
2686
2687
  method: "登录方式",
@@ -2704,9 +2705,8 @@ const zh = {
2704
2705
  "signOut.body": "退出后,DeepSeek Harness 里的 Meshy 技能在生成前会要求你重新登录。",
2705
2706
  close: "关闭",
2706
2707
  cli: "Meshy CLI {version}",
2707
- "cli.temporary": "通过 npm exec 运行",
2708
2708
  "error.cli": "找不到 Meshy CLI",
2709
- "error.cliHint": "请安装 Node.js 22.12 或更新版本,运行下面的命令后刷新:",
2709
+ "error.cliHint": "请在「插件」中重新安装 Meshy 插件,然后刷新。",
2710
2710
  "error.expired": "验证码已过期,请重新开始。",
2711
2711
  "error.generic": "出错了:{message}",
2712
2712
  "viewer.title": "3D 模型",
@@ -2754,6 +2754,7 @@ body[data-ds-dark-theme] .meshy-root{--meshy-accent:#c5f955;--meshy-accent-hover
2754
2754
  .meshy-divider{border-top:.5px solid var(--dsw-alias-border-l2)}
2755
2755
  .meshy-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:10px}
2756
2756
  .meshy-amount{display:inline-flex;align-items:center;gap:8px;font-size:18px;font-weight:510;line-height:28px}
2757
+ .meshy-account{display:flex;flex-direction:column;align-items:flex-end;min-width:0;text-align:right;overflow-wrap:anywhere}
2757
2758
  .meshy-coin{width:12px;height:12px;border-radius:50%;background:linear-gradient(135deg,#f9e855,#e99430)}
2758
2759
  .meshy-link{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;text-decoration:none;white-space:nowrap}
2759
2760
  .meshy-link:hover{background:var(--dsw-alias-interactive-bg-hover)}
@@ -3047,15 +3048,25 @@ function MeshyPanel({ t, view }) {
3047
3048
  onClick: signIn,
3048
3049
  children: t("retry")
3049
3050
  }) : void 0,
3050
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: problemText }), problem.kind === "cli" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3051
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: problemText }), problem.kind === "cli" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3051
3052
  className: "meshy-muted meshy-small",
3052
3053
  children: t("error.cliHint")
3053
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "npm install -g meshy-cli@0.7" })] })]
3054
+ })]
3054
3055
  }),
3055
3056
  status.cli && signedIn && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3056
3057
  className: "meshy-card meshy-rows",
3057
3058
  children: [
3058
3059
  !auth.verified && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Alert, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("unverified.hint") }) }),
3060
+ auth.account && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3061
+ className: "meshy-row",
3062
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("account") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3063
+ className: "meshy-account",
3064
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: auth.account.name ?? auth.account.email }), auth.account.name && auth.account.email && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3065
+ className: "meshy-muted meshy-small",
3066
+ children: auth.account.email
3067
+ })]
3068
+ })]
3069
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" })] }),
3059
3070
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3060
3071
  className: "meshy-row",
3061
3072
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("credits") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -3202,7 +3213,7 @@ function MeshyPanel({ t, view }) {
3202
3213
  }),
3203
3214
  status.cli && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3204
3215
  className: "meshy-foot meshy-muted meshy-small",
3205
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [t("cli", { version: status.cli.version }), status.cli.runner === "npm exec" ? ` · ${t("cli.temporary")}` : ""] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3216
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("cli", { version: status.cli.version }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3206
3217
  label: t("refresh"),
3207
3218
  side: "top",
3208
3219
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
@@ -3500,6 +3511,7 @@ function GlbBody({ content, resourceAddress, t }) {
3500
3511
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3501
3512
  label: t("viewer.reset"),
3502
3513
  side: "top",
3514
+ portal: true,
3503
3515
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3504
3516
  variant: "ghost",
3505
3517
  size: "sm",
@@ -3510,6 +3522,7 @@ function GlbBody({ content, resourceAddress, t }) {
3510
3522
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3511
3523
  label: spinning ? t("viewer.stop") : t("viewer.spin"),
3512
3524
  side: "top",
3525
+ portal: true,
3513
3526
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3514
3527
  variant: "ghost",
3515
3528
  size: "sm",
package/lib/index.js CHANGED
@@ -1,29 +1,40 @@
1
- // Host half of the Meshy settings page. In Web and Desktop it serves four authenticated routes
2
- // under /api that run the Meshy CLI with fixed arguments; in tui and headless, where there is
3
- // no `connection` service, it does nothing. The skills never call these routes.
1
+ // Host half of the plugin. It owns the Meshy sign-in: dsh runs model shell calls in a sandbox
2
+ // that cannot write the CLI's credential store, and a refresh that cannot be saved spends the
3
+ // login, so the host signs in, keeps the session fresh and hands every shell call a current
4
+ // credential (DSH_MESHY_*), together with the CLI this package ships, so no session installs
5
+ // one. It also registers `meshy_sign_in` for chats where no settings page is at hand, and, in
6
+ // Web and Desktop, four authenticated routes under /api for the settings page. Every CLI call
7
+ // uses fixed arguments.
4
8
  import { spawn } from 'node:child_process'
9
+ import { watch } from 'node:fs'
10
+ import { createRequire } from 'node:module'
11
+ import { basename, dirname, join } from 'node:path'
5
12
 
6
13
  export const name = 'meshy-dsh'
7
14
 
8
- const WIN = process.platform === 'win32'
9
- const MESHY = WIN ? 'meshy.cmd' : 'meshy'
10
- const NPM = WIN ? 'npm.cmd' : 'npm'
11
- // 0.7.3 is the first CLI whose --no-wait output leaves the device code out. Exact, because
12
- // npm exec keeps reusing whichever matching version it cached first.
13
- const TEMPORARY = ['exec', '--yes', '--package=meshy-cli@0.7.3', '--', 'meshy']
15
+ // The CLI this package depends on, run with the host's own Node. Desktop runs the host inside the
16
+ // Electron app binary, which ELECTRON_RUN_AS_NODE turns into a plain Node (as dsh's own `node`
17
+ // shim does); a shell call cannot set that variable, so there it gets `node` from PATH.
18
+ // MESHY_DSH_CLI is a test hook.
19
+ const cli = () => process.env.MESHY_DSH_CLI || createRequire(import.meta.url).resolve('meshy-cli')
20
+ const ELECTRON = Boolean(process.versions.electron)
21
+ const NODE = ELECTRON ? 'node' : process.execPath
14
22
  const JSON_FLAGS = ['--format', 'json', '--no-update-check']
23
+ // The CLI refreshes a token with under 30 minutes left; reading it this often keeps every
24
+ // credential handed to a shell good for at least 25 minutes.
25
+ const SESSION_REFRESH_MS = 5 * 60_000
15
26
  const MAX_OUTPUT = 1 << 20
16
27
  const FLOW_ID = /^[A-Za-z0-9_-]{16,64}$/
17
28
  const REGIONS = new Set(['global', 'cn'])
18
29
 
19
30
  /**
20
- * Run one command with fixed argv (no shell outside Windows, where .cmd shims need one; every
21
- * argument is a constant or validated), capped output and a deadline.
31
+ * Run one command with fixed argv (no shell; every argument is a constant or validated), capped
32
+ * output and a deadline.
22
33
  * @returns {Promise<{ code: number | null, stdout: string, timedOut: boolean }>}
23
34
  */
24
- export function run(cmd, args, timeoutMs) {
35
+ export function run(cmd, args, timeoutMs, env = process.env) {
25
36
  return new Promise((resolve, reject) => {
26
- const child = spawn(cmd, args, { shell: WIN, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })
37
+ const child = spawn(cmd, args, { env, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })
27
38
  let stdout = ''
28
39
  let timedOut = false
29
40
  const timer = setTimeout(() => { timedOut = true; child.kill() }, timeoutMs)
@@ -35,23 +46,176 @@ export function run(cmd, args, timeoutMs) {
35
46
  })
36
47
  }
37
48
 
38
- /** `meshy` from PATH when it is 0.7.3 or a later 0.7.x, else the temporary package. */
39
- async function runner() {
40
- const probe = await run(MESHY, ['--version'], 10_000).catch(() => undefined)
41
- const patch = /^0\.7\.(\d+)$/.exec(probe?.stdout.trim() ?? '')?.[1]
42
- return patch !== undefined && Number(patch) >= 3 ? [MESHY, []] : [NPM, TEMPORARY]
49
+ /**
50
+ * The host's environment without what would stand in for the stored login: dsh keeps an
51
+ * exported MESHY_API_KEY out of shell calls on purpose, so the host does not pass one on either,
52
+ * and a dsh started from a dsh shell must not read back the credential it was handed.
53
+ */
54
+ function hostEnv() {
55
+ const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => {
56
+ const key = k.toUpperCase()
57
+ return key !== 'MESHY_API_KEY' && !key.startsWith('DSH_MESHY_')
58
+ }))
59
+ if (ELECTRON) env.ELECTRON_RUN_AS_NODE = '1'
60
+ return env
43
61
  }
44
62
 
45
63
  async function meshy(args, timeoutMs = 60_000) {
46
- const [cmd, prefix] = await runner()
47
- const out = await run(cmd, [...prefix, ...args, ...JSON_FLAGS], timeoutMs)
64
+ const out = await run(process.execPath, [cli(), ...args, ...JSON_FLAGS], timeoutMs, hostEnv())
48
65
  let envelope
49
66
  try {
50
67
  envelope = JSON.parse(out.stdout)
51
68
  } catch {
52
69
  envelope = { ok: false, error: { message: out.timedOut ? 'timed out' : 'the Meshy CLI printed no result' } }
53
70
  }
54
- return { ...envelope, timedOut: out.timedOut, runner: prefix.length ? 'npm exec' : 'meshy' }
71
+ return { ...envelope, timedOut: out.timedOut }
72
+ }
73
+
74
+ const regionOf = (baseUrl) => typeof baseUrl === 'string' && baseUrl.includes('meshy.cn') ? 'cn' : 'global'
75
+
76
+ /** The signed-in session handed to shells, or null while signed out. Never sent to a page. */
77
+ let session = null
78
+ let reading = null
79
+ let watcher = null
80
+ let watchedFile = null
81
+
82
+ /**
83
+ * Re-read the session as soon as the credentials file changes. A refresh by any other process (a
84
+ * terminal, another agent) ends the access token this host holds, so waiting for the next timer
85
+ * tick would hand shells a rejected token in the meantime.
86
+ */
87
+ function watchStore(file) {
88
+ if (typeof file !== 'string' || !file || file === watchedFile) return
89
+ stopWatching()
90
+ try {
91
+ watcher = watch(dirname(file), { persistent: false }, (_event, name) => {
92
+ if (name === null || String(name) === basename(file)) void refreshSession()
93
+ })
94
+ watcher.on('error', stopWatching)
95
+ watchedFile = file
96
+ } catch {
97
+ // The directory does not exist yet (never signed in); the next read tries again.
98
+ }
99
+ }
100
+
101
+ function stopWatching() {
102
+ watcher?.close()
103
+ watcher = null
104
+ watchedFile = null
105
+ }
106
+
107
+ /**
108
+ * Re-read the session. `auth status --offline` refreshes the token here, where the store is
109
+ * writable, once it has under 30 minutes left; it makes no other network call.
110
+ */
111
+ export function refreshSession() {
112
+ reading ??= meshy(['auth', 'status', '--offline', '--show-token'])
113
+ .then((out) => {
114
+ const r = out.result ?? {}
115
+ watchStore(r.credentials_file)
116
+ session = out.ok && r.authenticated === true && typeof r.token === 'string' && r.token
117
+ ? {
118
+ token: r.token,
119
+ subject: typeof r.subject === 'string' ? r.subject : '',
120
+ region: regionOf(r.base_url_v1),
121
+ expiresAt: typeof r.expires_at === 'number' ? r.expires_at : null,
122
+ }
123
+ : null
124
+ })
125
+ .catch(() => {})
126
+ .finally(() => { reading = null })
127
+ return reading
128
+ }
129
+
130
+ const SHELL_VARIABLES = {
131
+ DSH_MESHY_NODE: { description: 'Node.js that runs the Meshy CLI: "$DSH_MESHY_NODE" "$DSH_MESHY_CLI" <command>.' },
132
+ DSH_MESHY_CLI: { description: 'The Meshy CLI this plugin ships (a JavaScript file run with DSH_MESHY_NODE).' },
133
+ DSH_MESHY_CREDENTIAL: { description: 'The Meshy sign-in, kept fresh by the plugin; the CLI reads it. Never print it.' },
134
+ DSH_MESHY_REGION: { description: 'The Meshy site of that sign-in: global or cn.' },
135
+ DSH_MESHY_SUBJECT: { description: 'The Meshy account the CLI binds its operation journal to.' },
136
+ DSH_MESHY_STATE_DIR: { description: "Where the Meshy CLI keeps its operation journal: .meshy in the session's workspace." },
137
+ }
138
+
139
+ /** What one shell call gets: the CLI, the session while signed in, and a writable journal. */
140
+ export function shellFacts(execution) {
141
+ const facts = { DSH_MESHY_NODE: NODE, DSH_MESHY_CLI: cli() }
142
+ const cwd = execution?.agent?.session?.header?.cwd
143
+ if (typeof cwd === 'string' && cwd) facts.DSH_MESHY_STATE_DIR = join(cwd, '.meshy')
144
+ if (session) {
145
+ // After a sleep the timer may not have run yet: refresh now, and leave out a token that
146
+ // would be rejected (the CLI then explains, and the next call has the fresh one).
147
+ const left = session.expiresAt === null ? Infinity : session.expiresAt - Date.now()
148
+ if (left < 60_000) void refreshSession()
149
+ if (left > 0) {
150
+ facts.DSH_MESHY_CREDENTIAL = session.token
151
+ facts.DSH_MESHY_REGION = session.region
152
+ if (session.subject) facts.DSH_MESHY_SUBJECT = session.subject
153
+ }
154
+ }
155
+ return facts
156
+ }
157
+
158
+ let signingIn = null
159
+
160
+ /**
161
+ * Start a browser sign-in on the host and finish it in the background: the CLI polls until the
162
+ * user approves or the code expires, and the session is re-read when it lands. A second call
163
+ * while one is waiting returns the same link and code.
164
+ */
165
+ export async function signIn(region) {
166
+ if (signingIn?.region === region) return signingIn.view
167
+ const started = await meshy(['auth', 'login', '--device', '--no-wait', '--region', region])
168
+ const r = started.result ?? {}
169
+ if (!started.ok || typeof r.verification_url !== 'string' || !r.verification_url.startsWith('https://') || !FLOW_ID.test(r.flow_id ?? '')) {
170
+ throw new Error(started.error?.message ?? 'the Meshy CLI could not start a sign-in')
171
+ }
172
+ const expiresIn = typeof r.expires_in === 'number' ? r.expires_in : 600
173
+ // Only what the user needs: an older CLI also prints the device code, a bearer secret.
174
+ const view = { status: 'waiting_for_approval', verification_url: r.verification_url, user_code: String(r.user_code ?? ''), expires_in: expiresIn }
175
+ const attempt = { region, view }
176
+ signingIn = attempt
177
+ meshy(['auth', 'login', `--device-flow=${r.flow_id}`], expiresIn * 1000 + 30_000)
178
+ .then((done) => done.ok ? refreshSession() : undefined)
179
+ .catch(() => {})
180
+ .finally(() => { if (signingIn === attempt) signingIn = null })
181
+ return view
182
+ }
183
+
184
+ const SIGN_IN_TOOL = {
185
+ name: 'meshy_sign_in',
186
+ description:
187
+ 'Sign the user in to Meshy, and how to run Meshy here. In DeepSeek Harness the Meshy plugin ships ' +
188
+ 'the Meshy CLI and keeps the sign-in: run every Meshy command as "$DSH_MESHY_NODE" "$DSH_MESHY_CLI" ' +
189
+ '<command> (PowerShell: & $env:DSH_MESHY_NODE $env:DSH_MESHY_CLI <command>), never a `meshy` found ' +
190
+ 'on PATH, which cannot see this sign-in, and install nothing. Call this tool only when such a ' +
191
+ 'command reports that nobody is signed in or the session was rejected; never run `auth login` in ' +
192
+ 'the shell, which cannot store a login. It returns a link and a code: show both to the user, wait ' +
193
+ 'until they say they approved it, then retry the command. Use region "cn" only when the user signs ' +
194
+ 'in on the China site (meshy.cn).',
195
+ parameters: {
196
+ type: 'object',
197
+ properties: { region: { type: 'string', enum: ['global', 'cn'], description: 'Meshy site; default global.' } },
198
+ additionalProperties: false,
199
+ },
200
+ output: {
201
+ schema: {
202
+ type: 'object',
203
+ properties: {
204
+ status: { type: 'string' },
205
+ verification_url: { type: 'string' },
206
+ user_code: { type: 'string' },
207
+ expires_in: { type: 'integer' },
208
+ },
209
+ required: ['status', 'verification_url', 'user_code', 'expires_in'],
210
+ additionalProperties: false,
211
+ },
212
+ render: (_args, v) => [{ type: 'text', text: `Open ${v.verification_url} and confirm code ${v.user_code} (valid ${Math.round(v.expires_in / 60)} minutes).` }],
213
+ },
214
+ async execute(args) {
215
+ const region = args?.region ?? 'global'
216
+ if (!REGIONS.has(region)) throw new Error('meshy_sign_in: region must be global or cn')
217
+ return signIn(region)
218
+ },
55
219
  }
56
220
 
57
221
  const json = (body, status = 200) => Response.json(body, { status, headers: { 'cache-control': 'no-store' } })
@@ -67,19 +231,22 @@ async function body(request) {
67
231
  }
68
232
 
69
233
  export async function status() {
70
- const [cmd, prefix] = await runner()
71
- const version = await run(cmd, [...prefix, '--version'], 120_000).catch(() => undefined)
72
- if (!version || version.code !== 0) return json({ cli: null, error: 'Meshy CLI not found: Node.js 22.12+ with npm is needed' })
234
+ const version = await run(process.execPath, [cli(), '--version'], 30_000, hostEnv()).catch(() => undefined)
235
+ if (!version || version.code !== 0) return json({ cli: null, error: 'Meshy CLI not found: reinstall the Meshy plugin' })
73
236
  const auth = await meshy(['auth', 'status'])
74
237
  const r = auth.result ?? {}
238
+ const text = (v) => typeof v === 'string' && v ? v : null
75
239
  return json({
76
- cli: { version: version.stdout.trim(), runner: prefix.length ? 'npm exec' : 'meshy' },
240
+ cli: { version: version.stdout.trim() },
77
241
  auth: {
78
242
  authenticated: r.authenticated === true,
79
243
  verified: r.verified === true,
80
244
  // How it signed in, never the credential: an OAuth access token starts msy_at_.
81
245
  method: r.authenticated !== true ? null : String(r.credential ?? '').startsWith('msy_at_') ? 'browser' : 'apiKey',
82
- region: typeof r.base_url_v1 === 'string' && r.base_url_v1.includes('meshy.cn') ? 'cn' : 'global',
246
+ // Who signed in, when the site reports it (not for an API key, a login before CLI 0.8, or
247
+ // the China site yet).
248
+ account: r.account && (text(r.account.name) || text(r.account.email)) ? { name: text(r.account.name), email: text(r.account.email) } : null,
249
+ region: regionOf(r.base_url_v1),
83
250
  balance: typeof r.balance?.balance === 'number' ? r.balance.balance : null,
84
251
  hint: r.hint ?? null,
85
252
  },
@@ -104,11 +271,13 @@ export async function loginFinish(request) {
104
271
  const done = await meshy(['auth', 'login', `--device-flow=${input.flow_id}`], 60_000)
105
272
  if (done.timedOut) return json({ status: 'pending' }, 202)
106
273
  if (!done.ok) return failure(done)
274
+ await refreshSession()
107
275
  return json({ status: done.result?.status ?? 'logged_in' })
108
276
  }
109
277
 
110
278
  export async function logout() {
111
279
  const out = await meshy(['auth', 'logout'])
280
+ await refreshSession()
112
281
  return out.ok ? json({ status: 'logged_out' }) : failure(out)
113
282
  }
114
283
 
@@ -120,6 +289,21 @@ const ROUTES = [
120
289
  ]
121
290
 
122
291
  export function apply(ctx) {
292
+ ctx.effect(() => {
293
+ void refreshSession()
294
+ const timer = setInterval(refreshSession, SESSION_REFRESH_MS)
295
+ timer.unref?.()
296
+ return () => {
297
+ clearInterval(timer)
298
+ stopWatching()
299
+ }
300
+ }, 'meshy-dsh: session refresh')
301
+ ctx.inject(['shellEnv'], (ctx) => {
302
+ ctx.shellEnv.register({ name: 'meshy', variables: SHELL_VARIABLES, resolve: shellFacts })
303
+ })
304
+ ctx.inject(['tools'], (ctx) => {
305
+ ctx.tools.register(SIGN_IN_TOOL)
306
+ })
123
307
  ctx.inject(['connection'], (ctx) => {
124
308
  for (const [path, method, handle] of ROUTES) {
125
309
  ctx.effect(() => ctx.connection.fetch.register({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meshy-dsh",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Meshy skills for DeepSeek Harness: textured, rigged and animated 3D models or print-ready files from text or images, through meshy-cli, with a Meshy settings page and a 3D preview for GLB files.",
5
5
  "keywords": [
6
6
  "dsh-plugin",
@@ -49,7 +49,7 @@
49
49
  "smoke": "node scripts/smoke.mjs"
50
50
  },
51
51
  "meshy": {
52
- "skills": "meshy-dev/meshy-3d-agent#v0.8.1"
52
+ "skills": "meshy-dev/meshy-3d-agent#v0.9.0"
53
53
  },
54
54
  "dsh": {
55
55
  "bundle": {
@@ -63,5 +63,8 @@
63
63
  "qrcode-generator": "^2.0.4",
64
64
  "three": "^0.187.0",
65
65
  "tsdown": "^0.23.4"
66
+ },
67
+ "dependencies": {
68
+ "meshy-cli": "0.8.1"
66
69
  }
67
70
  }
@@ -2,12 +2,12 @@
2
2
  name: meshy-3d-generation
3
3
  description: "Generates and edits digital 3D assets with the Meshy CLI: text-to-3D and image-to-3D models, texturing, remeshing and LODs, UV unwrapping, format conversion (GLB, FBX, OBJ, USDZ, STL, 3MF, Blender), rigging, animation, motion clips from text and reference images. Use when the user asks to make, texture, rig, animate or convert a 3D model or game asset. For physical 3D printing use meshy-3d-printing."
4
4
  license: MIT
5
- compatibility: "Needs Node.js 22.12+ and the Meshy CLI 0.7.x, 0.7.3 or later (npm install -g meshy-cli@0.7); network access to the Meshy API."
5
+ compatibility: "Needs Node.js 22.12+ and the Meshy CLI 0.8.x, 0.8.0 or later (npm install -g meshy-cli@0.8); network access to the Meshy API."
6
6
  ---
7
7
 
8
8
  # Meshy 3D Generation
9
9
 
10
- Use Meshy CLI **0.7** (0.7.3 or later) to turn the user's request into a delivered asset. Completion means
10
+ Use Meshy CLI **0.8** (0.8.0 or later) to turn the user's request into a delivered asset. Completion means
11
11
  saving the requested files in the requested location, inspecting an available preview, and
12
12
  finishing any project integration the user requested. Login or task submission alone is not
13
13
  completion. Choose the shortest suitable pipeline and reuse existing assets for follow-ups.
@@ -28,11 +28,17 @@ existing GLB needs no extra format conversion. Use command help when parameters
28
28
 
29
29
  ## First use and authorization
30
30
 
31
+ **DeepSeek Harness with the Meshy plugin** (`DSH_MESHY_CLI` is set; check with
32
+ `test -n "$DSH_MESHY_CLI"`): the plugin ships the CLI and keeps the sign-in. Run every command as
33
+ `"$DSH_MESHY_NODE" "$DSH_MESHY_CLI" …` in place of `meshy …` — never a `meshy` on PATH, which
34
+ cannot see that sign-in — install nothing, and when a command reports that nobody is signed in,
35
+ call the `meshy_sign_in` tool instead of `auth login` (Setup, section 1). Everywhere else:
36
+
31
37
  Before the first command run `meshy --version`; no need to ask. When `meshy` is missing or
32
- older than 0.7.3, install the newest 0.7.x with `npm install -g meshy-cli@0.7` and say so in
33
- one line; Setup covers a refused install and a CLI of 0.8 or newer. Reuse a verified session. If login is
38
+ older than 0.8.0, install the newest 0.8.x with `npm install -g meshy-cli@0.8` and say so in
39
+ one line; Setup covers a refused install and a CLI of 0.9 or newer. Reuse a verified session. If login is
34
40
  needed, follow Setup and run `auth login --device` (adding `--region cn` for a user in mainland
35
- China) in a persistent tool session. Show its
41
+ China: the same account and the same credits as the global site) in a persistent tool session. Show its
36
42
  verification URL and user code in **commentary/progress, not a final answer**. Await that same
37
43
  session in this turn until it exits, verify `auth status`, then continue the original request.
38
44
  A background process cannot resume a finished turn; do not require a "done" chat message, except in
@@ -1,4 +1,4 @@
1
- # Digital asset pipelines — CLI 0.7
1
+ # Digital asset pipelines — CLI 0.8
2
2
 
3
3
  Contents: route choice; shared lifecycle; text/image models; texture/topology/size; 2D images;
4
4
  downloads and recovery. Rigging, animation and generated motion are in [animation](animation.md);
@@ -2,7 +2,7 @@
2
2
 
3
3
  Shared by the generation and print workflows. Three things are settled before any job
4
4
  starts: **how to run the CLI**, **whether a session already exists**, and **where files go**.
5
- The supported CLI is **0.7.x, from 0.7.3,** on **Node.js 22.12 or newer**. No Python, request wrapper or
5
+ The supported CLI is **0.8.x, from 0.8.0,** on **Node.js 22.12 or newer**. No Python, request wrapper or
6
6
  separate token store is involved.
7
7
 
8
8
  Contents: 1 runner · 2 reuse a session · 3 first login · 4 where files go · 5 one session
@@ -10,6 +10,22 @@ everywhere · 6 API keys · 7 the China site.
10
10
 
11
11
  ## 1. Resolve the runner
12
12
 
13
+ In DeepSeek Harness with the Meshy plugin the plugin ships the CLI and holds the sign-in. Check
14
+ for it first:
15
+
16
+ ```bash
17
+ test -n "$DSH_MESHY_CLI" && echo meshy-dsh
18
+ ```
19
+
20
+ When that prints `meshy-dsh`, run every recipe as `"$DSH_MESHY_NODE" "$DSH_MESHY_CLI" …` in
21
+ place of `meshy …` (PowerShell: `& $env:DSH_MESHY_NODE $env:DSH_MESHY_CLI …`), keep both paths
22
+ quoted, install nothing, and go on to section 2. The shell there cannot store a login, so never
23
+ run `auth login`, set `MESHY_CONFIG_DIR` or copy a credential file in it: when `auth status`
24
+ reports no usable credential, or a command reports a rejected session, call the
25
+ `meshy_sign_in` tool (`region: "cn"` for the China site), show the user its link and code, and
26
+ retry once they say they approved; or ask them to sign in from Settings → Meshy. Everywhere
27
+ else:
28
+
13
29
  ```bash
14
30
  node --version
15
31
  meshy --version
@@ -17,25 +33,25 @@ meshy --version
17
33
 
18
34
  | Observation | What to do |
19
35
  |---|---|
20
- | `meshy --version` prints 0.7.3 or a later 0.7.x | run `meshy` |
21
- | no `meshy` command, or a version older than 0.7.3 | install the newest 0.7.x (below), then run `meshy` |
22
- | 0.8 or newer | keep it, since something else may rely on it, and run the temporary package |
36
+ | `meshy --version` prints 0.8.0 or a later 0.8.x | run `meshy` |
37
+ | no `meshy` command, or a version older than 0.8.0 | install the newest 0.8.x (below), then run `meshy` |
38
+ | 0.9 or newer | keep it, since something else may rely on it, and run the temporary package |
23
39
  | no Node.js, or Node older than 22.12 | stop and report it: the user installs Node.js 22.12+ |
24
40
 
25
41
  ```bash
26
- npm install -g meshy-cli@0.7
42
+ npm install -g meshy-cli@0.8
27
43
  ```
28
44
 
29
45
  Check and install without asking first; say in one line that you are installing it. Install at
30
- most once: when `meshy --version` still reports a version older than 0.7.3 afterwards, the
46
+ most once: when `meshy --version` still reports a version older than 0.8.0 afterwards, the
31
47
  registry this machine uses lags npm, so report that instead of installing again. Never use `sudo`
32
48
  or change system policy: when the install is refused (permissions, a managed machine, a sandbox), use the temporary package
33
49
  instead. It runs the same CLI without installing anything: put `npm exec --yes
34
- --package=meshy-cli@0.7.3 --` in front of the same arguments, and the exit code and the JSON on
50
+ --package=meshy-cli@0.8.0 --` in front of the same arguments, and the exit code and the JSON on
35
51
  stdout are forwarded unchanged. Recipes are written as `meshy …`; example:
36
52
 
37
53
  ```bash
38
- npm exec --yes --package=meshy-cli@0.7.3 -- meshy auth status --format json --no-update-check
54
+ npm exec --yes --package=meshy-cli@0.8.0 -- meshy auth status --format json --no-update-check
39
55
  ```
40
56
 
41
57
  The first such call downloads the package into the npm cache; later calls reuse it. It names an
@@ -55,12 +71,15 @@ Every command, auth included, prints one `meshy.cli/v1` envelope on stdout (`ok`
55
71
  the unauthenticated and unverified answers below are `ok: true` with exit 3.
56
72
 
57
73
  - `authenticated: true`, `verified: true`, exit 0: continue with this account. **No new login.**
74
+ `result.account` names who is signed in when the site reports it (`null` for an API key, a
75
+ login made before CLI 0.8, and the China site for now).
58
76
  - `authenticated: false`, exit 3: no usable credential; log in (next section).
59
77
  - `authenticated: true`, `verified: false`, exit 3: a credential exists but verification failed —
60
78
  which includes network and server errors, not just rejection. Do not start a login or delete
61
79
  credentials; see [troubleshooting.md](troubleshooting.md).
62
80
 
63
- `auth status --offline` skips the balance call but can still refresh OAuth over the network.
81
+ `auth status --offline` skips the balance and account calls but can still refresh OAuth over the
82
+ network.
64
83
  Use local `doctor` for a diagnostic that must avoid the network entirely.
65
84
 
66
85
  ## 3. First login: one browser approval, then resume the original request
@@ -165,9 +184,9 @@ meshy auth login --device-flow FLOW_ID --format json --no-update-check
165
184
 
166
185
  It waits while the approval is still pending, saves the session and prints
167
186
  `result.status: "logged_in"`; verify `auth status` and continue the original request. An expired
168
- or unknown flow means running step one again. A host whose question tool reaches the user
169
- (dsh's `ask_user_question` is forwarded by its chat bridges) can instead ask with the link and
170
- wait for the answer in the same turn, then run step two.
187
+ or unknown flow means running step one again. A host whose question tool reaches the user can
188
+ instead ask with the link and wait for the answer in the same turn, then run step two. In
189
+ DeepSeek Harness the `meshy_sign_in` tool replaces both steps (section 1).
171
190
 
172
191
  Do not use `--manual` from an agent — it prompts on stdin for a pasted code. Never show a token, a device
173
192
  code or a signed URL to the user or copy one into chat or a file: task results and sidecars
@@ -206,31 +225,37 @@ to delete.
206
225
 
207
226
  ## 5. One session, both skills, any directory
208
227
 
209
- The default store is `~/.config/meshy/credentials.json` (mode 0600). Generation and printing,
210
- in either plugin, reuse it when run as the same OS user with the same CLI configuration.
211
- Changing the working directory does not require another login. Different users, machines,
212
- containers or configuration directories do not automatically share sessions.
228
+ The default store is `~/.config/meshy/credentials.v2.json` (mode 0600); the key or tokens in it
229
+ are encrypted under a key the OS keeps (Keychain, DPAPI or the Secret Service; a `master.key`
230
+ file where none is usable). Generation and printing, in either plugin, reuse it when run as the
231
+ same OS user with the same CLI configuration. Changing the working directory does not require
232
+ another login. Different users, machines, containers or configuration directories do not
233
+ automatically share sessions. A CLI before 0.8 kept `credentials.json` instead; 0.8 moves that
234
+ login over on its first write, and an older CLI then signs in once on its own.
213
235
 
214
236
  `MESHY_CONFIG_DIR` changes the config directory; `MESHY_CREDENTIALS_PATH` overrides the
215
- credential file. Non-production API hosts use `credentials.dev.json` by default. Keep these
237
+ credential file. Non-production API hosts use `credentials.v2.dev.json` by default. Keep these
216
238
  settings consistent; do not copy tokens between plugins or read the credential file.
217
239
  `auth list` reports profile kinds with masked credentials. `auth use <name>` changes the shared
218
240
  active profile, so do not switch it independently in concurrent workflows.
219
241
 
220
- The CLI refreshes stored OAuth tokens near expiry on its own.
242
+ The CLI refreshes stored OAuth tokens near expiry on its own. Where it cannot write the store (a
243
+ sandboxed shell) it leaves the login alone instead: a still-valid token keeps working, and an
244
+ expired one is exit 3 saying the directory is not writable — run the command outside the sandbox
245
+ rather than signing in again inside it.
221
246
 
222
247
  ## 6. Existing API keys remain supported
223
248
 
224
- Credential priority is `--api-key` > `MESHY_API_KEY` > explicit `--api-key-file` > stored
225
- active profile. An existing environment key overrides browser login; report `source` when
249
+ Credential priority is `--api-key` > `MESHY_API_KEY` > explicit `--api-key-file` > the DeepSeek
250
+ Harness plugin's session > stored active profile. An existing environment key overrides browser login; report `source` when
226
251
  diagnosing account selection, and do not change the user's environment or account implicitly.
227
252
 
228
253
  DeepSeek Harness (`DSH_SHELL=1`) removes credential-shaped variables such as `MESHY_API_KEY`
229
254
  from every shell call, so a key the user exported before starting dsh never reaches the CLI.
230
- There, use the stored browser login (`meshy auth login`) or an explicit `--api-key-file`.
255
+ There the Meshy plugin's sign-in is used (section 1), or an explicit `--api-key-file`.
231
256
 
232
257
  There is no automatic `.env` discovery. If the user chooses a project key file, pass its
233
- explicit path on authenticated commands. In 0.7 **`auth status` ignores `--api-key-file`**,
258
+ explicit path on authenticated commands. **`auth status` ignores `--api-key-file`**,
234
259
  so verify that branch with a free balance call instead:
235
260
 
236
261
  ```bash
@@ -243,7 +268,8 @@ shell profiles or a new skill-managed file. Share masked status and actionable e
243
268
 
244
269
  ## 7. The China site
245
270
 
246
- One Meshy account works on both sites; only the hosts differ. When the user is in mainland China
271
+ One Meshy account works on both sites with the same credits; only the hosts differ. When the user
272
+ is in mainland China
247
273
  or asks for the China site, sign in with `--region cn` instead of the plain device login in
248
274
  section 3, with the same persistent-session procedure (the code is entered at `meshy.cn`):
249
275
 
@@ -11,10 +11,10 @@ timeout · deleting a task · local files.
11
11
 
12
12
  ## Runner problems
13
13
 
14
- - **`meshy: command not found`** or **a version older than 0.7.3**: install the newest 0.7.x as
14
+ - **`meshy: command not found`** or **a version older than 0.8.0**: install the newest 0.8.x as
15
15
  Setup describes. If the install is refused, use the temporary package
16
- (`npm exec --yes --package=meshy-cli@0.7.3 -- meshy …`) and carry on with the same job.
17
- - **A global 0.8 or newer** answers `--version`. Do not uninstall or downgrade it; use the
16
+ (`npm exec --yes --package=meshy-cli@0.8.0 -- meshy …`) and carry on with the same job.
17
+ - **A global 0.9 or newer** answers `--version`. Do not uninstall or downgrade it; use the
18
18
  temporary package for this work and mention the mismatch once.
19
19
  - **Node older than 22.12** fails the CLI's own runtime gate. Report the required version and the
20
20
  installed one; do not try to relax it or run an older CLI.
@@ -27,7 +27,7 @@ timeout · deleting a task · local files.
27
27
  resolved, while `authenticated: true, verified: false` also covers network and server failures.
28
28
  For the latter, use the hint or a free `meshy balance --format json --no-update-check` to
29
29
  obtain a typed error. Keep the same explicit `--api-key-file` if that is the selected source;
30
- status does not honor it in 0.7.
30
+ status does not honor it.
31
31
 
32
32
  - **Network failure during verification**: say it is a connectivity problem, keep the stored
33
33
  credential, and retry the check when the network is back. Do not start a new authorization.
@@ -42,7 +42,7 @@ status does not honor it in 0.7.
42
42
  - **`device_flow_not_supported`**: this API host has no device endpoint — the user logs in
43
43
  from their own desktop terminal, or supplies their own key privately.
44
44
 
45
- ## CLI 0.7 exit codes
45
+ ## CLI 0.8 exit codes
46
46
 
47
47
  | Exit | Meaning | Recovery |
48
48
  |---|---|---|
@@ -61,7 +61,7 @@ status does not honor it in 0.7.
61
61
  | 14 | Conflict: the task is running | A delete of an `IN_PROGRESS` task; see *Deleting a task* below. |
62
62
  | 130 | Interrupted (Ctrl-C, SIGTERM or SIGHUP) | Preserve task/operation context and reconcile before continuing. |
63
63
 
64
- These are 0.7 codes, not HTTP status codes. Some OAuth errors use generic exit 1; inspect
64
+ These are 0.8 codes, not HTTP status codes. Some OAuth errors use generic exit 1; inspect
65
65
  their message and hint, and `error.details.oauth_error` when it is present, as well.
66
66
 
67
67
  ## Unknown submission, failure and timeout
@@ -2,12 +2,12 @@
2
2
  name: meshy-3d-printing
3
3
  description: "Generates and prepares models for physical 3D printing with the Meshy CLI: white and multicolor prints (3MF, STL, OBJ), printability analysis and repair, splitting into parts, Creative Lab products such as figures, lamps and keychains, sizing, and slicer handoff (Bambu Studio, OrcaSlicer, PrusaSlicer, Cura). Use when the user wants something 3D-printed or asks for print or slicer files."
4
4
  license: MIT
5
- compatibility: "Needs Node.js 22.12+ and the Meshy CLI 0.7.x, 0.7.3 or later (npm install -g meshy-cli@0.7); network access to the Meshy API."
5
+ compatibility: "Needs Node.js 22.12+ and the Meshy CLI 0.8.x, 0.8.0 or later (npm install -g meshy-cli@0.8); network access to the Meshy API."
6
6
  ---
7
7
 
8
8
  # Meshy 3D Printing
9
9
 
10
- Use Meshy CLI **0.7** (0.7.3 or later) to deliver the requested print files at the intended size, with
10
+ Use Meshy CLI **0.8** (0.8.0 or later) to deliver the requested print files at the intended size, with
11
11
  analysis/repair results where applicable and a slicer handoff when requested. This skill is
12
12
  self-contained. Ordinary digital assets belong to meshy-3d-generation.
13
13
 
@@ -47,11 +47,17 @@ local dimension check cannot establish full printability.
47
47
 
48
48
  ## Cloud authorization
49
49
 
50
+ **DeepSeek Harness with the Meshy plugin** (`DSH_MESHY_CLI` is set; check with
51
+ `test -n "$DSH_MESHY_CLI"`): the plugin ships the CLI and keeps the sign-in. Run every command as
52
+ `"$DSH_MESHY_NODE" "$DSH_MESHY_CLI" …` in place of `meshy …` — never a `meshy` on PATH, which
53
+ cannot see that sign-in — install nothing, and when a command reports that nobody is signed in,
54
+ call the `meshy_sign_in` tool instead of `auth login` (Setup, section 1). Everywhere else:
55
+
50
56
  Before the first command run `meshy --version`; no need to ask. When `meshy` is missing or
51
- older than 0.7.3, install the newest 0.7.x with `npm install -g meshy-cli@0.7` and say so in
52
- one line; Setup covers a refused install and a CLI of 0.8 or newer. Local-only work stops at runner setup.
57
+ older than 0.8.0, install the newest 0.8.x with `npm install -g meshy-cli@0.8` and say so in
58
+ one line; Setup covers a refused install and a CLI of 0.9 or newer. Local-only work stops at runner setup.
53
59
  Cloud work reuses a verified session. If login is needed, keep `auth login --device` running (with `--region cn` for a
54
- user in mainland China),
60
+ user in mainland China: the same account and credits as the global site),
55
61
  show its URL and user code in **commentary/progress, never a final answer**, and await the
56
62
  same tool session in this turn. After it exits, verify `auth status` and resume the print job.
57
63
  Never ask for credentials in chat, nor for a "done" message except in Setup's two-step sign-in for a
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use [Setup](setup.md) for the runner, login and path rules, [Delivery](delivery.md) for cost,
4
4
  previews and hand-over, and [Troubleshooting](troubleshooting.md) for recovery. These recipes
5
- target **Meshy CLI 0.7** (0.7.1 or later) on Node.js 22.12+. Parameter details come from each command's `--help`;
5
+ target **Meshy CLI 0.8** (0.8.0 or later) on Node.js 22.12+. Parameter details come from each command's `--help`;
6
6
  the skill carries no API client.
7
7
 
8
8
  Contents: 0 local-only work · state · print size · 1 white prints · 2 analysis and repair · 3 multicolor ·
@@ -2,7 +2,7 @@
2
2
 
3
3
  Shared by the generation and print workflows. Three things are settled before any job
4
4
  starts: **how to run the CLI**, **whether a session already exists**, and **where files go**.
5
- The supported CLI is **0.7.x, from 0.7.3,** on **Node.js 22.12 or newer**. No Python, request wrapper or
5
+ The supported CLI is **0.8.x, from 0.8.0,** on **Node.js 22.12 or newer**. No Python, request wrapper or
6
6
  separate token store is involved.
7
7
 
8
8
  Contents: 1 runner · 2 reuse a session · 3 first login · 4 where files go · 5 one session
@@ -10,6 +10,22 @@ everywhere · 6 API keys · 7 the China site.
10
10
 
11
11
  ## 1. Resolve the runner
12
12
 
13
+ In DeepSeek Harness with the Meshy plugin the plugin ships the CLI and holds the sign-in. Check
14
+ for it first:
15
+
16
+ ```bash
17
+ test -n "$DSH_MESHY_CLI" && echo meshy-dsh
18
+ ```
19
+
20
+ When that prints `meshy-dsh`, run every recipe as `"$DSH_MESHY_NODE" "$DSH_MESHY_CLI" …` in
21
+ place of `meshy …` (PowerShell: `& $env:DSH_MESHY_NODE $env:DSH_MESHY_CLI …`), keep both paths
22
+ quoted, install nothing, and go on to section 2. The shell there cannot store a login, so never
23
+ run `auth login`, set `MESHY_CONFIG_DIR` or copy a credential file in it: when `auth status`
24
+ reports no usable credential, or a command reports a rejected session, call the
25
+ `meshy_sign_in` tool (`region: "cn"` for the China site), show the user its link and code, and
26
+ retry once they say they approved; or ask them to sign in from Settings → Meshy. Everywhere
27
+ else:
28
+
13
29
  ```bash
14
30
  node --version
15
31
  meshy --version
@@ -17,25 +33,25 @@ meshy --version
17
33
 
18
34
  | Observation | What to do |
19
35
  |---|---|
20
- | `meshy --version` prints 0.7.3 or a later 0.7.x | run `meshy` |
21
- | no `meshy` command, or a version older than 0.7.3 | install the newest 0.7.x (below), then run `meshy` |
22
- | 0.8 or newer | keep it, since something else may rely on it, and run the temporary package |
36
+ | `meshy --version` prints 0.8.0 or a later 0.8.x | run `meshy` |
37
+ | no `meshy` command, or a version older than 0.8.0 | install the newest 0.8.x (below), then run `meshy` |
38
+ | 0.9 or newer | keep it, since something else may rely on it, and run the temporary package |
23
39
  | no Node.js, or Node older than 22.12 | stop and report it: the user installs Node.js 22.12+ |
24
40
 
25
41
  ```bash
26
- npm install -g meshy-cli@0.7
42
+ npm install -g meshy-cli@0.8
27
43
  ```
28
44
 
29
45
  Check and install without asking first; say in one line that you are installing it. Install at
30
- most once: when `meshy --version` still reports a version older than 0.7.3 afterwards, the
46
+ most once: when `meshy --version` still reports a version older than 0.8.0 afterwards, the
31
47
  registry this machine uses lags npm, so report that instead of installing again. Never use `sudo`
32
48
  or change system policy: when the install is refused (permissions, a managed machine, a sandbox), use the temporary package
33
49
  instead. It runs the same CLI without installing anything: put `npm exec --yes
34
- --package=meshy-cli@0.7.3 --` in front of the same arguments, and the exit code and the JSON on
50
+ --package=meshy-cli@0.8.0 --` in front of the same arguments, and the exit code and the JSON on
35
51
  stdout are forwarded unchanged. Recipes are written as `meshy …`; example:
36
52
 
37
53
  ```bash
38
- npm exec --yes --package=meshy-cli@0.7.3 -- meshy auth status --format json --no-update-check
54
+ npm exec --yes --package=meshy-cli@0.8.0 -- meshy auth status --format json --no-update-check
39
55
  ```
40
56
 
41
57
  The first such call downloads the package into the npm cache; later calls reuse it. It names an
@@ -55,12 +71,15 @@ Every command, auth included, prints one `meshy.cli/v1` envelope on stdout (`ok`
55
71
  the unauthenticated and unverified answers below are `ok: true` with exit 3.
56
72
 
57
73
  - `authenticated: true`, `verified: true`, exit 0: continue with this account. **No new login.**
74
+ `result.account` names who is signed in when the site reports it (`null` for an API key, a
75
+ login made before CLI 0.8, and the China site for now).
58
76
  - `authenticated: false`, exit 3: no usable credential; log in (next section).
59
77
  - `authenticated: true`, `verified: false`, exit 3: a credential exists but verification failed —
60
78
  which includes network and server errors, not just rejection. Do not start a login or delete
61
79
  credentials; see [troubleshooting.md](troubleshooting.md).
62
80
 
63
- `auth status --offline` skips the balance call but can still refresh OAuth over the network.
81
+ `auth status --offline` skips the balance and account calls but can still refresh OAuth over the
82
+ network.
64
83
  Use local `doctor` for a diagnostic that must avoid the network entirely.
65
84
 
66
85
  ## 3. First login: one browser approval, then resume the original request
@@ -165,9 +184,9 @@ meshy auth login --device-flow FLOW_ID --format json --no-update-check
165
184
 
166
185
  It waits while the approval is still pending, saves the session and prints
167
186
  `result.status: "logged_in"`; verify `auth status` and continue the original request. An expired
168
- or unknown flow means running step one again. A host whose question tool reaches the user
169
- (dsh's `ask_user_question` is forwarded by its chat bridges) can instead ask with the link and
170
- wait for the answer in the same turn, then run step two.
187
+ or unknown flow means running step one again. A host whose question tool reaches the user can
188
+ instead ask with the link and wait for the answer in the same turn, then run step two. In
189
+ DeepSeek Harness the `meshy_sign_in` tool replaces both steps (section 1).
171
190
 
172
191
  Do not use `--manual` from an agent — it prompts on stdin for a pasted code. Never show a token, a device
173
192
  code or a signed URL to the user or copy one into chat or a file: task results and sidecars
@@ -206,31 +225,37 @@ to delete.
206
225
 
207
226
  ## 5. One session, both skills, any directory
208
227
 
209
- The default store is `~/.config/meshy/credentials.json` (mode 0600). Generation and printing,
210
- in either plugin, reuse it when run as the same OS user with the same CLI configuration.
211
- Changing the working directory does not require another login. Different users, machines,
212
- containers or configuration directories do not automatically share sessions.
228
+ The default store is `~/.config/meshy/credentials.v2.json` (mode 0600); the key or tokens in it
229
+ are encrypted under a key the OS keeps (Keychain, DPAPI or the Secret Service; a `master.key`
230
+ file where none is usable). Generation and printing, in either plugin, reuse it when run as the
231
+ same OS user with the same CLI configuration. Changing the working directory does not require
232
+ another login. Different users, machines, containers or configuration directories do not
233
+ automatically share sessions. A CLI before 0.8 kept `credentials.json` instead; 0.8 moves that
234
+ login over on its first write, and an older CLI then signs in once on its own.
213
235
 
214
236
  `MESHY_CONFIG_DIR` changes the config directory; `MESHY_CREDENTIALS_PATH` overrides the
215
- credential file. Non-production API hosts use `credentials.dev.json` by default. Keep these
237
+ credential file. Non-production API hosts use `credentials.v2.dev.json` by default. Keep these
216
238
  settings consistent; do not copy tokens between plugins or read the credential file.
217
239
  `auth list` reports profile kinds with masked credentials. `auth use <name>` changes the shared
218
240
  active profile, so do not switch it independently in concurrent workflows.
219
241
 
220
- The CLI refreshes stored OAuth tokens near expiry on its own.
242
+ The CLI refreshes stored OAuth tokens near expiry on its own. Where it cannot write the store (a
243
+ sandboxed shell) it leaves the login alone instead: a still-valid token keeps working, and an
244
+ expired one is exit 3 saying the directory is not writable — run the command outside the sandbox
245
+ rather than signing in again inside it.
221
246
 
222
247
  ## 6. Existing API keys remain supported
223
248
 
224
- Credential priority is `--api-key` > `MESHY_API_KEY` > explicit `--api-key-file` > stored
225
- active profile. An existing environment key overrides browser login; report `source` when
249
+ Credential priority is `--api-key` > `MESHY_API_KEY` > explicit `--api-key-file` > the DeepSeek
250
+ Harness plugin's session > stored active profile. An existing environment key overrides browser login; report `source` when
226
251
  diagnosing account selection, and do not change the user's environment or account implicitly.
227
252
 
228
253
  DeepSeek Harness (`DSH_SHELL=1`) removes credential-shaped variables such as `MESHY_API_KEY`
229
254
  from every shell call, so a key the user exported before starting dsh never reaches the CLI.
230
- There, use the stored browser login (`meshy auth login`) or an explicit `--api-key-file`.
255
+ There the Meshy plugin's sign-in is used (section 1), or an explicit `--api-key-file`.
231
256
 
232
257
  There is no automatic `.env` discovery. If the user chooses a project key file, pass its
233
- explicit path on authenticated commands. In 0.7 **`auth status` ignores `--api-key-file`**,
258
+ explicit path on authenticated commands. **`auth status` ignores `--api-key-file`**,
234
259
  so verify that branch with a free balance call instead:
235
260
 
236
261
  ```bash
@@ -243,7 +268,8 @@ shell profiles or a new skill-managed file. Share masked status and actionable e
243
268
 
244
269
  ## 7. The China site
245
270
 
246
- One Meshy account works on both sites; only the hosts differ. When the user is in mainland China
271
+ One Meshy account works on both sites with the same credits; only the hosts differ. When the user
272
+ is in mainland China
247
273
  or asks for the China site, sign in with `--region cn` instead of the plain device login in
248
274
  section 3, with the same persistent-session procedure (the code is entered at `meshy.cn`):
249
275
 
@@ -11,10 +11,10 @@ timeout · deleting a task · local files.
11
11
 
12
12
  ## Runner problems
13
13
 
14
- - **`meshy: command not found`** or **a version older than 0.7.3**: install the newest 0.7.x as
14
+ - **`meshy: command not found`** or **a version older than 0.8.0**: install the newest 0.8.x as
15
15
  Setup describes. If the install is refused, use the temporary package
16
- (`npm exec --yes --package=meshy-cli@0.7.3 -- meshy …`) and carry on with the same job.
17
- - **A global 0.8 or newer** answers `--version`. Do not uninstall or downgrade it; use the
16
+ (`npm exec --yes --package=meshy-cli@0.8.0 -- meshy …`) and carry on with the same job.
17
+ - **A global 0.9 or newer** answers `--version`. Do not uninstall or downgrade it; use the
18
18
  temporary package for this work and mention the mismatch once.
19
19
  - **Node older than 22.12** fails the CLI's own runtime gate. Report the required version and the
20
20
  installed one; do not try to relax it or run an older CLI.
@@ -27,7 +27,7 @@ timeout · deleting a task · local files.
27
27
  resolved, while `authenticated: true, verified: false` also covers network and server failures.
28
28
  For the latter, use the hint or a free `meshy balance --format json --no-update-check` to
29
29
  obtain a typed error. Keep the same explicit `--api-key-file` if that is the selected source;
30
- status does not honor it in 0.7.
30
+ status does not honor it.
31
31
 
32
32
  - **Network failure during verification**: say it is a connectivity problem, keep the stored
33
33
  credential, and retry the check when the network is back. Do not start a new authorization.
@@ -42,7 +42,7 @@ status does not honor it in 0.7.
42
42
  - **`device_flow_not_supported`**: this API host has no device endpoint — the user logs in
43
43
  from their own desktop terminal, or supplies their own key privately.
44
44
 
45
- ## CLI 0.7 exit codes
45
+ ## CLI 0.8 exit codes
46
46
 
47
47
  | Exit | Meaning | Recovery |
48
48
  |---|---|---|
@@ -61,7 +61,7 @@ status does not honor it in 0.7.
61
61
  | 14 | Conflict: the task is running | A delete of an `IN_PROGRESS` task; see *Deleting a task* below. |
62
62
  | 130 | Interrupted (Ctrl-C, SIGTERM or SIGHUP) | Preserve task/operation context and reconcile before continuing. |
63
63
 
64
- These are 0.7 codes, not HTTP status codes. Some OAuth errors use generic exit 1; inspect
64
+ These are 0.8 codes, not HTTP status codes. Some OAuth errors use generic exit 1; inspect
65
65
  their message and hint, and `error.details.oauth_error` when it is present, as well.
66
66
 
67
67
  ## Unknown submission, failure and timeout