@unisonlabs/sixminute-admin 0.1.1395-next → 0.1.1396-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.
@@ -20,7 +20,7 @@ import { homedir } from "node:os";
20
20
  import { fileURLToPath } from "node:url";
21
21
 
22
22
  // tools/admin/src/build-info.ts
23
- var BUILT = { version: "0.1.1395-next", commit: "75b7aa392d5dff42b54e6f7d39a64c154f2d55a6", surface: "ac6c731b1016a56b" };
23
+ var BUILT = { version: "0.1.1396-next", commit: "f07ead5d1c1cbdd2f459aa5e7fe7d1b9ac9a75c2", surface: "ac6c731b1016a56b" };
24
24
 
25
25
  // tools/admin/src/run.ts
26
26
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
@@ -5492,7 +5492,12 @@ var CATALOGUE = {
5492
5492
  run_id: GENERATE.run_id,
5493
5493
  day_offset: GENERATE.day_offset,
5494
5494
  entries_clipped: count(),
5495
- attempts: count()
5495
+ attempts: count(),
5496
+ online_calls_by_link: count(),
5497
+ online_calls_by_window: count(),
5498
+ online_calls_by_participants: count(),
5499
+ online_calls_by_nearest_start: count(),
5500
+ online_calls_unmatched: count()
5496
5501
  },
5497
5502
  wire: { name: "generate.finished" }
5498
5503
  }),
@@ -6837,6 +6842,231 @@ var TeamApplyResultSchema = exports_external.object({
6837
6842
  confirmation: TeamConfirmationSchema,
6838
6843
  connector: ConnectorSummarySchema.nullable()
6839
6844
  });
6845
+ // packages/contracts/src/call/note.ts
6846
+ var CallEndSchema = exports_external.enum([
6847
+ "left",
6848
+ "window_closed",
6849
+ "app_closed",
6850
+ "surface_gone",
6851
+ "released_unknown",
6852
+ "lock",
6853
+ "sleep",
6854
+ "capture_stopped",
6855
+ "app_quit",
6856
+ "engine_restart"
6857
+ ]);
6858
+ var CallPlatformSchema = exports_external.string().regex(/^[a-z][a-z0-9_]{0,31}$/);
6859
+ var CallInspectionStateSchema = exports_external.enum(["in_call", "no_surface", "window_gone", "unknown", "excluded"]);
6860
+ var CALL_PARTICIPANTS_MAX = 50;
6861
+ var CALL_NAME_MAX = 120;
6862
+ var CALL_TEXT_MAX = 2048;
6863
+ var SpanSchema = exports_external.object({ from: TimestampSchema, to: TimestampSchema });
6864
+ var SeenSchema = (max) => exports_external.object({ value: exports_external.string().min(1).max(max), at: TimestampSchema });
6865
+ var CallAppSchema = exports_external.object({ bundle_id: exports_external.string().min(1).max(CALL_NAME_MAX * 2), name: exports_external.string().min(1).max(CALL_NAME_MAX * 2) });
6866
+ var CallNoteSchema = exports_external.object({
6867
+ call_id: exports_external.string().min(1).max(64),
6868
+ resumes: exports_external.string().min(1).max(64).nullable(),
6869
+ state: exports_external.enum(["open", "closed"]),
6870
+ alive_at: TimestampSchema,
6871
+ started_at: TimestampSchema,
6872
+ ended_at: TimestampSchema.nullable(),
6873
+ end: CallEndSchema.nullable(),
6874
+ app: CallAppSchema,
6875
+ platform: CallPlatformSchema,
6876
+ holders: exports_external.array(exports_external.object({ image: exports_external.string().min(1).max(CALL_NAME_MAX * 2), spans: exports_external.array(SpanSchema).max(500) })).max(32),
6877
+ window_title: exports_external.array(SeenSchema(CALL_TEXT_MAX)).max(50),
6878
+ url: exports_external.array(SeenSchema(CALL_TEXT_MAX)).max(50),
6879
+ meeting_code: exports_external.array(SeenSchema(CALL_NAME_MAX)).max(50),
6880
+ participants: exports_external.array(SeenSchema(CALL_NAME_MAX)).max(CALL_PARTICIPANTS_MAX),
6881
+ inspections: exports_external.array(exports_external.object({ at: TimestampSchema, state: CallInspectionStateSchema, reason: exports_external.string().max(64).nullable(), matched: exports_external.string().max(CALL_NAME_MAX).nullable() })).max(2000),
6882
+ released: exports_external.array(SpanSchema).max(500),
6883
+ camera: exports_external.array(SpanSchema).max(500),
6884
+ build: exports_external.string().max(64),
6885
+ ui_language: exports_external.string().max(32).nullable(),
6886
+ policy_version: exports_external.string().max(64).nullable(),
6887
+ os_version: exports_external.string().max(64).nullable(),
6888
+ cost: exports_external.object({ inspections: exports_external.number().int().nonnegative(), slowest_ms: exports_external.number().int().nonnegative() })
6889
+ }).superRefine((note, ctx) => {
6890
+ if (note.state === "closed" && (note.ended_at === null || note.end === null))
6891
+ ctx.addIssue({ code: "custom", path: ["end"], message: "a closed note names its end" });
6892
+ if (note.state === "open" && (note.ended_at !== null || note.end !== null))
6893
+ ctx.addIssue({ code: "custom", path: ["end"], message: "an open note names no end" });
6894
+ if (note.ended_at !== null && Date.parse(note.ended_at) < Date.parse(note.started_at))
6895
+ ctx.addIssue({ code: "custom", path: ["ended_at"], message: "a call ends at or after its start" });
6896
+ if (Date.parse(note.alive_at) < Date.parse(note.started_at))
6897
+ ctx.addIssue({ code: "custom", path: ["alive_at"], message: "a call is alive at or after its start" });
6898
+ });
6899
+ var ContextCallSchema = exports_external.object({
6900
+ call_id: exports_external.string().min(1).max(64),
6901
+ app: exports_external.string().min(1).max(CALL_NAME_MAX * 2),
6902
+ platform: CallPlatformSchema,
6903
+ window_title: exports_external.string().min(1).max(CALL_TEXT_MAX).nullable(),
6904
+ participants: exports_external.array(exports_external.string().min(1).max(CALL_NAME_MAX)).max(CALL_PARTICIPANTS_MAX),
6905
+ live: exports_external.array(SpanSchema).min(1).max(64)
6906
+ });
6907
+ var CallNoteAnswerSchema = exports_external.object({ call_id: exports_external.string(), stored: exports_external.boolean() });
6908
+ // packages/contracts/src/call/controls.ts
6909
+ var CallControlKindSchema = exports_external.string().regex(/^[a-z][a-z0-9_]{0,31}$/);
6910
+ var Folded = exports_external.string().min(1).max(120).regex(/^[^\p{Lu}\p{Lt}]*$/u, "folded to lower case");
6911
+ var CallControlSchema = exports_external.object({
6912
+ kind: CallControlKindSchema,
6913
+ labels: exports_external.array(Folded),
6914
+ automation_ids: exports_external.array(exports_external.string().min(1).max(120)),
6915
+ starts: exports_external.boolean(),
6916
+ beside: exports_external.array(Folded)
6917
+ });
6918
+ var CallPlatformVocabularySchema = exports_external.object({
6919
+ platform: CallPlatformSchema,
6920
+ apps: exports_external.array(Folded),
6921
+ hosts: exports_external.array(Folded),
6922
+ titles: exports_external.array(Folded),
6923
+ controls: exports_external.array(CallControlSchema),
6924
+ surface: exports_external.array(Folded)
6925
+ });
6926
+ var CallControlsSchema = exports_external.object({
6927
+ version: exports_external.string().min(1),
6928
+ browsers: exports_external.array(Folded),
6929
+ platforms: exports_external.array(CallPlatformVocabularySchema)
6930
+ });
6931
+ var control = (kind, labels, starts, beside = [], automation_ids = []) => ({
6932
+ kind,
6933
+ labels,
6934
+ automation_ids,
6935
+ starts,
6936
+ beside
6937
+ });
6938
+ var CALL_CONTROLS = {
6939
+ version: "2026-11-07.3",
6940
+ browsers: [
6941
+ "com.google.chrome",
6942
+ "com.microsoft.edgemac",
6943
+ "org.mozilla.firefox",
6944
+ "com.apple.safari",
6945
+ "com.brave.browser",
6946
+ "company.thebrowser.browser",
6947
+ "chrome",
6948
+ "msedge",
6949
+ "firefox",
6950
+ "brave"
6951
+ ],
6952
+ platforms: [
6953
+ {
6954
+ platform: "teams",
6955
+ apps: ["com.microsoft.teams2", "com.microsoft.teams", "ms-teams", "teams"],
6956
+ hosts: ["teams.microsoft.com", "teams.live.com"],
6957
+ titles: ["microsoft teams"],
6958
+ controls: [
6959
+ control("leave", ["hang up"], true),
6960
+ control("leave", ["leave"], true, ["meeting controls", "calling controls", "meeting chat"]),
6961
+ control("mute", ["mute", "unmute", "mute mic", "unmute mic"], false),
6962
+ control("camera", ["turn camera on", "turn camera off", "camera"], false),
6963
+ control("share", ["share", "share content"], false),
6964
+ control("share", ["stop sharing"], true)
6965
+ ],
6966
+ surface: [
6967
+ "hang up",
6968
+ "leave",
6969
+ "meeting controls",
6970
+ "calling controls",
6971
+ "meeting chat",
6972
+ "mute",
6973
+ "unmute",
6974
+ "mute mic",
6975
+ "unmute mic",
6976
+ "turn camera on",
6977
+ "turn camera off",
6978
+ "camera",
6979
+ "share",
6980
+ "share content",
6981
+ "stop sharing",
6982
+ "you're sharing your screen",
6983
+ "join now"
6984
+ ]
6985
+ },
6986
+ {
6987
+ platform: "zoom",
6988
+ apps: ["us.zoom.xos", "zoom"],
6989
+ hosts: ["zoom.us", "zoom.com"],
6990
+ titles: ["zoom meeting", "zoom workplace"],
6991
+ controls: [
6992
+ control("leave", ["leave", "leave meeting"], true),
6993
+ control("leave", [], true, ["audio", "video"], ["leave"]),
6994
+ control("end", ["end meeting"], true),
6995
+ control("end", ["end"], true, ["mute", "unmute", "start video", "stop video"]),
6996
+ control("mute", ["mute", "unmute", "mute audio", "unmute audio"], false, [], ["audio"]),
6997
+ control("camera", ["start video", "stop video"], false, [], ["video"]),
6998
+ control("share", ["share screen", "share"], false, [], ["share"]),
6999
+ control("window", [], false, [], ["zm.meeting.window.main"]),
7000
+ control("share", ["stop share"], true),
7001
+ control("share", ["zoom share statusbar window"], true)
7002
+ ],
7003
+ surface: [
7004
+ "leave",
7005
+ "leave meeting",
7006
+ "end meeting",
7007
+ "end",
7008
+ "mute",
7009
+ "unmute",
7010
+ "mute audio",
7011
+ "unmute audio",
7012
+ "start video",
7013
+ "stop video",
7014
+ "share screen",
7015
+ "share",
7016
+ "stop share",
7017
+ "zoom share statusbar window",
7018
+ "audio",
7019
+ "video",
7020
+ "zm.meeting.window.main",
7021
+ "participants"
7022
+ ]
7023
+ },
7024
+ {
7025
+ platform: "meet",
7026
+ apps: [],
7027
+ hosts: ["meet.google.com"],
7028
+ titles: ["meet - ", "google meet"],
7029
+ controls: [
7030
+ control("leave", ["leave call"], true),
7031
+ control("mute", ["turn off microphone", "turn on microphone"], false),
7032
+ control("camera", ["turn off camera", "turn on camera"], false),
7033
+ control("share", ["present now", "share screen"], false)
7034
+ ],
7035
+ surface: [
7036
+ "leave call",
7037
+ "turn off microphone",
7038
+ "turn on microphone",
7039
+ "turn off camera",
7040
+ "turn on camera",
7041
+ "present now",
7042
+ "share screen",
7043
+ "join now",
7044
+ "ask to join"
7045
+ ]
7046
+ },
7047
+ {
7048
+ platform: "webex",
7049
+ apps: ["cisco-systems.spark", "com.webex.meetingmanager", "webex", "ciscocollabhost"],
7050
+ hosts: ["webex.com"],
7051
+ titles: ["webex"],
7052
+ controls: [
7053
+ control("leave", ["leave meeting", "leave meeting or end meeting for everyone"], true),
7054
+ control("end", ["end meeting"], true),
7055
+ control("mute", ["mute", "unmute"], false),
7056
+ control("camera", ["start video", "stop video"], false)
7057
+ ],
7058
+ surface: ["leave meeting", "leave meeting or end meeting for everyone", "end meeting", "mute", "unmute", "start video", "stop video"]
7059
+ },
7060
+ {
7061
+ platform: "slack",
7062
+ apps: ["com.tinyspeck.slackmacgap", "slack"],
7063
+ hosts: [],
7064
+ titles: [],
7065
+ controls: [control("leave", ["leave huddle"], true), control("end", ["end huddle"], true), control("mute", ["mute", "unmute"], false)],
7066
+ surface: ["leave huddle", "end huddle", "mute", "unmute"]
7067
+ }
7068
+ ]
7069
+ };
6840
7070
  // packages/contracts/src/capture.ts
6841
7071
  var captureSampleFields = exports_external.object({
6842
7072
  t: TimestampSchema,
@@ -6969,6 +7199,7 @@ var DEVICE_ROUTES = [
6969
7199
  { method: "POST", path: "/v1/intervals/{from}/context", platforms: DESKTOP_PLATFORMS },
6970
7200
  { method: "POST", path: "/v1/device/signals", platforms: DESKTOP_PLATFORMS },
6971
7201
  { method: "POST", path: "/v1/device/clock", platforms: DESKTOP_PLATFORMS },
7202
+ { method: "POST", path: "/v1/device/calls", platforms: DESKTOP_PLATFORMS },
6972
7203
  { method: "POST", path: "/v1/recordings/{id}/stop", platforms: DESKTOP_PLATFORMS },
6973
7204
  { method: "POST", path: "/v1/recordings/{id}/clock", platforms: DESKTOP_PLATFORMS },
6974
7205
  { method: "POST", path: "/v1/recordings/{id}/skip", platforms: DESKTOP_PLATFORMS },
@@ -7005,7 +7236,8 @@ var DevicePolicySchema = exports_external.object({
7005
7236
  time_zone: exports_external.string().min(1).nullable().default(null),
7006
7237
  context_retention_days: exports_external.number().int().nonnegative(),
7007
7238
  minimum_version: exports_external.string().nullable(),
7008
- always_on: FirmAlwaysOnSchema.default("member_choice")
7239
+ always_on: FirmAlwaysOnSchema.default("member_choice"),
7240
+ call_controls: CallControlsSchema.optional()
7009
7241
  });
7010
7242
  var DEVICE_KNOWN_MAX = 16;
7011
7243
  var DeviceKnownHeaderSchema = exports_external.string().transform((value) => [...new Set(value.split(",").map((one) => one.trim()).filter((one) => one !== ""))]).pipe(exports_external.array(DeviceIdSchema).max(DEVICE_KNOWN_MAX));
@@ -8385,7 +8617,8 @@ var intervalContextBody = {
8385
8617
  last_end_before: TimestampSchema.nullable(),
8386
8618
  first_end_inside: TimestampSchema.nullable()
8387
8619
  }),
8388
- lost: exports_external.array(exports_external.string()).optional()
8620
+ lost: exports_external.array(exports_external.string()).optional(),
8621
+ calls: exports_external.array(ContextCallSchema).max(8).optional()
8389
8622
  };
8390
8623
  var IntervalContextSchema = exports_external.object({
8391
8624
  schema_version: exports_external.literal(2),
@@ -8806,7 +9039,7 @@ async function send(ctx, token, method, path, body, actingFor) {
8806
9039
  }
8807
9040
  return { status: response.status, body: parsed, actingAs: response.headers.get(ACTING_AS_HEADER) };
8808
9041
  }
8809
- async function call(ctx, method, path, body, actingFor) {
9042
+ async function call2(ctx, method, path, body, actingFor) {
8810
9043
  let session = await currentSession(ctx.io, ctx.environment);
8811
9044
  let answer = await send(ctx, session.access_token, method, path, body, actingFor);
8812
9045
  if (answer.status === 401) {
@@ -9071,11 +9304,11 @@ async function runDemo(run2, subcommand) {
9071
9304
  const tenantId = required(run2.flags, "tenant", "which firm, an internal one");
9072
9305
  const path = (rest) => tenantPath(tenantId, rest);
9073
9306
  if (subcommand === "on" || subcommand === "off") {
9074
- const { tenant } = AdminDemoFlagSchema.parse(expectOk(await call(run2.api, "PUT", path("/demo"), { enabled: subcommand === "on" })));
9307
+ const { tenant } = AdminDemoFlagSchema.parse(expectOk(await call2(run2.api, "PUT", path("/demo"), { enabled: subcommand === "on" })));
9075
9308
  return render(run2, { tenant }, [`tenant ${tenant.id} ${tenant.name}`, `demo ${tenant.demo}`]);
9076
9309
  }
9077
9310
  if (subcommand === "status") {
9078
- const status = AdminDemoStatusSchema.parse(expectOk(await call(run2.api, "GET", path("/demo"))));
9311
+ const status = AdminDemoStatusSchema.parse(expectOk(await call2(run2.api, "GET", path("/demo"))));
9079
9312
  return render(run2, status, [
9080
9313
  `tenant ${status.tenant.id} ${status.tenant.name} demo ${status.tenant.demo}`,
9081
9314
  `member ${status.member_id}`,
@@ -9085,7 +9318,7 @@ async function runDemo(run2, subcommand) {
9085
9318
  }
9086
9319
  if (subcommand === "seed") {
9087
9320
  const { body, names } = seedBody(run2);
9088
- const done = AdminDemoSeedResultSchema.parse(expectOk(await call(run2.api, "POST", path("/demo/seed"), body)));
9321
+ const done = AdminDemoSeedResultSchema.parse(expectOk(await call2(run2.api, "POST", path("/demo/seed"), body)));
9089
9322
  const invited = (done.members ?? []).map((one) => `member ${one.email} ${one.outcome === "invited" ? "invited" : one.outcome === "member" ? "already a member, skipped" : "already invited, skipped"}`);
9090
9323
  if (done.range !== undefined) {
9091
9324
  return render(run2, done, [
@@ -9105,10 +9338,10 @@ async function runDemo(run2, subcommand) {
9105
9338
  if (subcommand === "reset" || subcommand === "remove") {
9106
9339
  const day2 = dayOf2(run2.flags, "day", `the seeded day to ${subcommand}`);
9107
9340
  if (subcommand === "remove") {
9108
- const done2 = AdminDemoRemoveResultSchema.parse(expectOk(await call(run2.api, "POST", path("/demo/remove"), { day: day2 })));
9341
+ const done2 = AdminDemoRemoveResultSchema.parse(expectOk(await call2(run2.api, "POST", path("/demo/remove"), { day: day2 })));
9109
9342
  return render(run2, done2, [`removed ${done2.day}: ${done2.recordings_deleted} recordings, ${done2.entries_deleted} entries`]);
9110
9343
  }
9111
- const done = AdminDemoResetResultSchema.parse(expectOk(await call(run2.api, "POST", path("/demo/reset"), { day: day2, generate: switched(run2.flags, "generate") })));
9344
+ const done = AdminDemoResetResultSchema.parse(expectOk(await call2(run2.api, "POST", path("/demo/reset"), { day: day2, generate: switched(run2.flags, "generate") })));
9112
9345
  return render(run2, done, [
9113
9346
  `reset ${done.day}: ${done.runs_deleted} Generate runs, ${done.drafts_deleted} drafts deleted, ${done.released_kept} released kept`,
9114
9347
  ...done.generate_run === null ? [] : [`generate ${done.generate_run}`]
@@ -9128,7 +9361,7 @@ async function runLearning(run2, subcommand) {
9128
9361
  if (member !== undefined)
9129
9362
  query.set("member", member);
9130
9363
  if (subcommand === "terms") {
9131
- const answer = await call(run2.api, "GET", `${tenantPath(tenant, "/learning/terms")}${query.size === 0 ? "" : `?${query}`}`);
9364
+ const answer = await call2(run2.api, "GET", `${tenantPath(tenant, "/learning/terms")}${query.size === 0 ? "" : `?${query}`}`);
9132
9365
  if (answer.status !== 200)
9133
9366
  return refused(run2, answer, [actingHead(tenant, answer)]);
9134
9367
  const { terms } = AdminLearnedTermsSchema.parse(answer.body);
@@ -9156,7 +9389,7 @@ async function runLearning(run2, subcommand) {
9156
9389
  throw new AdminUsageError(`--${name} is a date, YYYY-MM-DD, got ${JSON.stringify(value)}`);
9157
9390
  query.set(name, value);
9158
9391
  }
9159
- const answer = await call(run2.api, "GET", `${tenantPath(tenant, "/learning/report")}${query.size === 0 ? "" : `?${query}`}`);
9392
+ const answer = await call2(run2.api, "GET", `${tenantPath(tenant, "/learning/report")}${query.size === 0 ? "" : `?${query}`}`);
9160
9393
  if (answer.status !== 200)
9161
9394
  return refused(run2, answer, [actingHead(tenant, answer)]);
9162
9395
  const report = AdminLearningReportSchema.parse(answer.body);
@@ -9241,7 +9474,7 @@ function wantedAlerts() {
9241
9474
  class PosthogError extends Error {
9242
9475
  }
9243
9476
  function client(io, project) {
9244
- const call2 = async (method, path, body) => {
9477
+ const call3 = async (method, path, body) => {
9245
9478
  const response = await io.fetchImpl(`${POSTHOG_API}/api/projects/${encodeURIComponent(project)}${path}`, {
9246
9479
  method,
9247
9480
  headers: { Authorization: `Bearer ${io.posthogKey}`, "Content-Type": "application/json", Accept: "application/json" },
@@ -9253,9 +9486,9 @@ function client(io, project) {
9253
9486
  return text === "" ? null : JSON.parse(text);
9254
9487
  };
9255
9488
  return {
9256
- call: call2,
9489
+ call: call3,
9257
9490
  async list(path) {
9258
- const page = await call2("GET", path);
9491
+ const page = await call3("GET", path);
9259
9492
  return page?.results ?? [];
9260
9493
  }
9261
9494
  };
@@ -9942,7 +10175,7 @@ ${ADMIN_USAGE}`);
9942
10175
  async function runLogin(run2) {
9943
10176
  const { environment, deps } = run2;
9944
10177
  const session = await deviceLogin(deps, environment);
9945
- const probe = await call(run2.api, "GET", "/v1/admin/audit?limit=1").catch((err) => {
10178
+ const probe = await call2(run2.api, "GET", "/v1/admin/audit?limit=1").catch((err) => {
9946
10179
  if (err instanceof AdminUsageError && /is not an operator's/.test(err.message)) {
9947
10180
  deleteSession(deps.configDir, environment.name);
9948
10181
  throw new AdminUsageError(`signed in as ${session.email ?? "unknown address"}, but not to the Sixminute operators organisation, so the ` + `sign-in was not kept. ${signInAgain(environment.name)} and choose "Sixminute operators" on the sign-in screen.`);
@@ -9975,7 +10208,7 @@ async function runFirm(run2, group, subcommand) {
9975
10208
  const name = required(flags, "name", "a firm has a name, and it becomes the WorkOS organisation's");
9976
10209
  const admin2 = required(flags, "admin", "somebody has to be the firm's first admin");
9977
10210
  const role = roleOf(flags, "admin");
9978
- const done = FirmCreateResultSchema.parse(expectOk(await call(api2, "POST", "/v1/admin/firms", { name, admin_email: admin2, role })));
10211
+ const done = FirmCreateResultSchema.parse(expectOk(await call2(api2, "POST", "/v1/admin/firms", { name, admin_email: admin2, role })));
9979
10212
  const { organization, invitation } = done;
9980
10213
  return render(run2, done, [
9981
10214
  `organization ${organization.id} ${organization.name}`,
@@ -9987,14 +10220,14 @@ async function runFirm(run2, group, subcommand) {
9987
10220
  ]);
9988
10221
  }
9989
10222
  if (group === "firm" && subcommand === "list") {
9990
- const { organizations } = FirmListSchema.parse(expectOk(await call(api2, "GET", "/v1/admin/firms")));
10223
+ const { organizations } = FirmListSchema.parse(expectOk(await call2(api2, "GET", "/v1/admin/firms")));
9991
10224
  return render(run2, { organizations }, organizations.length === 0 ? ["no organisations"] : organizations.map((org) => `${org.id} ${org.name}`));
9992
10225
  }
9993
10226
  if (group === "firm" && subcommand === "invite") {
9994
10227
  const organizationId = required(flags, "org", "an invitation names the firm it is to");
9995
10228
  const email = required(flags, "email", "an invitation names the address it goes to");
9996
10229
  const role = roleOf(flags, "member");
9997
- const done = FirmInviteResultSchema.parse(expectOk(await call(api2, "POST", `/v1/admin/firms/${enc2(organizationId)}/invitations`, { email, role })));
10230
+ const done = FirmInviteResultSchema.parse(expectOk(await call2(api2, "POST", `/v1/admin/firms/${enc2(organizationId)}/invitations`, { email, role })));
9998
10231
  const { invitation } = done;
9999
10232
  return render(run2, done, [
10000
10233
  `invitation ${invitation.id} ${invitation.email} ${invitation.role} expires ${invitation.expires_at}`,
@@ -10006,12 +10239,12 @@ async function runFirm(run2, group, subcommand) {
10006
10239
  }
10007
10240
  if (group === "firm" && subcommand === "invitations") {
10008
10241
  const organizationId = required(flags, "org", "the pending invitations of which firm");
10009
- const { invitations } = FirmInvitationsSchema.parse(expectOk(await call(api2, "GET", `/v1/admin/firms/${enc2(organizationId)}/invitations`)));
10242
+ const { invitations } = FirmInvitationsSchema.parse(expectOk(await call2(api2, "GET", `/v1/admin/firms/${enc2(organizationId)}/invitations`)));
10010
10243
  return render(run2, { invitations }, invitations.length === 0 ? ["no pending invitations"] : invitations.map((row) => `${row.id} ${row.email} ${row.role} expires ${row.expires_at}`));
10011
10244
  }
10012
10245
  if (group === "invite" && subcommand === "revoke") {
10013
10246
  const id = required(flags, "id", "which invitation to revoke");
10014
- const done = InvitationRevokedSchema.parse(expectOk(await call(api2, "DELETE", `/v1/admin/invitations/${enc2(id)}`)));
10247
+ const done = InvitationRevokedSchema.parse(expectOk(await call2(api2, "DELETE", `/v1/admin/invitations/${enc2(id)}`)));
10015
10248
  return render(run2, done, [`revoked ${done.invitation.id} ${done.invitation.email}`]);
10016
10249
  }
10017
10250
  throw new AdminUsageError(`unknown command ${JSON.stringify([group, subcommand].filter(Boolean).join(" "))}.
@@ -10019,14 +10252,14 @@ async function runFirm(run2, group, subcommand) {
10019
10252
  ${ADMIN_USAGE}`);
10020
10253
  }
10021
10254
  var tenantPath = (tenant, rest = "") => `/v1/admin/tenants/${enc2(tenant)}${rest}`;
10022
- var firmCall = (run2, tenant, method, path, body) => call(run2.api, method, path, body, tenant);
10255
+ var firmCall = (run2, tenant, method, path, body) => call2(run2.api, method, path, body, tenant);
10023
10256
  async function runTenantList(run2) {
10024
- const { tenants } = AdminTenantListSchema.parse(expectOk(await call(run2.api, "GET", "/v1/admin/tenants")));
10257
+ const { tenants } = AdminTenantListSchema.parse(expectOk(await call2(run2.api, "GET", "/v1/admin/tenants")));
10025
10258
  return render(run2, { tenants }, tenants.length === 0 ? ["no firms"] : tenants.map((t) => `${t.id} ${t.workos_org_id} ${t.security_tier.padEnd(12)} ${t.internal ? "internal " : " "}${t.name}`));
10026
10259
  }
10027
10260
  async function runTenantShow(run2) {
10028
10261
  const tenantId = required(run2.flags, "tenant", "which firm to show");
10029
- const t = AdminTenantDetailSchema.parse(expectOk(await call(run2.api, "GET", tenantPath(tenantId))));
10262
+ const t = AdminTenantDetailSchema.parse(expectOk(await call2(run2.api, "GET", tenantPath(tenantId))));
10030
10263
  return render(run2, { tenant: t }, [
10031
10264
  `tenant ${t.id} ${t.name}`,
10032
10265
  `organization ${t.workos_org_id}`,
@@ -10045,7 +10278,7 @@ async function runTierSet(run2) {
10045
10278
  if (tier !== "standard" && tier !== "confidential") {
10046
10279
  throw new AdminUsageError(`--tier is standard or confidential, got ${JSON.stringify(tier)}`);
10047
10280
  }
10048
- const done = AdminTierResultSchema.parse(expectOk(await call(run2.api, "PUT", tenantPath(tenantId, "/tier"), { tier })));
10281
+ const done = AdminTierResultSchema.parse(expectOk(await call2(run2.api, "PUT", tenantPath(tenantId, "/tier"), { tier })));
10049
10282
  const tenant = { id: done.tenant.id, name: done.tenant.name, security_tier: done.security_tier };
10050
10283
  if (done.security_tier !== "confidential") {
10051
10284
  return render(run2, { tenant }, [`tenant ${tenant.id} ${tenant.name}`, `security_tier ${tenant.security_tier}`]);
@@ -10064,7 +10297,7 @@ async function runTenantInternalSet(run2) {
10064
10297
  const tenantId = required(run2.flags, "tenant", "which tenant is being marked");
10065
10298
  required(run2.flags, "internal", "true or false");
10066
10299
  const internal = booleanOf(run2.flags, "internal");
10067
- const { tenant } = AdminTenantFlagsSchema.parse(expectOk(await call(run2.api, "PUT", tenantPath(tenantId, "/internal"), { internal })));
10300
+ const { tenant } = AdminTenantFlagsSchema.parse(expectOk(await call2(run2.api, "PUT", tenantPath(tenantId, "/internal"), { internal })));
10068
10301
  return render(run2, { tenant }, [
10069
10302
  `tenant ${tenant.id} ${tenant.name}`,
10070
10303
  `internal ${tenant.internal}`,
@@ -10081,7 +10314,7 @@ async function runRawArchive(run2, subcommand) {
10081
10314
  }
10082
10315
  const allow = subcommand === "allow";
10083
10316
  const tenantId = required(run2.flags, "tenant", "which tenant the raw archive is being set for");
10084
- const { tenant } = AdminTenantFlagsSchema.parse(expectOk(await call(run2.api, "PUT", tenantPath(tenantId, "/raw-archive"), { allowed: allow })));
10317
+ const { tenant } = AdminTenantFlagsSchema.parse(expectOk(await call2(run2.api, "PUT", tenantPath(tenantId, "/raw-archive"), { allowed: allow })));
10085
10318
  return render(run2, { tenant: { id: tenant.id, name: tenant.name, raw_archive: tenant.raw_archive } }, [
10086
10319
  `tenant ${tenant.id} ${tenant.name}`,
10087
10320
  `raw_archive ${tenant.raw_archive}`,
@@ -10091,7 +10324,7 @@ async function runRawArchive(run2, subcommand) {
10091
10324
  }
10092
10325
  async function runShadowReport(run2) {
10093
10326
  const day2 = required(run2.flags, "day", "which local day, YYYY-MM-DD");
10094
- const found = ShadowReportSchema.parse(expectOk(await call(run2.api, "GET", `/v1/admin/pipeline/shadow-report?day=${encodeURIComponent(day2)}`)));
10327
+ const found = ShadowReportSchema.parse(expectOk(await call2(run2.api, "GET", `/v1/admin/pipeline/shadow-report?day=${encodeURIComponent(day2)}`)));
10095
10328
  const pct2 = (part, whole) => whole === 0 ? "-" : `${Math.round(100 * part / whole)}%`;
10096
10329
  return render(run2, found, [
10097
10330
  `day ${found.day}`,
@@ -10103,7 +10336,7 @@ async function runRetentionSet(run2) {
10103
10336
  const days2 = Number(required(run2.flags, "days", "how many days after each interval's day its context is kept"));
10104
10337
  if (!Number.isInteger(days2) || days2 < 1 || days2 > 365)
10105
10338
  throw new AdminUsageError("--days is a whole number from 1 to 365.");
10106
- const done = AdminContextRetentionResultSchema.parse(expectOk(await call(run2.api, "PUT", tenantPath(tenantId, "/context-retention"), { days: days2 })));
10339
+ const done = AdminContextRetentionResultSchema.parse(expectOk(await call2(run2.api, "PUT", tenantPath(tenantId, "/context-retention"), { days: days2 })));
10107
10340
  const moved = Object.entries(done.shifted).map(([table2, rows]) => `${table2} ${rows}`).join(", ");
10108
10341
  return render(run2, done, [
10109
10342
  `tenant ${done.tenant.id} ${done.tenant.name}`,
@@ -10122,7 +10355,7 @@ async function runNarrativeInstructions(run2, set) {
10122
10355
  throw new AdminUsageError(`--file ${file} is not readable: ${err.message}`);
10123
10356
  }
10124
10357
  }
10125
- const answer = await call(run2.api, set ? "PUT" : "GET", tenantPath(tenantId, "/narrative-instructions"), body);
10358
+ const answer = await call2(run2.api, set ? "PUT" : "GET", tenantPath(tenantId, "/narrative-instructions"), body);
10126
10359
  if (answer.status !== 200)
10127
10360
  return refused(run2, answer, [actingHead(tenantId, answer)]);
10128
10361
  const done = AdminNarrativeInstructionsSchema.parse(answer.body);
@@ -10138,7 +10371,7 @@ async function runNarrativeActivities(run2, set) {
10138
10371
  const tenantId = required(run2.flags, "tenant", "whose narrative activities");
10139
10372
  const file = set ? required(run2.flags, "file", "the table is a JSON array of rows, by rank, in a file") : optional(run2.flags, "file");
10140
10373
  const body = set ? { activities: readDocument(file, NarrativeActivitiesSchema, "a narrative activity table (a JSON array of rows, by rank)", "file").raw } : undefined;
10141
- const answer = await call(run2.api, set ? "PUT" : "GET", tenantPath(tenantId, "/narrative-activities"), body);
10374
+ const answer = await call2(run2.api, set ? "PUT" : "GET", tenantPath(tenantId, "/narrative-activities"), body);
10142
10375
  if (answer.status !== 200)
10143
10376
  return refused(run2, answer, [actingHead(tenantId, answer)]);
10144
10377
  const done = AdminNarrativeActivitiesSchema.parse(answer.body);
@@ -10156,7 +10389,7 @@ async function runNarrativeActivities(run2, set) {
10156
10389
  var ScrubStartedSchema = exports_external.object({ tenant: exports_external.string(), started: exports_external.number().int().nonnegative() });
10157
10390
  async function runScrubPlaintext(run2) {
10158
10391
  const tenantId = required(run2.flags, "tenant", "whose old rows to scrub");
10159
- const done = ScrubStartedSchema.parse(expectOk(await call(run2.api, "POST", tenantPath(tenantId, "/scrub-plaintext"))));
10392
+ const done = ScrubStartedSchema.parse(expectOk(await call2(run2.api, "POST", tenantPath(tenantId, "/scrub-plaintext"))));
10160
10393
  return render(run2, done, [
10161
10394
  `tenant ${done.tenant}`,
10162
10395
  `started ${done.started} scrub job(s), one per active member`
@@ -10164,7 +10397,7 @@ async function runScrubPlaintext(run2) {
10164
10397
  }
10165
10398
  async function runVersions(run2) {
10166
10399
  const tenantId = required(run2.flags, "tenant", "whose devices");
10167
- const found = AdminDeviceVersionListSchema.parse(expectOk(await call(run2.api, "GET", tenantPath(tenantId, "/devices"))));
10400
+ const found = AdminDeviceVersionListSchema.parse(expectOk(await call2(run2.api, "GET", tenantPath(tenantId, "/devices"))));
10168
10401
  return render(run2, found, [
10169
10402
  `tenant ${tenantId}${found.tenant.internal ? " (internal)" : ""}`,
10170
10403
  ...found.devices.length === 0 ? ["no devices"] : found.devices.map((d) => `${d.id} ${d.version ?? "unknown"} ${d.version_seen_at ?? "never"} ${d.platform} ` + `${d.email ?? "?"} ${d.name}${d.revoked ? " (revoked)" : ""}`)
@@ -10184,7 +10417,7 @@ async function runEntriesPurge(run2) {
10184
10417
  }
10185
10418
  const dryRun = switched(flags, "dry-run");
10186
10419
  const yes = switched(flags, "yes");
10187
- const purge = async (dry) => AdminEntriesPurgeResultSchema.parse(expectOk(await call(run2.api, "POST", tenantPath(tenantId, "/entries/purge"), { author, demo: demo2, unmatched, dry_run: dry })));
10420
+ const purge = async (dry) => AdminEntriesPurgeResultSchema.parse(expectOk(await call2(run2.api, "POST", tenantPath(tenantId, "/entries/purge"), { author, demo: demo2, unmatched, dry_run: dry })));
10188
10421
  const done = await purge(dryRun || !yes);
10189
10422
  const total = done.rows.demo.length + done.rows.unmatched.length;
10190
10423
  const listing = [
@@ -10232,7 +10465,7 @@ async function runAudit(run2) {
10232
10465
  query.set("limit", limit);
10233
10466
  }
10234
10467
  const q = query.toString();
10235
- const { actions } = OperatorAuditListSchema.parse(expectOk(await call(run2.api, "GET", `/v1/admin/audit${q === "" ? "" : `?${q}`}`)));
10468
+ const { actions } = OperatorAuditListSchema.parse(expectOk(await call2(run2.api, "GET", `/v1/admin/audit${q === "" ? "" : `?${q}`}`)));
10236
10469
  return render(run2, { actions }, actions.length === 0 ? ["no operator actions"] : actions.map((a) => `${a.created_at} ${a.status.padEnd(7)} ${String(a.http_status ?? "").padEnd(3)} ${a.action} ` + `${a.operator_email ?? a.operator_sub}${a.tenant_id === null ? "" : ` ${a.tenant_id}`}` + `${a.subject === null ? "" : ` ${a.subject}`}`));
10237
10470
  }
10238
10471
  async function runVocabulary(run2, group, subcommand, action, positionals) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisonlabs/sixminute-admin",
3
- "version": "0.1.1395-next",
3
+ "version": "0.1.1396-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": {