@egen-civitas/esm-embed-host 0.3.0 → 0.4.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/CHANGELOG.md +20 -0
- package/dist/connection.d.ts +0 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +4 -14
- package/dist/providers.d.ts +4 -10
- package/dist/providers.d.ts.map +1 -1
- package/dist/table.d.ts +1 -4
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +31 -120
- package/package.json +3 -3
- package/src/connection.ts +1 -11
- package/src/providers.ts +4 -11
- package/src/table.ts +15 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @egen-civitas/esm-embed-host
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3300bac: Toasts partagés : le Core est l'afficheur, l'app notifie en temps réel sans doublon. Politique d'opérateur dans le grant `notifications` (`exclusive`, défaut vrai ; `rate`, défaut 10 par 10 s), `id` de dédoublonnage, réponse `{ displayed }`, anti-spam `RATE_LIMITED`. Client : `egen.notify(toast, local?)` (point d'entrée unique, repli local si le Core n'affiche pas), `egen.coreDisplaysNotifications`, hook `useEgenNotify`. Hôte : le fournisseur peut répondre `false` (doublon). Testing : hôte de test, conformité et vérificateur couvrent le modèle.
|
|
8
|
+
- b2d283e: Retrait radical de l'ancienne couche d'assistance par agent. Elle était trop rigide et sera reconstruite sur une base saine, selon la nouvelle architecture documentée dans le dépôt Core (dossier de documentation de l'intégration de l'agent).
|
|
9
|
+
|
|
10
|
+
- **Packages supprimés** : les sept packages de l'ancienne couche (configuration, canal, contexte, événements, extensions, outils, façade). Le tag `pre-retrait-assistance-2026-11-25` conserve l'état précédent.
|
|
11
|
+
- `esm-framework` : ne ré-exporte plus la façade de l'ancienne couche. **Rupture** pour tout consommateur qui l'importait via `esm-framework`.
|
|
12
|
+
- `esm-styleguide` : le dossier `assistant/` est supprimé (orbe, robot 3D, scène Spline, saisie de prompt, fond d'érosion, modale « verre d'eau », audio), ainsi que les jetons CSS `--ui-*` dédiés à cette couche et les dépendances `three`, `@react-three/fiber`, `@splinetool/*`.
|
|
13
|
+
- `esm-app-shell` : le pont des variables d'environnement de l'ancienne couche vers `window` est supprimé (configuration, gabarit `index.ejs`, bootstrap natif). Le garde-fou des ponts ne porte plus que sur `EGEN_TENANT_*`.
|
|
14
|
+
- `rspack-config` : le préfixe de variable publique de l'ancienne couche est retiré de `PUBLIC_ENV_PREFIXES`.
|
|
15
|
+
- `esm-embed-*` : la capacité d'outils pilotés par un agent est retirée du catalogue du SDK embed (protocole, hôte, client, simulateur et vérificateur de test).
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [3300bac]
|
|
20
|
+
- Updated dependencies [b2d283e]
|
|
21
|
+
- @egen-civitas/esm-embed-protocol@0.4.0
|
|
22
|
+
|
|
3
23
|
## 0.3.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/connection.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export declare class HostConnection {
|
|
|
23
23
|
state: ConnectionState;
|
|
24
24
|
private nonce?;
|
|
25
25
|
private rpc?;
|
|
26
|
-
private cleanup?;
|
|
27
26
|
constructor(o: ConnectionOptions);
|
|
28
27
|
/** Nouvelle poignée de main (à chaque chargement de l'iframe) : ferme toute connexion précédente. */
|
|
29
28
|
hello(): void;
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,MAAM,EACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAA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ChF,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACxD,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAC3E,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,cAAc;IAKb,OAAO,CAAC,QAAQ,CAAC,CAAC;IAJ9B,KAAK,EAAE,eAAe,CAAU;IAChC,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,GAAG,CAAC,CAAc;gBAEG,CAAC,EAAE,iBAAiB;IAEjD,qGAAqG;IACrG,KAAK,IAAI,IAAI;IAOb,sGAAsG;IACtG,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAe9B,OAAO,CAAC,IAAI;IAgCZ,oGAAoG;IAC9F,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIrG,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,oFAAoF;IACpF,KAAK,IAAI,IAAI;IAOb,OAAO,IAAI,IAAI;CAIhB"}
|
package/dist/connection.js
CHANGED
|
@@ -196,7 +196,6 @@ import { availableCapabilities, createCapabilityTable } from './table.js';
|
|
|
196
196
|
_define_property(this, "state", void 0);
|
|
197
197
|
_define_property(this, "nonce", void 0);
|
|
198
198
|
_define_property(this, "rpc", void 0);
|
|
199
|
-
_define_property(this, "cleanup", void 0);
|
|
200
199
|
this.o = o;
|
|
201
200
|
this.state = 'idle';
|
|
202
201
|
}
|
|
@@ -282,14 +281,9 @@ import { availableCapabilities, createCapabilityTable } from './table.js';
|
|
|
282
281
|
moduleName: this.o.moduleName,
|
|
283
282
|
granted: granted,
|
|
284
283
|
providers: this.o.providers,
|
|
285
|
-
controls: this.o.controls
|
|
286
|
-
|
|
287
|
-
if (!_this.rpc) return Promise.reject(new Error('non connecté'));
|
|
288
|
-
return _this.rpc.call(cap, method, args);
|
|
289
|
-
}
|
|
290
|
-
}), table = _createCapabilityTable.table, subscribe = _createCapabilityTable.subscribe, cleanup = _createCapabilityTable.cleanup;
|
|
284
|
+
controls: this.o.controls
|
|
285
|
+
}), table = _createCapabilityTable.table, subscribe = _createCapabilityTable.subscribe;
|
|
291
286
|
var _ref = new MessageChannel(), port1 = _ref.port1, port2 = _ref.port2;
|
|
292
|
-
this.cleanup = cleanup;
|
|
293
287
|
this.rpc = new RpcEndpoint({
|
|
294
288
|
port: port1,
|
|
295
289
|
handlers: table,
|
|
@@ -299,9 +293,7 @@ import { availableCapabilities, createCapabilityTable } from './table.js';
|
|
|
299
293
|
},
|
|
300
294
|
limits: this.o.limits,
|
|
301
295
|
onClose: function onClose(reason) {
|
|
302
|
-
var
|
|
303
|
-
(_this_cleanup = (_this1 = _this).cleanup) === null || _this_cleanup === void 0 ? void 0 : _this_cleanup.call(_this1);
|
|
304
|
-
_this.cleanup = undefined;
|
|
296
|
+
var _this_o_onClose, _this_o;
|
|
305
297
|
if (_this.state !== 'closed') _this.state = 'idle';
|
|
306
298
|
(_this_o_onClose = (_this_o = _this.o).onClose) === null || _this_o_onClose === void 0 ? void 0 : _this_o_onClose.call(_this_o, reason);
|
|
307
299
|
}
|
|
@@ -345,11 +337,9 @@ import { availableCapabilities, createCapabilityTable } from './table.js';
|
|
|
345
337
|
{
|
|
346
338
|
/** Ferme la connexion courante (rechargement de l'iframe) sans détruire l'objet. */ key: "reset",
|
|
347
339
|
value: function reset() {
|
|
348
|
-
var _this_rpc
|
|
340
|
+
var _this_rpc;
|
|
349
341
|
(_this_rpc = this.rpc) === null || _this_rpc === void 0 ? void 0 : _this_rpc.close();
|
|
350
342
|
this.rpc = undefined;
|
|
351
|
-
(_this_cleanup = (_this = this).cleanup) === null || _this_cleanup === void 0 ? void 0 : _this_cleanup.call(_this);
|
|
352
|
-
this.cleanup = undefined;
|
|
353
343
|
this.nonce = undefined;
|
|
354
344
|
if (this.state !== 'closed') this.state = 'idle';
|
|
355
345
|
}
|
package/dist/providers.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface CallerContext {
|
|
|
9
9
|
moduleName: string;
|
|
10
10
|
}
|
|
11
11
|
export interface NotificationInput {
|
|
12
|
+
/** Clé de dédoublonnage facultative : un même `id` ne produit pas deux toasts rapprochés. */
|
|
13
|
+
id?: string;
|
|
12
14
|
kind: 'info' | 'success' | 'warning' | 'error';
|
|
13
15
|
title: string;
|
|
14
16
|
subtitle?: string;
|
|
@@ -20,11 +22,6 @@ export interface ExtensionInfo {
|
|
|
20
22
|
order?: number;
|
|
21
23
|
meta: Record<string, unknown>;
|
|
22
24
|
}
|
|
23
|
-
export interface AiToolDescriptor {
|
|
24
|
-
name: string;
|
|
25
|
-
description: string;
|
|
26
|
-
inputSchema?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
25
|
/**
|
|
29
26
|
* Services du Core mis à disposition des apps embarquées. Toute capacité sans fournisseur est
|
|
30
27
|
* automatiquement refusée à la négociation (`UNAVAILABLE`) : on ne promet que ce qu'on sait servir.
|
|
@@ -46,8 +43,9 @@ export interface HostProviders {
|
|
|
46
43
|
publish(topic: string, payload: unknown, ctx: CallerContext): void;
|
|
47
44
|
subscribe(topic: string, cb: (payload: unknown) => void): Unsub;
|
|
48
45
|
};
|
|
46
|
+
/** Affiche le toast dans l'interface du Core ; retourne `false` si non affiché (doublon, etc.). Le Core attribue le toast à son app d'origine. */
|
|
49
47
|
notifications?: {
|
|
50
|
-
show(n: NotificationInput, ctx: CallerContext): void | Promise<void>;
|
|
48
|
+
show(n: NotificationInput, ctx: CallerContext): void | boolean | Promise<void | boolean>;
|
|
51
49
|
};
|
|
52
50
|
dialogs?: {
|
|
53
51
|
confirm(d: {
|
|
@@ -65,9 +63,5 @@ export interface HostProviders {
|
|
|
65
63
|
log(level: 'debug' | 'info' | 'warn' | 'error', message: string, ctx: Record<string, unknown> | undefined, from: CallerContext): void;
|
|
66
64
|
metric(name: string, value: number, tags: Record<string, unknown> | undefined, from: CallerContext): void;
|
|
67
65
|
};
|
|
68
|
-
aiTools?: {
|
|
69
|
-
register(moduleName: string, tools: AiToolDescriptor[], invoke: (name: string, args: Record<string, unknown>) => Promise<unknown>): void;
|
|
70
|
-
unregister(moduleName: string, names: string[]): void;
|
|
71
|
-
};
|
|
72
66
|
}
|
|
73
67
|
//# sourceMappingURL=providers.d.ts.map
|
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC;AAE/B,wDAAwD;AACxD,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC;CAC3C;AAED,MAAM,WAAW,aAAa;IAC5B,uGAAuG;IACvG,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAA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MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;QACtI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;KAC3G,CAAC;CACH"}
|
package/dist/table.d.ts
CHANGED
|
@@ -21,16 +21,13 @@ export interface TableOptions {
|
|
|
21
21
|
granted: CapabilityGranted[];
|
|
22
22
|
providers: HostProviders;
|
|
23
23
|
controls: HostControls;
|
|
24
|
-
/** Appel hôte → app (`ai-tools.invoke`). */
|
|
25
|
-
callApp: (cap: string, method: string, args: unknown[]) => Promise<unknown>;
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
26
|
* Construit la table de dispatch FERMÉE d'une connexion : seules les capacités accordées (et servies) y figurent,
|
|
29
|
-
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux
|
|
27
|
+
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux).
|
|
30
28
|
*/
|
|
31
29
|
export declare function createCapabilityTable(o: TableOptions): {
|
|
32
30
|
table: HandlerTable;
|
|
33
31
|
subscribe: SubscribeHandler;
|
|
34
|
-
cleanup: () => void;
|
|
35
32
|
};
|
|
36
33
|
//# sourceMappingURL=table.d.ts.map
|
package/dist/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1E,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,6DAA6D;IAC7D,OAAO,EAAE,GAAG,CAAC;CACd;AAED,8HAA8H;AAC9H,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,CAczE;AAID,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,gBAAgB,CAAA;CAAE,CA+F3G"}
|
package/dist/table.js
CHANGED
|
@@ -6,9 +6,6 @@ function _array_like_to_array(arr, len) {
|
|
|
6
6
|
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function _array_without_holes(arr) {
|
|
10
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
-
}
|
|
12
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
10
|
try {
|
|
14
11
|
var info = gen[key](arg);
|
|
@@ -38,9 +35,6 @@ function _async_to_generator(fn) {
|
|
|
38
35
|
});
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
|
-
function _iterable_to_array(iter) {
|
|
42
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
43
|
-
}
|
|
44
38
|
function _iterable_to_array_limit(arr, i) {
|
|
45
39
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
46
40
|
if (_i == null) return;
|
|
@@ -68,15 +62,9 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
68
62
|
function _non_iterable_rest() {
|
|
69
63
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
70
64
|
}
|
|
71
|
-
function _non_iterable_spread() {
|
|
72
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
73
|
-
}
|
|
74
65
|
function _sliced_to_array(arr, i) {
|
|
75
66
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
76
67
|
}
|
|
77
|
-
function _to_consumable_array(arr) {
|
|
78
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
79
|
-
}
|
|
80
68
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
81
69
|
if (!o) return;
|
|
82
70
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -184,7 +172,7 @@ function _ts_generator(thisArg, body) {
|
|
|
184
172
|
};
|
|
185
173
|
}
|
|
186
174
|
}
|
|
187
|
-
import { CAPABILITIES, EmbedError, slotAllowed, topicAllowed } from '@egen-civitas/esm-embed-protocol';
|
|
175
|
+
import { CAPABILITIES, createSlidingLimiter, notificationPolicy, EmbedError, slotAllowed, topicAllowed } from '@egen-civitas/esm-embed-protocol';
|
|
188
176
|
/** Capacités que l'hôte sait servir avec ces fournisseurs. `navigation`, `lifecycle` et `telemetry` sont toujours servies. */ export function availableCapabilities(p) {
|
|
189
177
|
var s = new Set([
|
|
190
178
|
'navigation',
|
|
@@ -223,10 +211,6 @@ import { CAPABILITIES, EmbedError, slotAllowed, topicAllowed } from '@egen-civit
|
|
|
223
211
|
[
|
|
224
212
|
'extensions',
|
|
225
213
|
p.extensions
|
|
226
|
-
],
|
|
227
|
-
[
|
|
228
|
-
'ai-tools',
|
|
229
|
-
p.aiTools
|
|
230
214
|
]
|
|
231
215
|
];
|
|
232
216
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -256,7 +240,7 @@ var list = function list(cfg, key) {
|
|
|
256
240
|
};
|
|
257
241
|
/**
|
|
258
242
|
* Construit la table de dispatch FERMÉE d'une connexion : seules les capacités accordées (et servies) y figurent,
|
|
259
|
-
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux
|
|
243
|
+
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux).
|
|
260
244
|
*/ export function createCapabilityTable(o) {
|
|
261
245
|
var p = o.providers, c = o.controls;
|
|
262
246
|
var ctx = {
|
|
@@ -269,7 +253,6 @@ var list = function list(cfg, key) {
|
|
|
269
253
|
];
|
|
270
254
|
}));
|
|
271
255
|
var table = {};
|
|
272
|
-
var registeredTools = new Set();
|
|
273
256
|
var denied = function denied(msg) {
|
|
274
257
|
return new EmbedError('DENIED', msg);
|
|
275
258
|
};
|
|
@@ -342,26 +325,34 @@ var list = function list(cfg, key) {
|
|
|
342
325
|
}
|
|
343
326
|
};
|
|
344
327
|
}
|
|
345
|
-
if (cfgOf.has('notifications') && p.notifications)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
328
|
+
if (cfgOf.has('notifications') && p.notifications) {
|
|
329
|
+
// Anti-spam : une iframe ne doit pas pouvoir inonder l'interface du Core (ni imiter des messages système en rafale).
|
|
330
|
+
var policy = notificationPolicy(cfgOf.get('notifications'));
|
|
331
|
+
var allow = createSlidingLimiter(policy.rate.max, policy.rate.perSeconds);
|
|
332
|
+
table.notifications = {
|
|
333
|
+
show: function show(n) {
|
|
334
|
+
return _async_to_generator(function() {
|
|
335
|
+
var _tmp;
|
|
336
|
+
return _ts_generator(this, function(_state) {
|
|
337
|
+
switch(_state.label){
|
|
338
|
+
case 0:
|
|
339
|
+
if (!allow()) throw new EmbedError('RATE_LIMITED', 'Trop de notifications');
|
|
340
|
+
_tmp = {};
|
|
341
|
+
return [
|
|
342
|
+
4,
|
|
343
|
+
p.notifications.show(n, ctx)
|
|
344
|
+
];
|
|
345
|
+
case 1:
|
|
346
|
+
return [
|
|
347
|
+
2,
|
|
348
|
+
(_tmp.displayed = _state.sent() !== false, _tmp)
|
|
349
|
+
];
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
})();
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
365
356
|
if (cfgOf.has('dialogs') && p.dialogs) table.dialogs = {
|
|
366
357
|
confirm: function confirm(d) {
|
|
367
358
|
return _async_to_generator(function() {
|
|
@@ -398,82 +389,6 @@ var list = function list(cfg, key) {
|
|
|
398
389
|
}
|
|
399
390
|
};
|
|
400
391
|
}
|
|
401
|
-
if (cfgOf.has('ai-tools') && p.aiTools) {
|
|
402
|
-
var allowed = list(cfgOf.get('ai-tools'), 'tools');
|
|
403
|
-
table['ai-tools'] = {
|
|
404
|
-
register: function register(tools) {
|
|
405
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
406
|
-
try {
|
|
407
|
-
for(var _iterator = tools[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
408
|
-
var t = _step.value;
|
|
409
|
-
if (!topicAllowed(allowed, t.name)) throw denied("Outil non autoris\xe9 : ".concat(t.name));
|
|
410
|
-
}
|
|
411
|
-
} catch (err) {
|
|
412
|
-
_didIteratorError = true;
|
|
413
|
-
_iteratorError = err;
|
|
414
|
-
} finally{
|
|
415
|
-
try {
|
|
416
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
417
|
-
_iterator.return();
|
|
418
|
-
}
|
|
419
|
-
} finally{
|
|
420
|
-
if (_didIteratorError) {
|
|
421
|
-
throw _iteratorError;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
p.aiTools.register(o.moduleName, tools, function(name, args) {
|
|
426
|
-
return o.callApp('ai-tools', 'invoke', [
|
|
427
|
-
name,
|
|
428
|
-
args
|
|
429
|
-
]);
|
|
430
|
-
});
|
|
431
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
432
|
-
try {
|
|
433
|
-
for(var _iterator1 = tools[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
434
|
-
var t1 = _step1.value;
|
|
435
|
-
registeredTools.add(t1.name);
|
|
436
|
-
}
|
|
437
|
-
} catch (err) {
|
|
438
|
-
_didIteratorError1 = true;
|
|
439
|
-
_iteratorError1 = err;
|
|
440
|
-
} finally{
|
|
441
|
-
try {
|
|
442
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
443
|
-
_iterator1.return();
|
|
444
|
-
}
|
|
445
|
-
} finally{
|
|
446
|
-
if (_didIteratorError1) {
|
|
447
|
-
throw _iteratorError1;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
unregister: function unregister(names) {
|
|
453
|
-
p.aiTools.unregister(o.moduleName, names);
|
|
454
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
455
|
-
try {
|
|
456
|
-
for(var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
457
|
-
var n = _step.value;
|
|
458
|
-
registeredTools.delete(n);
|
|
459
|
-
}
|
|
460
|
-
} catch (err) {
|
|
461
|
-
_didIteratorError = true;
|
|
462
|
-
_iteratorError = err;
|
|
463
|
-
} finally{
|
|
464
|
-
try {
|
|
465
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
466
|
-
_iterator.return();
|
|
467
|
-
}
|
|
468
|
-
} finally{
|
|
469
|
-
if (_didIteratorError) {
|
|
470
|
-
throw _iteratorError;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
392
|
if (cfgOf.has('telemetry')) {
|
|
478
393
|
table.telemetry = {
|
|
479
394
|
log: function log(level, message, extra) {
|
|
@@ -543,10 +458,6 @@ var list = function list(cfg, key) {
|
|
|
543
458
|
};
|
|
544
459
|
return {
|
|
545
460
|
table: table,
|
|
546
|
-
subscribe: subscribe
|
|
547
|
-
cleanup: function cleanup() {
|
|
548
|
-
if (registeredTools.size && p.aiTools) p.aiTools.unregister(o.moduleName, _to_consumable_array(registeredTools));
|
|
549
|
-
registeredTools.clear();
|
|
550
|
-
}
|
|
461
|
+
subscribe: subscribe
|
|
551
462
|
};
|
|
552
463
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/esm-embed-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Hôte (côté Shell/Core) des applications embarquées : iframe sécurisée, poignée de main v2, grants, fournisseurs de capacités, navigation partagée, compatibilité du pont 1.1.",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@egen-civitas/esm-embed-client": "^0.
|
|
60
|
+
"@egen-civitas/esm-embed-client": "^0.3.0",
|
|
61
61
|
"@swc/cli": "0.8.1",
|
|
62
62
|
"@swc/core": "1.15.21",
|
|
63
63
|
"@types/node": "^20",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"vitest": "^4.1.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@egen-civitas/esm-embed-protocol": "^0.
|
|
72
|
+
"@egen-civitas/esm-embed-protocol": "^0.4.0"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/connection.ts
CHANGED
|
@@ -39,7 +39,6 @@ export class HostConnection {
|
|
|
39
39
|
state: ConnectionState = 'idle';
|
|
40
40
|
private nonce?: string;
|
|
41
41
|
private rpc?: RpcEndpoint;
|
|
42
|
-
private cleanup?: () => void;
|
|
43
42
|
|
|
44
43
|
constructor(private readonly o: ConnectionOptions) {}
|
|
45
44
|
|
|
@@ -76,18 +75,13 @@ export class HostConnection {
|
|
|
76
75
|
if (avail.has(g.id)) granted.push(g);
|
|
77
76
|
else denied.push({ id: g.id, reason: 'UNAVAILABLE' });
|
|
78
77
|
}
|
|
79
|
-
const { table, subscribe
|
|
78
|
+
const { table, subscribe } = createCapabilityTable({
|
|
80
79
|
moduleName: this.o.moduleName,
|
|
81
80
|
granted,
|
|
82
81
|
providers: this.o.providers,
|
|
83
82
|
controls: this.o.controls,
|
|
84
|
-
callApp: (cap, method, args) => {
|
|
85
|
-
if (!this.rpc) return Promise.reject(new Error('non connecté'));
|
|
86
|
-
return this.rpc.call(cap, method, args);
|
|
87
|
-
},
|
|
88
83
|
});
|
|
89
84
|
const { port1, port2 } = new MessageChannel();
|
|
90
|
-
this.cleanup = cleanup;
|
|
91
85
|
this.rpc = new RpcEndpoint({
|
|
92
86
|
port: port1,
|
|
93
87
|
handlers: table,
|
|
@@ -95,8 +89,6 @@ export class HostConnection {
|
|
|
95
89
|
validate: (cap, method, args) => validateCall(cap, method, args, 'app-to-host'),
|
|
96
90
|
limits: this.o.limits,
|
|
97
91
|
onClose: (reason) => {
|
|
98
|
-
this.cleanup?.();
|
|
99
|
-
this.cleanup = undefined;
|
|
100
92
|
if (this.state !== 'closed') this.state = 'idle';
|
|
101
93
|
this.o.onClose?.(reason);
|
|
102
94
|
},
|
|
@@ -119,8 +111,6 @@ export class HostConnection {
|
|
|
119
111
|
reset(): void {
|
|
120
112
|
this.rpc?.close();
|
|
121
113
|
this.rpc = undefined;
|
|
122
|
-
this.cleanup?.();
|
|
123
|
-
this.cleanup = undefined;
|
|
124
114
|
this.nonce = undefined;
|
|
125
115
|
if (this.state !== 'closed') this.state = 'idle';
|
|
126
116
|
}
|
package/src/providers.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface CallerContext {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface NotificationInput {
|
|
15
|
+
/** Clé de dédoublonnage facultative : un même `id` ne produit pas deux toasts rapprochés. */
|
|
16
|
+
id?: string;
|
|
15
17
|
kind: 'info' | 'success' | 'warning' | 'error';
|
|
16
18
|
title: string;
|
|
17
19
|
subtitle?: string;
|
|
@@ -25,12 +27,6 @@ export interface ExtensionInfo {
|
|
|
25
27
|
meta: Record<string, unknown>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
export interface AiToolDescriptor {
|
|
29
|
-
name: string;
|
|
30
|
-
description: string;
|
|
31
|
-
inputSchema?: Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
/**
|
|
35
31
|
* Services du Core mis à disposition des apps embarquées. Toute capacité sans fournisseur est
|
|
36
32
|
* automatiquement refusée à la négociation (`UNAVAILABLE`) : on ne promet que ce qu'on sait servir.
|
|
@@ -44,7 +40,8 @@ export interface HostProviders {
|
|
|
44
40
|
config?: Watchable<Record<string, unknown>>;
|
|
45
41
|
flags?: { isEnabled(name: string): boolean | Promise<boolean>; subscribe?(cb: () => void): Unsub };
|
|
46
42
|
events?: { publish(topic: string, payload: unknown, ctx: CallerContext): void; subscribe(topic: string, cb: (payload: unknown) => void): Unsub };
|
|
47
|
-
|
|
43
|
+
/** Affiche le toast dans l'interface du Core ; retourne `false` si non affiché (doublon, etc.). Le Core attribue le toast à son app d'origine. */
|
|
44
|
+
notifications?: { show(n: NotificationInput, ctx: CallerContext): void | boolean | Promise<void | boolean> };
|
|
48
45
|
dialogs?: { confirm(d: { title: string; message: string; danger?: boolean }, ctx: CallerContext): boolean | Promise<boolean> };
|
|
49
46
|
/** Extensions attachées à un slot du Core (apps internes, framework, autres apps) : métadonnées seulement, jamais le rendu. */
|
|
50
47
|
extensions?: { list(slot: string): ExtensionInfo[] | Promise<ExtensionInfo[]>; subscribe?(slot: string, cb: (list: ExtensionInfo[]) => void): Unsub };
|
|
@@ -52,8 +49,4 @@ export interface HostProviders {
|
|
|
52
49
|
log(level: 'debug' | 'info' | 'warn' | 'error', message: string, ctx: Record<string, unknown> | undefined, from: CallerContext): void;
|
|
53
50
|
metric(name: string, value: number, tags: Record<string, unknown> | undefined, from: CallerContext): void;
|
|
54
51
|
};
|
|
55
|
-
aiTools?: {
|
|
56
|
-
register(moduleName: string, tools: AiToolDescriptor[], invoke: (name: string, args: Record<string, unknown>) => Promise<unknown>): void;
|
|
57
|
-
unregister(moduleName: string, names: string[]): void;
|
|
58
|
-
};
|
|
59
52
|
}
|
package/src/table.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CAPABILITIES,
|
|
3
|
+
createSlidingLimiter,
|
|
4
|
+
notificationPolicy,
|
|
3
5
|
EmbedError,
|
|
4
6
|
slotAllowed,
|
|
5
7
|
topicAllowed,
|
|
@@ -35,7 +37,6 @@ export function availableCapabilities(p: HostProviders): Set<CapabilityId> {
|
|
|
35
37
|
['notifications', p.notifications],
|
|
36
38
|
['dialogs', p.dialogs],
|
|
37
39
|
['extensions', p.extensions],
|
|
38
|
-
['ai-tools', p.aiTools],
|
|
39
40
|
];
|
|
40
41
|
for (const [id, prov] of map) if (prov) s.add(id);
|
|
41
42
|
return s;
|
|
@@ -48,20 +49,17 @@ export interface TableOptions {
|
|
|
48
49
|
granted: CapabilityGranted[];
|
|
49
50
|
providers: HostProviders;
|
|
50
51
|
controls: HostControls;
|
|
51
|
-
/** Appel hôte → app (`ai-tools.invoke`). */
|
|
52
|
-
callApp: (cap: string, method: string, args: unknown[]) => Promise<unknown>;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
/**
|
|
56
55
|
* Construit la table de dispatch FERMÉE d'une connexion : seules les capacités accordées (et servies) y figurent,
|
|
57
|
-
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux
|
|
56
|
+
* chaque méthode applique son grant (sujets d'événements, slots découvrables, drapeaux).
|
|
58
57
|
*/
|
|
59
|
-
export function createCapabilityTable(o: TableOptions): { table: HandlerTable; subscribe: SubscribeHandler
|
|
58
|
+
export function createCapabilityTable(o: TableOptions): { table: HandlerTable; subscribe: SubscribeHandler } {
|
|
60
59
|
const { providers: p, controls: c } = o;
|
|
61
60
|
const ctx: CallerContext = { moduleName: o.moduleName };
|
|
62
61
|
const cfgOf = new Map(o.granted.map((g) => [g.id, g.config]));
|
|
63
62
|
const table: HandlerTable = {};
|
|
64
|
-
const registeredTools = new Set<string>();
|
|
65
63
|
|
|
66
64
|
const denied = (msg: string) => new EmbedError('DENIED', msg);
|
|
67
65
|
|
|
@@ -87,7 +85,17 @@ export function createCapabilityTable(o: TableOptions): { table: HandlerTable; s
|
|
|
87
85
|
},
|
|
88
86
|
};
|
|
89
87
|
}
|
|
90
|
-
if (cfgOf.has('notifications') && p.notifications)
|
|
88
|
+
if (cfgOf.has('notifications') && p.notifications) {
|
|
89
|
+
// Anti-spam : une iframe ne doit pas pouvoir inonder l'interface du Core (ni imiter des messages système en rafale).
|
|
90
|
+
const policy = notificationPolicy(cfgOf.get('notifications'));
|
|
91
|
+
const allow = createSlidingLimiter(policy.rate.max, policy.rate.perSeconds);
|
|
92
|
+
table.notifications = {
|
|
93
|
+
show: async (n: any) => {
|
|
94
|
+
if (!allow()) throw new EmbedError('RATE_LIMITED', 'Trop de notifications');
|
|
95
|
+
return { displayed: (await p.notifications!.show(n, ctx)) !== false };
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
91
99
|
if (cfgOf.has('dialogs') && p.dialogs) table.dialogs = { confirm: async (d: any) => !!(await p.dialogs!.confirm(d, ctx)) };
|
|
92
100
|
if (cfgOf.has('extensions') && p.extensions) {
|
|
93
101
|
const discover = list(cfgOf.get('extensions'), 'discover');
|
|
@@ -98,20 +106,6 @@ export function createCapabilityTable(o: TableOptions): { table: HandlerTable; s
|
|
|
98
106
|
},
|
|
99
107
|
};
|
|
100
108
|
}
|
|
101
|
-
if (cfgOf.has('ai-tools') && p.aiTools) {
|
|
102
|
-
const allowed = list(cfgOf.get('ai-tools'), 'tools');
|
|
103
|
-
table['ai-tools'] = {
|
|
104
|
-
register: (tools: Array<{ name: string; description: string; inputSchema?: Record<string, unknown> }>) => {
|
|
105
|
-
for (const t of tools) if (!topicAllowed(allowed, t.name)) throw denied(`Outil non autorisé : ${t.name}`);
|
|
106
|
-
p.aiTools!.register(o.moduleName, tools, (name, args) => o.callApp('ai-tools', 'invoke', [name, args]));
|
|
107
|
-
for (const t of tools) registeredTools.add(t.name);
|
|
108
|
-
},
|
|
109
|
-
unregister: (names: string[]) => {
|
|
110
|
-
p.aiTools!.unregister(o.moduleName, names);
|
|
111
|
-
for (const n of names) registeredTools.delete(n);
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
109
|
if (cfgOf.has('telemetry')) {
|
|
116
110
|
table.telemetry = {
|
|
117
111
|
log: (level: any, message: string, extra?: Record<string, unknown>) => void p.telemetry?.log(level, message, extra, ctx),
|
|
@@ -155,9 +149,5 @@ export function createCapabilityTable(o: TableOptions): { table: HandlerTable; s
|
|
|
155
149
|
return {
|
|
156
150
|
table,
|
|
157
151
|
subscribe,
|
|
158
|
-
cleanup: () => {
|
|
159
|
-
if (registeredTools.size && p.aiTools) p.aiTools.unregister(o.moduleName, [...registeredTools]);
|
|
160
|
-
registeredTools.clear();
|
|
161
|
-
},
|
|
162
152
|
};
|
|
163
153
|
}
|