@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.
- package/README.md +119 -72
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,109 +1,156 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ourlu/assistant-sdk
|
|
2
2
|
|
|
3
|
-
SDK JavaScript
|
|
3
|
+
SDK JavaScript pour intégrer le chatbot IA Ourlu sur les sites web de collectivités.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
-
|
|
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
|
-
|
|
9
|
+
Ajoutez ce snippet avant la balise `</body>` de votre site :
|
|
12
10
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
+
### npm (usage programmatique)
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
```bash
|
|
26
|
+
npm i @ourlu/assistant-sdk
|
|
27
|
+
```
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
32
|
+
bootstrapWidgetRuntime({
|
|
33
|
+
loaderUrl: 'https://occe.ourlu.fr/v1/widget/runtime/loader.v1.js'
|
|
34
|
+
});
|
|
35
|
+
```
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
---
|
|
34
38
|
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
+
---
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
64
|
+
HTML pur, Jekyll, Hugo, Eleventy, Cloudflare Pages, Netlify, Vercel, GitHub Pages.
|
|
58
65
|
|
|
59
|
-
|
|
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
|
-
|
|
68
|
+
- Chrome 66+
|
|
69
|
+
- Firefox 60+
|
|
70
|
+
- Safari 12+
|
|
71
|
+
- Edge 79+
|
|
72
|
+
- Mobile (iOS Safari, Chrome Android)
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
---
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
- `GET /v1/widget/runtime/ui.v1.js`
|
|
71
|
-
- `GET /v1/widget/runtime/engine.v1.js`
|
|
76
|
+
## Fonctionnalités
|
|
72
77
|
|
|
73
|
-
|
|
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
|
-
|
|
87
|
+
---
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
2. exécuter la synchronisation côté `ourlu`.
|
|
89
|
+
## Protection anti-bot (optionnelle)
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
Pour activer Cloudflare Turnstile :
|
|
81
92
|
|
|
82
|
-
```
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
135
|
+
---
|
|
90
136
|
|
|
91
|
-
|
|
137
|
+
## Sécurité & RGPD
|
|
92
138
|
|
|
93
|
-
-
|
|
94
|
-
-
|
|
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
|
-
|
|
145
|
+
---
|
|
97
146
|
|
|
98
|
-
|
|
99
|
-
- changelog: `CHANGELOG.md`
|
|
100
|
-
- stratégie de release: `docs/RELEASE_STRATEGY.md`
|
|
147
|
+
## Support
|
|
101
148
|
|
|
102
|
-
|
|
149
|
+
- Documentation : espace admin Ourlu > Intégration
|
|
150
|
+
- Contact technique : integration@ourlu.fr
|
|
103
151
|
|
|
104
|
-
|
|
152
|
+
---
|
|
105
153
|
|
|
106
|
-
|
|
154
|
+
## Licence
|
|
107
155
|
|
|
108
|
-
|
|
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.
|