@wilm-ai/wilma-cli 1.6.0 → 1.6.2

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.
Files changed (4) hide show
  1. package/README.md +28 -0
  2. package/dist/index.js +34 -11
  3. package/package.json +11 -10
  4. package/LICENSE +0 -21
package/README.md CHANGED
@@ -99,6 +99,34 @@ If you've saved your TOTP secret via interactive setup, `--totp-secret` is not n
99
99
  Local config is stored in `~/.config/wilmai/config.json` (or `$XDG_CONFIG_HOME/wilmai/config.json`).
100
100
  Use `wilma config clear` to remove it. Override with `WILMAI_CONFIG_PATH`.
101
101
 
102
+ ## Troubleshooting: TLS errors on a managed laptop
103
+
104
+ A TLS certificate error means the network is intercepting TLS and re-signing with a
105
+ private root CA (common behind a corporate secure web gateway). Node ignores the OS
106
+ trust store, so `curl` and your browser keep working while every Wilma request fails.
107
+ A successful `npm install` is not evidence that TLS is healthy — the npm registry is
108
+ commonly exempt from inspection.
109
+
110
+ ```bash
111
+ NODE_USE_SYSTEM_CA=1 wilma summary --json # Node >=22.19 / >=24.6
112
+ node --use-system-ca "$(command -v wilma)" summary --json # Node >=22.15
113
+ NODE_EXTRA_CA_CERTS=/path/to/root-ca.pem wilma summary --json # explicit root
114
+ ```
115
+
116
+ Never use `NODE_TLS_REJECT_UNAUTHORIZED=0` — it turns verification off entirely.
117
+
118
+ With `--json`, transport failures carry a `code` and a `hint` alongside `status` and
119
+ `message`, so agents can branch on the cause:
120
+
121
+ ```json
122
+ {
123
+ "status": "error",
124
+ "message": "TLS certificate verification failed for https://example.inschool.fi (UNABLE_TO_GET_ISSUER_CERT_LOCALLY)",
125
+ "code": "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
126
+ "hint": "..."
127
+ }
128
+ ```
129
+
102
130
  ## Notes
103
131
  - Credentials and TOTP secrets are stored with lightweight obfuscation for convenience.
104
132
  - For multi-child accounts, you can pass `--student <id|name>` or `--all-students`.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { readFile, writeFile, mkdir, open, rm } from "node:fs/promises";
6
6
  import { spawn } from "node:child_process";
7
7
  import { homedir } from "node:os";
8
8
  import { dirname, resolve } from "node:path";
9
- import { WilmaClient, MfaRequiredError, listTenants, } from "@wilm-ai/wilma-client";
9
+ import { WilmaClient, MfaRequiredError, NetworkError, listTenants, } from "@wilm-ai/wilma-client";
10
10
  import { clearConfig, getConfigPath, loadConfig, obfuscateSecret, revealSecret, saveConfig, } from "./config.js";
11
11
  // Enable keypress events for escape key detection
12
12
  if (process.stdin.isTTY) {
@@ -1777,28 +1777,41 @@ function formatContent(value) {
1777
1777
  }
1778
1778
  async function getStudentsForCommand(profile, config) {
1779
1779
  const stored = config.profiles.find((p) => p.id === config.lastProfileId);
1780
- const fresh = await WilmaClient.listStudents(profile);
1781
- if (stored) {
1780
+ const fresh = await WilmaClient.listStudents({ ...profile, studentNumber: null });
1781
+ if (stored && fresh.length > 0) {
1782
1782
  stored.students = fresh.map((s) => ({ studentNumber: s.studentNumber, name: s.name }));
1783
1783
  await saveConfig(config);
1784
1784
  }
1785
- return fresh;
1785
+ if (fresh.length > 0) {
1786
+ return fresh;
1787
+ }
1788
+ return (stored?.students ?? []).map((student) => ({
1789
+ ...student,
1790
+ href: `/!${student.studentNumber}/`,
1791
+ }));
1786
1792
  }
1787
1793
  async function resolveStudentForFlags(profile, config, student) {
1788
1794
  if (student) {
1795
+ const normalized = student.trim();
1796
+ if (/^\d+$/.test(normalized)) {
1797
+ const stored = config.profiles.find((p) => p.id === config.lastProfileId);
1798
+ const cached = stored?.students?.find((item) => item.studentNumber === normalized);
1799
+ return {
1800
+ studentNumber: normalized,
1801
+ name: cached?.name ?? normalized,
1802
+ href: `/!${normalized}/`,
1803
+ };
1804
+ }
1789
1805
  const students = await getStudentsForCommand(profile, config);
1790
- const exact = students.find((s) => s.studentNumber === student);
1791
- if (exact)
1792
- return exact;
1793
- const needle = student.toLowerCase();
1806
+ const needle = normalized.toLowerCase();
1794
1807
  const substring = students.find((s) => s.name.toLowerCase().includes(needle));
1795
1808
  if (substring)
1796
1809
  return substring;
1797
- const match = students.find((s) => fuzzyIncludes(s.name, student));
1810
+ const match = students.find((s) => fuzzyIncludes(s.name, normalized));
1798
1811
  if (match)
1799
1812
  return match;
1800
1813
  // No match found - show available students and exit
1801
- console.error(`Error: No student matching "${student}" found.`);
1814
+ console.error(`Error: No student matching "${normalized}" found.`);
1802
1815
  if (students.length > 0) {
1803
1816
  console.error("Available students:");
1804
1817
  students.forEach((s) => console.error(` ${s.studentNumber} ${s.name}`));
@@ -2008,11 +2021,21 @@ main().catch((err) => {
2008
2021
  process.exit(1);
2009
2022
  }
2010
2023
  const message = err instanceof Error ? err.message : String(err);
2024
+ const isNetwork = err instanceof NetworkError;
2011
2025
  if (process.argv.includes("--json")) {
2012
- console.log(JSON.stringify({ status: "error", message }, null, 2));
2026
+ console.log(JSON.stringify({
2027
+ status: "error",
2028
+ message,
2029
+ ...(isNetwork && err.code ? { code: err.code } : {}),
2030
+ ...(isNetwork && err.hint ? { hint: err.hint } : {}),
2031
+ }, null, 2));
2013
2032
  }
2014
2033
  else {
2015
2034
  console.error("CLI error:", message);
2035
+ if (isNetwork && err.hint) {
2036
+ console.error("");
2037
+ console.error(err.hint);
2038
+ }
2016
2039
  }
2017
2040
  process.exit(1);
2018
2041
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wilm-ai/wilma-cli",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,9 +8,17 @@
8
8
  "wilmai": "dist/index.js",
9
9
  "wilma": "dist/index.js"
10
10
  },
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "lint": "echo 'add lint'",
14
+ "test": "pnpm --filter @wilm-ai/wilma-client build && pnpm run build && node test/news-resources.mjs",
15
+ "start": "node dist/index.js",
16
+ "prepack": "pnpm --filter @wilm-ai/wilma-client build && pnpm --filter @wilm-ai/wilma-cli build",
17
+ "test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
18
+ },
11
19
  "dependencies": {
12
20
  "@inquirer/prompts": "^5.3.8",
13
- "@wilm-ai/wilma-client": "^1.5.0"
21
+ "@wilm-ai/wilma-client": "^1.5.2"
14
22
  },
15
23
  "devDependencies": {
16
24
  "typescript": "^5.6.3"
@@ -21,12 +29,5 @@
21
29
  ],
22
30
  "publishConfig": {
23
31
  "access": "public"
24
- },
25
- "scripts": {
26
- "build": "tsc -p tsconfig.json",
27
- "lint": "echo 'add lint'",
28
- "test": "pnpm --filter @wilm-ai/wilma-client build && pnpm run build && node test/news-resources.mjs",
29
- "start": "node dist/index.js",
30
- "test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
31
32
  }
32
- }
33
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Wilm.ai
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.