@oxy.so/contracts 4.11.0-oxy-one.0 → 4.11.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 (98) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +5 -3
  3. package/dist/cjs/agency.js +178 -96
  4. package/dist/cjs/agentKeys.js +80 -26
  5. package/dist/cjs/capabilityBindings.js +2 -2
  6. package/dist/cjs/capabilityInvocation.js +3 -1
  7. package/dist/cjs/commonsSignIn.js +2 -2
  8. package/dist/cjs/deviceSession.js +5 -1
  9. package/dist/cjs/email/messages.js +70 -4
  10. package/dist/cjs/emailAgentContext.js +16 -8
  11. package/dist/cjs/externalIdentity.js +30 -12
  12. package/dist/cjs/identity.js +14 -6
  13. package/dist/cjs/identityLink.js +7 -2
  14. package/dist/cjs/identityProof.js +2 -1
  15. package/dist/cjs/index.js +5 -3
  16. package/dist/cjs/inference/catalogue.js +2 -12
  17. package/dist/cjs/inference/decisions.js +102 -83
  18. package/dist/cjs/inference/economics.js +15 -5
  19. package/dist/cjs/inference/embeddings.js +44 -6
  20. package/dist/cjs/inference/inbox.js +33 -2
  21. package/dist/cjs/inference/providerConnection.js +21 -6
  22. package/dist/cjs/inference/realtime.js +114 -107
  23. package/dist/cjs/inference/scopedExecution.js +12 -12
  24. package/dist/cjs/inference/usage.js +2 -9
  25. package/dist/cjs/notifications.js +25 -5
  26. package/dist/cjs/oauth.js +30 -14
  27. package/dist/cjs/oxyRecordTypes.js +2 -2
  28. package/dist/cjs/products/access.js +146 -57
  29. package/dist/cjs/products/billing.js +71 -17
  30. package/dist/cjs/products/checkout.js +24 -6
  31. package/dist/cjs/products/plans.js +22 -7
  32. package/dist/cjs/recommendations.js +4 -6
  33. package/dist/cjs/reputation.js +3 -6
  34. package/dist/cjs/sessionStatus.js +1 -6
  35. package/dist/cjs/signIn.js +17 -4
  36. package/dist/cjs/transparency.js +3 -1
  37. package/dist/cjs/updates.js +2 -4
  38. package/dist/cjs/userResponse.js +27 -7
  39. package/dist/cjs/username.js +3 -1
  40. package/dist/esm/.tsbuildinfo +1 -1
  41. package/dist/esm/accountGraph.js +5 -3
  42. package/dist/esm/agency.js +178 -96
  43. package/dist/esm/agentKeys.js +80 -26
  44. package/dist/esm/capabilityBindings.js +2 -2
  45. package/dist/esm/capabilityInvocation.js +3 -1
  46. package/dist/esm/commonsSignIn.js +2 -2
  47. package/dist/esm/deviceSession.js +5 -1
  48. package/dist/esm/email/messages.js +69 -3
  49. package/dist/esm/emailAgentContext.js +16 -8
  50. package/dist/esm/externalIdentity.js +30 -12
  51. package/dist/esm/identity.js +14 -6
  52. package/dist/esm/identityLink.js +7 -2
  53. package/dist/esm/identityProof.js +2 -1
  54. package/dist/esm/index.js +7 -7
  55. package/dist/esm/inference/aliaModelRelease.js +1 -1
  56. package/dist/esm/inference/catalogue.js +3 -13
  57. package/dist/esm/inference/decisions.js +108 -89
  58. package/dist/esm/inference/economics.js +16 -6
  59. package/dist/esm/inference/embeddings.js +44 -6
  60. package/dist/esm/inference/inbox.js +32 -1
  61. package/dist/esm/inference/providerConnection.js +21 -6
  62. package/dist/esm/inference/realtime.js +123 -116
  63. package/dist/esm/inference/scopedExecution.js +15 -15
  64. package/dist/esm/inference/usage.js +2 -9
  65. package/dist/esm/notifications.js +25 -5
  66. package/dist/esm/oauth.js +30 -14
  67. package/dist/esm/oxyRecordTypes.js +2 -2
  68. package/dist/esm/products/access.js +146 -57
  69. package/dist/esm/products/billing.js +71 -17
  70. package/dist/esm/products/checkout.js +24 -6
  71. package/dist/esm/products/plans.js +22 -7
  72. package/dist/esm/recommendations.js +4 -6
  73. package/dist/esm/reputation.js +3 -6
  74. package/dist/esm/sessionStatus.js +1 -6
  75. package/dist/esm/signIn.js +17 -4
  76. package/dist/esm/transparency.js +3 -1
  77. package/dist/esm/updates.js +2 -4
  78. package/dist/esm/userResponse.js +27 -7
  79. package/dist/esm/username.js +3 -1
  80. package/dist/types/.tsbuildinfo +1 -1
  81. package/dist/types/accountGraph.d.ts +1 -1
  82. package/dist/types/commonsSignIn.d.ts +2 -2
  83. package/dist/types/email/messages.d.ts +208 -2
  84. package/dist/types/identity.d.ts +1 -1
  85. package/dist/types/index.d.ts +8 -8
  86. package/dist/types/inference/decisions.d.ts +1 -1
  87. package/dist/types/inference/inbox.d.ts +129 -5
  88. package/dist/types/inference/realtime.d.ts +1 -1
  89. package/dist/types/inference/scopedExecution.d.ts +1 -1
  90. package/dist/types/moderationReputation.d.ts +1 -1
  91. package/dist/types/oxyRecordTypes.d.ts +2 -2
  92. package/dist/types/products/access.d.ts +102 -102
  93. package/dist/types/products/checkout.d.ts +3 -3
  94. package/dist/types/products/plans.d.ts +40 -40
  95. package/dist/types/reputation.d.ts +4 -4
  96. package/dist/types/updates.d.ts +1 -1
  97. package/dist/types/userResponse.d.ts +22 -23
  98. package/package.json +1 -2
@@ -14,30 +14,24 @@ const probability = zod_1.z.number().finite().min(0).max(1);
14
14
  const text = zod_1.z.string().min(1).max(65536);
15
15
  const id = zod_1.z.string().min(1).max(128);
16
16
  const tolerance = 1e-6;
17
- exports.decisionEffortSchema = zod_1.z.enum([
18
- "instant",
19
- "low",
20
- "medium",
21
- "high",
22
- "xhigh",
23
- ]);
17
+ exports.decisionEffortSchema = zod_1.z.enum(['instant', 'low', 'medium', 'high', 'xhigh']);
24
18
  const common = { id, question: text, criteria: text.optional() };
25
- exports.decisionQuestionSchema = zod_1.z.discriminatedUnion("kind", [
19
+ exports.decisionQuestionSchema = zod_1.z.discriminatedUnion('kind', [
26
20
  zod_1.z
27
21
  .object({
28
22
  ...common,
29
- kind: zod_1.z.literal("choice"),
23
+ kind: zod_1.z.literal('choice'),
30
24
  options: zod_1.z.array(text).min(2).max(255),
31
25
  })
32
26
  .strict(),
33
27
  zod_1.z
34
28
  .object({
35
29
  ...common,
36
- kind: zod_1.z.literal("score"),
30
+ kind: zod_1.z.literal('score'),
37
31
  levels: zod_1.z.array(text).min(2).max(10),
38
32
  })
39
33
  .strict(),
40
- zod_1.z.object({ ...common, kind: zod_1.z.literal("noul") }).strict(),
34
+ zod_1.z.object({ ...common, kind: zod_1.z.literal('noul') }).strict(),
41
35
  ]);
42
36
  const payloadFields = {
43
37
  state: zod_1.z.string().max(65536),
@@ -53,23 +47,38 @@ const payloadFields = {
53
47
  * Kaana must also check its final serialized body before sending it.
54
48
  */
55
49
  function decisionInputBudget(payload) {
56
- const bytes = (value) => new TextEncoder().encode(JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`)).length;
57
- const model = "x".repeat(255);
50
+ const bytes = (value) => new TextEncoder().encode(JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`)).length;
51
+ const model = 'x'.repeat(255);
58
52
  const measure = (questions) => {
59
- const wireQuestions = Object.fromEntries(questions.map((q) => [q.id, {
53
+ const wireQuestions = Object.fromEntries(questions.map((q) => [
54
+ q.id,
55
+ {
60
56
  type: q.kind,
61
57
  instructions: {
62
58
  question: q.question,
63
59
  ...(payload.instructions === undefined ? {} : { instructions: payload.instructions }),
64
60
  ...(q.criteria === undefined ? {} : { criteria: q.criteria }),
65
61
  },
66
- ...(q.kind === "choice" ? { criteria: Object.fromEntries(q.options.map((label) => [label, null])) } :
67
- q.kind === "score" ? { criteria: q.levels } : {}),
68
- }]));
69
- return Math.max(bytes({ ...payload, model, questions }), bytes({ model, state: payload.state, questions: wireQuestions, ...(payload.effort === undefined ? {} : { effort: payload.effort }) }));
62
+ ...(q.kind === 'choice'
63
+ ? { criteria: Object.fromEntries(q.options.map((label) => [label, null])) }
64
+ : q.kind === 'score'
65
+ ? { criteria: q.levels }
66
+ : {}),
67
+ },
68
+ ]));
69
+ return Math.max(bytes({ ...payload, model, questions }), bytes({
70
+ model,
71
+ state: payload.state,
72
+ questions: wireQuestions,
73
+ ...(payload.effort === undefined ? {} : { effort: payload.effort }),
74
+ }));
70
75
  };
71
76
  const total = measure(payload.questions);
72
- return { total, context: Math.max(...payload.questions.map((q) => measure([q]))), gateway: total + 4096 };
77
+ return {
78
+ total,
79
+ context: Math.max(...payload.questions.map((q) => measure([q]))),
80
+ gateway: total + 4096,
81
+ };
73
82
  }
74
83
  /** OpenRouter's TOTAL limit is separate from direct state-plus-longest context. */
75
84
  function decisionFitsGateway(payload) {
@@ -92,18 +101,18 @@ function hasUnpairedSurrogate(value) {
92
101
  }
93
102
  function validateInput(payload, ctx) {
94
103
  const fields = [
95
- { value: payload.state, path: ["state"] },
96
- { value: payload.instructions, path: ["instructions"] },
104
+ { value: payload.state, path: ['state'] },
105
+ { value: payload.instructions, path: ['instructions'] },
97
106
  ];
98
107
  for (const [index, question] of payload.questions.entries()) {
99
- for (const field of ["id", "question", "criteria"]) {
100
- fields.push({ value: question[field], path: ["questions", index, field] });
108
+ for (const field of ['id', 'question', 'criteria']) {
109
+ fields.push({ value: question[field], path: ['questions', index, field] });
101
110
  }
102
- if (question.kind === "choice" || question.kind === "score") {
103
- const field = question.kind === "choice" ? "options" : "levels";
104
- const labels = question.kind === "choice" ? question.options : question.levels;
111
+ if (question.kind === 'choice' || question.kind === 'score') {
112
+ const field = question.kind === 'choice' ? 'options' : 'levels';
113
+ const labels = question.kind === 'choice' ? question.options : question.levels;
105
114
  for (const [labelIndex, value] of labels.entries()) {
106
- fields.push({ value, path: ["questions", index, field, labelIndex] });
115
+ fields.push({ value, path: ['questions', index, field, labelIndex] });
107
116
  }
108
117
  }
109
118
  }
@@ -111,57 +120,57 @@ function validateInput(payload, ctx) {
111
120
  for (const { value, path } of fields) {
112
121
  if (value !== undefined && hasUnpairedSurrogate(value)) {
113
122
  invalidUnicode = true;
114
- ctx.addIssue({ code: "custom", path, message: "Decisions require paired UTF-16 surrogates." });
123
+ ctx.addIssue({
124
+ code: 'custom',
125
+ path,
126
+ message: 'Decisions require paired UTF-16 surrogates.',
127
+ });
115
128
  }
116
129
  }
117
130
  // Reject before measuring/reserving text that the execution runtime would change.
118
131
  if (invalidUnicode)
119
132
  return;
120
- if (new Set(payload.questions.map((q) => q.id)).size !==
121
- payload.questions.length)
133
+ if (new Set(payload.questions.map((q) => q.id)).size !== payload.questions.length)
122
134
  ctx.addIssue({
123
- code: "custom",
124
- path: ["questions"],
125
- message: "Question IDs must be unique.",
135
+ code: 'custom',
136
+ path: ['questions'],
137
+ message: 'Question IDs must be unique.',
126
138
  });
127
139
  for (const [index, question] of payload.questions.entries()) {
128
- const labels = question.kind === "choice"
140
+ const labels = question.kind === 'choice'
129
141
  ? question.options
130
- : question.kind === "score"
142
+ : question.kind === 'score'
131
143
  ? question.levels
132
144
  : [];
133
145
  if (new Set(labels).size !== labels.length)
134
146
  ctx.addIssue({
135
- code: "custom",
136
- path: ["questions", index],
137
- message: "Options and levels must be unique.",
147
+ code: 'custom',
148
+ path: ['questions', index],
149
+ message: 'Options and levels must be unique.',
138
150
  });
139
151
  }
140
152
  const budget = decisionInputBudget(payload);
141
153
  if (budget.total > 64000 || budget.context > 32000)
142
154
  ctx.addIssue({
143
- code: "custom",
144
- path: ["state"],
145
- message: "Decisions exceed the serialized 64000-byte total or 32000-byte per-question context budget.",
155
+ code: 'custom',
156
+ path: ['state'],
157
+ message: 'Decisions exceed the serialized 64000-byte total or 32000-byte per-question context budget.',
146
158
  });
147
159
  }
148
- exports.decisionInputSchema = zod_1.z
149
- .object(payloadFields)
150
- .strict()
151
- .superRefine(validateInput);
160
+ exports.decisionInputSchema = zod_1.z.object(payloadFields).strict().superRefine(validateInput);
152
161
  exports.decisionRequestSchema = zod_1.z
153
162
  .object({
154
- model: identifiers_1.modelReferenceSchema.refine((model) => model.includes("@"), "Decisions require a revision-pinned model."),
163
+ model: identifiers_1.modelReferenceSchema.refine((model) => model.includes('@'), 'Decisions require a revision-pinned model.'),
155
164
  ...payloadFields,
156
165
  })
157
166
  .strict()
158
167
  .superRefine(validateInput);
159
168
  exports.decisionAnswerSchema = zod_1.z
160
- .discriminatedUnion("kind", [
169
+ .discriminatedUnion('kind', [
161
170
  zod_1.z
162
171
  .object({
163
172
  id,
164
- kind: zod_1.z.literal("choice"),
173
+ kind: zod_1.z.literal('choice'),
165
174
  /** Actual provider-selected option. Never reconstructed from probabilities. */
166
175
  reply: text,
167
176
  /** Provider-returned confidence, not a correctness probability. */
@@ -172,7 +181,7 @@ exports.decisionAnswerSchema = zod_1.z
172
181
  zod_1.z
173
182
  .object({
174
183
  id,
175
- kind: zod_1.z.literal("score"),
184
+ kind: zod_1.z.literal('score'),
176
185
  /** Actual provider score. Kept separate from the validated expected index. */
177
186
  reply: zod_1.z.number().finite().min(0).max(9),
178
187
  confidence: probability,
@@ -180,42 +189,45 @@ exports.decisionAnswerSchema = zod_1.z
180
189
  distribution: zod_1.z.array(probability).min(2).max(10),
181
190
  })
182
191
  .strict(),
183
- zod_1.z.object({ id, kind: zod_1.z.literal("noul"), probability }).strict(),
192
+ zod_1.z.object({ id, kind: zod_1.z.literal('noul'), probability }).strict(),
184
193
  ])
185
194
  .superRefine((answer, ctx) => {
186
- if (answer.kind === "noul")
195
+ if (answer.kind === 'noul')
187
196
  return;
188
- if (answer.kind === "score" && Math.abs(answer.reply - answer.mean) > tolerance) {
189
- ctx.addIssue({ code: "custom", path: ["reply"], message: "Provider score must match the expected level index." });
197
+ if (answer.kind === 'score' && Math.abs(answer.reply - answer.mean) > tolerance) {
198
+ ctx.addIssue({
199
+ code: 'custom',
200
+ path: ['reply'],
201
+ message: 'Provider score must match the expected level index.',
202
+ });
190
203
  }
191
- const distribution = answer.kind === "choice" ? answer.probabilities : answer.distribution;
192
- if (Math.abs(distribution.reduce((sum, value) => sum + value, 0) - 1) >
193
- tolerance)
204
+ const distribution = answer.kind === 'choice' ? answer.probabilities : answer.distribution;
205
+ if (Math.abs(distribution.reduce((sum, value) => sum + value, 0) - 1) > tolerance)
194
206
  ctx.addIssue({
195
- code: "custom",
196
- message: "Probabilities must sum to one.",
207
+ code: 'custom',
208
+ message: 'Probabilities must sum to one.',
197
209
  });
198
- if (answer.kind === "score" &&
199
- Math.abs(distribution.reduce((sum, value, index) => sum + index * value, 0) -
200
- answer.mean) > tolerance)
210
+ if (answer.kind === 'score' &&
211
+ Math.abs(distribution.reduce((sum, value, index) => sum + index * value, 0) - answer.mean) >
212
+ tolerance)
201
213
  ctx.addIssue({
202
- code: "custom",
203
- path: ["mean"],
204
- message: "Mean must equal the expected zero-based level index.",
214
+ code: 'custom',
215
+ path: ['mean'],
216
+ message: 'Mean must equal the expected zero-based level index.',
205
217
  });
206
218
  });
207
219
  const resultFields = {
208
220
  schemaVersion: zod_1.z.literal(1),
209
221
  requestId: identifiers_1.requestIdSchema,
210
- model: identifiers_1.modelReferenceSchema.refine((model) => model.includes("@"), "Decisions require an immutable model revision."),
222
+ model: identifiers_1.modelReferenceSchema.refine((model) => model.includes('@'), 'Decisions require an immutable model revision.'),
211
223
  data: zod_1.z.array(exports.decisionAnswerSchema).min(1).max(255),
212
224
  };
213
225
  function uniqueAnswers(result, ctx) {
214
226
  if (new Set(result.data.map((answer) => answer.id)).size !== result.data.length)
215
227
  ctx.addIssue({
216
- code: "custom",
217
- path: ["data"],
218
- message: "Answer IDs must be unique.",
228
+ code: 'custom',
229
+ path: ['data'],
230
+ message: 'Answer IDs must be unique.',
219
231
  });
220
232
  }
221
233
  exports.decisionResultSchema = zod_1.z
@@ -225,11 +237,11 @@ exports.decisionResultSchema = zod_1.z
225
237
  .superRefine((result, ctx) => {
226
238
  if (result.usage.requestId !== result.requestId ||
227
239
  result.usage.resolvedModelReference !== result.model ||
228
- result.usage.outcome !== "completed") {
240
+ result.usage.outcome !== 'completed') {
229
241
  ctx.addIssue({
230
- code: "custom",
231
- path: ["usage"],
232
- message: "Decision usage must describe this completed request and immutable model.",
242
+ code: 'custom',
243
+ path: ['usage'],
244
+ message: 'Decision usage must describe this completed request and immutable model.',
233
245
  });
234
246
  }
235
247
  });
@@ -248,11 +260,19 @@ exports.decisionFailureSchema = zod_1.z
248
260
  .strict()
249
261
  .superRefine((failure, ctx) => {
250
262
  if (failure.error.requestId !== failure.requestId) {
251
- ctx.addIssue({ code: "custom", path: ["error", "requestId"], message: "The error must answer this request." });
263
+ ctx.addIssue({
264
+ code: 'custom',
265
+ path: ['error', 'requestId'],
266
+ message: 'The error must answer this request.',
267
+ });
252
268
  }
253
269
  if (failure.usage !== undefined &&
254
- (failure.usage.requestId !== failure.requestId || failure.usage.outcome === "completed")) {
255
- ctx.addIssue({ code: "custom", path: ["usage"], message: "Failure usage must describe this request and an incomplete outcome." });
270
+ (failure.usage.requestId !== failure.requestId || failure.usage.outcome === 'completed')) {
271
+ ctx.addIssue({
272
+ code: 'custom',
273
+ path: ['usage'],
274
+ message: 'Failure usage must describe this request and an incomplete outcome.',
275
+ });
256
276
  }
257
277
  });
258
278
  exports.decisionSuccessSchema = zod_1.z
@@ -270,17 +290,16 @@ function decisionAnswersMatch(input, answers) {
270
290
  return false;
271
291
  return input.questions.every((question) => {
272
292
  const answer = answers.find((candidate) => candidate.id === question.id);
273
- if (!answer ||
274
- !exports.decisionAnswerSchema.safeParse(answer).success ||
275
- answer.kind !== question.kind)
293
+ if (!answer || !exports.decisionAnswerSchema.safeParse(answer).success || answer.kind !== question.kind)
276
294
  return false;
277
- if (question.kind === "choice" && answer.kind === "choice") {
295
+ if (question.kind === 'choice' && answer.kind === 'choice') {
278
296
  const index = question.options.indexOf(answer.reply);
279
- return question.options.length === answer.probabilities.length && index >= 0 &&
280
- answer.probabilities[index] + tolerance >= Math.max(...answer.probabilities);
297
+ return (question.options.length === answer.probabilities.length &&
298
+ index >= 0 &&
299
+ answer.probabilities[index] + tolerance >= Math.max(...answer.probabilities));
281
300
  }
282
- if (question.kind === "score" && answer.kind === "score")
301
+ if (question.kind === 'score' && answer.kind === 'score')
283
302
  return question.levels.length === answer.distribution.length;
284
- return question.kind === "noul";
303
+ return question.kind === 'noul';
285
304
  });
286
305
  }
@@ -107,7 +107,8 @@ exports.costCenterUsageSchema = zod_1.z
107
107
  })
108
108
  .strict();
109
109
  /** A technical generation record for an internal request, never a financial receipt. */
110
- exports.meteredGenerationSchema = zod_1.z.object({
110
+ exports.meteredGenerationSchema = zod_1.z
111
+ .object({
111
112
  schemaVersion: zod_1.z.literal(2),
112
113
  kind: zod_1.z.literal('metered_usage'),
113
114
  meteredUsageId: zod_1.z.string().min(1),
@@ -126,10 +127,19 @@ exports.meteredGenerationSchema = zod_1.z.object({
126
127
  resolvedModelReference: identifiers_1.modelReferenceSchema,
127
128
  servingProvider: zod_1.z.string().min(1),
128
129
  tariff: zod_1.z.discriminatedUnion('status', [
129
- zod_1.z.object({ status: zod_1.z.literal('quoted'), amount: money_1.exactDecimalSchema, currency: money_1.currencyCodeSchema,
130
- priceVersionId: zod_1.z.string().min(1) }).strict(),
131
- zod_1.z.object({ status: zod_1.z.literal('unpriced'), priceVersionId: zod_1.z.string().min(1).nullable() }).strict(),
130
+ zod_1.z
131
+ .object({
132
+ status: zod_1.z.literal('quoted'),
133
+ amount: money_1.exactDecimalSchema,
134
+ currency: money_1.currencyCodeSchema,
135
+ priceVersionId: zod_1.z.string().min(1),
136
+ })
137
+ .strict(),
138
+ zod_1.z
139
+ .object({ status: zod_1.z.literal('unpriced'), priceVersionId: zod_1.z.string().min(1).nullable() })
140
+ .strict(),
132
141
  ]),
133
142
  customerCharge: zod_1.z.object({ status: zod_1.z.literal('not_charged') }).strict(),
134
143
  settledAt: zod_1.z.string().datetime(),
135
- }).strict();
144
+ })
145
+ .strict();
@@ -3,17 +3,55 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.embeddingResponseSchema = exports.embeddingFailureSchema = exports.embeddingSuccessSchema = exports.embeddingUsageSchema = exports.embeddingVectorSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const errors_1 = require("./errors");
6
- exports.embeddingVectorSchema = zod_1.z.object({ index: zod_1.z.number().int().nonnegative(), embedding: zod_1.z.array(zod_1.z.number().finite()).min(1).max(1024) }).strict();
7
- exports.embeddingUsageSchema = zod_1.z.object({ inputTokens: zod_1.z.number().int().nonnegative(), totalTokens: zod_1.z.number().int().nonnegative() }).strict().refine((usage) => usage.totalTokens >= usage.inputTokens, { message: 'totalTokens must be greater than or equal to inputTokens', path: ['totalTokens'] });
8
- exports.embeddingSuccessSchema = zod_1.z.object({ schemaVersion: zod_1.z.literal(1), requestId: zod_1.z.string().min(1).max(128), model: zod_1.z.string().min(1).max(255), dimension: zod_1.z.number().int().positive().max(1024), data: zod_1.z.array(exports.embeddingVectorSchema).min(1).max(2048), usage: exports.embeddingUsageSchema }).strict().superRefine((result, context) => {
6
+ exports.embeddingVectorSchema = zod_1.z
7
+ .object({
8
+ index: zod_1.z.number().int().nonnegative(),
9
+ embedding: zod_1.z.array(zod_1.z.number().finite()).min(1).max(1024),
10
+ })
11
+ .strict();
12
+ exports.embeddingUsageSchema = zod_1.z
13
+ .object({
14
+ inputTokens: zod_1.z.number().int().nonnegative(),
15
+ totalTokens: zod_1.z.number().int().nonnegative(),
16
+ })
17
+ .strict()
18
+ .refine((usage) => usage.totalTokens >= usage.inputTokens, {
19
+ message: 'totalTokens must be greater than or equal to inputTokens',
20
+ path: ['totalTokens'],
21
+ });
22
+ exports.embeddingSuccessSchema = zod_1.z
23
+ .object({
24
+ schemaVersion: zod_1.z.literal(1),
25
+ requestId: zod_1.z.string().min(1).max(128),
26
+ model: zod_1.z.string().min(1).max(255),
27
+ dimension: zod_1.z.number().int().positive().max(1024),
28
+ data: zod_1.z.array(exports.embeddingVectorSchema).min(1).max(2048),
29
+ usage: exports.embeddingUsageSchema,
30
+ })
31
+ .strict()
32
+ .superRefine((result, context) => {
9
33
  const indexes = new Set();
10
34
  for (const [position, vector] of result.data.entries()) {
11
35
  if (vector.embedding.length !== result.dimension)
12
- context.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ['data', position, 'embedding'], message: 'embedding length must equal dimension' });
36
+ context.addIssue({
37
+ code: zod_1.z.ZodIssueCode.custom,
38
+ path: ['data', position, 'embedding'],
39
+ message: 'embedding length must equal dimension',
40
+ });
13
41
  if (indexes.has(vector.index))
14
- context.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ['data', position, 'index'], message: 'embedding indexes must be unique' });
42
+ context.addIssue({
43
+ code: zod_1.z.ZodIssueCode.custom,
44
+ path: ['data', position, 'index'],
45
+ message: 'embedding indexes must be unique',
46
+ });
15
47
  indexes.add(vector.index);
16
48
  }
17
49
  });
18
- exports.embeddingFailureSchema = zod_1.z.object({ schemaVersion: zod_1.z.literal(1), requestId: zod_1.z.string().min(1).max(128), error: errors_1.inferenceErrorSchema }).strict();
50
+ exports.embeddingFailureSchema = zod_1.z
51
+ .object({
52
+ schemaVersion: zod_1.z.literal(1),
53
+ requestId: zod_1.z.string().min(1).max(128),
54
+ error: errors_1.inferenceErrorSchema,
55
+ })
56
+ .strict();
19
57
  exports.embeddingResponseSchema = zod_1.z.union([exports.embeddingSuccessSchema, exports.embeddingFailureSchema]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inboxInferenceStreamEventSchema = exports.inboxThreadSummaryResponseSchema = exports.inboxSmartRepliesResponseSchema = exports.inboxNaturalSearchResponseSchema = exports.inboxInferenceTextResponseSchema = exports.inboxMessageInferenceParamsSchema = exports.inboxNaturalSearchRequestSchema = exports.inboxDailyBriefRequestSchema = exports.inboxComposeRequestSchema = void 0;
3
+ exports.inboxInferenceStreamEventSchema = exports.inboxThreadSummaryResponseSchema = exports.inboxSmartRepliesResponseSchema = exports.inboxDailyBriefResponseSchema = exports.INBOX_DAILY_BRIEF_SECTIONS = exports.inboxNaturalSearchResponseSchema = exports.inboxInferenceTextResponseSchema = exports.inboxMessageInferenceParamsSchema = exports.inboxNaturalSearchRequestSchema = exports.inboxDailyBriefRequestSchema = exports.inboxComposeRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const errors_1 = require("./errors");
6
6
  const inboxTextSchema = zod_1.z.string().trim().min(1).max(20000);
@@ -40,7 +40,8 @@ exports.inboxComposeRequestSchema = zod_1.z.discriminatedUnion('operation', [
40
40
  exports.inboxDailyBriefRequestSchema = zod_1.z.object({
41
41
  startAt: inboxUtcTimestampSchema,
42
42
  endAt: inboxUtcTimestampSchema,
43
- stream: zod_1.z.boolean().optional(),
43
+ /** BCP 47 tag of the language the brief is written in; English when absent. */
44
+ locale: zod_1.z.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35).optional(),
44
45
  }).strict().superRefine((value, context) => {
45
46
  const durationMs = Date.parse(value.endAt) - Date.parse(value.startAt);
46
47
  if (!Number.isFinite(durationMs) || durationMs <= 0) {
@@ -82,6 +83,36 @@ exports.inboxNaturalSearchResponseSchema = zod_1.z.object({
82
83
  }).strict(),
83
84
  interpretation: zod_1.z.string().max(1000),
84
85
  }).strict();
86
+ /** Where the brief puts a message: it asks something of the owner, it is today's news, or it is still unread from before. */
87
+ exports.INBOX_DAILY_BRIEF_SECTIONS = ['needs_you', 'today', 'earlier'];
88
+ /**
89
+ * The Daily Brief as data, so a client draws it rather than printing a wall of
90
+ * text: a short summary, then the messages it mentions — each with the
91
+ * server's own copy of its sender, subject, time and unread state, so a client
92
+ * can show and open it, and a one-line note of why it matters.
93
+ */
94
+ exports.inboxDailyBriefResponseSchema = zod_1.z.object({
95
+ schemaVersion: zod_1.z.literal(1),
96
+ requestId: zod_1.z.string().min(1).max(128),
97
+ generationId: zod_1.z.string().min(1).max(128).optional(),
98
+ summary: zod_1.z.string().max(400),
99
+ counts: zod_1.z.object({
100
+ received: zod_1.z.number().int().nonnegative(),
101
+ unread: zod_1.z.number().int().nonnegative(),
102
+ starred: zod_1.z.number().int().nonnegative(),
103
+ earlierUnread: zod_1.z.number().int().nonnegative(),
104
+ }).strict(),
105
+ items: zod_1.z.array(zod_1.z.object({
106
+ messageId: inboxMessageIdSchema,
107
+ section: zod_1.z.enum(exports.INBOX_DAILY_BRIEF_SECTIONS),
108
+ note: zod_1.z.string().max(200),
109
+ from: zod_1.z.object({ name: zod_1.z.string().max(998).nullable(), address: zod_1.z.string().max(320) }).strict(),
110
+ subject: zod_1.z.string().max(998),
111
+ receivedAt: zod_1.z.string().datetime(),
112
+ unread: zod_1.z.boolean(),
113
+ hasAttachments: zod_1.z.boolean(),
114
+ }).strict()).max(20),
115
+ }).strict();
85
116
  exports.inboxSmartRepliesResponseSchema = zod_1.z.object({
86
117
  replies: zod_1.z.array(zod_1.z.string().trim().min(1).max(500)).max(3),
87
118
  }).strict();
@@ -95,8 +95,7 @@ function isVisibleASCIIProviderCredential(value) {
95
95
  return false;
96
96
  const finalQuartet = offset + 4 === value.length;
97
97
  if (finalQuartet &&
98
- ((padding === 2 && (second & 0x0f) !== 0) ||
99
- (padding === 1 && (third & 0x03) !== 0))) {
98
+ ((padding === 2 && (second & 0x0f) !== 0) || (padding === 1 && (third & 0x03) !== 0))) {
100
99
  return false;
101
100
  }
102
101
  const packed = (first << 18) | (second << 12) | (third << 6) | fourth;
@@ -134,7 +133,11 @@ exports.kaanaCredentialRotateMutationSchema = exports.kaanaCredentialIdentitySch
134
133
  operationId: exports.kaanaCredentialOperationIdSchema,
135
134
  operationActor: kaanaCredentialOperationActorSchema,
136
135
  credentialHandle: exports.kaanaCredentialHandleSchema,
137
- expectedRevision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER - 1),
136
+ expectedRevision: zod_1.z
137
+ .number()
138
+ .int()
139
+ .positive()
140
+ .max(Number.MAX_SAFE_INTEGER - 1),
138
141
  secretBase64: kaanaCredentialSecretBase64Schema,
139
142
  })
140
143
  .strict();
@@ -145,7 +148,11 @@ exports.kaanaCredentialRevokeMutationSchema = exports.kaanaCredentialIdentitySch
145
148
  operationId: exports.kaanaCredentialOperationIdSchema,
146
149
  operationActor: kaanaCredentialOperationActorSchema,
147
150
  credentialHandle: exports.kaanaCredentialHandleSchema,
148
- expectedRevision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER - 1),
151
+ expectedRevision: zod_1.z
152
+ .number()
153
+ .int()
154
+ .positive()
155
+ .max(Number.MAX_SAFE_INTEGER - 1),
149
156
  })
150
157
  .strict();
151
158
  exports.kaanaCredentialMutationSchema = zod_1.z.discriminatedUnion('action', [
@@ -166,7 +173,11 @@ exports.kaanaCredentialRotateOutcomeRequestSchema = exports.kaanaCredentialIdent
166
173
  action: zod_1.z.literal('rotate'),
167
174
  operationId: exports.kaanaCredentialOperationIdSchema,
168
175
  credentialHandle: exports.kaanaCredentialHandleSchema,
169
- expectedRevision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER - 1),
176
+ expectedRevision: zod_1.z
177
+ .number()
178
+ .int()
179
+ .positive()
180
+ .max(Number.MAX_SAFE_INTEGER - 1),
170
181
  })
171
182
  .strict();
172
183
  exports.kaanaCredentialRevokeOutcomeRequestSchema = exports.kaanaCredentialIdentitySchema
@@ -175,7 +186,11 @@ exports.kaanaCredentialRevokeOutcomeRequestSchema = exports.kaanaCredentialIdent
175
186
  action: zod_1.z.literal('revoke'),
176
187
  operationId: exports.kaanaCredentialOperationIdSchema,
177
188
  credentialHandle: exports.kaanaCredentialHandleSchema,
178
- expectedRevision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER - 1),
189
+ expectedRevision: zod_1.z
190
+ .number()
191
+ .int()
192
+ .positive()
193
+ .max(Number.MAX_SAFE_INTEGER - 1),
179
194
  })
180
195
  .strict();
181
196
  exports.kaanaCredentialOutcomeRequestSchema = zod_1.z.discriminatedUnion('action', [