@breign/db-schemas 0.1.81 → 0.1.83
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/dist/types/engine.d.ts +15 -0
- package/dist/types/gitlab-integration.d.ts +70 -9
- package/dist/types/organization.d.ts +0 -2
- package/dist/types/scheduled-task-run.d.ts +2 -2
- package/dist/types/scheduled-task.d.ts +9 -2
- package/package.json +1 -1
- package/src/types/engine.ts +17 -0
- package/src/types/gitlab-integration.ts +76 -9
- package/src/types/organization.ts +0 -2
- package/src/types/scheduled-task-run.ts +2 -2
- package/src/types/scheduled-task.ts +8 -2
package/dist/types/engine.d.ts
CHANGED
|
@@ -14,6 +14,21 @@ export type Provider = {
|
|
|
14
14
|
isPlatform?: boolean;
|
|
15
15
|
};
|
|
16
16
|
export type ProviderSource = 'INTERNAL' | 'EXTERNAL';
|
|
17
|
+
/**
|
|
18
|
+
* Accès d'une organisation à un modèle, identifié par `(providerId, modelId)` où `modelId` est
|
|
19
|
+
* l'identifiant du fournisseur (ex. `gpt-4o`), pas l'id interne du modèle.
|
|
20
|
+
* Pour un moteur plateforme, l'existence de l'accès vaut attribution à l'organisation ; pour un
|
|
21
|
+
* moteur d'organisation, il ne sert qu'à restreindre le modèle à certains membres.
|
|
22
|
+
*/
|
|
23
|
+
export type ModelOrganizationAccess = {
|
|
24
|
+
providerId: string;
|
|
25
|
+
modelId: string;
|
|
26
|
+
organizationId: string;
|
|
27
|
+
/** Vrai ⇒ seuls `userIds` (et les admins de l'organisation) peuvent utiliser le modèle. */
|
|
28
|
+
restrictToUsers: boolean;
|
|
29
|
+
userIds: string[];
|
|
30
|
+
};
|
|
31
|
+
export type ModelRef = Pick<ModelOrganizationAccess, 'providerId' | 'modelId'>;
|
|
17
32
|
export type ProviderSimple = Pick<Provider, 'id' | 'name' | 'providerType' | 'models'>;
|
|
18
33
|
export type EngineOptions = {
|
|
19
34
|
store?: boolean;
|
|
@@ -94,17 +94,33 @@ export type ExternalEventRouting = {
|
|
|
94
94
|
agentName: string | null;
|
|
95
95
|
instruction: string;
|
|
96
96
|
};
|
|
97
|
-
/**
|
|
98
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Ce qu'on garde d'un appel de webhook générique. `body` est le JSON reçu s'il tient dans la
|
|
99
|
+
* limite de stockage ; sinon `body` est `null` et `bodyText` en garde le début.
|
|
100
|
+
*/
|
|
101
|
+
export type WebhookEventPayload = {
|
|
102
|
+
contentType: string;
|
|
103
|
+
body: unknown;
|
|
104
|
+
bodyText: string | null;
|
|
105
|
+
bodyTruncated: boolean;
|
|
106
|
+
/** Une liste blanche d'en-têtes (jamais `Authorization`), noms en minuscules. */
|
|
107
|
+
headers: Record<string, string>;
|
|
108
|
+
/** `X-Breign-Thread` tel qu'envoyé : les appels de même clé reprennent la même conversation. */
|
|
109
|
+
thread: string | null;
|
|
110
|
+
};
|
|
111
|
+
type ExternalEventBase = {
|
|
99
112
|
id: string;
|
|
100
|
-
integrationId: string;
|
|
101
113
|
organizationId: string;
|
|
102
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* GitLab : `X-Gitlab-Event-UUID` ; webhook : `<endpointId>:<Idempotency-Key>` (ou un uuid
|
|
116
|
+
* généré), préfixé pour rester unique entre endpoints. Unique avec l'intégration ou l'endpoint :
|
|
117
|
+
* un renvoi n'est pas rejoué.
|
|
118
|
+
*/
|
|
103
119
|
eventUuid: string;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
120
|
+
/**
|
|
121
|
+
* GitLab : instance + projet + objet + discussion ; webhook : endpoint + clé de fil, ou
|
|
122
|
+
* l'événement seul. Deux événements d'un même fil s'y retrouvent, l'un après l'autre.
|
|
123
|
+
*/
|
|
108
124
|
threadKey: string;
|
|
109
125
|
botAccountId: string | null;
|
|
110
126
|
agentId: string | null;
|
|
@@ -125,7 +141,51 @@ export type ExternalEvent = {
|
|
|
125
141
|
finishedAt: string | null;
|
|
126
142
|
updatedAt: string;
|
|
127
143
|
};
|
|
128
|
-
/**
|
|
144
|
+
/** Une mention reçue d'une intégration GitLab. */
|
|
145
|
+
export type GitlabExternalEvent = ExternalEventBase & {
|
|
146
|
+
source: 'gitlab';
|
|
147
|
+
integrationId: string;
|
|
148
|
+
webhookEndpointId: null;
|
|
149
|
+
kind: ExternalEventKind;
|
|
150
|
+
payload: ExternalEventPayload;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Un appel du webhook d'une automatisation : l'automatisation et l'agent sont connus dès la
|
|
154
|
+
* réception, il n'y a pas de routage (ni compte bot, ni réponse dans un fil).
|
|
155
|
+
*/
|
|
156
|
+
export type WebhookExternalEvent = ExternalEventBase & {
|
|
157
|
+
source: 'webhook';
|
|
158
|
+
integrationId: null;
|
|
159
|
+
webhookEndpointId: string;
|
|
160
|
+
kind: 'webhook';
|
|
161
|
+
payload: WebhookEventPayload;
|
|
162
|
+
};
|
|
163
|
+
/** Un événement reçu d'une source externe, et son passage dans la file. */
|
|
164
|
+
export type ExternalEvent = GitlabExternalEvent | WebhookExternalEvent;
|
|
165
|
+
export type ExternalEventSource = ExternalEvent['source'];
|
|
166
|
+
export type WebhookEndpointStatus = 'active' | 'disabled';
|
|
167
|
+
/**
|
|
168
|
+
* L'adresse publique d'une automatisation déclenchée par webhook :
|
|
169
|
+
* `POST /webhooks/automations/:id`. Régénérer l'URL crée un nouvel `id`, l'ancien répond 404.
|
|
170
|
+
*/
|
|
171
|
+
export type WebhookEndpoint = {
|
|
172
|
+
id: string;
|
|
173
|
+
organizationId: string;
|
|
174
|
+
/** Une automatisation a au plus un endpoint. */
|
|
175
|
+
taskId: string;
|
|
176
|
+
/** Le secret (Bearer ou clé HMAC), chiffré en base. */
|
|
177
|
+
secret: string;
|
|
178
|
+
/**
|
|
179
|
+
* Le membre de l'organisation au nom duquel tournent les conversations : outils MCP de portée
|
|
180
|
+
* utilisateur, quotas, et qui retrouve la conversation dans son historique.
|
|
181
|
+
*/
|
|
182
|
+
runAsUserId: string;
|
|
183
|
+
status: WebhookEndpointStatus;
|
|
184
|
+
lastEventAt: string | null;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
updatedAt: string;
|
|
187
|
+
};
|
|
188
|
+
/** La conversation d'un agent dans un fil (GitLab, ou clé de fil d'un webhook) : les événements suivants la reprennent. */
|
|
129
189
|
export type ExternalThread = {
|
|
130
190
|
threadKey: string;
|
|
131
191
|
agentId: string;
|
|
@@ -134,3 +194,4 @@ export type ExternalThread = {
|
|
|
134
194
|
createdAt: string;
|
|
135
195
|
lastRunAt: string | null;
|
|
136
196
|
};
|
|
197
|
+
export {};
|
|
@@ -11,8 +11,6 @@ export type Organization = {
|
|
|
11
11
|
};
|
|
12
12
|
/** Configuration OCR de l'organisation. Absente ⇒ OCR désactivé. */
|
|
13
13
|
ocr?: OrganizationOcrConfig | null;
|
|
14
|
-
/** L'organisation peut choisir les moteurs plateforme (clé Breign). */
|
|
15
|
-
allowPlatformEngines?: boolean;
|
|
16
14
|
users: {
|
|
17
15
|
id: string;
|
|
18
16
|
role: 'admin' | 'user' | string;
|
|
@@ -10,7 +10,7 @@ export type RunStep = {
|
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Qui exécute le run : `external`, l'exécuteur des tâches programmées (via la file) ;
|
|
13
|
-
* `internal`, brain-api lui-même (runs déclenchés par un événement). L'exécuteur externe et la
|
|
13
|
+
* `internal`, brain-api lui-même (runs déclenchés par un événement ou un webhook). L'exécuteur externe et la
|
|
14
14
|
* reprise des runs bloqués ignorent les runs `internal`.
|
|
15
15
|
*/
|
|
16
16
|
export type RunExecutor = 'internal' | 'external';
|
|
@@ -26,7 +26,7 @@ export type ScheduledTaskRun = {
|
|
|
26
26
|
claimedAt?: Date;
|
|
27
27
|
retryCount: number;
|
|
28
28
|
steps: RunStep[];
|
|
29
|
-
/** L'événement externe à l'origine du run (mention GitLab). */
|
|
29
|
+
/** L'événement externe à l'origine du run (mention GitLab, appel de webhook). */
|
|
30
30
|
triggerEventId?: string;
|
|
31
31
|
/** Absent : `external`. */
|
|
32
32
|
executor?: RunExecutor;
|
|
@@ -48,7 +48,14 @@ export type TaskTriggerEvent = {
|
|
|
48
48
|
ack: boolean;
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Déclenchée par un appel de son webhook (`WebhookEndpoint`, retrouvé par l'automatisation) : le
|
|
53
|
+
* payload remplit le modèle, le résultat part sur `callbackUrl`.
|
|
54
|
+
*/
|
|
55
|
+
export type TaskTriggerWebhook = {
|
|
56
|
+
type: 'webhook';
|
|
57
|
+
};
|
|
58
|
+
export type TaskTrigger = TaskTriggerSchedule | TaskTriggerEvent | TaskTriggerWebhook;
|
|
52
59
|
export type ScheduledTask = {
|
|
53
60
|
id: string;
|
|
54
61
|
agentId: string;
|
|
@@ -57,7 +64,7 @@ export type ScheduledTask = {
|
|
|
57
64
|
message: string;
|
|
58
65
|
mode: TaskMode;
|
|
59
66
|
status: TaskStatus;
|
|
60
|
-
/** `null` pour une automatisation déclenchée par un événement. */
|
|
67
|
+
/** `null` pour une automatisation déclenchée par un événement ou un webhook. */
|
|
61
68
|
schedule: TaskSchedule | null;
|
|
62
69
|
/** Absent : `{ type: 'schedule' }`. */
|
|
63
70
|
trigger?: TaskTrigger;
|
package/package.json
CHANGED
package/src/types/engine.ts
CHANGED
|
@@ -17,6 +17,23 @@ export type Provider = {
|
|
|
17
17
|
|
|
18
18
|
export type ProviderSource = 'INTERNAL' | 'EXTERNAL';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Accès d'une organisation à un modèle, identifié par `(providerId, modelId)` où `modelId` est
|
|
22
|
+
* l'identifiant du fournisseur (ex. `gpt-4o`), pas l'id interne du modèle.
|
|
23
|
+
* Pour un moteur plateforme, l'existence de l'accès vaut attribution à l'organisation ; pour un
|
|
24
|
+
* moteur d'organisation, il ne sert qu'à restreindre le modèle à certains membres.
|
|
25
|
+
*/
|
|
26
|
+
export type ModelOrganizationAccess = {
|
|
27
|
+
providerId: string;
|
|
28
|
+
modelId: string;
|
|
29
|
+
organizationId: string;
|
|
30
|
+
/** Vrai ⇒ seuls `userIds` (et les admins de l'organisation) peuvent utiliser le modèle. */
|
|
31
|
+
restrictToUsers: boolean;
|
|
32
|
+
userIds: string[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ModelRef = Pick<ModelOrganizationAccess, 'providerId' | 'modelId'>;
|
|
36
|
+
|
|
20
37
|
export type ProviderSimple = Pick<Provider, 'id' | 'name' | 'providerType' | 'models'>;
|
|
21
38
|
|
|
22
39
|
export type EngineOptions = {
|
|
@@ -114,17 +114,34 @@ export type ExternalEventRouting = {
|
|
|
114
114
|
instruction: string;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Ce qu'on garde d'un appel de webhook générique. `body` est le JSON reçu s'il tient dans la
|
|
119
|
+
* limite de stockage ; sinon `body` est `null` et `bodyText` en garde le début.
|
|
120
|
+
*/
|
|
121
|
+
export type WebhookEventPayload = {
|
|
122
|
+
contentType: string;
|
|
123
|
+
body: unknown;
|
|
124
|
+
bodyText: string | null;
|
|
125
|
+
bodyTruncated: boolean;
|
|
126
|
+
/** Une liste blanche d'en-têtes (jamais `Authorization`), noms en minuscules. */
|
|
127
|
+
headers: Record<string, string>;
|
|
128
|
+
/** `X-Breign-Thread` tel qu'envoyé : les appels de même clé reprennent la même conversation. */
|
|
129
|
+
thread: string | null;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type ExternalEventBase = {
|
|
119
133
|
id: string;
|
|
120
|
-
integrationId: string;
|
|
121
134
|
organizationId: string;
|
|
122
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* GitLab : `X-Gitlab-Event-UUID` ; webhook : `<endpointId>:<Idempotency-Key>` (ou un uuid
|
|
137
|
+
* généré), préfixé pour rester unique entre endpoints. Unique avec l'intégration ou l'endpoint :
|
|
138
|
+
* un renvoi n'est pas rejoué.
|
|
139
|
+
*/
|
|
123
140
|
eventUuid: string;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
/**
|
|
142
|
+
* GitLab : instance + projet + objet + discussion ; webhook : endpoint + clé de fil, ou
|
|
143
|
+
* l'événement seul. Deux événements d'un même fil s'y retrouvent, l'un après l'autre.
|
|
144
|
+
*/
|
|
128
145
|
threadKey: string;
|
|
129
146
|
botAccountId: string | null;
|
|
130
147
|
agentId: string | null;
|
|
@@ -146,7 +163,57 @@ export type ExternalEvent = {
|
|
|
146
163
|
updatedAt: string;
|
|
147
164
|
};
|
|
148
165
|
|
|
149
|
-
/**
|
|
166
|
+
/** Une mention reçue d'une intégration GitLab. */
|
|
167
|
+
export type GitlabExternalEvent = ExternalEventBase & {
|
|
168
|
+
source: 'gitlab';
|
|
169
|
+
integrationId: string;
|
|
170
|
+
webhookEndpointId: null;
|
|
171
|
+
kind: ExternalEventKind;
|
|
172
|
+
payload: ExternalEventPayload;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Un appel du webhook d'une automatisation : l'automatisation et l'agent sont connus dès la
|
|
177
|
+
* réception, il n'y a pas de routage (ni compte bot, ni réponse dans un fil).
|
|
178
|
+
*/
|
|
179
|
+
export type WebhookExternalEvent = ExternalEventBase & {
|
|
180
|
+
source: 'webhook';
|
|
181
|
+
integrationId: null;
|
|
182
|
+
webhookEndpointId: string;
|
|
183
|
+
kind: 'webhook';
|
|
184
|
+
payload: WebhookEventPayload;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/** Un événement reçu d'une source externe, et son passage dans la file. */
|
|
188
|
+
export type ExternalEvent = GitlabExternalEvent | WebhookExternalEvent;
|
|
189
|
+
|
|
190
|
+
export type ExternalEventSource = ExternalEvent['source'];
|
|
191
|
+
|
|
192
|
+
export type WebhookEndpointStatus = 'active' | 'disabled';
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* L'adresse publique d'une automatisation déclenchée par webhook :
|
|
196
|
+
* `POST /webhooks/automations/:id`. Régénérer l'URL crée un nouvel `id`, l'ancien répond 404.
|
|
197
|
+
*/
|
|
198
|
+
export type WebhookEndpoint = {
|
|
199
|
+
id: string;
|
|
200
|
+
organizationId: string;
|
|
201
|
+
/** Une automatisation a au plus un endpoint. */
|
|
202
|
+
taskId: string;
|
|
203
|
+
/** Le secret (Bearer ou clé HMAC), chiffré en base. */
|
|
204
|
+
secret: string;
|
|
205
|
+
/**
|
|
206
|
+
* Le membre de l'organisation au nom duquel tournent les conversations : outils MCP de portée
|
|
207
|
+
* utilisateur, quotas, et qui retrouve la conversation dans son historique.
|
|
208
|
+
*/
|
|
209
|
+
runAsUserId: string;
|
|
210
|
+
status: WebhookEndpointStatus;
|
|
211
|
+
lastEventAt: string | null;
|
|
212
|
+
createdAt: string;
|
|
213
|
+
updatedAt: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/** La conversation d'un agent dans un fil (GitLab, ou clé de fil d'un webhook) : les événements suivants la reprennent. */
|
|
150
217
|
export type ExternalThread = {
|
|
151
218
|
threadKey: string;
|
|
152
219
|
agentId: string;
|
|
@@ -12,8 +12,6 @@ export type Organization = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Configuration OCR de l'organisation. Absente ⇒ OCR désactivé. */
|
|
14
14
|
ocr?: OrganizationOcrConfig | null;
|
|
15
|
-
/** L'organisation peut choisir les moteurs plateforme (clé Breign). */
|
|
16
|
-
allowPlatformEngines?: boolean;
|
|
17
15
|
users: {
|
|
18
16
|
id: string;
|
|
19
17
|
role: 'admin' | 'user' | string;
|
|
@@ -17,7 +17,7 @@ export type RunStep = {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Qui exécute le run : `external`, l'exécuteur des tâches programmées (via la file) ;
|
|
20
|
-
* `internal`, brain-api lui-même (runs déclenchés par un événement). L'exécuteur externe et la
|
|
20
|
+
* `internal`, brain-api lui-même (runs déclenchés par un événement ou un webhook). L'exécuteur externe et la
|
|
21
21
|
* reprise des runs bloqués ignorent les runs `internal`.
|
|
22
22
|
*/
|
|
23
23
|
export type RunExecutor = 'internal' | 'external';
|
|
@@ -34,7 +34,7 @@ export type ScheduledTaskRun = {
|
|
|
34
34
|
claimedAt?: Date;
|
|
35
35
|
retryCount: number;
|
|
36
36
|
steps: RunStep[];
|
|
37
|
-
/** L'événement externe à l'origine du run (mention GitLab). */
|
|
37
|
+
/** L'événement externe à l'origine du run (mention GitLab, appel de webhook). */
|
|
38
38
|
triggerEventId?: string;
|
|
39
39
|
/** Absent : `external`. */
|
|
40
40
|
executor?: RunExecutor;
|
|
@@ -38,7 +38,13 @@ export type TaskTriggerEvent = {
|
|
|
38
38
|
reply: { thread: boolean; ack: boolean };
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Déclenchée par un appel de son webhook (`WebhookEndpoint`, retrouvé par l'automatisation) : le
|
|
43
|
+
* payload remplit le modèle, le résultat part sur `callbackUrl`.
|
|
44
|
+
*/
|
|
45
|
+
export type TaskTriggerWebhook = { type: 'webhook' };
|
|
46
|
+
|
|
47
|
+
export type TaskTrigger = TaskTriggerSchedule | TaskTriggerEvent | TaskTriggerWebhook;
|
|
42
48
|
|
|
43
49
|
export type ScheduledTask = {
|
|
44
50
|
id: string;
|
|
@@ -48,7 +54,7 @@ export type ScheduledTask = {
|
|
|
48
54
|
message: string;
|
|
49
55
|
mode: TaskMode;
|
|
50
56
|
status: TaskStatus;
|
|
51
|
-
/** `null` pour une automatisation déclenchée par un événement. */
|
|
57
|
+
/** `null` pour une automatisation déclenchée par un événement ou un webhook. */
|
|
52
58
|
schedule: TaskSchedule | null;
|
|
53
59
|
/** Absent : `{ type: 'schedule' }`. */
|
|
54
60
|
trigger?: TaskTrigger;
|