@iveri/contracts 0.143.0 → 0.145.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 +4 -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 +33 -0
- package/dist/api/unibox/ai-agent-setting.type.js +4 -0
- package/dist/api/unibox/index.d.ts +1 -0
- package/dist/api/unibox/index.js +1 -0
- package/dist/api/unibox/message-author-type.enum.d.ts +2 -1
- package/dist/api/unibox/message-author-type.enum.js +2 -1
- package/dist/api/unibox-ai/agent-run.type.d.ts +56 -1
- package/dist/api/unibox-ai/agent-run.type.js +24 -0
- package/dist/enum/user-permission.enum.d.ts +6 -0
- package/dist/enum/user-permission.enum.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -322,6 +322,10 @@ 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.145.0` adds `tenderedMinor` / `changeMinor` on `RestaurantPayment`, an optional `tenderedMinor` on
|
|
326
|
+
`RecordRestaurantPaymentRequest` and `round` on `RestaurantKitchenTicket`, for printed receipts and kitchen tickets.
|
|
327
|
+
- Version `0.144.0` adds `unibox:ai:run-any`, `AiAgentSetting` and `UpdateAiAgentSettingBody` under
|
|
328
|
+
`@iveri/contracts/unibox`, and `AgentRunOutcome`, `AgentRunResult` and optional `AgentRunRequest` fields under `/unibox-ai`.
|
|
325
329
|
- Version `0.143.0` adds `billing:payment:refund` (moved off `billing:payment:manage`), `ClinicOnlineRefund`,
|
|
326
330
|
`ClinicOnlineRefundStatus` and `ClinicVisitPayments.onlineRefunds`, and refund members of `ClinicRefusal` and `CommerceRefusal`.
|
|
327
331
|
- Version `0.142.0` adds `isErased` on `ChatPersonCard`, `ChatParticipant` and `ChatMessageSender`, and
|
|
@@ -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;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
/** The longest instructions a company may give its AI agent, in characters. */
|
|
5
|
+
export declare const AI_AGENT_INSTRUCTIONS_MAX_LENGTH = 4000;
|
|
6
|
+
/** The most MCP servers one company's AI agent may use. */
|
|
7
|
+
export declare const AI_AGENT_MAX_MCP_SERVERS = 10;
|
|
8
|
+
/**
|
|
9
|
+
* Whether a company's AI agent answers its customers, and with what.
|
|
10
|
+
*
|
|
11
|
+
* **Off unless somebody turns it on.** While it is on, every inbound message on a conversation nobody has taken over is
|
|
12
|
+
* answered by the agent through the company's own channel; a person pressing "Take over" stops it for that
|
|
13
|
+
* conversation for good (`Conversation.handedOverAt`). A company that never saved a setting reads as off, with
|
|
14
|
+
* `updatedAt` null.
|
|
15
|
+
*
|
|
16
|
+
* `mcpServerIds` name servers registered in `unibox-ai` (`McpServer.id`), the only tools the agent may call. An id that
|
|
17
|
+
* no longer names an active server is skipped when a run starts, never an error a customer would see.
|
|
18
|
+
*/
|
|
19
|
+
export interface AiAgentSetting {
|
|
20
|
+
isEnabled: boolean;
|
|
21
|
+
/** The company's own words for the agent (tone, what it may promise). Null uses the default. */
|
|
22
|
+
instructions: Nullable<string>;
|
|
23
|
+
mcpServerIds: UUID[];
|
|
24
|
+
updatedAt: Nullable<IsoDateTime>;
|
|
25
|
+
}
|
|
26
|
+
/** `PUT /api/v1/ai-agent`. The whole setting, replaced. */
|
|
27
|
+
export interface UpdateAiAgentSettingBody {
|
|
28
|
+
isEnabled: boolean;
|
|
29
|
+
/** Up to {@link AI_AGENT_INSTRUCTIONS_MAX_LENGTH} characters; null or blank uses the default. */
|
|
30
|
+
instructions: Nullable<string>;
|
|
31
|
+
/** Up to {@link AI_AGENT_MAX_MCP_SERVERS} distinct ids. */
|
|
32
|
+
mcpServerIds: UUID[];
|
|
33
|
+
}
|
package/dist/api/unibox/index.js
CHANGED
|
@@ -13,7 +13,8 @@ export declare enum MessageAuthorType {
|
|
|
13
13
|
/** A human agent. `authorUserId` names them. */
|
|
14
14
|
AGENT = "agent",
|
|
15
15
|
/**
|
|
16
|
-
* The AI agent.
|
|
16
|
+
* The AI agent. `unibox-api` writes it for a reply `unibox-ai` composed, sent through the company's channel like an
|
|
17
|
+
* agent's; `authorUserId` is null.
|
|
17
18
|
*
|
|
18
19
|
* Distinct from `AGENT` because "did a person say this?" is the question a human asks before
|
|
19
20
|
* taking over, and because a customer who later asks whether they were talking to a bot
|
|
@@ -14,7 +14,8 @@ export var MessageAuthorType;
|
|
|
14
14
|
/** A human agent. `authorUserId` names them. */
|
|
15
15
|
MessageAuthorType["AGENT"] = "agent";
|
|
16
16
|
/**
|
|
17
|
-
* The AI agent.
|
|
17
|
+
* The AI agent. `unibox-api` writes it for a reply `unibox-ai` composed, sent through the company's channel like an
|
|
18
|
+
* agent's; `authorUserId` is null.
|
|
18
19
|
*
|
|
19
20
|
* Distinct from `AGENT` because "did a person say this?" is the question a human asks before
|
|
20
21
|
* taking over, and because a customer who later asks whether they were talking to a bot
|
|
@@ -24,13 +24,68 @@ export interface AgentRunRequest {
|
|
|
24
24
|
contactDisplayName: string;
|
|
25
25
|
conversationStatus: ConversationStatus;
|
|
26
26
|
handedOverAt: Nullable<IsoDateTime>;
|
|
27
|
+
/**
|
|
28
|
+
* The conversation so far, oldest first: what the contact and the company said to each other. Internal notes are
|
|
29
|
+
* never sent. The runtime keeps none of it; it builds the prompt from this and forgets it when the run ends.
|
|
30
|
+
*/
|
|
27
31
|
messages: AgentContextMessage[];
|
|
32
|
+
/**
|
|
33
|
+
* The company the run is for, named only by a token holding `unibox:ai:run-any` from Iveri's operator workspace
|
|
34
|
+
* (403 otherwise). Omitted, the run is for the token's own company.
|
|
35
|
+
*/
|
|
36
|
+
tenantId?: Nullable<UUID>;
|
|
37
|
+
/** `unibox-api`'s own id for the request, kept on the run row so the two records can be joined. */
|
|
38
|
+
agentRequestId?: Nullable<UUID>;
|
|
39
|
+
/** The company's own instructions for the agent (`AiAgentSetting` in `@iveri/contracts/unibox`); null or absent uses the default. */
|
|
40
|
+
instructions?: Nullable<string>;
|
|
41
|
+
/** The company's MCP servers the agent may call. An id naming no active server is skipped. */
|
|
42
|
+
mcpServerIds?: UUID[];
|
|
28
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* How one agent run ended. Only `answered` carries a reply; every other outcome means nothing is sent.
|
|
46
|
+
*
|
|
47
|
+
* - `answered`: the model wrote a reply.
|
|
48
|
+
* - `no-reply`: nothing to answer (the last message is not the contact's) or the model chose to write nothing.
|
|
49
|
+
* - `handed-over`: a person had taken the conversation before the run started; nothing was generated.
|
|
50
|
+
* - `budget-exceeded`: the run hit its token budget or its limit of tool rounds before writing a reply.
|
|
51
|
+
* - `timed-out`: the run hit its time limit, or the caller went away and the run was cancelled.
|
|
52
|
+
* - `refused`: the model declined to answer.
|
|
53
|
+
* - `unavailable`: no model provider is configured, so nothing can be generated.
|
|
54
|
+
* - `failed`: the model provider failed.
|
|
55
|
+
*/
|
|
56
|
+
export declare enum AgentRunOutcome {
|
|
57
|
+
ANSWERED = "answered",
|
|
58
|
+
NO_REPLY = "no-reply",
|
|
59
|
+
HANDED_OVER = "handed-over",
|
|
60
|
+
BUDGET_EXCEEDED = "budget-exceeded",
|
|
61
|
+
TIMED_OUT = "timed-out",
|
|
62
|
+
REFUSED = "refused",
|
|
63
|
+
UNAVAILABLE = "unavailable",
|
|
64
|
+
FAILED = "failed"
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `POST /api/v1/agent-runs`: the run, finished. The caller decides whether to send `replyText`; the runtime never
|
|
68
|
+
* sends anything itself, so a person who takes the conversation while the model is thinking still wins.
|
|
69
|
+
*/
|
|
70
|
+
export interface AgentRunResult {
|
|
71
|
+
runId: UUID;
|
|
72
|
+
outcome: AgentRunOutcome;
|
|
73
|
+
/** The reply to send. Set only when `outcome` is `answered`. */
|
|
74
|
+
replyText: Nullable<string>;
|
|
75
|
+
/** The model that ran, null when none did. */
|
|
76
|
+
model: Nullable<string>;
|
|
77
|
+
inputTokens: number;
|
|
78
|
+
outputTokens: number;
|
|
79
|
+
/** Tool calls the model asked for, each recorded as an MCP execution row. */
|
|
80
|
+
toolCallCount: number;
|
|
81
|
+
completedAt: IsoDateTime;
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated The acceptance stage `POST /api/v1/agent-runs` answered before runs generated; see {@link AgentRunOutcome}. */
|
|
29
84
|
export declare enum AgentRunStatus {
|
|
30
85
|
ACCEPTED = "accepted",
|
|
31
86
|
HANDED_OVER = "handed_over"
|
|
32
87
|
}
|
|
33
|
-
/** The acceptance response
|
|
88
|
+
/** @deprecated The acceptance response from before runs generated; `POST /api/v1/agent-runs` answers {@link AgentRunResult}. */
|
|
34
89
|
export interface AgentRunAcceptedResponse {
|
|
35
90
|
runId: UUID;
|
|
36
91
|
status: AgentRunStatus;
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How one agent run ended. Only `answered` carries a reply; every other outcome means nothing is sent.
|
|
3
|
+
*
|
|
4
|
+
* - `answered`: the model wrote a reply.
|
|
5
|
+
* - `no-reply`: nothing to answer (the last message is not the contact's) or the model chose to write nothing.
|
|
6
|
+
* - `handed-over`: a person had taken the conversation before the run started; nothing was generated.
|
|
7
|
+
* - `budget-exceeded`: the run hit its token budget or its limit of tool rounds before writing a reply.
|
|
8
|
+
* - `timed-out`: the run hit its time limit, or the caller went away and the run was cancelled.
|
|
9
|
+
* - `refused`: the model declined to answer.
|
|
10
|
+
* - `unavailable`: no model provider is configured, so nothing can be generated.
|
|
11
|
+
* - `failed`: the model provider failed.
|
|
12
|
+
*/
|
|
13
|
+
export var AgentRunOutcome;
|
|
14
|
+
(function (AgentRunOutcome) {
|
|
15
|
+
AgentRunOutcome["ANSWERED"] = "answered";
|
|
16
|
+
AgentRunOutcome["NO_REPLY"] = "no-reply";
|
|
17
|
+
AgentRunOutcome["HANDED_OVER"] = "handed-over";
|
|
18
|
+
AgentRunOutcome["BUDGET_EXCEEDED"] = "budget-exceeded";
|
|
19
|
+
AgentRunOutcome["TIMED_OUT"] = "timed-out";
|
|
20
|
+
AgentRunOutcome["REFUSED"] = "refused";
|
|
21
|
+
AgentRunOutcome["UNAVAILABLE"] = "unavailable";
|
|
22
|
+
AgentRunOutcome["FAILED"] = "failed";
|
|
23
|
+
})(AgentRunOutcome || (AgentRunOutcome = {}));
|
|
24
|
+
/** @deprecated The acceptance stage `POST /api/v1/agent-runs` answered before runs generated; see {@link AgentRunOutcome}. */
|
|
1
25
|
export var AgentRunStatus;
|
|
2
26
|
(function (AgentRunStatus) {
|
|
3
27
|
AgentRunStatus["ACCEPTED"] = "accepted";
|
|
@@ -258,6 +258,12 @@ export declare enum UserPermission {
|
|
|
258
258
|
UNIBOX_REALTIME_PUBLISH_ANY = "unibox:realtime:publish-any",
|
|
259
259
|
/** Allows a trusted service principal to submit bounded conversation context for generation. */
|
|
260
260
|
UNIBOX_AI_RUN = "unibox:ai:run",
|
|
261
|
+
/**
|
|
262
|
+
* Ask for an agent run in a company the request names in `tenantId`, rather than the token's own. A platform
|
|
263
|
+
* permission, held beside {@link UserPermission.UNIBOX_AI_RUN} only by `unibox-api`'s credential in Iveri's operator
|
|
264
|
+
* workspace, so one key answers every company's inbound messages, each with that company's own MCP servers.
|
|
265
|
+
*/
|
|
266
|
+
UNIBOX_AI_RUN_ANY = "unibox:ai:run-any",
|
|
261
267
|
/** Read tenant MCP server metadata; credential values are never returned. */
|
|
262
268
|
UNIBOX_MCP_READ = "unibox:mcp:read",
|
|
263
269
|
/** Create, update or disconnect a tenant MCP server. */
|
|
@@ -305,6 +305,12 @@ export var UserPermission;
|
|
|
305
305
|
// ── AI runtime ──────────────────────────────────────────────────────────
|
|
306
306
|
/** Allows a trusted service principal to submit bounded conversation context for generation. */
|
|
307
307
|
UserPermission["UNIBOX_AI_RUN"] = "unibox:ai:run";
|
|
308
|
+
/**
|
|
309
|
+
* Ask for an agent run in a company the request names in `tenantId`, rather than the token's own. A platform
|
|
310
|
+
* permission, held beside {@link UserPermission.UNIBOX_AI_RUN} only by `unibox-api`'s credential in Iveri's operator
|
|
311
|
+
* workspace, so one key answers every company's inbound messages, each with that company's own MCP servers.
|
|
312
|
+
*/
|
|
313
|
+
UserPermission["UNIBOX_AI_RUN_ANY"] = "unibox:ai:run-any";
|
|
308
314
|
// ── MCP registry ────────────────────────────────────────────────────────
|
|
309
315
|
/** Read tenant MCP server metadata; credential values are never returned. */
|
|
310
316
|
UserPermission["UNIBOX_MCP_READ"] = "unibox:mcp:read";
|
|
@@ -869,6 +875,7 @@ export const PLATFORM_PERMISSIONS = Object.freeze([
|
|
|
869
875
|
UserPermission.MOBILITY_DISPATCH_OPERATE_ANY,
|
|
870
876
|
UserPermission.CONDUIT_DISPATCH_SEND_ANY,
|
|
871
877
|
UserPermission.UNIBOX_REALTIME_PUBLISH_ANY,
|
|
878
|
+
UserPermission.UNIBOX_AI_RUN_ANY,
|
|
872
879
|
UserPermission.DELIVERY_JOB_READ_ANY,
|
|
873
880
|
UserPermission.DELIVERY_JOB_CREATE_ANY,
|
|
874
881
|
UserPermission.DELIVERY_JOB_OPERATE_ANY,
|