@unisonlabs/sixminute-admin 0.1.1316-next → 0.1.1319-next

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.
@@ -21,7 +21,7 @@ import { homedir } from "node:os";
21
21
  import { fileURLToPath } from "node:url";
22
22
 
23
23
  // tools/admin/src/build-info.ts
24
- var BUILT = { version: "0.1.1316-next", commit: "9e8ff11edd81a96f428ac4768460c578e1117f7a", surface: "f49f14b46968a210" };
24
+ var BUILT = { version: "0.1.1319-next", commit: "6d30aea0d9b85e000832b99df54a9cebb542dfc1", surface: "b6f5e5ab99843501" };
25
25
 
26
26
  // tools/admin/src/run.ts
27
27
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
@@ -5043,7 +5043,8 @@ var JobKindSchema = oneOf([
5043
5043
  "scrub_plaintext",
5044
5044
  "purge_expired",
5045
5045
  "research_purge",
5046
- "sweep"
5046
+ "sweep",
5047
+ "matter_learning"
5047
5048
  ]);
5048
5049
  var SettingSchema = oneOf([
5049
5050
  "unit_minutes",
@@ -6493,7 +6494,8 @@ var CompletionPurposeSchema = exports_external.enum([
6493
6494
  "judge_shortlist",
6494
6495
  "judge_calendar_event",
6495
6496
  "judge_calendar_matter",
6496
- "judge_calendar_attendance"
6497
+ "judge_calendar_attendance",
6498
+ "learn_terms"
6497
6499
  ]);
6498
6500
  var CompletionDecisionSchema = exports_external.object({
6499
6501
  property: exports_external.string().min(1),
@@ -6732,6 +6734,50 @@ var AdminNarrativeActivitiesSchema = exports_external.object({
6732
6734
  language: NarrativeLanguageSchema,
6733
6735
  activities: exports_external.array(NarrativeActivitySchema)
6734
6736
  });
6737
+ var AdminLearningQuerySchema = exports_external.object({
6738
+ member: MemberIdSchema.optional(),
6739
+ from: exports_external.string().date().optional(),
6740
+ to: exports_external.string().date().optional()
6741
+ });
6742
+ var AdminLearnedTermSchema = exports_external.object({
6743
+ member_id: MemberIdSchema,
6744
+ email: exports_external.string(),
6745
+ scope: exports_external.enum(["matter", "client"]),
6746
+ owner_id: exports_external.string(),
6747
+ matter_code: exports_external.string().nullable(),
6748
+ client_name: exports_external.string().nullable(),
6749
+ term: exports_external.string(),
6750
+ kind: exports_external.string(),
6751
+ status: exports_external.enum(["candidate", "promoted"]),
6752
+ sightings: exports_external.number().int(),
6753
+ first_seen: exports_external.string(),
6754
+ last_seen: exports_external.string()
6755
+ });
6756
+ var AdminLearnedTermsSchema = exports_external.object({
6757
+ tenant: exports_external.object({ id: TenantIdSchema, name: exports_external.string() }),
6758
+ terms: exports_external.array(AdminLearnedTermSchema)
6759
+ });
6760
+ var AdminLearningRanksSchema = exports_external.object({ at1: exports_external.number().int(), top20: exports_external.number().int() });
6761
+ var AdminLearningMemberReportSchema = exports_external.object({
6762
+ member_id: MemberIdSchema,
6763
+ email: exports_external.string(),
6764
+ intervals: exports_external.number().int(),
6765
+ decided_by: exports_external.record(exports_external.string(), exports_external.number().int()),
6766
+ lifted: exports_external.number().int(),
6767
+ scored: exports_external.number().int(),
6768
+ baseline: AdminLearningRanksSchema,
6769
+ learned: AdminLearningRanksSchema,
6770
+ picked_right: exports_external.number().int(),
6771
+ helped: exports_external.number().int(),
6772
+ hurt: exports_external.number().int(),
6773
+ lifts: exports_external.array(exports_external.object({ matter_id: exports_external.string(), lifted: exports_external.number().int(), right: exports_external.number().int(), wrong: exports_external.number().int() }))
6774
+ });
6775
+ var AdminLearningReportSchema = exports_external.object({
6776
+ tenant: exports_external.object({ id: TenantIdSchema, name: exports_external.string() }),
6777
+ from: exports_external.string(),
6778
+ to: exports_external.string(),
6779
+ members: exports_external.array(AdminLearningMemberReportSchema)
6780
+ });
6735
6781
  // packages/contracts/src/admin-firm-acting.ts
6736
6782
  var ACTING_AS_HEADER = "X-Six-Minute-Acting-As";
6737
6783
  var TeamApplyRequestSchema = exports_external.object({
@@ -7421,6 +7467,7 @@ var COMPAT_MARKERS = [
7421
7467
  "services/api/src/features/evidence/retention.ts",
7422
7468
  "services/api/src/features/evidence/telemetry.ts",
7423
7469
  "services/api/src/features/operator/tenants.ts",
7470
+ "services/api/src/features/practice/store.ts",
7424
7471
  "services/api/src/platform/jobs/jobs.ts",
7425
7472
  "services/api/src/platform/jobs/ledger.ts",
7426
7473
  "services/api/src/platform/jobs/service.ts",
@@ -8670,6 +8717,58 @@ async function runDemo(run2, subcommand) {
8670
8717
  throw new AdminUsageError(`unknown command: demo ${subcommand ?? ""}`.trim());
8671
8718
  }
8672
8719
 
8720
+ // tools/admin/src/learning.ts
8721
+ var DATE = /^\d{4}-\d{2}-\d{2}$/;
8722
+ var pct = (n, of) => of === 0 ? "-" : `${(100 * n / of).toFixed(1)}%`;
8723
+ async function runLearning(run2, subcommand) {
8724
+ const { flags } = run2;
8725
+ const tenant = required(flags, "tenant", "whose matter learning");
8726
+ const query = new URLSearchParams;
8727
+ const member = optional(flags, "member");
8728
+ if (member !== undefined)
8729
+ query.set("member", member);
8730
+ if (subcommand === "terms") {
8731
+ const answer = await call(run2.api, "GET", `${tenantPath(tenant, "/learning/terms")}${query.size === 0 ? "" : `?${query}`}`);
8732
+ if (answer.status !== 200)
8733
+ return refused(run2, answer, [actingHead(tenant, answer)]);
8734
+ const { terms } = AdminLearnedTermsSchema.parse(answer.body);
8735
+ const promoted = terms.filter((t) => t.status === "promoted").length;
8736
+ return render(run2, { member: member ?? null, terms }, [
8737
+ actingHead(tenant, answer),
8738
+ `${terms.length} term(s), ${promoted} promoted`,
8739
+ ...terms.map((t) => [
8740
+ ` ${t.email}`,
8741
+ t.scope === "matter" ? `matter ${t.matter_code ?? t.owner_id}` : `client ${t.client_name ?? t.owner_id}`,
8742
+ t.kind,
8743
+ t.status,
8744
+ `${t.sightings} sighting(s)`,
8745
+ `${t.first_seen.slice(0, 10)}..${t.last_seen.slice(0, 10)}`,
8746
+ JSON.stringify(t.term)
8747
+ ].join(" "))
8748
+ ]);
8749
+ }
8750
+ if (subcommand === "report") {
8751
+ for (const name of ["from", "to"]) {
8752
+ const value = optional(flags, name);
8753
+ if (value === undefined)
8754
+ continue;
8755
+ if (!DATE.test(value))
8756
+ throw new AdminUsageError(`--${name} is a date, YYYY-MM-DD, got ${JSON.stringify(value)}`);
8757
+ query.set(name, value);
8758
+ }
8759
+ const answer = await call(run2.api, "GET", `${tenantPath(tenant, "/learning/report")}${query.size === 0 ? "" : `?${query}`}`);
8760
+ if (answer.status !== 200)
8761
+ return refused(run2, answer, [actingHead(tenant, answer)]);
8762
+ const report = AdminLearningReportSchema.parse(answer.body);
8763
+ const lines = [actingHead(tenant, answer), `window ${report.from} to ${report.to}`];
8764
+ for (const m of report.members) {
8765
+ lines.push("", `${m.email} ${m.member_id}`, ` intervals ${m.intervals}, ${m.lifted} lifted by a learned term, ${m.scored} under a released entry`, ` decided by ${Object.entries(m.decided_by).sort().map(([kind, n]) => `${kind} ${n}`).join(", ") || "-"}`, ` rank@1 baseline ${pct(m.baseline.at1, m.scored)} learned ${pct(m.learned.at1, m.scored)}`, ` top 20 baseline ${pct(m.baseline.top20, m.scored)} learned ${pct(m.learned.top20, m.scored)}`, ` charged ${pct(m.picked_right, m.scored)} the released matter`, ` lifts ${m.helped} helped, ${m.hurt} hurt`, ...m.lifts.slice(0, 10).map((l) => ` ${l.matter_id} lifted ${l.lifted} right ${l.right} wrong ${l.wrong}`));
8766
+ }
8767
+ return render(run2, report, lines);
8768
+ }
8769
+ throw new AdminUsageError(`unknown command: learning ${subcommand ?? ""}`.trim());
8770
+ }
8771
+
8673
8772
  // tools/admin/src/member.ts
8674
8773
  var enc = encodeURIComponent;
8675
8774
  async function runMember(run2, subcommand) {
@@ -8962,6 +9061,19 @@ is required; without one every command answers 403.
8962
9061
  empty table, a repeated key, or a table where no row has a pattern in
8963
9062
  the firm's default narrative language.
8964
9063
 
9064
+ sixminute-admin learning terms --env <env> --tenant tenant_... [--member member_...] [--json]
9065
+ The learned matter terms of one member, or of every member of the
9066
+ firm, opened: member, matter or client, kind, status, how many entries
9067
+ carried it, first and last seen, and the term. An internal firm only:
9068
+ the terms are copied from a lawyer's screens. Each read is audited.
9069
+
9070
+ sixminute-admin learning report --env <env> --tenant tenant_... [--member member_...] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--json]
9071
+ Matter learning's shadow comparison, per member, over the window (the
9072
+ last 30 days by default): how often the matter the person released was
9073
+ first, and in the first 20, of the word order without learned terms
9074
+ and with them, how often the matter call charged it, and how many lifts
9075
+ helped or hurt. Matter ids and counts only.
9076
+
8965
9077
  sixminute-admin pipeline shadow-report --env <env> --day YYYY-MM-DD [--json]
8966
9078
  The cloud pipeline's shadow against the device for one local day, for
8967
9079
  every person of an internal firm with a shadow recording: intervals
@@ -9173,9 +9285,9 @@ is required; without one every command answers 403.
9173
9285
  sixminute-admin connector approval --env <env> --firm tenant_... \\
9174
9286
  --member <member-id> (--auto | --review) [--json]
9175
9287
  What one member's release does in a system that takes drafts for
9176
- approval: --review, the draft waits there until it is approved (the
9177
- default), or --auto, it is written as approved time on that member's
9178
- account, with no draft. Where the system refuses that, the release
9288
+ approval: --auto, it is written as approved time on that member's
9289
+ account, with no draft (the default), or --review, the draft waits
9290
+ there until it is approved. Where the system refuses that, the release
9179
9291
  fails and says why. One member a call; a sync never changes it.
9180
9292
 
9181
9293
  sixminute-admin connector status --env <env> --firm tenant_... [--json]
@@ -9398,6 +9510,8 @@ async function runAdmin(argv, deps) {
9398
9510
  return runTenantShow(run2);
9399
9511
  if (group === "member")
9400
9512
  return runMember(run2, subcommand);
9513
+ if (group === "learning")
9514
+ return runLearning(run2, subcommand);
9401
9515
  if (group === "client")
9402
9516
  return runClient(run2, subcommand);
9403
9517
  if (group === "matter")
@@ -9584,10 +9698,10 @@ async function runRawArchive(run2, subcommand) {
9584
9698
  async function runShadowReport(run2) {
9585
9699
  const day2 = required(run2.flags, "day", "which local day, YYYY-MM-DD");
9586
9700
  const found = ShadowReportSchema.parse(expectOk(await call(run2.api, "GET", `/v1/admin/pipeline/shadow-report?day=${encodeURIComponent(day2)}`)));
9587
- const pct = (part, whole) => whole === 0 ? "-" : `${Math.round(100 * part / whole)}%`;
9701
+ const pct2 = (part, whole) => whole === 0 ? "-" : `${Math.round(100 * part / whole)}%`;
9588
9702
  return render(run2, found, [
9589
9703
  `day ${found.day}`,
9590
- ...found.people.length === 0 ? ["no shadow recording on this day"] : found.people.map((p) => `${p.member_id} intervals device ${p.intervals_device} cloud ${p.intervals_cloud} both ${p.intervals_both}, ` + `same matter ${pct(p.matter_agree, p.intervals_both)}; minutes device ${p.minutes_device} cloud ${p.minutes_cloud}, ` + `same matter ${pct(p.minutes_matter_agree, p.minutes_device)}, same client ${pct(p.minutes_client_agree, p.minutes_device)}; ` + `latency p50 ${p.latency_p50_s ?? "-"} s p95 ${p.latency_p95_s ?? "-"} s; $${p.cost_usd.toFixed(3)}; ` + `failed ${p.runs_failed} held ${p.runs_held}`)
9704
+ ...found.people.length === 0 ? ["no shadow recording on this day"] : found.people.map((p) => `${p.member_id} intervals device ${p.intervals_device} cloud ${p.intervals_cloud} both ${p.intervals_both}, ` + `same matter ${pct2(p.matter_agree, p.intervals_both)}; minutes device ${p.minutes_device} cloud ${p.minutes_cloud}, ` + `same matter ${pct2(p.minutes_matter_agree, p.minutes_device)}, same client ${pct2(p.minutes_client_agree, p.minutes_device)}; ` + `latency p50 ${p.latency_p50_s ?? "-"} s p95 ${p.latency_p95_s ?? "-"} s; $${p.cost_usd.toFixed(3)}; ` + `failed ${p.runs_failed} held ${p.runs_held}`)
9591
9705
  ]);
9592
9706
  }
9593
9707
  async function runRetentionSet(run2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisonlabs/sixminute-admin",
3
- "version": "0.1.1316-next",
3
+ "version": "0.1.1319-next",
4
4
  "description": "Sixminute operator tool: the admin commands of the Sixminute API, run with your own operator sign-in.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {