@handsforbots/storage-backend 0.0.0-stage → 2.0.0-alpha.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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2024 Alex Lana and Hands for Bots contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @handsforbots/storage-backend
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Keeps the Hands for Bots conversation on your backend, with retention the server enforces.
4
+
5
+ Part of [Hands for Bots](https://github.com/handsforbots/handsforbots), a headless multimodal and action layer between users, GUIs and agents.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @handsforbots/storage-backend@alpha @handsforbots/core@alpha
11
+ ```
12
+
13
+ ## Documentation
14
+
15
+ - [This package](https://github.com/handsforbots/handsforbots/blob/main/docs/en-us/plugins.md#storage-backend)
16
+ - [Getting started](https://github.com/handsforbots/handsforbots/blob/main/docs/en-us/getting-started.md)
17
+ - [Documentação em português](https://github.com/handsforbots/handsforbots/blob/main/docs/pt-br/README.md)
18
+
19
+ ## License
20
+
21
+ MIT
@@ -0,0 +1,41 @@
1
+ import { type Retention, type Storage } from '@handsforbots/core';
2
+ export type { Retention } from '@handsforbots/core';
3
+ export type BackendRetention = Exclude<Retention, 'key'>;
4
+ export type BackendStorageOptions = {
5
+ /** Endpoint for this conversation: GET loads, PUT saves, DELETE clears. */
6
+ url: string;
7
+ /** Default retention, sent to the server in `X-H4B-Retention`. Default 'server'. */
8
+ retention?: BackendRetention;
9
+ /** Retentions the end user may pick (e.g. in the widget). Empty (default) = fixed by the developer. */
10
+ userChoices?: BackendRetention[];
11
+ headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
12
+ /** Default 'same-origin', so the server also sees its own (HttpOnly) session cookie. */
13
+ credentials?: RequestCredentials;
14
+ fetch?: typeof fetch;
15
+ /** Browser key that holds the conversation id. Default 'h4b:conversation-id'. */
16
+ idKey?: string;
17
+ /**
18
+ * Granted consent purposes, sent in `X-H4B-Consent` (comma-separated) so the
19
+ * server knows what it may do with the conversation (e.g. `review`). The
20
+ * plugin fills it from `h4b.consent` when consent is on.
21
+ */
22
+ consentPurposes?: () => string[] | undefined;
23
+ };
24
+ export type BackendStorage = Storage & {
25
+ readonly retention: BackendRetention;
26
+ /** Remembers a retention for this browser and deletes what the server held under the previous one. Save again to keep it. */
27
+ setRetention(retention: BackendRetention): Promise<void>;
28
+ /** Forgets the conversation ids and the retention preference kept in this browser (call `clear()` first to delete it on the server). */
29
+ forget(): void;
30
+ };
31
+ export declare const storageBackend: (config: BackendStorageOptions) => import("@handsforbots/core").Plugin<BackendStorageOptions>;
32
+ /**
33
+ * Keeps the conversation on your server. Every request carries
34
+ * `X-H4B-Conversation` (a random id kept in localStorage, or in sessionStorage
35
+ * with the `'tab'` retention, so a closed tab can't reach it again) and
36
+ * `X-H4B-Retention` (`server`, `tab` or the TTL in minutes). The server
37
+ * enforces the retention and should tie the id to the user's own session
38
+ * when there is one: anyone holding the id can read the conversation.
39
+ */
40
+ export declare function createBackendStorage(options: BackendStorageOptions): BackendStorage;
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EAGd,KAAK,OAAO,EACb,MAAM,oBAAoB,CAAA;AAE3B,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AAExD,MAAM,MAAM,qBAAqB,GAAG;IAClC,2EAA2E;IAC3E,GAAG,EAAE,MAAM,CAAA;IACX,oFAAoF;IACpF,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,uGAAuG;IACvG,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IACnG,wFAAwF;IACxF,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,MAAM,EAAE,GAAG,SAAS,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG;IACrC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAA;IACpC,6HAA6H;IAC7H,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,wIAAwI;IACxI,MAAM,IAAI,IAAI,CAAA;CACf,CAAA;AAED,eAAO,MAAM,cAAc,+FAoDzB,CAAA;AAEF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA+FnF"}
package/dist/index.js ADDED
@@ -0,0 +1,174 @@
1
+ import { createId, definePlugin, sameRetention, storableSnapshot, } from '@handsforbots/core';
2
+ export const storageBackend = definePlugin({
3
+ name: 'storage-backend',
4
+ provides: ['storage', 'retention'],
5
+ consent: 'persistence',
6
+ apply(ctx, options) {
7
+ const consent = ctx.app.consent;
8
+ const granted = () => (consent.enabled ? consent.purposes.filter((p) => consent.granted(p)) : undefined);
9
+ const storage = createBackendStorage({ consentPurposes: granted, ...options });
10
+ const choices = choicesOf(options);
11
+ const listeners = new Set();
12
+ const control = {
13
+ get current() {
14
+ return storage.retention;
15
+ },
16
+ choices,
17
+ location: 'server',
18
+ encrypted: false,
19
+ async set(retention) {
20
+ if (retention === 'key' || !choices.some((c) => sameRetention(c, retention))) {
21
+ throw new Error(`[h4b] storage-backend: retention ${JSON.stringify(retention)} is not one of the choices`);
22
+ }
23
+ await storage.setRetention(retention);
24
+ await ctx.app.persist();
25
+ listeners.forEach((l) => l());
26
+ },
27
+ subscribe(listener) {
28
+ listeners.add(listener);
29
+ return () => void listeners.delete(listener);
30
+ },
31
+ };
32
+ ctx.provide('storage', storage);
33
+ ctx.provide('retention', control);
34
+ // Tell the server at once when what it may do with the conversation changes (e.g. `review`).
35
+ let sent = granted()?.join(',');
36
+ ctx.on('consent.changed', () => {
37
+ const now = granted()?.join(',');
38
+ if (now === sent)
39
+ return;
40
+ sent = now;
41
+ if (ctx.app.messages.length > 0)
42
+ void ctx.app.persist();
43
+ });
44
+ ctx.onRevoke(() => storage.forget());
45
+ },
46
+ // Denied on a later visit: delete what an earlier one kept, without mounting.
47
+ async erase(app, options) {
48
+ const consent = app.consent;
49
+ const storage = createBackendStorage({
50
+ consentPurposes: () => consent.purposes.filter((p) => consent.granted(p)),
51
+ ...options,
52
+ });
53
+ await storage.clear();
54
+ storage.forget();
55
+ },
56
+ });
57
+ /**
58
+ * Keeps the conversation on your server. Every request carries
59
+ * `X-H4B-Conversation` (a random id kept in localStorage, or in sessionStorage
60
+ * with the `'tab'` retention, so a closed tab can't reach it again) and
61
+ * `X-H4B-Retention` (`server`, `tab` or the TTL in minutes). The server
62
+ * enforces the retention and should tie the id to the user's own session
63
+ * when there is one: anyone holding the id can read the conversation.
64
+ */
65
+ export function createBackendStorage(options) {
66
+ const idKey = options.idKey ?? 'h4b:conversation-id';
67
+ const prefKey = `${idKey}:retention`;
68
+ const choices = choicesOf(options);
69
+ const area = (r) => {
70
+ try {
71
+ return r === 'tab' ? sessionStorage : localStorage;
72
+ }
73
+ catch {
74
+ return undefined;
75
+ }
76
+ };
77
+ let memoryId; // when browser storage is blocked
78
+ const existingId = (r) => area(r)?.getItem(idKey) ?? memoryId;
79
+ const idFor = (r) => {
80
+ const store = area(r);
81
+ const existing = store?.getItem(idKey) ?? memoryId;
82
+ if (existing)
83
+ return existing;
84
+ const id = createId('conv');
85
+ if (store)
86
+ store.setItem(idKey, id);
87
+ else
88
+ memoryId = id;
89
+ return id;
90
+ };
91
+ const retention = () => {
92
+ try {
93
+ const saved = localStorage.getItem(prefKey);
94
+ if (saved) {
95
+ const parsed = JSON.parse(saved);
96
+ if (choices.some((c) => sameRetention(c, parsed)))
97
+ return parsed;
98
+ }
99
+ }
100
+ catch {
101
+ /* unavailable or corrupted: use the default */
102
+ }
103
+ return choices[0];
104
+ };
105
+ const request = async (method, r, body) => {
106
+ const doFetch = options.fetch ?? globalThis.fetch;
107
+ const headers = typeof options.headers === 'function' ? await options.headers() : options.headers;
108
+ const purposes = options.consentPurposes?.();
109
+ const response = await doFetch(options.url, {
110
+ method,
111
+ headers: {
112
+ accept: 'application/json',
113
+ ...(body ? { 'content-type': 'application/json' } : {}),
114
+ 'x-h4b-conversation': idFor(r),
115
+ 'x-h4b-retention': typeof r === 'object' ? String(r.ttlMinutes) : r,
116
+ ...(purposes ? { 'x-h4b-consent': purposes.join(',') } : {}),
117
+ ...headers,
118
+ },
119
+ credentials: options.credentials ?? 'same-origin',
120
+ body: body ? JSON.stringify(body) : undefined,
121
+ });
122
+ if (method === 'GET' && (response.status === 204 || response.status === 404))
123
+ return null;
124
+ if (!response.ok)
125
+ throw new Error(`[h4b] storage-backend: ${method} ${options.url} returned ${response.status}`);
126
+ return method === 'GET' ? (await response.json()) : null;
127
+ };
128
+ return {
129
+ get retention() {
130
+ return retention();
131
+ },
132
+ async setRetention(next) {
133
+ const before = retention();
134
+ try {
135
+ localStorage.setItem(prefKey, JSON.stringify(next));
136
+ }
137
+ catch {
138
+ /* not remembered across reloads */
139
+ }
140
+ if (sameRetention(before, next))
141
+ return;
142
+ if (existingId(before))
143
+ await request('DELETE', before);
144
+ area(before)?.removeItem(idKey);
145
+ },
146
+ async load() {
147
+ const snapshot = await request('GET', retention());
148
+ return snapshot?.threadId && Array.isArray(snapshot.messages) ? snapshot : null;
149
+ },
150
+ async save(snapshot) {
151
+ await request('PUT', retention(), storableSnapshot(snapshot));
152
+ },
153
+ async clear() {
154
+ if (existingId(retention()))
155
+ await request('DELETE', retention()); // never mint an id just to delete
156
+ },
157
+ forget() {
158
+ for (const r of ['server', 'tab'])
159
+ area(r)?.removeItem(idKey);
160
+ memoryId = undefined;
161
+ try {
162
+ localStorage.removeItem(prefKey);
163
+ }
164
+ catch {
165
+ /* blocked storage: nothing was kept */
166
+ }
167
+ },
168
+ };
169
+ }
170
+ function choicesOf(options) {
171
+ const list = [options.retention ?? 'server', ...(options.userChoices ?? [])];
172
+ return list.filter((r, i) => list.findIndex((o) => sameRetention(o, r)) === i);
173
+ }
174
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,Q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C,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@handsforbots/storage-backend",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "2.0.0-alpha.0",
4
+ "description": "Keeps the Hands for Bots conversation on your backend, with retention the server enforces.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/handsforbots/handsforbots/blob/main/docs/en-us/plugins.md#storage-backend",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/handsforbots/handsforbots.git",
10
+ "directory": "packages/storage-backend"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/handsforbots/handsforbots/issues"
14
+ },
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "peerDependencies": {
30
+ "@handsforbots/core": "^2.0.0-alpha.0"
31
+ },
32
+ "devDependencies": {
33
+ "jsdom": "^27.0.0",
34
+ "@handsforbots/core": "^2.0.0-alpha.0",
35
+ "@handsforbots/testkit": "^2.0.0-alpha.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.build.json",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit"
40
+ }
6
41
  }