@iveri/contracts 0.144.0 → 0.146.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.
- package/README.md +8 -0
- package/dist/api/clinic/clinic-appointment.type.d.ts +6 -0
- package/dist/api/clinic/clinic-cancellation-deposit.enum.d.ts +15 -0
- package/dist/api/clinic/clinic-cancellation-deposit.enum.js +16 -0
- package/dist/api/clinic/clinic-deposit-on-cancel.enum.d.ts +18 -0
- package/dist/api/clinic/clinic-deposit-on-cancel.enum.js +19 -0
- package/dist/api/clinic/clinic-my-appointment.type.d.ts +16 -0
- package/dist/api/clinic/clinic-online-refund-origin.enum.d.ts +10 -0
- package/dist/api/clinic/clinic-online-refund-origin.enum.js +11 -0
- package/dist/api/clinic/clinic-payment.type.d.ts +5 -0
- package/dist/api/clinic/clinic-profile.type.d.ts +9 -0
- package/dist/api/clinic/clinic-public.type.d.ts +2 -0
- package/dist/api/clinic/index.d.ts +3 -0
- package/dist/api/clinic/index.js +3 -0
- package/dist/api/restaurant/restaurant-bill.type.d.ts +9 -0
- package/dist/api/restaurant/restaurant-kitchen.type.d.ts +5 -0
- package/dist/api/unibox/ai-agent-setting.type.d.ts +15 -0
- package/dist/api/unibox/ai-agent-setting.type.js +4 -0
- package/dist/api/unibox-ai/agent-run.type.d.ts +40 -1
- package/dist/api/unibox-ai/agent-run.type.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -322,6 +322,14 @@ Conduit's outbox.
|
|
|
322
322
|
`UniboxAgents` under `@iveri/contracts/unibox`, so the inbox picks agents by name.
|
|
323
323
|
- Version `0.139.0` adds a trainer's notes on a member: `GymTrainerNote`, `GymTrainerNotes`, `SaveGymTrainerNoteRequest`,
|
|
324
324
|
`GymMyTrainerNote` and the `GymRefusal` member `not-their-trainer` under `@iveri/contracts/gym`.
|
|
325
|
+
- Version `0.146.0` adds the Unibox AI agent's daily token cap (`AiAgentSetting.dailyTokenCap`,
|
|
326
|
+
`AgentRunRequest.dailyTokenCap`, the `AgentRunOutcome` members `cap-reached` and `cap-pending`, `AgentRunDailySpend`
|
|
327
|
+
and `UniboxAiUsageMetric`), and a clinic's automatic deposit refund on a client's cancellation:
|
|
328
|
+
`ClinicProfile.depositRefundCutoffHours` and `takesDeposits`, `PublicClinic.depositRefundCutoffHours`,
|
|
329
|
+
`depositOnCancel` (`ClinicDepositOnCancel`) on both appointment shapes, `MyClinicCancellation` with
|
|
330
|
+
`ClinicCancellationDeposit`, and `ClinicOnlineRefund.origin` (`ClinicOnlineRefundOrigin`).
|
|
331
|
+
- Version `0.145.0` adds `tenderedMinor` / `changeMinor` on `RestaurantPayment`, an optional `tenderedMinor` on
|
|
332
|
+
`RecordRestaurantPaymentRequest` and `round` on `RestaurantKitchenTicket`, for printed receipts and kitchen tickets.
|
|
325
333
|
- Version `0.144.0` adds `unibox:ai:run-any`, `AiAgentSetting` and `UpdateAiAgentSettingBody` under
|
|
326
334
|
`@iveri/contracts/unibox`, and `AgentRunOutcome`, `AgentRunResult` and optional `AgentRunRequest` fields under `/unibox-ai`.
|
|
327
335
|
- Version `0.143.0` adds `billing:payment:refund` (moved off `billing:payment:manage`), `ClinicOnlineRefund`,
|
|
@@ -2,6 +2,7 @@ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
|
2
2
|
import type { Nullable } from '../../type/nil.type.js';
|
|
3
3
|
import type { UUID } from '../../type/uuid.type.js';
|
|
4
4
|
import type { ClinicAppointmentStatus } from './clinic-appointment-status.enum.js';
|
|
5
|
+
import type { ClinicDepositOnCancel } from './clinic-deposit-on-cancel.enum.js';
|
|
5
6
|
import type { ClinicDepositStatus } from './clinic-deposit-status.enum.js';
|
|
6
7
|
import type { LocalizedText } from './localized-text.type.js';
|
|
7
8
|
/** One option as it was when the appointment was booked. A later price change does not touch it. */
|
|
@@ -46,6 +47,11 @@ export interface ClinicAppointment {
|
|
|
46
47
|
* a visit that was no longer happening.
|
|
47
48
|
*/
|
|
48
49
|
cancelledAt: Nullable<IsoDateTime>;
|
|
50
|
+
/**
|
|
51
|
+
* What became of a paid deposit when the client cancelled the visit themselves: `kept` is one the desk may still
|
|
52
|
+
* give back by hand. `null` when nothing was decided, which includes every visit the clinic cancelled.
|
|
53
|
+
*/
|
|
54
|
+
depositOnCancel: Nullable<ClinicDepositOnCancel>;
|
|
49
55
|
lines: ClinicAppointmentLine[];
|
|
50
56
|
note: Nullable<string>;
|
|
51
57
|
createdAt: IsoDateTime;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What cancelling a visit now would do with its online deposit, as the clinic decides it, so a client is told before
|
|
3
|
+
* they confirm.
|
|
4
|
+
*
|
|
5
|
+
* - `none`: there is no paid deposit left to give back.
|
|
6
|
+
* - `given-back`: it goes back to the client in full, because they cancel early enough.
|
|
7
|
+
* - `kept-late`: the clinic gives deposits back, but not this close to the visit.
|
|
8
|
+
* - `kept`: the clinic does not give deposits back when a visit is cancelled.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum ClinicCancellationDeposit {
|
|
11
|
+
NONE = "none",
|
|
12
|
+
GIVEN_BACK = "given-back",
|
|
13
|
+
KEPT_LATE = "kept-late",
|
|
14
|
+
KEPT = "kept"
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What cancelling a visit now would do with its online deposit, as the clinic decides it, so a client is told before
|
|
3
|
+
* they confirm.
|
|
4
|
+
*
|
|
5
|
+
* - `none`: there is no paid deposit left to give back.
|
|
6
|
+
* - `given-back`: it goes back to the client in full, because they cancel early enough.
|
|
7
|
+
* - `kept-late`: the clinic gives deposits back, but not this close to the visit.
|
|
8
|
+
* - `kept`: the clinic does not give deposits back when a visit is cancelled.
|
|
9
|
+
*/
|
|
10
|
+
export var ClinicCancellationDeposit;
|
|
11
|
+
(function (ClinicCancellationDeposit) {
|
|
12
|
+
ClinicCancellationDeposit["NONE"] = "none";
|
|
13
|
+
ClinicCancellationDeposit["GIVEN_BACK"] = "given-back";
|
|
14
|
+
ClinicCancellationDeposit["KEPT_LATE"] = "kept-late";
|
|
15
|
+
ClinicCancellationDeposit["KEPT"] = "kept";
|
|
16
|
+
})(ClinicCancellationDeposit || (ClinicCancellationDeposit = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What became of a paid online deposit when the client cancelled the visit themselves.
|
|
3
|
+
*
|
|
4
|
+
* `null` on a visit nobody cancelled, one with no paid deposit, and one the clinic cancelled: reception gives a deposit
|
|
5
|
+
* back by hand, so nothing was decided for them.
|
|
6
|
+
*
|
|
7
|
+
* - `kept`: the clinic keeps it, because it gives nothing back automatically or the visit was cancelled too late. The
|
|
8
|
+
* clinic can still give it back by hand, and the visit then reads `refunded`.
|
|
9
|
+
* - `refund-pending`: asked of the bank, not yet confirmed. The clinic keeps asking on its own.
|
|
10
|
+
* - `refunded`: the bank gave the money back.
|
|
11
|
+
* - `refund-failed`: the bank refused; the client should contact the clinic.
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ClinicDepositOnCancel {
|
|
14
|
+
KEPT = "kept",
|
|
15
|
+
REFUND_PENDING = "refund-pending",
|
|
16
|
+
REFUNDED = "refunded",
|
|
17
|
+
REFUND_FAILED = "refund-failed"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What became of a paid online deposit when the client cancelled the visit themselves.
|
|
3
|
+
*
|
|
4
|
+
* `null` on a visit nobody cancelled, one with no paid deposit, and one the clinic cancelled: reception gives a deposit
|
|
5
|
+
* back by hand, so nothing was decided for them.
|
|
6
|
+
*
|
|
7
|
+
* - `kept`: the clinic keeps it, because it gives nothing back automatically or the visit was cancelled too late. The
|
|
8
|
+
* clinic can still give it back by hand, and the visit then reads `refunded`.
|
|
9
|
+
* - `refund-pending`: asked of the bank, not yet confirmed. The clinic keeps asking on its own.
|
|
10
|
+
* - `refunded`: the bank gave the money back.
|
|
11
|
+
* - `refund-failed`: the bank refused; the client should contact the clinic.
|
|
12
|
+
*/
|
|
13
|
+
export var ClinicDepositOnCancel;
|
|
14
|
+
(function (ClinicDepositOnCancel) {
|
|
15
|
+
ClinicDepositOnCancel["KEPT"] = "kept";
|
|
16
|
+
ClinicDepositOnCancel["REFUND_PENDING"] = "refund-pending";
|
|
17
|
+
ClinicDepositOnCancel["REFUNDED"] = "refunded";
|
|
18
|
+
ClinicDepositOnCancel["REFUND_FAILED"] = "refund-failed";
|
|
19
|
+
})(ClinicDepositOnCancel || (ClinicDepositOnCancel = {}));
|
|
@@ -3,6 +3,8 @@ import type { Nullable } from '../../type/nil.type.js';
|
|
|
3
3
|
import type { UUID } from '../../type/uuid.type.js';
|
|
4
4
|
import type { ClinicAppointmentStatus } from './clinic-appointment-status.enum.js';
|
|
5
5
|
import type { ClinicAppointmentLine } from './clinic-appointment.type.js';
|
|
6
|
+
import type { ClinicCancellationDeposit } from './clinic-cancellation-deposit.enum.js';
|
|
7
|
+
import type { ClinicDepositOnCancel } from './clinic-deposit-on-cancel.enum.js';
|
|
6
8
|
import type { ClinicDepositStatus } from './clinic-deposit-status.enum.js';
|
|
7
9
|
import type { ClinicScreeningAnswerRequest, SignClinicConsentRequest } from './clinic-record.type.js';
|
|
8
10
|
import type { LocalizedText } from './localized-text.type.js';
|
|
@@ -32,6 +34,8 @@ export interface MyClinicAppointment {
|
|
|
32
34
|
* a visit that was no longer happening.
|
|
33
35
|
*/
|
|
34
36
|
cancelledAt: Nullable<IsoDateTime>;
|
|
37
|
+
/** What became of a paid deposit when the client cancelled, or `null` when nothing was decided. */
|
|
38
|
+
depositOnCancel: Nullable<ClinicDepositOnCancel>;
|
|
35
39
|
lines: ClinicAppointmentLine[];
|
|
36
40
|
note: Nullable<string>;
|
|
37
41
|
/** Whether the clinic's rules still let this client cancel it themselves. */
|
|
@@ -39,6 +43,18 @@ export interface MyClinicAppointment {
|
|
|
39
43
|
/** Whether this visit is over and has not been reviewed yet. */
|
|
40
44
|
canReview: boolean;
|
|
41
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* What cancelling one of my visits now would do with its deposit (`GET /me/appointments/:id/cancellation`). Read just
|
|
48
|
+
* before the client confirms; the clinic decides again when the cancellation arrives, by its own clock.
|
|
49
|
+
*/
|
|
50
|
+
export interface MyClinicCancellation {
|
|
51
|
+
deposit: ClinicCancellationDeposit;
|
|
52
|
+
/** What would come back or be kept, in minor units of `currency`. Zero with `none`. */
|
|
53
|
+
depositMinor: number;
|
|
54
|
+
currency: string;
|
|
55
|
+
/** How many hours before the visit a cancellation still gets the deposit back, or `null` when it never does. */
|
|
56
|
+
depositRefundCutoffHours: Nullable<number>;
|
|
57
|
+
}
|
|
42
58
|
/** Another time for a visit already booked. Everything agreed for it stays as it was. */
|
|
43
59
|
export interface RescheduleMyClinicAppointmentRequest {
|
|
44
60
|
startsAt: IsoDateTime;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who asked for an online payment to be given back.
|
|
3
|
+
*
|
|
4
|
+
* - `desk`: somebody at the clinic, with the Refund button.
|
|
5
|
+
* - `client-cancellation`: the clinic's own rule, when a client cancelled early enough. Nobody at the desk asked.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ClinicOnlineRefundOrigin {
|
|
8
|
+
DESK = "desk",
|
|
9
|
+
CLIENT_CANCELLATION = "client-cancellation"
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who asked for an online payment to be given back.
|
|
3
|
+
*
|
|
4
|
+
* - `desk`: somebody at the clinic, with the Refund button.
|
|
5
|
+
* - `client-cancellation`: the clinic's own rule, when a client cancelled early enough. Nobody at the desk asked.
|
|
6
|
+
*/
|
|
7
|
+
export var ClinicOnlineRefundOrigin;
|
|
8
|
+
(function (ClinicOnlineRefundOrigin) {
|
|
9
|
+
ClinicOnlineRefundOrigin["DESK"] = "desk";
|
|
10
|
+
ClinicOnlineRefundOrigin["CLIENT_CANCELLATION"] = "client-cancellation";
|
|
11
|
+
})(ClinicOnlineRefundOrigin || (ClinicOnlineRefundOrigin = {}));
|
|
@@ -3,6 +3,7 @@ import type { Nullable } from '../../type/nil.type.js';
|
|
|
3
3
|
import type { UUID } from '../../type/uuid.type.js';
|
|
4
4
|
import type { ClinicAppointmentStatus } from './clinic-appointment-status.enum.js';
|
|
5
5
|
import type { ClinicCourse, MyClinicCourse } from './clinic-course.type.js';
|
|
6
|
+
import type { ClinicOnlineRefundOrigin } from './clinic-online-refund-origin.enum.js';
|
|
6
7
|
import type { ClinicOnlineRefundStatus } from './clinic-online-refund-status.enum.js';
|
|
7
8
|
import type { ClinicPaymentMethod } from './clinic-payment-method.enum.js';
|
|
8
9
|
import type { LocalizedText } from './localized-text.type.js';
|
|
@@ -59,9 +60,13 @@ export interface ClinicOnlineRefund {
|
|
|
59
60
|
amountMinor: number;
|
|
60
61
|
currency: string;
|
|
61
62
|
status: ClinicOnlineRefundStatus;
|
|
63
|
+
/** Somebody at the desk, or the clinic's own rule when a client cancelled early enough. */
|
|
64
|
+
origin: ClinicOnlineRefundOrigin;
|
|
65
|
+
/** Why, as the desk wrote it. The clinic's rule writes a fixed English line, which a client shows by `origin`. */
|
|
62
66
|
reason: string;
|
|
63
67
|
/** The ledger's negative line, once the bank confirmed. */
|
|
64
68
|
refundPaymentId: Nullable<UUID>;
|
|
69
|
+
/** Who asked at the desk, or `null` for the clinic's own rule. */
|
|
65
70
|
requestedByName: Nullable<string>;
|
|
66
71
|
createdAt: IsoDateTime;
|
|
67
72
|
/** When the bank's answer was recorded, either way. */
|
|
@@ -28,6 +28,13 @@ export interface ClinicProfile {
|
|
|
28
28
|
clientCancelCutoffHours: number;
|
|
29
29
|
/** How far ahead a client can book. */
|
|
30
30
|
bookingHorizonDays: number;
|
|
31
|
+
/**
|
|
32
|
+
* A client who cancels at least this many hours before a visit gets its online deposit back automatically, in full.
|
|
33
|
+
* `null`, the default, gives nothing back on its own: reception decides with the Refund button.
|
|
34
|
+
*/
|
|
35
|
+
depositRefundCutoffHours: Nullable<number>;
|
|
36
|
+
/** Whether this deployment takes online deposits for this clinic. The deposit settings mean nothing without it. */
|
|
37
|
+
takesDeposits: boolean;
|
|
31
38
|
/** The share of money paid that comes back as bonus. Zero means the clinic runs no bonus programme. */
|
|
32
39
|
bonusEarnPercent: number;
|
|
33
40
|
createdAt: IsoDateTime;
|
|
@@ -46,4 +53,6 @@ export interface SaveClinicProfileRequest {
|
|
|
46
53
|
clientCancelCutoffHours: number;
|
|
47
54
|
bookingHorizonDays: number;
|
|
48
55
|
bonusEarnPercent?: number;
|
|
56
|
+
/** Omitted keeps what is stored; `null` turns the automatic refund off. Refused where no deposits are taken. */
|
|
57
|
+
depositRefundCutoffHours?: Nullable<number>;
|
|
49
58
|
}
|
|
@@ -21,6 +21,8 @@ export interface PublicClinic {
|
|
|
21
21
|
phone: Nullable<string>;
|
|
22
22
|
email: Nullable<string>;
|
|
23
23
|
bookingHorizonDays: number;
|
|
24
|
+
/** A client cancelling at least this many hours ahead gets an online deposit back, or `null` when they never do. */
|
|
25
|
+
depositRefundCutoffHours: Nullable<number>;
|
|
24
26
|
}
|
|
25
27
|
export interface PublicSpecialty {
|
|
26
28
|
id: UUID;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './clinic-appointment-status.enum.js';
|
|
2
2
|
export * from './clinic-appointment.type.js';
|
|
3
|
+
export * from './clinic-cancellation-deposit.enum.js';
|
|
3
4
|
export * from './clinic-client.type.js';
|
|
4
5
|
export * from './clinic-consent-form.type.js';
|
|
5
6
|
export * from './clinic-course.type.js';
|
|
7
|
+
export * from './clinic-deposit-on-cancel.enum.js';
|
|
6
8
|
export * from './clinic-deposit-status.enum.js';
|
|
7
9
|
export * from './clinic-deposit.type.js';
|
|
8
10
|
export * from './clinic-device.type.js';
|
|
@@ -17,6 +19,7 @@ export * from './clinic-gallery.type.js';
|
|
|
17
19
|
export * from './clinic-media.type.js';
|
|
18
20
|
export * from './clinic-newsletter-channel.enum.js';
|
|
19
21
|
export * from './clinic-newsletter.type.js';
|
|
22
|
+
export * from './clinic-online-refund-origin.enum.js';
|
|
20
23
|
export * from './clinic-online-refund-status.enum.js';
|
|
21
24
|
export * from './clinic-payment-method.enum.js';
|
|
22
25
|
export * from './clinic-payment.type.js';
|
package/dist/api/clinic/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './clinic-appointment-status.enum.js';
|
|
2
2
|
export * from './clinic-appointment.type.js';
|
|
3
|
+
export * from './clinic-cancellation-deposit.enum.js';
|
|
3
4
|
export * from './clinic-client.type.js';
|
|
4
5
|
export * from './clinic-consent-form.type.js';
|
|
5
6
|
export * from './clinic-course.type.js';
|
|
7
|
+
export * from './clinic-deposit-on-cancel.enum.js';
|
|
6
8
|
export * from './clinic-deposit-status.enum.js';
|
|
7
9
|
export * from './clinic-deposit.type.js';
|
|
8
10
|
export * from './clinic-device.type.js';
|
|
@@ -17,6 +19,7 @@ export * from './clinic-gallery.type.js';
|
|
|
17
19
|
export * from './clinic-media.type.js';
|
|
18
20
|
export * from './clinic-newsletter-channel.enum.js';
|
|
19
21
|
export * from './clinic-newsletter.type.js';
|
|
22
|
+
export * from './clinic-online-refund-origin.enum.js';
|
|
20
23
|
export * from './clinic-online-refund-status.enum.js';
|
|
21
24
|
export * from './clinic-payment-method.enum.js';
|
|
22
25
|
export * from './clinic-payment.type.js';
|
|
@@ -11,6 +11,13 @@ export interface RestaurantPayment {
|
|
|
11
11
|
/** Negative for a refund. */
|
|
12
12
|
amountMinor: number;
|
|
13
13
|
tipMinor: number;
|
|
14
|
+
/**
|
|
15
|
+
* The cash the diner handed over, when the till recorded it: at least the amount and the tip. Null for a card, an
|
|
16
|
+
* online payment, a refund, and cash taken without counting what was handed over.
|
|
17
|
+
*/
|
|
18
|
+
tenderedMinor: number | null;
|
|
19
|
+
/** What was given back from `tenderedMinor`, worked out by the server. Null whenever `tenderedMinor` is. */
|
|
20
|
+
changeMinor: number | null;
|
|
14
21
|
/** The payment a refund gives back. */
|
|
15
22
|
refundOfId: UUID | null;
|
|
16
23
|
note: string | null;
|
|
@@ -60,6 +67,8 @@ export interface RecordRestaurantPaymentRequest {
|
|
|
60
67
|
method: RestaurantPaymentMethod.CASH | RestaurantPaymentMethod.CARD;
|
|
61
68
|
amountMinor: number;
|
|
62
69
|
tipMinor?: number;
|
|
70
|
+
/** Cash only: what the diner handed over, at least `amountMinor` plus `tipMinor`. The change is the rest. */
|
|
71
|
+
tenderedMinor?: number | null;
|
|
63
72
|
note?: string | null;
|
|
64
73
|
}
|
|
65
74
|
export interface RefundRestaurantPaymentRequest {
|
|
@@ -18,6 +18,11 @@ export interface RestaurantKitchenLine {
|
|
|
18
18
|
export interface RestaurantKitchenTicket {
|
|
19
19
|
orderId: UUID;
|
|
20
20
|
number: number;
|
|
21
|
+
/**
|
|
22
|
+
* Which round of its bill this order is: 1 for the first, 2 for the next a table ordered, and so on. Cancelled
|
|
23
|
+
* orders are not counted. A takeaway or a delivery is always 1.
|
|
24
|
+
*/
|
|
25
|
+
round: number;
|
|
21
26
|
stationId: UUID;
|
|
22
27
|
channel: RestaurantChannel;
|
|
23
28
|
tableLabel: string | null;
|
|
@@ -5,6 +5,10 @@ import type { UUID } from '../../type/uuid.type.js';
|
|
|
5
5
|
export declare const AI_AGENT_INSTRUCTIONS_MAX_LENGTH = 4000;
|
|
6
6
|
/** The most MCP servers one company's AI agent may use. */
|
|
7
7
|
export declare const AI_AGENT_MAX_MCP_SERVERS = 10;
|
|
8
|
+
/** The smallest daily allowance of tokens a company may set; below it no single run could finish. */
|
|
9
|
+
export declare const AI_AGENT_DAILY_TOKEN_CAP_MIN = 1000;
|
|
10
|
+
/** The largest daily allowance of tokens a company may set (what one integer column holds, rounded down). */
|
|
11
|
+
export declare const AI_AGENT_DAILY_TOKEN_CAP_MAX = 2000000000;
|
|
8
12
|
/**
|
|
9
13
|
* Whether a company's AI agent answers its customers, and with what.
|
|
10
14
|
*
|
|
@@ -21,6 +25,12 @@ export interface AiAgentSetting {
|
|
|
21
25
|
/** The company's own words for the agent (tone, what it may promise). Null uses the default. */
|
|
22
26
|
instructions: Nullable<string>;
|
|
23
27
|
mcpServerIds: UUID[];
|
|
28
|
+
/**
|
|
29
|
+
* Input and output tokens the agent may spend in one day (a calendar day in UTC), or null for no limit. Once the
|
|
30
|
+
* day's spend reaches it, no new run starts until midnight UTC and the conversations it would have answered are left
|
|
31
|
+
* for a person; a run already going when it is crossed finishes.
|
|
32
|
+
*/
|
|
33
|
+
dailyTokenCap: Nullable<number>;
|
|
24
34
|
updatedAt: Nullable<IsoDateTime>;
|
|
25
35
|
}
|
|
26
36
|
/** `PUT /api/v1/ai-agent`. The whole setting, replaced. */
|
|
@@ -30,4 +40,9 @@ export interface UpdateAiAgentSettingBody {
|
|
|
30
40
|
instructions: Nullable<string>;
|
|
31
41
|
/** Up to {@link AI_AGENT_MAX_MCP_SERVERS} distinct ids. */
|
|
32
42
|
mcpServerIds: UUID[];
|
|
43
|
+
/**
|
|
44
|
+
* Between {@link AI_AGENT_DAILY_TOKEN_CAP_MIN} and {@link AI_AGENT_DAILY_TOKEN_CAP_MAX}, or null for no limit.
|
|
45
|
+
* Absent keeps the stored allowance, so a client that does not know it cannot clear it.
|
|
46
|
+
*/
|
|
47
|
+
dailyTokenCap?: Nullable<number>;
|
|
33
48
|
}
|
|
@@ -2,3 +2,7 @@
|
|
|
2
2
|
export const AI_AGENT_INSTRUCTIONS_MAX_LENGTH = 4000;
|
|
3
3
|
/** The most MCP servers one company's AI agent may use. */
|
|
4
4
|
export const AI_AGENT_MAX_MCP_SERVERS = 10;
|
|
5
|
+
/** The smallest daily allowance of tokens a company may set; below it no single run could finish. */
|
|
6
|
+
export const AI_AGENT_DAILY_TOKEN_CAP_MIN = 1_000;
|
|
7
|
+
/** The largest daily allowance of tokens a company may set (what one integer column holds, rounded down). */
|
|
8
|
+
export const AI_AGENT_DAILY_TOKEN_CAP_MAX = 2_000_000_000;
|
|
@@ -40,6 +40,12 @@ export interface AgentRunRequest {
|
|
|
40
40
|
instructions?: Nullable<string>;
|
|
41
41
|
/** The company's MCP servers the agent may call. An id naming no active server is skipped. */
|
|
42
42
|
mcpServerIds?: UUID[];
|
|
43
|
+
/**
|
|
44
|
+
* The company's daily allowance of tokens (`AiAgentSetting.dailyTokenCap`), null or absent for none. The runtime
|
|
45
|
+
* counts the day (UTC) from its own run rows and refuses to start a run once the allowance is spent
|
|
46
|
+
* (`cap-reached`), or while runs still going could spend the rest of it (`cap-pending`).
|
|
47
|
+
*/
|
|
48
|
+
dailyTokenCap?: Nullable<number>;
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* How one agent run ended. Only `answered` carries a reply; every other outcome means nothing is sent.
|
|
@@ -52,6 +58,10 @@ export interface AgentRunRequest {
|
|
|
52
58
|
* - `refused`: the model declined to answer.
|
|
53
59
|
* - `unavailable`: no model provider is configured, so nothing can be generated.
|
|
54
60
|
* - `failed`: the model provider failed.
|
|
61
|
+
* - `cap-reached`: the company's tokens for the day (UTC) have reached its daily allowance; nothing was generated and
|
|
62
|
+
* nothing is until the day ends. The conversation is left for a person.
|
|
63
|
+
* - `cap-pending`: runs still going could spend the rest of the day's allowance; nothing was generated. Asking again
|
|
64
|
+
* once they have finished may be answered.
|
|
55
65
|
*/
|
|
56
66
|
export declare enum AgentRunOutcome {
|
|
57
67
|
ANSWERED = "answered",
|
|
@@ -61,7 +71,9 @@ export declare enum AgentRunOutcome {
|
|
|
61
71
|
TIMED_OUT = "timed-out",
|
|
62
72
|
REFUSED = "refused",
|
|
63
73
|
UNAVAILABLE = "unavailable",
|
|
64
|
-
FAILED = "failed"
|
|
74
|
+
FAILED = "failed",
|
|
75
|
+
CAP_REACHED = "cap-reached",
|
|
76
|
+
CAP_PENDING = "cap-pending"
|
|
65
77
|
}
|
|
66
78
|
/**
|
|
67
79
|
* `POST /api/v1/agent-runs`: the run, finished. The caller decides whether to send `replyText`; the runtime never
|
|
@@ -80,6 +92,33 @@ export interface AgentRunResult {
|
|
|
80
92
|
toolCallCount: number;
|
|
81
93
|
completedAt: IsoDateTime;
|
|
82
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* `GET /api/v1/agent-runs/today`: what the company's AI agent has spent today, a day being a calendar day in UTC. Counted
|
|
97
|
+
* from the run rows, so a run still going counts only once it has finished.
|
|
98
|
+
*/
|
|
99
|
+
export interface AgentRunDailySpend {
|
|
100
|
+
/** The day, `YYYY-MM-DD` in UTC. */
|
|
101
|
+
day: string;
|
|
102
|
+
/** Input and output tokens of the runs finished today. */
|
|
103
|
+
tokens: number;
|
|
104
|
+
inputTokens: number;
|
|
105
|
+
outputTokens: number;
|
|
106
|
+
/** Runs that called the model today. */
|
|
107
|
+
runCount: number;
|
|
108
|
+
/** Messages the agent did not answer today because the daily allowance was spent (`cap-reached`). */
|
|
109
|
+
capReachedCount: number;
|
|
110
|
+
/** When the day ends and the allowance starts again: the next midnight UTC. */
|
|
111
|
+
resetsAt: IsoDateTime;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* What `unibox-ai` meters into `iveri-billing-api` for each company, one report per finished run and metric: the
|
|
115
|
+
* metric names billing stores, under the `unibox` product's prefix. Input and output are apart because a model
|
|
116
|
+
* provider prices them apart. **Counted, never enforced by billing**: the company's daily allowance is the only limit.
|
|
117
|
+
*/
|
|
118
|
+
export declare enum UniboxAiUsageMetric {
|
|
119
|
+
INPUT_TOKENS = "unibox.ai-input-tokens",
|
|
120
|
+
OUTPUT_TOKENS = "unibox.ai-output-tokens"
|
|
121
|
+
}
|
|
83
122
|
/** @deprecated The acceptance stage `POST /api/v1/agent-runs` answered before runs generated; see {@link AgentRunOutcome}. */
|
|
84
123
|
export declare enum AgentRunStatus {
|
|
85
124
|
ACCEPTED = "accepted",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* - `refused`: the model declined to answer.
|
|
10
10
|
* - `unavailable`: no model provider is configured, so nothing can be generated.
|
|
11
11
|
* - `failed`: the model provider failed.
|
|
12
|
+
* - `cap-reached`: the company's tokens for the day (UTC) have reached its daily allowance; nothing was generated and
|
|
13
|
+
* nothing is until the day ends. The conversation is left for a person.
|
|
14
|
+
* - `cap-pending`: runs still going could spend the rest of the day's allowance; nothing was generated. Asking again
|
|
15
|
+
* once they have finished may be answered.
|
|
12
16
|
*/
|
|
13
17
|
export var AgentRunOutcome;
|
|
14
18
|
(function (AgentRunOutcome) {
|
|
@@ -20,7 +24,19 @@ export var AgentRunOutcome;
|
|
|
20
24
|
AgentRunOutcome["REFUSED"] = "refused";
|
|
21
25
|
AgentRunOutcome["UNAVAILABLE"] = "unavailable";
|
|
22
26
|
AgentRunOutcome["FAILED"] = "failed";
|
|
27
|
+
AgentRunOutcome["CAP_REACHED"] = "cap-reached";
|
|
28
|
+
AgentRunOutcome["CAP_PENDING"] = "cap-pending";
|
|
23
29
|
})(AgentRunOutcome || (AgentRunOutcome = {}));
|
|
30
|
+
/**
|
|
31
|
+
* What `unibox-ai` meters into `iveri-billing-api` for each company, one report per finished run and metric: the
|
|
32
|
+
* metric names billing stores, under the `unibox` product's prefix. Input and output are apart because a model
|
|
33
|
+
* provider prices them apart. **Counted, never enforced by billing**: the company's daily allowance is the only limit.
|
|
34
|
+
*/
|
|
35
|
+
export var UniboxAiUsageMetric;
|
|
36
|
+
(function (UniboxAiUsageMetric) {
|
|
37
|
+
UniboxAiUsageMetric["INPUT_TOKENS"] = "unibox.ai-input-tokens";
|
|
38
|
+
UniboxAiUsageMetric["OUTPUT_TOKENS"] = "unibox.ai-output-tokens";
|
|
39
|
+
})(UniboxAiUsageMetric || (UniboxAiUsageMetric = {}));
|
|
24
40
|
/** @deprecated The acceptance stage `POST /api/v1/agent-runs` answered before runs generated; see {@link AgentRunOutcome}. */
|
|
25
41
|
export var AgentRunStatus;
|
|
26
42
|
(function (AgentRunStatus) {
|