@read-frog/api-contract 0.14.0 → 0.16.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.
Files changed (41) hide show
  1. package/dist/index.d.ts +1186 -481
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +326 -97
  4. package/dist/index.js.map +1 -1
  5. package/package.json +15 -14
  6. package/src/contracts/beta-access.ts +3 -6
  7. package/src/contracts/billing.ts +5 -5
  8. package/src/contracts/card-template.ts +45 -39
  9. package/src/contracts/card.ts +22 -19
  10. package/src/contracts/ebook.ts +13 -11
  11. package/src/contracts/hosted-ai.ts +5 -5
  12. package/src/contracts/mcp-connection.ts +26 -0
  13. package/src/contracts/notebase-column.ts +40 -32
  14. package/src/contracts/notebase-row.ts +85 -45
  15. package/src/contracts/notebase.ts +60 -40
  16. package/src/contracts/shared.ts +21 -2
  17. package/src/contracts/srs.ts +96 -63
  18. package/src/contracts/stats.ts +9 -11
  19. package/src/contracts/user.ts +3 -3
  20. package/src/contracts/video-transcript.ts +22 -12
  21. package/src/index.ts +40 -33
  22. package/src/public-errors.ts +74 -51
  23. package/src/schemas/beta-access.ts +12 -10
  24. package/src/schemas/billing.ts +103 -59
  25. package/src/schemas/card.ts +66 -63
  26. package/src/schemas/ebook.ts +165 -129
  27. package/src/schemas/hosted-ai.ts +84 -74
  28. package/src/schemas/mcp-connection.ts +28 -0
  29. package/src/schemas/notebase-column.ts +50 -36
  30. package/src/schemas/notebase-row.ts +88 -57
  31. package/src/schemas/notebase-stats.ts +28 -20
  32. package/src/schemas/notebase-view.ts +59 -49
  33. package/src/schemas/notebase.ts +136 -96
  34. package/src/schemas/pagination.ts +9 -0
  35. package/src/schemas/resource-mutation.ts +6 -0
  36. package/src/schemas/srs-stats.ts +30 -22
  37. package/src/schemas/srs.ts +152 -106
  38. package/src/schemas/stats.ts +27 -21
  39. package/src/schemas/timezone.ts +19 -16
  40. package/src/schemas/user.ts +27 -19
  41. package/src/schemas/video-transcript.ts +33 -32
package/dist/index.js CHANGED
@@ -261,6 +261,18 @@ const HostedAiQuotaExhaustedDataSchema = z.strictObject({
261
261
  resetAt: z.iso.datetime().nullable()
262
262
  });
263
263
  const PUBLIC_APP_ERROR_DEFS = {
264
+ RESOURCE_UPDATE_CONFLICT: {
265
+ message: "The resource changed. Read it again before updating.",
266
+ status: 409
267
+ },
268
+ RESOURCE_ALREADY_EXISTS: {
269
+ message: "A resource with this ID already exists.",
270
+ status: 409
271
+ },
272
+ FIELD_TYPE_CHANGE_UNSUPPORTED: {
273
+ message: "This operation cannot change the field type.",
274
+ status: 400
275
+ },
264
276
  HOSTED_AI_TIER_RESTRICTED: {
265
277
  data: HostedAiTierRestrictedDataSchema,
266
278
  message: "This Built-in AI tier is not available for this account",
@@ -460,6 +472,30 @@ const billingPlanSchema = z.enum([
460
472
  "pro",
461
473
  "ultra"
462
474
  ]);
475
+ /**
476
+ * Whether a plan may use a feature, given the plans that feature allows.
477
+ *
478
+ * An explicit set rather than a minimum tier: there is no rank table to keep in
479
+ * step with the plan enum, and any combination is expressible by writing it
480
+ * down. The cost is that nothing derives from it automatically -- a feature's
481
+ * pricing-card placement is a companion edit, noted at each `*_ALLOWED_PLANS`.
482
+ */
483
+ function isPlanAllowed(plan, allowed) {
484
+ return allowed.includes(plan);
485
+ }
486
+ /**
487
+ * Plans that may use the remote MCP server.
488
+ *
489
+ * Read by the server-side gate AND by the website's copy, so the page cannot
490
+ * promise access the API refuses. `satisfies` keeps the literal tuple type so
491
+ * the UI can render the plan names from this constant instead of hardcoding
492
+ * them.
493
+ *
494
+ * Companion edit when this changes: the feature bullet in
495
+ * `apps/www/src/routes/pricing.tsx` lives on the lowest allowed plan's card
496
+ * (higher cards inherit it through their "everything in <lower plan>" line).
497
+ */
498
+ const MCP_ALLOWED_PLANS = ["ultra"];
463
499
  const billingCheckoutPlanSchema = z.enum(["pro", "ultra"]);
464
500
  const billingCurrencySchema = z.enum([
465
501
  "usd",
@@ -540,6 +576,42 @@ const billingContract = {
540
576
  }).output(billingCancelScheduledChangeOutputSchema)
541
577
  };
542
578
  //#endregion
579
+ //#region src/contracts/shared.ts
580
+ /**
581
+ * Declares a procedure that is exposed to agents as an MCP tool, not only to
582
+ * the REST/OpenAPI surface.
583
+ *
584
+ * oRPC types `~orpc.route` as the widened `Route`, so `route.summary` reads back
585
+ * as `string | undefined` whatever is passed in. `$meta` is the only channel it
586
+ * keeps generic, so the prose is mirrored there and stays a required `string`
587
+ * for tool definitions. OpenAPI keeps reading `route`.
588
+ */
589
+ function defineAgentProcedure(route) {
590
+ return oc.$meta({
591
+ summary: route.summary,
592
+ description: route.description
593
+ }).route(route);
594
+ }
595
+ //#endregion
596
+ //#region src/schemas/pagination.ts
597
+ const paginationShape = {
598
+ limit: z.number().int().min(1).max(500).optional(),
599
+ offset: z.number().int().min(0).optional()
600
+ };
601
+ function pageSchema(itemSchema) {
602
+ return z.object({
603
+ items: z.array(itemSchema),
604
+ hasMore: z.boolean()
605
+ });
606
+ }
607
+ //#endregion
608
+ //#region src/schemas/resource-mutation.ts
609
+ const expectedUpdatedAtSchema = z.iso.datetime({ offset: true });
610
+ const deletionResultSchema = z.object({
611
+ id: z.uuid(),
612
+ txid: z.number()
613
+ });
614
+ //#endregion
543
615
  //#region src/schemas/card.ts
544
616
  const cardTemplateSchema = z.object({
545
617
  id: z.uuid(),
@@ -549,8 +621,11 @@ const cardTemplateSchema = z.object({
549
621
  createdAt: z.coerce.date(),
550
622
  updatedAt: z.coerce.date()
551
623
  });
552
- const CardTemplateListInputSchema = z.object({ notebaseId: z.uuid() });
553
- const CardTemplateListOutputSchema = z.array(cardTemplateSchema);
624
+ const CardTemplateListInputSchema = z.object({
625
+ ...paginationShape,
626
+ notebaseId: z.uuid().optional()
627
+ });
628
+ const CardTemplateListOutputSchema = pageSchema(cardTemplateSchema);
554
629
  const CardTemplateGetInputSchema = z.object({ id: z.uuid() });
555
630
  const CardTemplateGetOutputSchema = cardTemplateSchema;
556
631
  const CardTemplateCreateInputSchema = z.object({
@@ -561,13 +636,14 @@ const CardTemplateCreateInputSchema = z.object({
561
636
  }).strict();
562
637
  const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({ txid: z.number() });
563
638
  const CardTemplateUpdateInputSchema = z.object({
639
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
564
640
  id: z.uuid(),
565
641
  name: z.string().min(1).optional(),
566
642
  config: cardTemplateConfigSchema.optional()
567
643
  }).strict();
568
644
  const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({ txid: z.number() });
569
645
  const CardTemplateDeleteInputSchema = z.object({ id: z.uuid() });
570
- const CardTemplateDeleteOutputSchema = z.object({ txid: z.number() });
646
+ const CardTemplateDeleteOutputSchema = deletionResultSchema;
571
647
  const cardSchema = z.object({
572
648
  ...cardIdentityShape,
573
649
  ...cardMemoryStateShape,
@@ -579,12 +655,12 @@ const renderedCardSchema = cardSchema.extend({
579
655
  back: z.string()
580
656
  });
581
657
  const CardListInputSchema = z.object({
582
- notebaseId: z.uuid(),
658
+ notebaseId: z.uuid().optional(),
583
659
  templateId: z.uuid().optional(),
584
- limit: z.number().int().min(1).max(500).optional(),
585
- offset: z.number().int().min(0).optional()
660
+ scheduleStatus: scheduleStatusSchema.optional(),
661
+ ...paginationShape
586
662
  });
587
- const CardListOutputSchema = z.array(renderedCardSchema);
663
+ const CardListOutputSchema = pageSchema(renderedCardSchema);
588
664
  const CardGetInputSchema = z.object({ id: z.uuid() });
589
665
  const CardGetOutputSchema = renderedCardSchema;
590
666
  const CardGenerateInputSchema = z.object({
@@ -596,24 +672,23 @@ const CardGenerateOutputSchema = z.object({
596
672
  txid: z.number()
597
673
  });
598
674
  //#endregion
599
- //#region src/contracts/shared.ts
600
- const notebaseProcedure = oc;
601
- //#endregion
602
675
  //#region src/contracts/card.ts
603
676
  const cardContract = {
604
- list: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
677
+ list: defineAgentProcedure({
605
678
  method: "GET",
606
679
  path: "/cards",
607
- summary: "List rendered cards",
680
+ summary: "List cards",
681
+ description: "Browse owned cards with rendered fronts, backs, source IDs and learning state. Optionally filter by notebase, template or scheduleStatus. Supports limit and offset pagination.",
608
682
  tags: ["Cards"]
609
- }).input(CardListInputSchema).output(CardListOutputSchema),
610
- get: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND")).route({
683
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(CardListInputSchema).output(CardListOutputSchema),
684
+ get: defineAgentProcedure({
611
685
  method: "GET",
612
686
  path: "/cards/{id}",
613
- summary: "Get rendered card",
687
+ summary: "Get card",
688
+ description: "Read one owned card with its rendered front, back, source IDs and learning state.",
614
689
  tags: ["Cards"]
615
- }).input(CardGetInputSchema).output(CardGetOutputSchema),
616
- generate: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_NOT_FOUND")).route({
690
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND")).input(CardGetInputSchema).output(CardGetOutputSchema),
691
+ generate: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_NOT_FOUND")).route({
617
692
  method: "POST",
618
693
  path: "/cards/generate",
619
694
  summary: "Generate missing cards",
@@ -623,36 +698,41 @@ const cardContract = {
623
698
  //#endregion
624
699
  //#region src/contracts/card-template.ts
625
700
  const cardTemplateContract = {
626
- list: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
701
+ list: defineAgentProcedure({
627
702
  method: "GET",
628
703
  path: "/card-templates",
629
704
  summary: "List card templates",
705
+ description: "List owned card templates, optionally filtered by notebase. Supports limit and offset pagination.",
630
706
  tags: ["Card Templates"]
631
- }).input(CardTemplateListInputSchema).output(CardTemplateListOutputSchema),
632
- get: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).route({
707
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(CardTemplateListInputSchema).output(CardTemplateListOutputSchema),
708
+ get: defineAgentProcedure({
633
709
  method: "GET",
634
710
  path: "/card-templates/{id}",
635
711
  summary: "Get card template",
712
+ description: "Read the complete definition and updatedAt timestamp of an owned card template.",
636
713
  tags: ["Card Templates"]
637
- }).input(CardTemplateGetInputSchema).output(CardTemplateGetOutputSchema),
638
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).route({
714
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).input(CardTemplateGetInputSchema).output(CardTemplateGetOutputSchema),
715
+ create: defineAgentProcedure({
639
716
  method: "POST",
640
717
  path: "/card-templates",
641
718
  summary: "Create card template",
719
+ description: "Create a template in an owned notebase using existing field IDs in its patterns. This generates cards for existing notes.",
642
720
  tags: ["Card Templates"]
643
- }).input(CardTemplateCreateInputSchema).output(CardTemplateCreateOutputSchema),
644
- update: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).route({
721
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(CardTemplateCreateInputSchema).output(CardTemplateCreateOutputSchema),
722
+ update: defineAgentProcedure({
645
723
  method: "PATCH",
646
724
  path: "/card-templates/{id}",
647
725
  summary: "Update card template",
726
+ description: "Change an owned template name or definition. Rendered cards reflect the saved template. expectedUpdatedAt guards against editing stale data.",
648
727
  tags: ["Card Templates"]
649
- }).input(CardTemplateUpdateInputSchema).output(CardTemplateUpdateOutputSchema),
650
- delete: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).route({
728
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT")).input(CardTemplateUpdateInputSchema).output(CardTemplateUpdateOutputSchema),
729
+ delete: defineAgentProcedure({
651
730
  method: "DELETE",
652
731
  path: "/card-templates/{id}",
653
732
  summary: "Delete card template",
733
+ description: "Permanently delete an owned template and its generated cards and review records. Source notes are preserved.",
654
734
  tags: ["Card Templates"]
655
- }).input(CardTemplateDeleteInputSchema).output(CardTemplateDeleteOutputSchema)
735
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).input(CardTemplateDeleteInputSchema).output(CardTemplateDeleteOutputSchema)
656
736
  };
657
737
  //#endregion
658
738
  //#region src/schemas/ebook.ts
@@ -846,6 +926,43 @@ const hostedAiContract = {
846
926
  }).input(HostedAiNoteSuggestionStreamInputSchema).output(eventIterator(HostedAiStreamPartSchema)).errors(hostedAiStreamErrors) }
847
927
  };
848
928
  //#endregion
929
+ //#region src/schemas/mcp-connection.ts
930
+ const mcpConnectionSchema = z.object({
931
+ /** OAuth client identifier. For a CIMD client this is an https URL. */
932
+ clientId: z.string(),
933
+ /** The client's registered display name, absent when it never gave one. */
934
+ clientName: z.string().nullable(),
935
+ scopes: z.array(z.string()),
936
+ requestedUserInfoClaims: z.array(z.string()),
937
+ grantedAt: z.date().nullable(),
938
+ updatedAt: z.date().nullable(),
939
+ /**
940
+ * When this client last obtained an access token — the closest honest
941
+ * proxy for "last used" the OAuth tables record. A token is issued on
942
+ * connect and on every refresh, so an idle client's value stops advancing.
943
+ */
944
+ lastAuthorizedAt: z.date().nullable()
945
+ }).strict();
946
+ const mcpConnectionListOutputSchema = z.array(mcpConnectionSchema);
947
+ const mcpConnectionRevokeInputSchema = z.object({ clientId: z.string().min(1) }).strict();
948
+ const mcpConnectionRevokeOutputSchema = z.object({ clientId: z.string() }).strict();
949
+ //#endregion
950
+ //#region src/contracts/mcp-connection.ts
951
+ const mcpConnectionContract = {
952
+ list: oc.route({
953
+ method: "GET",
954
+ path: "/mcp-connections",
955
+ summary: "List the OAuth clients the caller has authorized",
956
+ tags: ["MCP Connections"]
957
+ }).output(mcpConnectionListOutputSchema),
958
+ revoke: oc.route({
959
+ method: "POST",
960
+ path: "/mcp-connections/revoke",
961
+ summary: "Withdraw a client's authorization and revoke its tokens",
962
+ tags: ["MCP Connections"]
963
+ }).input(mcpConnectionRevokeInputSchema).output(mcpConnectionRevokeOutputSchema)
964
+ };
965
+ //#endregion
849
966
  //#region src/schemas/notebase-column.ts
850
967
  const notebaseColumnWidthSchema = z.number().int().min(NOTEBASE_COLUMN_MIN_WIDTH).max(NOTEBASE_COLUMN_MAX_WIDTH);
851
968
  const notebaseColumnSchema = z.object({
@@ -866,6 +983,7 @@ const notebaseColumnCreateDataSchema = z.object({
866
983
  config: notebaseColumnConfigSchema
867
984
  }).strict();
868
985
  const notebaseColumnUpdateDataSchema = z.object({
986
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
869
987
  name: z.string().min(1).optional(),
870
988
  config: notebaseColumnConfigSchema.optional(),
871
989
  width: notebaseColumnWidthSchema.nullable().optional(),
@@ -875,14 +993,20 @@ const NotebaseColumnCreateInputSchema = z.object({
875
993
  notebaseId: z.uuid(),
876
994
  data: notebaseColumnCreateDataSchema
877
995
  });
878
- const NotebaseColumnCreateOutputSchema = z.object({ txid: z.number() });
996
+ const NotebaseColumnCreateOutputSchema = z.object({
997
+ field: notebaseColumnSchema,
998
+ txid: z.number()
999
+ });
879
1000
  const NotebaseColumnUpdateInputSchema = z.object({
880
1001
  notebaseColumnId: z.uuid(),
881
1002
  data: notebaseColumnUpdateDataSchema
882
1003
  });
883
- const NotebaseColumnUpdateOutputSchema = z.object({ txid: z.number() });
1004
+ const NotebaseColumnUpdateOutputSchema = z.object({
1005
+ field: notebaseColumnSchema,
1006
+ txid: z.number()
1007
+ });
884
1008
  const NotebaseColumnDeleteInputSchema = z.object({ notebaseColumnId: z.uuid() });
885
- const NotebaseColumnDeleteOutputSchema = z.object({ txid: z.number() });
1009
+ const NotebaseColumnDeleteOutputSchema = deletionResultSchema;
886
1010
  const NotebaseColumnReorderInputSchema = z.object({
887
1011
  notebaseId: z.uuid(),
888
1012
  ids: z.array(z.uuid())
@@ -903,12 +1027,18 @@ const notebaseRowCreateDataSchema = z.object({
903
1027
  id: z.uuid().optional(),
904
1028
  cells: notebaseRowCellsSchema.optional()
905
1029
  }).strict();
906
- const notebaseRowUpdateDataSchema = z.object({ cells: notebaseRowCellsSchema.optional() }).strict();
1030
+ const notebaseRowUpdateDataSchema = z.object({
1031
+ cells: notebaseRowCellsSchema.optional(),
1032
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
1033
+ }).strict();
907
1034
  const NotebaseRowCreateInputSchema = z.object({
908
1035
  notebaseId: z.uuid(),
909
1036
  data: notebaseRowCreateDataSchema
910
1037
  });
911
- const NotebaseRowCreateOutputSchema = z.object({ txid: z.number() });
1038
+ const NotebaseRowCreateOutputSchema = z.object({
1039
+ note: notebaseRowSchema,
1040
+ txid: z.number()
1041
+ });
912
1042
  const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50;
913
1043
  const NotebaseRowCreateManyInputSchema = z.object({
914
1044
  notebaseId: z.uuid(),
@@ -932,7 +1062,10 @@ const NotebaseRowCreateManyInputSchema = z.object({
932
1062
  seenIds.add(row.id);
933
1063
  });
934
1064
  });
935
- const NotebaseRowCreateManyOutputSchema = z.object({ txid: z.number() });
1065
+ const NotebaseRowCreateManyOutputSchema = z.object({
1066
+ items: z.array(notebaseRowSchema),
1067
+ txid: z.number()
1068
+ });
936
1069
  const NotebaseRowUpdateInputSchema = z.object({
937
1070
  notebaseRowId: z.uuid(),
938
1071
  data: notebaseRowUpdateDataSchema
@@ -947,12 +1080,23 @@ const NotebaseRowUpdateOutputSchema = z.object({
947
1080
  txid: z.number()
948
1081
  });
949
1082
  const NotebaseRowDeleteInputSchema = z.object({ notebaseRowId: z.uuid() });
950
- const NotebaseRowDeleteOutputSchema = z.object({ txid: z.number() });
1083
+ const NotebaseRowDeleteOutputSchema = deletionResultSchema;
951
1084
  const NotebaseRowReorderInputSchema = z.object({
952
1085
  notebaseId: z.uuid(),
953
1086
  ids: z.array(z.uuid())
954
1087
  });
955
1088
  const NotebaseRowReorderOutputSchema = z.object({ txid: z.number() });
1089
+ const NotebaseRowListInputSchema = z.object({
1090
+ notebaseId: z.uuid().optional(),
1091
+ query: z.string().trim().min(2).max(200).optional(),
1092
+ ...paginationShape
1093
+ }).refine((input) => input.query === void 0 || input.notebaseId !== void 0, {
1094
+ error: "notebaseId is required when query is set",
1095
+ path: ["notebaseId"]
1096
+ });
1097
+ const NotebaseRowListOutputSchema = pageSchema(notebaseRowSchema);
1098
+ const NotebaseRowGetInputSchema = z.object({ id: z.uuid() });
1099
+ const NotebaseRowGetOutputSchema = notebaseRowSchema;
956
1100
  //#endregion
957
1101
  //#region src/schemas/notebase-view.ts
958
1102
  const notebaseViewTypeSchema = z.enum([
@@ -1006,10 +1150,11 @@ const notebaseViewSchema = z.object({
1006
1150
  //#endregion
1007
1151
  //#region src/schemas/notebase.ts
1008
1152
  const NotebaseListInputSchema = z.object({});
1009
- const NotebaseListItemSchema = z.object({
1153
+ const notebaseSummarySchema = z.object({
1010
1154
  id: z.string(),
1011
1155
  name: z.string()
1012
1156
  });
1157
+ const NotebaseListItemSchema = notebaseSummarySchema;
1013
1158
  const NotebaseListOutputSchema = z.array(NotebaseListItemSchema);
1014
1159
  const notebaseSchema = z.object({
1015
1160
  id: z.string(),
@@ -1070,7 +1215,10 @@ const notebaseCreateDataSchema = z.object({
1070
1215
  }).optional()
1071
1216
  }).strict();
1072
1217
  const NotebaseCreateInputSchema = notebaseCreateDataSchema;
1073
- const NotebaseCreateOutputSchema = z.object({ txid: z.number() });
1218
+ const NotebaseCreateOutputSchema = z.object({
1219
+ notebase: notebaseSchema,
1220
+ txid: z.number()
1221
+ });
1074
1222
  const notebaseUpdateDataSchema = z.object({
1075
1223
  name: z.string().min(1).optional(),
1076
1224
  srsNewPerDay: schedulingParamsShape.newPerDay.optional(),
@@ -1078,10 +1226,19 @@ const notebaseUpdateDataSchema = z.object({
1078
1226
  srsDesiredRetention: schedulingParamsShape.desiredRetention.optional()
1079
1227
  }).strict();
1080
1228
  const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({ id: z.uuid() });
1081
- const NotebaseUpdateOutputSchema = z.object({ txid: z.number() });
1229
+ const NotebaseUpdateOutputSchema = z.object({
1230
+ notebase: notebaseSchema,
1231
+ txid: z.number()
1232
+ });
1082
1233
  const NotebaseDeleteInputSchema = z.object({ id: z.uuid() });
1083
- const NotebaseDeleteOutputSchema = z.object({ txid: z.number() });
1234
+ const NotebaseDeleteOutputSchema = deletionResultSchema;
1084
1235
  const NotebaseGetInputSchema = z.object({ id: z.uuid() });
1236
+ const NotebaseGetSummaryInputSchema = z.object({ id: z.uuid() });
1237
+ const NotebaseGetSummaryOutputSchema = notebaseSummarySchema.extend({
1238
+ srsNewPerDay: schedulingParamsShape.newPerDay,
1239
+ srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,
1240
+ srsDesiredRetention: schedulingParamsShape.desiredRetention
1241
+ });
1085
1242
  const NotebaseGetSchemaInputSchema = z.object({ id: z.uuid() });
1086
1243
  const NotebaseGetOutputSchema = notebaseSchema.extend({
1087
1244
  createdAt: z.coerce.date(),
@@ -1099,65 +1256,80 @@ const NotebaseGetSchemaOutputSchema = z.object({
1099
1256
  //#endregion
1100
1257
  //#region src/contracts/notebase.ts
1101
1258
  const notebaseContract = {
1102
- list: notebaseProcedure.route({
1259
+ list: defineAgentProcedure({
1103
1260
  method: "GET",
1104
1261
  path: "/notebases",
1105
1262
  summary: "List notebases",
1263
+ description: "List the notebases (word books) owned by the current user.",
1106
1264
  tags: ["Notebases"]
1107
1265
  }).input(NotebaseListInputSchema).output(NotebaseListOutputSchema),
1108
- get: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1266
+ getSummary: defineAgentProcedure({
1267
+ method: "GET",
1268
+ path: "/notebases/{id}/summary",
1269
+ summary: "Get notebase summary",
1270
+ description: "Read the name and public study settings of an owned notebase without loading note content.",
1271
+ tags: ["Notebases"]
1272
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseGetSummaryInputSchema).output(NotebaseGetSummaryOutputSchema),
1273
+ get: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1109
1274
  method: "GET",
1110
1275
  path: "/notebases/{id}",
1111
1276
  summary: "Get notebase with notebase columns, rows, and views",
1112
1277
  tags: ["Notebases"]
1113
1278
  }).input(NotebaseGetInputSchema).output(NotebaseGetOutputSchema),
1114
- getSchema: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1279
+ getSchema: defineAgentProcedure({
1115
1280
  method: "GET",
1116
1281
  path: "/notebases/{id}/schema",
1117
1282
  summary: "Get notebase schema",
1283
+ description: "Read an owned notebase name and field definitions, including field IDs, types and updatedAt timestamps. Does not return note content.",
1118
1284
  tags: ["Notebases"]
1119
- }).input(NotebaseGetSchemaInputSchema).output(NotebaseGetSchemaOutputSchema),
1120
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTE_LIMIT_EXCEEDED", "CELL_VALIDATION_FAILED")).route({
1285
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseGetSchemaInputSchema).output(NotebaseGetSchemaOutputSchema),
1286
+ create: defineAgentProcedure({
1121
1287
  method: "POST",
1122
1288
  path: "/notebases",
1123
1289
  summary: "Create notebase",
1290
+ description: "Create an owned notebase with optional initial fields and notes. Client-provided entity IDs are supported; duplicate IDs produce a conflict.",
1124
1291
  tags: ["Notebases"]
1125
- }).input(NotebaseCreateInputSchema).output(NotebaseCreateOutputSchema),
1126
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1292
+ }).errors(pickPublicErrorMap("NOTE_LIMIT_EXCEEDED", "CELL_VALIDATION_FAILED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseCreateInputSchema).output(NotebaseCreateOutputSchema),
1293
+ update: defineAgentProcedure({
1127
1294
  method: "PUT",
1128
1295
  path: "/notebases/{id}",
1129
1296
  summary: "Update notebase",
1297
+ description: "Update the supplied name or public study settings of an owned notebase, preserving omitted properties.",
1130
1298
  tags: ["Notebases"]
1131
- }).input(NotebaseUpdateInputSchema).output(NotebaseUpdateOutputSchema),
1132
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1299
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseUpdateInputSchema).output(NotebaseUpdateOutputSchema),
1300
+ delete: defineAgentProcedure({
1133
1301
  method: "DELETE",
1134
1302
  path: "/notebases/{id}",
1135
1303
  summary: "Delete notebase",
1304
+ description: "Permanently delete an owned notebase and its fields, notes, templates, cards and review records. Return the deleted notebase ID.",
1136
1305
  tags: ["Notebases"]
1137
- }).input(NotebaseDeleteInputSchema).output(NotebaseDeleteOutputSchema)
1306
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseDeleteInputSchema).output(NotebaseDeleteOutputSchema)
1138
1307
  };
1139
1308
  //#endregion
1140
1309
  //#region src/contracts/notebase-column.ts
1141
1310
  const notebaseColumnContract = {
1142
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1311
+ create: defineAgentProcedure({
1143
1312
  method: "POST",
1144
1313
  path: "/notebase-columns",
1145
- summary: "Create notebase column",
1314
+ summary: "Create notebase field",
1315
+ description: "Create a field in an owned notebase. The returned field ID is used as a key in note cells.",
1146
1316
  tags: ["Notebase Columns"]
1147
- }).input(NotebaseColumnCreateInputSchema).output(NotebaseColumnCreateOutputSchema),
1148
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND")).route({
1317
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseColumnCreateInputSchema).output(NotebaseColumnCreateOutputSchema),
1318
+ update: defineAgentProcedure({
1149
1319
  method: "PATCH",
1150
1320
  path: "/notebase-columns/{notebaseColumnId}",
1151
- summary: "Update notebase column",
1321
+ summary: "Update notebase field",
1322
+ description: "Update an owned field without changing its type. Removing select options clears affected note values. expectedUpdatedAt guards against editing stale data.",
1152
1323
  tags: ["Notebase Columns"]
1153
- }).input(NotebaseColumnUpdateInputSchema).output(NotebaseColumnUpdateOutputSchema),
1154
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND", "PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED", "CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE", "CONCURRENT_POSITION_CONFLICT")).route({
1324
+ }).errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT", "FIELD_TYPE_CHANGE_UNSUPPORTED")).input(NotebaseColumnUpdateInputSchema).output(NotebaseColumnUpdateOutputSchema),
1325
+ delete: defineAgentProcedure({
1155
1326
  method: "DELETE",
1156
1327
  path: "/notebase-columns/{notebaseColumnId}",
1157
- summary: "Delete notebase column",
1328
+ summary: "Delete notebase field",
1329
+ description: "Delete an owned field and remove its values from notes. Primary fields and fields referenced by templates cannot be deleted.",
1158
1330
  tags: ["Notebase Columns"]
1159
- }).input(NotebaseColumnDeleteInputSchema).output(NotebaseColumnDeleteOutputSchema),
1160
- reorder: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1331
+ }).errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND", "PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED", "CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE", "CONCURRENT_POSITION_CONFLICT")).input(NotebaseColumnDeleteInputSchema).output(NotebaseColumnDeleteOutputSchema),
1332
+ reorder: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1161
1333
  method: "POST",
1162
1334
  path: "/notebase-columns/reorder",
1163
1335
  summary: "Reorder notebase columns",
@@ -1167,31 +1339,49 @@ const notebaseColumnContract = {
1167
1339
  //#endregion
1168
1340
  //#region src/contracts/notebase-row.ts
1169
1341
  const notebaseRowContract = {
1170
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).route({
1342
+ list: defineAgentProcedure({
1343
+ method: "GET",
1344
+ path: "/notebase-rows",
1345
+ summary: "List or search notes",
1346
+ description: "List or search owned notes, optionally within one notebase. Supply query to search; omit it to browse, which returns every note in scope rather than a filtered set. Searching requires notebaseId and covers that one notebase, so cover several by listing them first and calling this once per notebase. The query filter is at least two characters, matches a literal case-insensitive substring, and only searches fields of type string, so values in number, boolean, date and select fields are never matched. Supports limit and offset pagination.",
1347
+ tags: ["Notebase Rows"]
1348
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseRowListInputSchema).output(NotebaseRowListOutputSchema),
1349
+ get: defineAgentProcedure({
1350
+ method: "GET",
1351
+ path: "/notebase-rows/{id}",
1352
+ summary: "Get note",
1353
+ description: "Read one owned note with field-ID values and the updatedAt timestamp used for modification checks.",
1354
+ tags: ["Notebase Rows"]
1355
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND")).input(NotebaseRowGetInputSchema).output(NotebaseRowGetOutputSchema),
1356
+ create: defineAgentProcedure({
1171
1357
  method: "POST",
1172
1358
  path: "/notebase-rows",
1173
- summary: "Create notebase row",
1359
+ summary: "Create note",
1360
+ description: "Create a note in an owned notebase using field IDs and their declared value types. Existing templates generate cards. A duplicate entity ID produces a conflict.",
1174
1361
  tags: ["Notebase Rows"]
1175
- }).input(NotebaseRowCreateInputSchema).output(NotebaseRowCreateOutputSchema),
1176
- createMany: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).route({
1362
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseRowCreateInputSchema).output(NotebaseRowCreateOutputSchema),
1363
+ createMany: defineAgentProcedure({
1177
1364
  method: "POST",
1178
1365
  path: "/notebase-rows/batch",
1179
- summary: "Create notebase rows in a single transaction",
1366
+ summary: "Create notes",
1367
+ description: "Create 1–50 notes atomically in one owned notebase. Cells use field IDs and declared value types. Existing templates generate cards. Duplicate entity IDs roll back the whole batch.",
1180
1368
  tags: ["Notebase Rows"]
1181
- }).input(NotebaseRowCreateManyInputSchema).output(NotebaseRowCreateManyOutputSchema),
1182
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CELL_VALIDATION_FAILED")).route({
1369
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseRowCreateManyInputSchema).output(NotebaseRowCreateManyOutputSchema),
1370
+ update: defineAgentProcedure({
1183
1371
  method: "PATCH",
1184
1372
  path: "/notebase-rows/{notebaseRowId}",
1185
- summary: "Update notebase row cells",
1373
+ summary: "Update note",
1374
+ description: "Merge supplied fields into an owned note, preserving omitted fields. Use null to clear a field. expectedUpdatedAt guards against editing stale data; reread on a modification conflict.",
1186
1375
  tags: ["Notebase Rows"]
1187
- }).input(NotebaseRowUpdateInputSchema).output(NotebaseRowUpdateOutputSchema),
1188
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1376
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CELL_VALIDATION_FAILED")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT")).input(NotebaseRowUpdateInputSchema).output(NotebaseRowUpdateOutputSchema),
1377
+ delete: defineAgentProcedure({
1189
1378
  method: "DELETE",
1190
1379
  path: "/notebase-rows/{notebaseRowId}",
1191
- summary: "Delete notebase row",
1380
+ summary: "Delete note",
1381
+ description: "Permanently delete an owned note and its derived cards and review records. Return the deleted note ID.",
1192
1382
  tags: ["Notebase Rows"]
1193
- }).input(NotebaseRowDeleteInputSchema).output(NotebaseRowDeleteOutputSchema),
1194
- reorder: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1383
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).input(NotebaseRowDeleteInputSchema).output(NotebaseRowDeleteOutputSchema),
1384
+ reorder: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1195
1385
  method: "POST",
1196
1386
  path: "/notebase-rows/reorder",
1197
1387
  summary: "Reorder notebase rows",
@@ -1233,7 +1423,10 @@ const srsReviewInputSchema = z.object({
1233
1423
  durationMs: z.number().int().min(0).max(SRS_REVIEW_DURATION_MS_MAX),
1234
1424
  timezone: timezoneSchema
1235
1425
  }).strict();
1236
- const srsRollbackReviewInputSchema = z.object({ cardId: z.uuid() }).strict();
1426
+ const srsRollbackReviewInputSchema = z.object({
1427
+ expectedReviewId: z.uuid().optional(),
1428
+ cardId: z.uuid()
1429
+ }).strict();
1237
1430
  const srsScheduleStatusStatsSchema = z.record(activeScheduleStatusSchema, z.number().int().min(0));
1238
1431
  const srsScheduleStatusStatsInputSchema = z.object({
1239
1432
  notebaseIds: z.array(z.uuid()).optional(),
@@ -1261,8 +1454,15 @@ const srsRevlogSchema = z.object({
1261
1454
  createdAt: z.coerce.date()
1262
1455
  });
1263
1456
  const srsRevlogWithoutSnapshotSchema = srsRevlogSchema.omit({ fsrsReviewLogSnapshot: true });
1264
- const srsListCardRevlogsInputSchema = z.object({ cardId: z.uuid() }).strict();
1265
- const srsListCardRevlogsOutputSchema = z.object({ items: z.array(srsRevlogWithoutSnapshotSchema) }).strict();
1457
+ const srsListCardRevlogsInputSchema = z.object({
1458
+ ...paginationShape,
1459
+ notebaseId: z.uuid().optional(),
1460
+ cardId: z.uuid().optional()
1461
+ }).strict();
1462
+ const srsListCardRevlogsOutputSchema = z.object({
1463
+ items: z.array(srsRevlogWithoutSnapshotSchema),
1464
+ hasMore: z.boolean()
1465
+ }).strict();
1266
1466
  const srsReviewOutputSchema = z.object({
1267
1467
  card: cardSchema,
1268
1468
  revlog: srsRevlogSchema,
@@ -1277,6 +1477,16 @@ const srsRollbackReviewOutputSchema = z.object({
1277
1477
  const srsTxidOutputSchema = z.object({ txid: z.number() });
1278
1478
  const srsSetCardBuriedOutputSchema = srsTxidOutputSchema;
1279
1479
  const srsSetCardSuspendedOutputSchema = srsTxidOutputSchema;
1480
+ const srsListUnreadOptimizerResultsInputSchema = z.object({}).strict();
1481
+ const srsOptimizerUnreadResultSchema = z.object({
1482
+ runId: z.uuid(),
1483
+ notebaseName: z.string().min(1),
1484
+ revlogCount: z.number().int().positive(),
1485
+ improvement: z.number().nonnegative().nullable()
1486
+ }).strict();
1487
+ const srsListUnreadOptimizerResultsOutputSchema = z.array(srsOptimizerUnreadResultSchema);
1488
+ const srsAcknowledgeOptimizerResultsInputSchema = z.object({ runIds: z.array(z.uuid()).min(1) }).strict();
1489
+ const srsAcknowledgeOptimizerResultsOutputSchema = z.object({ acknowledgedCount: z.number().int().nonnegative() }).strict();
1280
1490
  function formatLastReviewTime(lastReviewTime) {
1281
1491
  return lastReviewTime ? new Date(lastReviewTime).toISOString() : nullLastReviewTimeSentinel;
1282
1492
  }
@@ -1313,42 +1523,60 @@ function bytesToUuid(bytes) {
1313
1523
  //#endregion
1314
1524
  //#region src/contracts/srs.ts
1315
1525
  const srsContract = {
1316
- scheduleStatusStats: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1526
+ scheduleStatusStats: defineAgentProcedure({
1317
1527
  method: "GET",
1318
1528
  path: "/srs/schedule-status-stats",
1319
- summary: "List today schedule status stats for notebases",
1529
+ summary: "Get study statistics",
1530
+ description: "Read existing study queue counts for owned notebases in the supplied timezone. Does not return note content or card faces.",
1531
+ tags: ["SRS"]
1532
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(srsScheduleStatusStatsInputSchema).output(srsScheduleStatusStatsOutputSchema),
1533
+ listUnreadOptimizerResults: oc.route({
1534
+ method: "GET",
1535
+ path: "/srs/optimizer-results/unread",
1536
+ summary: "List unread applied SRS optimizer results",
1537
+ tags: ["SRS"]
1538
+ }).input(srsListUnreadOptimizerResultsInputSchema).output(srsListUnreadOptimizerResultsOutputSchema),
1539
+ acknowledgeOptimizerResults: oc.route({
1540
+ method: "POST",
1541
+ path: "/srs/optimizer-results/acknowledge",
1542
+ summary: "Acknowledge current SRS optimizer results",
1320
1543
  tags: ["SRS"]
1321
- }).input(srsScheduleStatusStatsInputSchema).output(srsScheduleStatusStatsOutputSchema),
1322
- listCardRevlogs: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND")).route({
1544
+ }).input(srsAcknowledgeOptimizerResultsInputSchema).output(srsAcknowledgeOptimizerResultsOutputSchema),
1545
+ listCardRevlogs: defineAgentProcedure({
1323
1546
  method: "GET",
1324
- path: "/srs/cards/{cardId}/revlogs",
1325
- summary: "List complete review history for a card",
1547
+ path: "/srs/revlogs",
1548
+ summary: "List review history",
1549
+ description: "Read owned review records, optionally filtered by notebase or card. Supports limit and offset pagination. Note content, card faces and rollback snapshots are excluded.",
1326
1550
  tags: ["SRS"]
1327
- }).input(srsListCardRevlogsInputSchema).output(srsListCardRevlogsOutputSchema),
1328
- review: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_NOT_REVIEWABLE", "CARD_REVIEW_STATE_STALE")).route({
1551
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "NOTEBASE_NOT_FOUND")).input(srsListCardRevlogsInputSchema).output(srsListCardRevlogsOutputSchema),
1552
+ review: defineAgentProcedure({
1329
1553
  method: "POST",
1330
1554
  path: "/srs/review",
1331
- summary: "Review a card with SRS scheduling",
1555
+ summary: "Record review",
1556
+ description: "Submit one rating for a known owned card without a queue, session or prerequisite read. Existing SRS eligibility, scheduling and sibling rules apply. The optional id is the existing state-derived review ID, not an arbitrary UUID; calls without a stable id are not guaranteed to deduplicate.",
1332
1557
  tags: ["SRS"]
1333
- }).input(srsReviewInputSchema).output(srsReviewOutputSchema),
1334
- rollbackReview: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_REVIEW_ROLLBACK_UNAVAILABLE")).route({
1558
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_NOT_REVIEWABLE", "CARD_REVIEW_STATE_STALE")).input(srsReviewInputSchema).output(srsReviewOutputSchema),
1559
+ rollbackReview: defineAgentProcedure({
1335
1560
  method: "POST",
1336
1561
  path: "/srs/review/rollback",
1337
- summary: "Roll back the latest SRS review for a card",
1562
+ summary: "Undo review",
1563
+ description: "Undo the latest eligible review of one owned card, preserving existing SRS restrictions and sibling restoration. expectedReviewId guards against undoing an earlier review on a retry.",
1338
1564
  tags: ["SRS"]
1339
- }).input(srsRollbackReviewInputSchema).output(srsRollbackReviewOutputSchema),
1340
- setCardBuried: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_BURIED", "CARD_NOT_BURIED", "CARD_STATUS_CHANGE_UNAVAILABLE")).route({
1565
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_REVIEW_ROLLBACK_UNAVAILABLE", "CARD_REVIEW_STATE_STALE")).input(srsRollbackReviewInputSchema).output(srsRollbackReviewOutputSchema),
1566
+ setCardBuried: defineAgentProcedure({
1341
1567
  method: "POST",
1342
1568
  path: "/srs/card/bury",
1343
- summary: "Manually bury or unbury a card",
1569
+ summary: "Set card buried",
1570
+ description: "Bury or unbury one owned card. enabled=true buries and enabled=false unburies it. Existing state-change rules apply.",
1344
1571
  tags: ["SRS"]
1345
- }).input(srsSetCardBuriedInputSchema).output(srsSetCardBuriedOutputSchema),
1346
- setCardSuspended: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_SUSPENDED", "CARD_NOT_SUSPENDED", "CARD_STATUS_CHANGE_UNAVAILABLE")).route({
1572
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_BURIED", "CARD_NOT_BURIED", "CARD_STATUS_CHANGE_UNAVAILABLE")).input(srsSetCardBuriedInputSchema).output(srsSetCardBuriedOutputSchema),
1573
+ setCardSuspended: defineAgentProcedure({
1347
1574
  method: "POST",
1348
1575
  path: "/srs/card/suspend",
1349
- summary: "Manually suspend or unsuspend a card",
1576
+ summary: "Set card suspended",
1577
+ description: "Suspend or resume one owned card. enabled=true suspends and enabled=false resumes it. Existing state-change rules apply.",
1350
1578
  tags: ["SRS"]
1351
- }).input(srsSetCardSuspendedInputSchema).output(srsSetCardSuspendedOutputSchema)
1579
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_SUSPENDED", "CARD_NOT_SUSPENDED", "CARD_STATUS_CHANGE_UNAVAILABLE")).input(srsSetCardSuspendedInputSchema).output(srsSetCardSuspendedOutputSchema)
1352
1580
  };
1353
1581
  //#endregion
1354
1582
  //#region src/schemas/notebase-stats.ts
@@ -1403,19 +1631,19 @@ const activityStatsOutputSchema = z.object({
1403
1631
  //#endregion
1404
1632
  //#region src/contracts/stats.ts
1405
1633
  const statsContract = {
1406
- activity: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1634
+ activity: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1407
1635
  method: "GET",
1408
1636
  path: "/stats/activity",
1409
1637
  summary: "Get SRS and notebase activity statistics",
1410
1638
  tags: ["Statistics"]
1411
1639
  }).input(statsInputSchema).output(activityStatsOutputSchema),
1412
- srsMemoryGrowth: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1640
+ srsMemoryGrowth: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1413
1641
  method: "GET",
1414
1642
  path: "/srs/stats/memory-growth",
1415
1643
  summary: "Get SRS long-term memory growth statistics",
1416
1644
  tags: ["Statistics"]
1417
1645
  }).input(statsInputSchema).output(srsMemoryGrowthStatsOutputSchema),
1418
- notebaseRowGrowth: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1646
+ notebaseRowGrowth: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1419
1647
  method: "GET",
1420
1648
  path: "/notebases/stats/row-growth",
1421
1649
  summary: "Get notebase row growth statistics",
@@ -1502,6 +1730,7 @@ const contract = {
1502
1730
  cardTemplate: cardTemplateContract,
1503
1731
  ebook: ebookContract,
1504
1732
  hostedAi: hostedAiContract,
1733
+ mcpConnection: mcpConnectionContract,
1505
1734
  notebase: notebaseContract,
1506
1735
  notebaseColumn: notebaseColumnContract,
1507
1736
  notebaseRow: notebaseRowContract,
@@ -1536,6 +1765,6 @@ const contract = {
1536
1765
  }
1537
1766
  };
1538
1767
  //#endregion
1539
- export { BetaAccessStatusInputSchema, BetaAccessStatusOutputSchema, BetaFeatureKeySchema, CardGenerateInputSchema, CardGenerateOutputSchema, CardGetInputSchema, CardGetOutputSchema, CardListInputSchema, CardListOutputSchema, CardTemplateCreateInputSchema, CardTemplateCreateOutputSchema, CardTemplateDeleteInputSchema, CardTemplateDeleteOutputSchema, CardTemplateGetInputSchema, CardTemplateGetOutputSchema, CardTemplateInvalidColumnsDataSchema, CardTemplateListInputSchema, CardTemplateListOutputSchema, CardTemplateUpdateInputSchema, CardTemplateUpdateOutputSchema, CellValidationFailedDataSchema, CellValidationFailureDetailsSchema, CellValidationFailureReasonSchema, HOSTED_AI_CLIENT_STREAM_PART_TYPES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiCreditPeriodKindSchema, HostedAiCreditPolicyIdSchema, HostedAiCreditStatusSchema, HostedAiFeatureSchema, HostedAiFeatureStatusSchema, HostedAiModelTierSchema, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiQuotaExhaustedDataSchema, HostedAiQuotaScopeSchema, HostedAiRateLimitErrorDataSchema, HostedAiRequestIdSchema, HostedAiStatusInputSchema, HostedAiStatusOutputSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, HostedAiTierRestrictedDataSchema, HostedAiTierStatusSchema, HostedAiUnavailableReasonSchema, NOTEBASE_ROW_CREATE_MANY_MAX_ROWS, NotebaseColumnCreateInputSchema, NotebaseColumnCreateOutputSchema, NotebaseColumnDeleteInputSchema, NotebaseColumnDeleteOutputSchema, NotebaseColumnReorderInputSchema, NotebaseColumnReorderOutputSchema, NotebaseColumnUpdateInputSchema, NotebaseColumnUpdateOutputSchema, NotebaseCreateInputSchema, NotebaseCreateOutputSchema, NotebaseDeleteInputSchema, NotebaseDeleteOutputSchema, NotebaseGetInputSchema, NotebaseGetOutputSchema, NotebaseGetSchemaInputSchema, NotebaseGetSchemaOutputSchema, NotebaseListInputSchema, NotebaseListItemSchema, NotebaseListOutputSchema, NotebaseRowCreateInputSchema, NotebaseRowCreateManyInputSchema, NotebaseRowCreateManyOutputSchema, NotebaseRowCreateOutputSchema, NotebaseRowDeleteInputSchema, NotebaseRowDeleteOutputSchema, NotebaseRowReorderInputSchema, NotebaseRowReorderOutputSchema, NotebaseRowUpdateInputSchema, NotebaseRowUpdateOutputSchema, NotebaseUpdateInputSchema, NotebaseUpdateOutputSchema, PUBLIC_APP_ERROR_DEFS, SRS_REVIEW_CLIENT_ID_NAMESPACE, SRS_REVIEW_DURATION_MS_MAX, activityStatsOutputSchema, billingAccessSourceSchema, billingCancelScheduledChangeOutputSchema, billingCheckoutPlanSchema, billingCreateCheckoutSessionInputSchema, billingCreateCustomerPortalSessionInputSchema, billingCurrencySchema, billingIntervalSchema, billingLocaleSchema, billingPlanSchema, billingScheduledChangeSchema, billingSessionUrlOutputSchema, billingStatusSchema, billingSubscriptionStatusSchema, cardSchema, cardStateSchema, cardTemplateSchema, contract, createSrsReviewClientId, ebookCoverContentTypeSchema, ebookDeleteInputSchema, ebookDeleteOutputSchema, ebookDetailSchema, ebookFinalizeUploadInputSchema, ebookFinalizeUploadOutputSchema, ebookGetDownloadUrlInputSchema, ebookGetDownloadUrlOutputSchema, ebookGetInputSchema, ebookGetOutputSchema, ebookListInputSchema, ebookListItemSchema, ebookListOutputSchema, ebookPresignedPostSchema, ebookQuotaSchema, ebookRenameDataSchema, ebookRenameInputSchema, ebookRenameOutputSchema, ebookRequestUploadInputSchema, ebookRequestUploadOutputSchema, ebookStatusSchema, ebookUpdateProgressDataSchema, ebookUpdateProgressInputSchema, ebookUpdateProgressOutputSchema, getPublicErrorDefinition, isPublicAppErrorCode, notebaseActivityStatsItemSchema, notebaseActivityStatsOutputSchema, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowGrowthStatsItemSchema, notebaseRowGrowthStatsOutputSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsActivityStatsItemSchema, srsActivityStatsOutputSchema, srsListCardRevlogsInputSchema, srsListCardRevlogsOutputSchema, srsManualCardStatusInputSchema, srsMemoryGrowthStatsItemSchema, srsMemoryGrowthStatsOutputSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, statsInputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsagePoolSchema, videoTranscriptUsageSchema };
1768
+ export { BetaAccessStatusInputSchema, BetaAccessStatusOutputSchema, BetaFeatureKeySchema, CardGenerateInputSchema, CardGenerateOutputSchema, CardGetInputSchema, CardGetOutputSchema, CardListInputSchema, CardListOutputSchema, CardTemplateCreateInputSchema, CardTemplateCreateOutputSchema, CardTemplateDeleteInputSchema, CardTemplateDeleteOutputSchema, CardTemplateGetInputSchema, CardTemplateGetOutputSchema, CardTemplateInvalidColumnsDataSchema, CardTemplateListInputSchema, CardTemplateListOutputSchema, CardTemplateUpdateInputSchema, CardTemplateUpdateOutputSchema, CellValidationFailedDataSchema, CellValidationFailureDetailsSchema, CellValidationFailureReasonSchema, HOSTED_AI_CLIENT_STREAM_PART_TYPES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiCreditPeriodKindSchema, HostedAiCreditPolicyIdSchema, HostedAiCreditStatusSchema, HostedAiFeatureSchema, HostedAiFeatureStatusSchema, HostedAiModelTierSchema, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiQuotaExhaustedDataSchema, HostedAiQuotaScopeSchema, HostedAiRateLimitErrorDataSchema, HostedAiRequestIdSchema, HostedAiStatusInputSchema, HostedAiStatusOutputSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, HostedAiTierRestrictedDataSchema, HostedAiTierStatusSchema, HostedAiUnavailableReasonSchema, MCP_ALLOWED_PLANS, NOTEBASE_ROW_CREATE_MANY_MAX_ROWS, NotebaseColumnCreateInputSchema, NotebaseColumnCreateOutputSchema, NotebaseColumnDeleteInputSchema, NotebaseColumnDeleteOutputSchema, NotebaseColumnReorderInputSchema, NotebaseColumnReorderOutputSchema, NotebaseColumnUpdateInputSchema, NotebaseColumnUpdateOutputSchema, NotebaseCreateInputSchema, NotebaseCreateOutputSchema, NotebaseDeleteInputSchema, NotebaseDeleteOutputSchema, NotebaseGetInputSchema, NotebaseGetOutputSchema, NotebaseGetSchemaInputSchema, NotebaseGetSchemaOutputSchema, NotebaseGetSummaryInputSchema, NotebaseGetSummaryOutputSchema, NotebaseListInputSchema, NotebaseListItemSchema, NotebaseListOutputSchema, NotebaseRowCreateInputSchema, NotebaseRowCreateManyInputSchema, NotebaseRowCreateManyOutputSchema, NotebaseRowCreateOutputSchema, NotebaseRowDeleteInputSchema, NotebaseRowDeleteOutputSchema, NotebaseRowGetInputSchema, NotebaseRowGetOutputSchema, NotebaseRowListInputSchema, NotebaseRowListOutputSchema, NotebaseRowReorderInputSchema, NotebaseRowReorderOutputSchema, NotebaseRowUpdateInputSchema, NotebaseRowUpdateOutputSchema, NotebaseUpdateInputSchema, NotebaseUpdateOutputSchema, PUBLIC_APP_ERROR_DEFS, SRS_REVIEW_CLIENT_ID_NAMESPACE, SRS_REVIEW_DURATION_MS_MAX, activityStatsOutputSchema, billingAccessSourceSchema, billingCancelScheduledChangeOutputSchema, billingCheckoutPlanSchema, billingCreateCheckoutSessionInputSchema, billingCreateCustomerPortalSessionInputSchema, billingCurrencySchema, billingIntervalSchema, billingLocaleSchema, billingPlanSchema, billingScheduledChangeSchema, billingSessionUrlOutputSchema, billingStatusSchema, billingSubscriptionStatusSchema, cardSchema, cardStateSchema, cardTemplateSchema, contract, createSrsReviewClientId, defineAgentProcedure, deletionResultSchema, ebookCoverContentTypeSchema, ebookDeleteInputSchema, ebookDeleteOutputSchema, ebookDetailSchema, ebookFinalizeUploadInputSchema, ebookFinalizeUploadOutputSchema, ebookGetDownloadUrlInputSchema, ebookGetDownloadUrlOutputSchema, ebookGetInputSchema, ebookGetOutputSchema, ebookListInputSchema, ebookListItemSchema, ebookListOutputSchema, ebookPresignedPostSchema, ebookQuotaSchema, ebookRenameDataSchema, ebookRenameInputSchema, ebookRenameOutputSchema, ebookRequestUploadInputSchema, ebookRequestUploadOutputSchema, ebookStatusSchema, ebookUpdateProgressDataSchema, ebookUpdateProgressInputSchema, ebookUpdateProgressOutputSchema, expectedUpdatedAtSchema, getPublicErrorDefinition, isPlanAllowed, isPublicAppErrorCode, mcpConnectionListOutputSchema, mcpConnectionRevokeInputSchema, mcpConnectionRevokeOutputSchema, mcpConnectionSchema, notebaseActivityStatsItemSchema, notebaseActivityStatsOutputSchema, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowGrowthStatsItemSchema, notebaseRowGrowthStatsOutputSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseSummarySchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pageSchema, paginationShape, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsAcknowledgeOptimizerResultsInputSchema, srsAcknowledgeOptimizerResultsOutputSchema, srsActivityStatsItemSchema, srsActivityStatsOutputSchema, srsListCardRevlogsInputSchema, srsListCardRevlogsOutputSchema, srsListUnreadOptimizerResultsInputSchema, srsListUnreadOptimizerResultsOutputSchema, srsManualCardStatusInputSchema, srsMemoryGrowthStatsItemSchema, srsMemoryGrowthStatsOutputSchema, srsOptimizerUnreadResultSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, statsInputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsagePoolSchema, videoTranscriptUsageSchema };
1540
1769
 
1541
1770
  //# sourceMappingURL=index.js.map