@ourlu/assistant-sdk 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +119 -72
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,109 +1,156 @@
1
- # Assistant SDK JS
1
+ # @ourlu/assistant-sdk
2
2
 
3
- SDK JavaScript du widget assistant, maintenu dans `assistant-sdk-js`.
3
+ SDK JavaScript pour intégrer le chatbot IA Ourlu sur les sites web de collectivités.
4
4
 
5
- ## Mise à jour mission (2026-05-17)
5
+ ## Installation
6
6
 
7
- - Aucun changement de périmètre fonctionnel SDK lié à la rationalisation microservices backend.
8
- - Le SDK reste découplé de Temporal et des choix d'orchestration backend.
9
- - Priorité conservée: stabilité contractuelle (`SDK_CONTRACT_V1`) et diffusion versionnée.
7
+ ### Copier-coller (recommandé)
10
8
 
11
- ## Périmètre
9
+ Ajoutez ce snippet avant la balise `</body>` de votre site :
12
10
 
13
- Ce package fournit:
11
+ ```html
12
+ <script
13
+ src="https://occe.ourlu.fr/v1/widget/runtime/loader.v1.js"
14
+ data-tenant-id="votre-identifiant-mairie"
15
+ data-widget-key="wpk_votre_cle_publique"
16
+ data-api-base-url="https://occe.ourlu.fr"
17
+ async
18
+ ></script>
19
+ ```
14
20
 
15
- - le loader IIFE (`loader.v1.js`) pour intégration `<script ...>`;
16
- - les runtimes UI/engine (`ui.v1.js`, `engine.v1.js`);
17
- - une API ESM (`dist/esm/index.js`) pour bootstrap programmatique.
21
+ Le chatbot apparaît automatiquement en bas à droite de votre site.
18
22
 
19
- Le package n'écrit jamais dans `ourlu` directement. La copie vers le backend est pilotée côté consommateur via script dédié.
23
+ ### npm (usage programmatique)
20
24
 
21
- ## Arborescence réelle
25
+ ```bash
26
+ npm i @ourlu/assistant-sdk
27
+ ```
22
28
 
23
- - `src/loader/loader.v1.js`: chargeur principal exécuté côté navigateur.
24
- - `src/runtime/loader.runtime.ui.v1.js`: UI widget, rendu, interactions.
25
- - `src/runtime/loader.runtime.engine.v1.js`: appels API chat/audio + orchestration runtime.
26
- - `src/esm/index.js`: helpers publics (`bootstrapWidgetRuntime`, `mountWidgetFromScript`) et managers ESM.
27
- - `scripts/build.mjs`: build par copie contrôlée `src -> dist`.
28
- - `tests/runtime-url-resolver.test.mjs`: tests Node du resolver d'URLs runtime.
29
- - `.github/workflows/sdk-ci-release.yml`: pipeline CI + publication sur tags `v*`.
29
+ ```javascript
30
+ import { bootstrapWidgetRuntime } from '@ourlu/assistant-sdk';
30
31
 
31
- ## API publique (ESM)
32
+ bootstrapWidgetRuntime({
33
+ loaderUrl: 'https://occe.ourlu.fr/v1/widget/runtime/loader.v1.js'
34
+ });
35
+ ```
32
36
 
33
- Exports (`src/esm/index.js`):
37
+ ---
34
38
 
35
- - `bootstrapWidgetRuntime(options)`: charge `ui.v1.js` + `engine.v1.js`.
36
- - `mountWidgetFromScript(scriptTag)`: délègue au runtime global `window.__CompanionWidgetRuntimeV1`.
37
- - `RuntimeUrlResolverManager`
38
- - `BrowserScriptLoaderManager`
39
- - `RuntimeBootstrapManager`
40
- - `sdkVersion` (`"v1"`).
39
+ ## Configuration
41
40
 
42
- Options principales `bootstrapWidgetRuntime`:
41
+ | Attribut | Requis | Description |
42
+ |----------|--------|-------------|
43
+ | `data-tenant-id` | ✅ | Identifiant de votre collectivité |
44
+ | `data-widget-key` | ✅ | Clé publique du widget (fournie dans l'espace admin) |
45
+ | `data-api-base-url` | ✅ | URL de la plateforme (`https://occe.ourlu.fr`) |
46
+ | `data-turnstile-site-key` | ❌ | Clé Cloudflare Turnstile pour protection anti-bot |
43
47
 
44
- - `loaderUrl` (recommandé) pour résoudre automatiquement `ui.v1.js` et `engine.v1.js`;
45
- - `uiUrl` / `engineUrl` (optionnels) pour surcharger explicitement;
46
- - `timeoutMs` (optionnel, défaut interne `8000`).
48
+ Le thème (couleurs, mascotte, position, textes) est géré automatiquement depuis votre espace d'administration Ourlu. Aucune modification du code d'intégration n'est nécessaire après un changement de design.
47
49
 
48
- ## Build, test, packaging
50
+ ---
49
51
 
50
- ```powershell
51
- npm ci
52
- npm run build
53
- npm run test
54
- npm run pack:check
55
- ```
52
+ ## Compatibilité
53
+
54
+ ### CMS & plateformes
55
+
56
+ WordPress, Drupal, SPIP, Joomla, TYPO3, Wix, Squarespace, Webflow, Shopify, et tout site acceptant un tag `<script>`.
57
+
58
+ ### Frameworks JavaScript
59
+
60
+ React, Vue, Svelte, Angular, Next.js, Nuxt, Astro, Remix, SvelteKit.
61
+
62
+ ### Sites statiques
56
63
 
57
- Scripts disponibles (`package.json`):
64
+ HTML pur, Jekyll, Hugo, Eleventy, Cloudflare Pages, Netlify, Vercel, GitHub Pages.
58
65
 
59
- - `build`: `node ./scripts/build.mjs`
60
- - `test`: `node --test ./tests/*.test.mjs`
61
- - `prepack`: build + test
62
- - `pack:check`: `npm pack --dry-run`
63
- - `publish:dry-run`: `npm publish --dry-run`
66
+ ### Navigateurs supportés
64
67
 
65
- ## Intégration avec `ourlu`
68
+ - Chrome 66+
69
+ - Firefox 60+
70
+ - Safari 12+
71
+ - Edge 79+
72
+ - Mobile (iOS Safari, Chrome Android)
66
73
 
67
- Le backend `ourlu` sert les assets runtime via:
74
+ ---
68
75
 
69
- - `GET /v1/widget/runtime/loader.v1.js`
70
- - `GET /v1/widget/runtime/ui.v1.js`
71
- - `GET /v1/widget/runtime/engine.v1.js`
76
+ ## Fonctionnalités
72
77
 
73
- Ces assets sont embarqués dans le binaire backend (`go:embed`) après synchronisation.
78
+ - 💬 Chat textuel avec assistant IA en temps réel (streaming SSE)
79
+ - 🎙️ Entrée vocale avec transcription automatique
80
+ - 🎨 Thème personnalisable (couleurs, position, mascotte)
81
+ - 🌓 Mode sombre automatique (suit les préférences système)
82
+ - 🛡️ Protection anti-bot Cloudflare Turnstile (optionnelle)
83
+ - 🔒 Authentification JWT automatique
84
+ - ♿ Accessible (navigation clavier, échappement pour fermer)
85
+ - 📱 Responsive (mobile et desktop)
74
86
 
75
- ### Mode workspace (développement local)
87
+ ---
76
88
 
77
- 1. builder le SDK dans ce dossier (`npm run build`);
78
- 2. exécuter la synchronisation côté `ourlu`.
89
+ ## Protection anti-bot (optionnelle)
79
90
 
80
- Depuis la racine du workspace:
91
+ Pour activer Cloudflare Turnstile :
81
92
 
82
- ```powershell
83
- .\ourlu\backend\scripts\sync-assistant-sdk-assets.ps1
93
+ ```html
94
+ <script
95
+ src="https://occe.ourlu.fr/v1/widget/runtime/loader.v1.js"
96
+ data-tenant-id="votre-mairie"
97
+ data-widget-key="wpk_..."
98
+ data-api-base-url="https://occe.ourlu.fr"
99
+ data-turnstile-site-key="0x4AAAAAAA..."
100
+ async
101
+ ></script>
84
102
  ```
85
103
 
86
- Lock utilisé: `ourlu/backend/scripts/assistant-sdk.lock.json`
87
- (`workspaceDistDirectory=..\..\sdks\js\assistant-sdk-js\dist\iife`).
104
+ Le captcha est invisible dans 99% des cas. Sans la clé Turnstile, le chatbot fonctionne normalement sans protection anti-bot.
105
+
106
+ ---
107
+
108
+ ## API publique (ESM)
109
+
110
+ Pour une intégration programmatique avancée :
111
+
112
+ ```javascript
113
+ import {
114
+ bootstrapWidgetRuntime,
115
+ mountWidgetFromScript,
116
+ sdkVersion
117
+ } from '@ourlu/assistant-sdk';
118
+ ```
119
+
120
+ | Export | Description |
121
+ |--------|-------------|
122
+ | `bootstrapWidgetRuntime(options)` | Charge et initialise le widget |
123
+ | `mountWidgetFromScript(scriptTag)` | Monte le widget depuis un élément script existant |
124
+ | `sdkVersion` | Version du SDK (`"v1"`) |
125
+
126
+ ### Options `bootstrapWidgetRuntime`
127
+
128
+ | Option | Description | Défaut |
129
+ |--------|-------------|--------|
130
+ | `loaderUrl` | URL du loader (résout automatiquement UI + engine) | — |
131
+ | `uiUrl` | URL explicite du runtime UI | Auto |
132
+ | `engineUrl` | URL explicite du runtime engine | Auto |
133
+ | `timeoutMs` | Timeout de chargement en ms | `8000` |
88
134
 
89
- ### Mode npm (release versionnée)
135
+ ---
90
136
 
91
- Le script de sync backend supporte `sourceMode=npm` via:
137
+ ## Sécurité & RGPD
92
138
 
93
- - `ourlu/backend/scripts/assistant-sdk.lock.npm.example.json`
94
- - champs `registryUrl` et `npmAuthTokenEnvVar`
139
+ - Aucun cookie tiers installé
140
+ - Anonymisation native des données personnelles (PII masking)
141
+ - Compatible Content Security Policy (CSP) stricte
142
+ - Option auto-hébergement des fichiers JS
143
+ - Option reverse-proxy pour anonymisation IP
95
144
 
96
- ## Contrat et compatibilité
145
+ ---
97
146
 
98
- - contrat public SDK: `../../../docs/SDK_CONTRACT_V1.md`
99
- - changelog: `CHANGELOG.md`
100
- - stratégie de release: `docs/RELEASE_STRATEGY.md`
147
+ ## Support
101
148
 
102
- Règle: toute rupture contractuelle sur les `data-*`, méthodes ou événements publics implique un changement majeur (`v2`).
149
+ - Documentation : espace admin Ourlu > Intégration
150
+ - Contact technique : integration@ourlu.fr
103
151
 
104
- ## CI/CD
152
+ ---
105
153
 
106
- Workflow: `.github/workflows/sdk-ci-release.yml`
154
+ ## Licence
107
155
 
108
- - job `validate` sur branches/PR: `npm ci`, `npm run test`, `npm run build`, `npm run pack:check`;
109
- - job `publish` sur tag `v*`: `npm publish --access restricted` avec `NPM_TOKEN`.
156
+ Propriétaire Ourlu SAS. Usage réservé aux collectivités clientes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ourlu/assistant-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "SDK JavaScript pour l'assistant conversationnel Ourlu — widget intégrable pour les mairies.",
5
5
  "type": "module",
6
6
  "private": false,