{"record":{"id":"e48e10b15c310e86","repo":"multica-ai/multica","slug":"mint-pat-target-api-url-not-set","errorCode":null,"errorMessage":"mint PAT: target API URL not set","messagePattern":"mint PAT: target API URL not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/src/main/daemon-manager.ts","lineNumber":603,"sourceCode":"    }\n    case \"restart\":\n      console.log(\n        `[daemon] CLI version mismatch (bundled=${bundled} running=${running?.cli_version}) — restarting daemon`,\n      );\n      pendingVersionRestart = false;\n      await restartDaemon();\n      return \"restarted\";\n  }\n}\n\n/**\n * Exchange the user's JWT for a long-lived PAT via POST /api/tokens. The\n * daemon needs a PAT (or `mul_` / `mdt_` token) because JWTs expire in 30\n * days and signatures are tied to a specific backend instance.\n */\nasync function mintPat(jwt: string): Promise<string> {\n  if (!targetApiBaseUrl) {\n    throw new Error(\"mint PAT: target API URL not set\");\n  }\n  const url = `${targetApiBaseUrl.replace(/\\/+$/, \"\")}/api/tokens`;\n  const res = await fetch(url, {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n      Authorization: `Bearer ${jwt}`,\n    },\n    // Omit expires_in_days → server treats as null → non-expiring PAT.\n    body: JSON.stringify({ name: \"Multica Desktop\" }),\n  });\n  if (!res.ok) {\n    const body = await res.text().catch(() => \"\");\n    // Attach the status so callers can tell a genuine auth rejection (401 — the\n    // session token is dead) apart from a transient failure (5xx, etc.) without\n    // string-matching the message.\n    throw Object.assign(\n      new Error(`mint PAT failed: ${res.status} ${res.statusText} ${body}`),","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/apps/desktop/src/main/daemon-manager.ts#L585-L621","documentation":"Thrown by prepareHermesHome when params demand an existing source home (sourceMustExist) and os.Stat on the resolved shared home fails or the path is not a directory. The resolved home is either the explicitly configured source or the platform default (platformDefaultHermesHome()). The message names the exact path and the hermes CLI command to fix it.","triggerScenarios":"prepareHermesHome is called with sourceMustExist == true and sharedHome (HermesSourceHome after TrimSpace, or the platform default when empty) does not exist, is a file, or is not readable by the daemon user.","commonSituations":"Hermes never installed/profile never created on the daemon host; HermesSourceHome pointing at a home directory that was moved or deleted; running the daemon in a container without mounting the host's hermes home; wrong $HOME so platformDefaultHermesHome() resolves elsewhere.","solutions":["Run `hermes profile create` (or otherwise materialize the home) on the daemon host at the exact path shown in the error message.","Correct the agent's HermesSourceHome configuration to the real home directory path.","In containers, mount the host's hermes home at the path the daemon expects.","If the home genuinely may be absent, unset the must-exist flag (HermesSourceMustExist) so a missing source degrades instead of failing."],"exampleFix":"# before: home missing → prepare fails\n$ ls /home/user/.hermes\nls: cannot access '/home/user/.hermes': No such file or directory\n\n# after\n$ hermes profile create   # materializes the platform default home\n$ ls -d /home/user/.hermes","handlingStrategy":"validation","validationCode":"if sourceMustExist {\n    fi, err := os.Stat(strings.TrimSpace(sourceHome))\n    if err != nil || !fi.IsDir() {\n        return fmt.Errorf(\"hermes home missing — run `hermes profile create` or fix %s\", sourceHome)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := prepareHermesHome(...); err != nil {\n    if strings.Contains(err.Error(), \"not found (create it with\") {\n        // actionable: create the profile home, then re-run prepare — deterministic fix, no retry loop\n    }\n}","preventionTips":["Stat-verify the configured hermes home at agent registration.","In containers, mount the hermes home explicitly and pin its path.","Prefer HermesSourceMustExist=true to catch config drift early."],"tags":["go","hermes","execenv","filesystem","profile","config"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}