@read-frog/api-contract 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@read-frog/api-contract",
3
3
  "type": "module",
4
- "version": "0.12.4",
4
+ "version": "0.12.6",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
@@ -36,6 +36,76 @@ export const hostedAiContract = {
36
36
  .output(eventIterator(HostedAiStreamPartSchema))
37
37
  .errors(hostedAiStreamErrors),
38
38
  },
39
+ selectionTranslation: {
40
+ streamText: oc
41
+ .route({
42
+ method: "POST",
43
+ path: "/hosted-ai/selection-translation/stream-text",
44
+ summary: "Stream hosted selection translation text output",
45
+ tags: ["Hosted AI"],
46
+ })
47
+ .input(HostedAiStreamTextInputSchema)
48
+ .output(eventIterator(HostedAiStreamPartSchema))
49
+ .errors(hostedAiStreamErrors),
50
+ },
51
+ videoSubtitles: {
52
+ // Subtitle lines and the video summary share this route: both are short
53
+ // text and both bill against `videoSubtitles`.
54
+ streamText: oc
55
+ .route({
56
+ method: "POST",
57
+ path: "/hosted-ai/video-subtitles/stream-text",
58
+ summary: "Stream hosted subtitle translation or video summary text output",
59
+ tags: ["Hosted AI"],
60
+ })
61
+ .input(HostedAiStreamTextInputSchema)
62
+ .output(eventIterator(HostedAiStreamPartSchema))
63
+ .errors(hostedAiStreamErrors),
64
+ /**
65
+ * Segmentation shares the `videoSubtitles` feature but not its route,
66
+ * because `endpointMaxOutputTokens` sizes the credit reservation: emitting
67
+ * a WebVTT block needs several times a subtitle line's budget, and folding
68
+ * both into one route would make every line reserve — and, near the end of
69
+ * a credit window, fail to afford — what only segmentation needs.
70
+ */
71
+ streamSegmentation: oc
72
+ .route({
73
+ method: "POST",
74
+ path: "/hosted-ai/video-subtitles/stream-segmentation",
75
+ summary: "Stream hosted subtitle segmentation output",
76
+ tags: ["Hosted AI"],
77
+ })
78
+ .input(HostedAiStreamTextInputSchema)
79
+ .output(eventIterator(HostedAiStreamPartSchema))
80
+ .errors(hostedAiStreamErrors),
81
+ },
82
+ inputTranslation: {
83
+ streamText: oc
84
+ .route({
85
+ method: "POST",
86
+ path: "/hosted-ai/input-translation/stream-text",
87
+ summary: "Stream hosted input box translation text output",
88
+ tags: ["Hosted AI"],
89
+ })
90
+ .input(HostedAiStreamTextInputSchema)
91
+ .output(eventIterator(HostedAiStreamPartSchema))
92
+ .errors(hostedAiStreamErrors),
93
+ },
94
+ languageDetection: {
95
+ // Detection wants one short string back, not a stream, but the quota
96
+ // reserve/settle path is stream-shaped end to end. Reusing it keeps one
97
+ // metering implementation; the client collects the deltas.
98
+ streamText: oc
99
+ .route({
100
+ method: "POST",
101
+ path: "/hosted-ai/language-detection/stream-text",
102
+ summary: "Stream hosted language detection output",
103
+ tags: ["Hosted AI"],
104
+ })
105
+ .input(HostedAiStreamTextInputSchema)
106
+ .output(eventIterator(HostedAiStreamPartSchema))
107
+ .errors(hostedAiStreamErrors),
108
+ },
39
109
  customAction: {
40
110
  streamStructuredObject: oc
41
111
  .route({
@@ -9,11 +9,28 @@ export const HostedAiOutputFieldSchema = z.strictObject({
9
9
 
10
10
  const HostedAiInstructionsSchema = z.string().trim().min(1).max(16000)
11
11
 
12
- export const HostedAiModelTierSchema = z.enum(["normal", "ultra"])
12
+ /**
13
+ * Which hosted model a request runs on. Deliberately NOT named after a billing
14
+ * plan: which plans may reach which tier is policy (see `access-policy.ts`),
15
+ * not identity, so a future plan can be sold with any tier without a rename.
16
+ */
17
+ export const HostedAiModelTierSchema = z.enum(["normal", "advance"])
18
+ /**
19
+ * The billing/access subject of a hosted request, not a route id. Sub-calls
20
+ * bill against the feature they serve: the page summary is `pageTranslation`,
21
+ * and the video summary and subtitle segmentation are `videoSubtitles`.
22
+ *
23
+ * Appended last on purpose: the db pgEnum mirrors this order, and appending
24
+ * keeps drizzle from emitting the ADD VALUE ... BEFORE variant.
25
+ */
13
26
  export const HostedAiFeatureSchema = z.enum([
14
27
  "pageTranslation",
15
28
  "customAction",
16
29
  "noteSuggestion",
30
+ "selectionTranslation",
31
+ "videoSubtitles",
32
+ "inputTranslation",
33
+ "languageDetection",
17
34
  ])
18
35
  export const HostedAiRequestIdSchema = z.uuid()
19
36
 
@@ -207,7 +224,7 @@ export const HostedAiTierStatusSchema = z.strictObject({
207
224
 
208
225
  export const HostedAiFeatureStatusSchema = z.strictObject({
209
226
  normal: HostedAiTierStatusSchema,
210
- ultra: HostedAiTierStatusSchema,
227
+ advance: HostedAiTierStatusSchema,
211
228
  })
212
229
 
213
230
  export const HostedAiStatusOutputSchema = z.strictObject({
@@ -216,6 +233,10 @@ export const HostedAiStatusOutputSchema = z.strictObject({
216
233
  pageTranslation: HostedAiFeatureStatusSchema,
217
234
  customAction: HostedAiFeatureStatusSchema,
218
235
  noteSuggestion: HostedAiFeatureStatusSchema,
236
+ selectionTranslation: HostedAiFeatureStatusSchema,
237
+ videoSubtitles: HostedAiFeatureStatusSchema,
238
+ inputTranslation: HostedAiFeatureStatusSchema,
239
+ languageDetection: HostedAiFeatureStatusSchema,
219
240
  }),
220
241
  })
221
242