recess-cli 3.42.0 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -233,6 +233,37 @@ export class RecessAdminApi {
233
233
  throw apiError(response.status, body);
234
234
  return body;
235
235
  }
236
+ /** File a full MAP report PDF (e.g. Learning Statements) for one season. */
237
+ async uploadMapTestReport(studentId, query, pdf, fileName) {
238
+ this.requireAuth();
239
+ const formData = new FormData();
240
+ const pdfBody = new Uint8Array(pdf.byteLength);
241
+ pdfBody.set(pdf);
242
+ formData.append("file", new Blob([pdfBody.buffer], { type: "application/pdf" }), fileName);
243
+ const headers = cliRequestHeaders({ cookie: this.config.sessionCookie }, this.reason, this.clientTag);
244
+ applyIdempotencyHeaders(headers);
245
+ const url = new URL(`/tutor/students/${encodeURIComponent(studentId)}/map-test-reports`, this.config.apiOrigin);
246
+ for (const [key, value] of Object.entries(query)) {
247
+ if (value !== undefined)
248
+ url.searchParams.set(key, String(value));
249
+ }
250
+ const response = await fetch(url, {
251
+ method: "POST",
252
+ headers,
253
+ body: formData,
254
+ });
255
+ const text = await response.text();
256
+ let body = text;
257
+ try {
258
+ body = text ? JSON.parse(text) : null;
259
+ }
260
+ catch {
261
+ // Preserve a non-JSON API response as text.
262
+ }
263
+ if (!response.ok)
264
+ throw apiError(response.status, body);
265
+ return body;
266
+ }
236
267
  /** The packet's tuition agreement as a PDF, to sign by hand. */
237
268
  async downloadAdmissionContract(packetId, optionId) {
238
269
  this.requireAuth();
package/dist/cli.js CHANGED
@@ -22,7 +22,7 @@ import { runDmsCommand } from "./commands/dms.js";
22
22
  import { runFeedCommand } from "./commands/feed.js";
23
23
  import { runFamiliesCommand } from "./commands/families.js";
24
24
  import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/family.js";
25
- import { runStudentsTextsCommand, runUsersPhoneCommand, } from "./commands/phone-and-texts.js";
25
+ import { runStudentsTextsCommand, runUsersPhoneCommand, runUsersTextCommand, runStudentsTextParentCommand, } from "./commands/phone-and-texts.js";
26
26
  import { hasCommunityHour, runUsersCommunityHourCommand, } from "./commands/community-hour.js";
27
27
  import { runTuitionPlansCommand } from "./commands/tuition-plans.js";
28
28
  import { runReportsCommand } from "./commands/reports.js";
@@ -1290,6 +1290,8 @@ const SCHOOL_TIER_IDS = SCHOOL_TIER_OPTIONS.map((tier) => tier.id);
1290
1290
  // own paths. The server's POST /admin/users/change-role/ enforces the same set.
1291
1291
  const RESTORABLE_ROLES = ["KID", "GUARDIAN", "GUIDE", "PROGRAM"];
1292
1292
  const MAX_MAP_PDF_BYTES = 15 * 1024 * 1024;
1293
+ /** `students map-reports upload`: the report route + MAP_REPORT policy cap. */
1294
+ const MAX_MAP_REPORT_PDF_BYTES = 32 * 1024 * 1024;
1293
1295
  const GOAL_TEMPLATE_KINDS = ["SIMPLE", "BLUEPRINT"];
1294
1296
  const GOAL_TEMPLATE_SETUP_AUDIENCES = ["KID_FRIENDLY", "PARENT_SETUP"];
1295
1297
  const STORE_ITEM_STATUSES = ["ACTIVE", "INACTIVE", "COMING_SOON"];
@@ -1943,7 +1945,16 @@ async function resolveExpectedTemplateVersion(api, parsed, templateId, recovered
1943
1945
  return { expectedVersion: current.version, pinnedFrom: "current" };
1944
1946
  }
1945
1947
  const PINNED_VERSION_NOTE = "--expected-version was omitted, so the version read at preview is pinned: a template change before confirm changes this preview and the confirm is refused. Retrying after a landed write needs --expected-version <the previewed version>.";
1946
- async function readMapScorePdf(filePath) {
1948
+ const MAP_REPORT_SUBJECTS = [
1949
+ "MATH",
1950
+ "READING",
1951
+ "LANGUAGE_USAGE",
1952
+ "SCIENCE",
1953
+ "OTHER",
1954
+ ];
1955
+ const MAP_REPORT_SEASONS = ["FALL", "WINTER", "SPRING", "SUMMER"];
1956
+ const MAP_REPORT_KINDS = ["LEARNING_STATEMENTS", "OTHER"];
1957
+ async function readMapScorePdf(filePath, maxBytes = MAX_MAP_PDF_BYTES) {
1947
1958
  const absolutePath = path.resolve(filePath);
1948
1959
  if (path.extname(absolutePath).toLowerCase() !== ".pdf") {
1949
1960
  throw new CliError("invalid_arguments", "--file must point to a PDF report.");
@@ -1964,8 +1975,8 @@ async function readMapScorePdf(filePath) {
1964
1975
  if (stat.size === 0) {
1965
1976
  throw new CliError("invalid_arguments", "MAP score PDF is empty.");
1966
1977
  }
1967
- if (stat.size > MAX_MAP_PDF_BYTES) {
1968
- throw new CliError("invalid_arguments", "MAP score PDF exceeds the 15 MB upload limit.");
1978
+ if (stat.size > maxBytes) {
1979
+ throw new CliError("invalid_arguments", `MAP PDF exceeds the ${Math.round(maxBytes / 1024 / 1024)} MB upload limit.`);
1969
1980
  }
1970
1981
  const bytes = await fs.readFile(absolutePath);
1971
1982
  return {
@@ -3237,6 +3248,9 @@ export async function executeRecessCommand(argv, options = {}) {
3237
3248
  if (noun === "users" && verb === "phone") {
3238
3249
  return runUsersPhoneCommand({ parsed, api, writeCommand });
3239
3250
  }
3251
+ if (noun === "users" && verb === "text") {
3252
+ return runUsersTextCommand({ parsed, api, writeCommand });
3253
+ }
3240
3254
  if (noun === "users" && verb === "community-hour") {
3241
3255
  return runUsersCommunityHourCommand({ parsed, api, writeCommand });
3242
3256
  }
@@ -3532,6 +3546,9 @@ export async function executeRecessCommand(argv, options = {}) {
3532
3546
  return { studentId, added, removed: remove };
3533
3547
  });
3534
3548
  }
3549
+ if (noun === "students" && verb === "text-parent") {
3550
+ return runStudentsTextParentCommand({ parsed, api, writeCommand });
3551
+ }
3535
3552
  if (noun === "students" && verb === "notes") {
3536
3553
  if (parsed.positionals[2] !== "add") {
3537
3554
  throw new CliError("invalid_arguments", "Use students notes add.");
@@ -3565,6 +3582,48 @@ export async function executeRecessCommand(argv, options = {}) {
3565
3582
  },
3566
3583
  }, () => api.uploadMapTestScores(studentId, pdf.bytes, pdf.fileName));
3567
3584
  }
3585
+ if (noun === "students" && verb === "map-reports") {
3586
+ const action = parsed.positionals[2];
3587
+ const studentId = flagString(parsed, "student", { required: true });
3588
+ if (action === "list") {
3589
+ return unwrap(await api.client.GET("/tutor/students/{studentId}/map-test-reports", {
3590
+ params: { path: { studentId } },
3591
+ }));
3592
+ }
3593
+ if (action === "upload") {
3594
+ const subject = assertChoice(flagString(parsed, "subject", { required: true }).toUpperCase(), MAP_REPORT_SUBJECTS, "--subject");
3595
+ const season = assertChoice(flagString(parsed, "season", { required: true }).toUpperCase(), MAP_REPORT_SEASONS, "--season");
3596
+ const schoolYear = flagString(parsed, "school-year", { required: true });
3597
+ if (!/^\d{4}-\d{4}$/.test(schoolYear)) {
3598
+ throw new CliError("invalid_arguments", '--school-year must look like "2025-2026".');
3599
+ }
3600
+ const kind = assertChoice((flagString(parsed, "kind") ?? "learning-statements")
3601
+ .toUpperCase()
3602
+ .replace(/-/g, "_"), MAP_REPORT_KINDS, "--kind");
3603
+ const pdf = await readMapScorePdf(flagString(parsed, "file", { required: true }), MAX_MAP_REPORT_PDF_BYTES);
3604
+ const query = { kind, subject, season, schoolYear };
3605
+ return writeCommand(parsed, {
3606
+ action: "file a full MAP report PDF beside this season's scores (parents, the kid, and their guides can open it; replaces any existing report for the same subject + season)",
3607
+ target: { studentId },
3608
+ request: {
3609
+ ...query,
3610
+ file: pdf.absolutePath,
3611
+ fileName: pdf.fileName,
3612
+ sizeBytes: pdf.bytes.byteLength,
3613
+ sha256: pdf.sha256,
3614
+ },
3615
+ }, () => api.uploadMapTestReport(studentId, query, pdf.bytes, pdf.fileName));
3616
+ }
3617
+ if (action === "delete") {
3618
+ const reportId = flagString(parsed, "report", { required: true });
3619
+ return writeCommand(parsed, {
3620
+ action: "remove a filed MAP report PDF from the kid's dashboard",
3621
+ target: { studentId, reportId },
3622
+ request: {},
3623
+ }, async () => unwrap(await api.client.DELETE("/tutor/students/{studentId}/map-test-reports/{reportId}", { params: { path: { studentId, reportId } } })));
3624
+ }
3625
+ throw new CliError("invalid_arguments", "Use students map-reports list|upload|delete.");
3626
+ }
3568
3627
  if (noun === "enrollments" && verb === "list") {
3569
3628
  const userId = flagString(parsed, "user", { required: true });
3570
3629
  const data = unwrap(await api.client.GET("/admin/users/operations-search", {
@@ -6518,7 +6577,7 @@ export async function executeRecessCommand(argv, options = {}) {
6518
6577
  return { studentId, flashcardReviewEnabled: on };
6519
6578
  });
6520
6579
  }
6521
- throw new CliError("invalid_arguments", "Use students list|today|schedule|todos|analysis|xp-history|mastery|upload-map-scores|issue-email|goblins|web-todos|flashcards.");
6580
+ throw new CliError("invalid_arguments", "Use students list|today|schedule|todos|analysis|xp-history|mastery|upload-map-scores|map-reports|issue-email|goblins|web-todos|flashcards.");
6522
6581
  }
6523
6582
  if (noun === "todos") {
6524
6583
  if (verb === "create") {
@@ -585,11 +585,15 @@ const STAFF_COMMANDS = new Set([
585
585
  "school update",
586
586
  "store-items list",
587
587
  "students upload-map-scores",
588
+ "students map-reports list",
589
+ "students map-reports upload",
590
+ "students map-reports delete",
588
591
  "students issue-email",
589
592
  "students goblins",
590
593
  "students web-todos",
591
594
  "students flashcards",
592
595
  "students notes add",
596
+ "students text-parent",
593
597
  "students interests",
594
598
  "students todos",
595
599
  "students analysis",
@@ -971,10 +971,6 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
971
971
  },
972
972
  wins: today.insights.wins,
973
973
  struggles: today.insights.struggles,
974
- // Adaptive coins: a required to-do pays 10 × its subject's multiplier.
975
- ...(today.coinMultipliers && {
976
- coinMultipliers: today.coinMultipliers,
977
- }),
978
974
  };
979
975
  }
980
976
  if (verb === "goals") {
@@ -1903,7 +1899,7 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
1903
1899
  target: { ...kidTarget(kid), goalId },
1904
1900
  request: { coins },
1905
1901
  details: {
1906
- consequence: "Its open and future to-dos pay this (default: required 20, optional 5; undo: family undo).",
1902
+ consequence: "Its open and future to-dos pay this (default: by subject, math 20, reading 10, else 5; undo: family undo).",
1907
1903
  },
1908
1904
  }, async () => {
1909
1905
  const result = unwrap(await api.client.PATCH("/parent-v2/kid/{kidId}/challenges/{goalId}/coins/", { params: { path: { kidId, goalId } }, body: { coins } }));
@@ -1945,7 +1941,7 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
1945
1941
  params: { path: { kidId } },
1946
1942
  }));
1947
1943
  return {
1948
- challenges: goals.map((goal) => `${goal.id} · ${goal.title} · ${goal.required ? "required" : "optional"} · ${goal.todoCoins ?? (goal.required ? 20 : 5)} coins/to-do · ${goal.status.toLowerCase()}`),
1944
+ challenges: goals.map((goal) => `${goal.id} · ${goal.title} · ${goal.required ? "required" : "optional"} · ${goal.todoCoins ?? "subject-priced"} coins/to-do · ${goal.status.toLowerCase()}`),
1949
1945
  page: `${api.config.webOrigin}/ai?kid=${encodeURIComponent(kidId)}&tab=challenges`,
1950
1946
  browse: `${api.config.webOrigin}/activity/challenges`,
1951
1947
  };
@@ -6,6 +6,112 @@ const TEXT_FREQUENCIES = ["all", "daily", "important"];
6
6
  function fullName(user) {
7
7
  return [user.firstName, user.lastName].filter(Boolean).join(" ");
8
8
  }
9
+ /**
10
+ * What the parent reads: the server leads the text with the sender's name so
11
+ * they can tell a person wrote it (`staffTextBody` in
12
+ * web-server `parent-agent/staff-text.ts`). Shown in the preview for approval.
13
+ */
14
+ async function staffTextPreview(api, text) {
15
+ const session = unwrap(await api.client.GET("/auth/admin-cli/session/"));
16
+ const name = session.user.firstName?.trim();
17
+ return `${name ? `${name} from Recess` : "Recess team"}: ${text}`;
18
+ }
19
+ /**
20
+ * `users text <user-id> --text TEXT` — text a parent from Rocky's number, led
21
+ * by the sender's name. Their reply goes to Rocky, who sees the text in the
22
+ * thread.
23
+ */
24
+ export async function runUsersTextCommand({ parsed, api, writeCommand, }) {
25
+ const userId = positional(parsed, 2, "user ID");
26
+ const text = flagString(parsed, "text", { required: true }).trim();
27
+ if (!text || text.length > 1000) {
28
+ throw new CliError("invalid_arguments", "--text must be 1 to 1000 characters.");
29
+ }
30
+ const { user } = unwrap(await api.client.GET("/admin/users/{userId}", {
31
+ params: { path: { userId } },
32
+ }));
33
+ if (user.role !== "GUARDIAN" && user.role !== "ADMIN") {
34
+ throw new CliError("invalid_arguments", `Only a parent can get a text from Rocky; this user is a ${user.role}.`);
35
+ }
36
+ if (!user.phoneNumber) {
37
+ throw new CliError("invalid_arguments", "This parent has no phone number.");
38
+ }
39
+ return writeCommand(parsed, {
40
+ action: "text this parent from Rocky's number, signed with your first name (it sends right away; their reply goes to Rocky)",
41
+ target: { userId: user.id },
42
+ request: { text },
43
+ details: {
44
+ recipient: {
45
+ name: fullName(user),
46
+ role: user.role,
47
+ phoneNumber: user.phoneNumber,
48
+ },
49
+ parentReads: await staffTextPreview(api, text),
50
+ },
51
+ }, async () => {
52
+ const result = unwrap(await api.client.POST("/admin/users/{userId}/rocky-text/", {
53
+ params: { path: { userId: user.id } },
54
+ body: { text },
55
+ }));
56
+ if (!result.sent) {
57
+ throw new CliError("text_not_sent", `The text was not sent: ${result.skippedReason ?? "unknown reason"}.`);
58
+ }
59
+ return { userId: user.id, name: fullName(user), ...result };
60
+ });
61
+ }
62
+ /**
63
+ * `students text-parent --student <kid-id> [--parent <id>] --text TEXT` — the
64
+ * same text, for a parent of a kid the caller manages (guides and admins).
65
+ * `--parent` is only needed when the kid has more than one parent who can get
66
+ * a text.
67
+ */
68
+ export async function runStudentsTextParentCommand({ parsed, api, writeCommand, }) {
69
+ const studentId = flagString(parsed, "student", { required: true });
70
+ const parentFlag = flagString(parsed, "parent");
71
+ const text = flagString(parsed, "text", { required: true }).trim();
72
+ if (!text || text.length > 1000) {
73
+ throw new CliError("invalid_arguments", "--text must be 1 to 1000 characters.");
74
+ }
75
+ const { parents } = unwrap(await api.client.GET("/tutor/students/{studentId}/parents", {
76
+ params: { path: { studentId } },
77
+ }));
78
+ const reachable = parents.filter((p) => p.hasPhone && !p.textsOff);
79
+ const parent = parentFlag
80
+ ? parents.find((p) => p.id === parentFlag)
81
+ : reachable.length === 1
82
+ ? reachable[0]
83
+ : undefined;
84
+ if (!parent) {
85
+ throw new CliError("invalid_arguments", parentFlag
86
+ ? "--parent is not a parent of this kid."
87
+ : reachable.length
88
+ ? "This kid has more than one parent who can get a text: choose one with --parent."
89
+ : "This kid has no parent who can get a text.", 1, { parents });
90
+ }
91
+ if (!parent.hasPhone || parent.textsOff) {
92
+ throw new CliError("invalid_arguments", parent.textsOff
93
+ ? "This parent replied STOP to Rocky's texts."
94
+ : "This parent has no phone number.");
95
+ }
96
+ return writeCommand(parsed, {
97
+ action: "text this parent from Rocky's number, signed with your first name (it sends right away; their reply goes to Rocky)",
98
+ target: { studentUserId: studentId, parentUserId: parent.id },
99
+ request: { text },
100
+ details: {
101
+ recipient: { name: parent.name },
102
+ parentReads: await staffTextPreview(api, text),
103
+ },
104
+ }, async () => {
105
+ const result = unwrap(await api.client.POST("/tutor/students/{studentId}/parents/{parentId}/text", {
106
+ params: { path: { studentId, parentId: parent.id } },
107
+ body: { text },
108
+ }));
109
+ if (!result.sent) {
110
+ throw new CliError("text_not_sent", `The text was not sent: ${result.skippedReason ?? "unknown reason"}.`);
111
+ }
112
+ return { parentId: parent.id, name: parent.name, ...result };
113
+ });
114
+ }
9
115
  /**
10
116
  * `users phone get|set|clear` — a user's SMS/login phone number. The server
11
117
  * normalizes whatever is typed to E.164 (bare numbers read as US) and rejects
package/dist/help.js CHANGED
@@ -52,6 +52,7 @@ Usage:
52
52
  recess [--json] users phone get <user-id>
53
53
  recess [--json] users phone set <user-id> --phone <number> [--confirm]
54
54
  recess [--json] users phone clear <user-id> [--confirm]
55
+ recess [--json] users text <user-id> --text TEXT [--confirm]
55
56
  recess [--json] users lock <user-id> [--confirm]
56
57
  recess [--json] users unlock <user-id> [--confirm]
57
58
  recess [--json] users community-hour get <kid-id>
@@ -78,12 +79,20 @@ Usage:
78
79
  [--focus <text> | --clear-focus] [--confirm]
79
80
  recess [--json] students upload-map-scores --student <kid-id>
80
81
  --file </path/to/map-report.pdf> [--confirm]
82
+ recess [--json] students map-reports list --student <kid-id>
83
+ recess [--json] students map-reports upload --student <kid-id>
84
+ --file </path/to/report.pdf> --subject math|reading|language_usage|science|other
85
+ --season fall|winter|spring|summer --school-year <YYYY-YYYY>
86
+ [--kind learning-statements|other] [--confirm]
87
+ recess [--json] students map-reports delete --student <kid-id> --report <report-id>
88
+ [--confirm]
81
89
  recess [--json] students issue-email --student <kid-id> [--confirm]
82
90
  recess [--json] students goblins --student <kid-id> [--course <slug>] [--search TEXT]
83
91
  [--confirm]
84
92
  recess [--json] students web-todos --student <kid-id> [--on|--off] [--confirm]
85
93
  recess [--json] students flashcards --student <kid-id> [--on|--off] [--confirm]
86
94
  recess [--json] students notes add --student <kid-id> --text TEXT [--confirm]
95
+ recess [--json] students text-parent --student <kid-id> [--parent <parent-id>] --text TEXT [--confirm]
87
96
  recess [--json] students interests --student <kid-id> [--add LABEL]...
88
97
  [--remove <interest-id>]... [--confirm]
89
98
  recess [--json] chat-logs list --student <user-id> [--limit 100] [--cursor <cursor>]
@@ -1249,6 +1258,7 @@ export const COMMAND_SUMMARIES = {
1249
1258
  "users phone get": "Read a user's phone number and verification.",
1250
1259
  "users phone set": "Set a user's phone number (stored E.164, unverified).",
1251
1260
  "users phone clear": "Remove a user's phone number.",
1261
+ "users text": "Text a parent from Rocky's number, signed with your first name.",
1252
1262
  "users community-hour get": "Show whether a kid can join Community Hour.",
1253
1263
  "users community-hour unlock": "Let a kid join Community Hour and enter the Village.",
1254
1264
  "users community-hour lock": "Stop a kid joining Community Hour or the Village.",
@@ -1267,11 +1277,15 @@ export const COMMAND_SUMMARIES = {
1267
1277
  "students texts set": "Change a kid's SMS summary switch or send hour.",
1268
1278
  "students texts set-guardian": "Change one adult's SMS frequency, focus, or on/off.",
1269
1279
  "students upload-map-scores": "Upload a NWEA MAP score report PDF for a kid.",
1280
+ "students map-reports list": "List the full MAP report PDFs filed for a kid, by subject and season.",
1281
+ "students map-reports upload": "File a full MAP report PDF (e.g. Learning Statements) beside that season's scores for parents, the kid, and guides.",
1282
+ "students map-reports delete": "Remove a filed MAP report PDF.",
1270
1283
  "students issue-email": "Issue a Recess email address for a kid.",
1271
1284
  "students goblins": "Roster a kid into Goblins so their Goblins todos sign them straight in.",
1272
1285
  "students web-todos": "Show or set whether a kid's todos run on web (off: they open in the desktop app).",
1273
1286
  "students flashcards": "Show or set whether a kid gets a daily flashcard review todo.",
1274
1287
  "students interests": "List, add, or remove a kid's interests (Rocky, the feed, and reading/writing passages use them).",
1288
+ "students text-parent": "Text a kid's parent from Rocky's number, signed with your first name; the reply goes to Rocky.",
1275
1289
  "students notes add": "Add a staff-visible guide note to a kid's profile (Rocky reads it).",
1276
1290
  "chat-logs list": "List a student's AI chat conversations.",
1277
1291
  "chat-logs get": "Read one AI chat conversation.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.42.0",
3
+ "version": "3.44.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -30,7 +30,7 @@ recess --json skills guardian get recess-family
30
30
  recess --json skills guardian get recess-challenge-design
31
31
  # Research, author, or apply a goal or reusable goal template
32
32
  recess --json skills guardian get recess-goal-authoring
33
- # Guide (guide_students): your students, class ops, Math Academy linking and activity
33
+ # Guide (guide_students): your students, class ops, Math Academy, Goblins math practice
34
34
  recess --json skills guardian get recess-guide
35
35
  # Staff operations (full_admin), then the one playbook its table names
36
36
  recess --json skills admin get recess-admin