@tpsdev-ai/flair-client 0.2.1 → 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/dist/client.d.ts +1 -0
- package/dist/client.js +11 -1
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* const ctx = await flair.bootstrap({ maxTokens: 4000 })
|
|
9
9
|
*/
|
|
10
10
|
import { loadPrivateKey, resolveKeyPath, signRequest } from "./auth.js";
|
|
11
|
-
const DEFAULT_URL = "http://localhost:
|
|
11
|
+
const DEFAULT_URL = "http://localhost:19926";
|
|
12
12
|
const DEFAULT_TIMEOUT = 10_000;
|
|
13
13
|
export class FlairClient {
|
|
14
14
|
url;
|
|
@@ -19,11 +19,18 @@ export class FlairClient {
|
|
|
19
19
|
keyResolved = false;
|
|
20
20
|
keyPath;
|
|
21
21
|
timeoutMs;
|
|
22
|
+
basicAuth = null;
|
|
22
23
|
constructor(config) {
|
|
23
24
|
this.url = (config.url ?? process.env.FLAIR_URL ?? DEFAULT_URL).replace(/\/$/, "");
|
|
24
25
|
this.agentId = config.agentId || process.env.FLAIR_AGENT_ID || "";
|
|
25
26
|
this.keyPath = config.keyPath;
|
|
26
27
|
this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT;
|
|
28
|
+
// Basic auth fallback for standalone deployments without Ed25519 keys
|
|
29
|
+
const adminUser = config.adminUser ?? process.env.FLAIR_ADMIN_USER;
|
|
30
|
+
const adminPass = config.adminPassword ?? process.env.FLAIR_ADMIN_PASSWORD;
|
|
31
|
+
if (adminUser && adminPass) {
|
|
32
|
+
this.basicAuth = `Basic ${Buffer.from(`${adminUser}:${adminPass}`).toString("base64")}`;
|
|
33
|
+
}
|
|
27
34
|
this.memory = new MemoryApi(this);
|
|
28
35
|
this.soul = new SoulApi(this);
|
|
29
36
|
}
|
|
@@ -46,6 +53,9 @@ export class FlairClient {
|
|
|
46
53
|
if (key) {
|
|
47
54
|
headers["Authorization"] = signRequest(this.agentId, key, method, path);
|
|
48
55
|
}
|
|
56
|
+
else if (this.basicAuth) {
|
|
57
|
+
headers["Authorization"] = this.basicAuth;
|
|
58
|
+
}
|
|
49
59
|
const res = await fetch(`${this.url}${path}`, {
|
|
50
60
|
method,
|
|
51
61
|
headers,
|
package/dist/types.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface BootstrapResult {
|
|
|
41
41
|
}
|
|
42
42
|
/** Client configuration. */
|
|
43
43
|
export interface FlairClientConfig {
|
|
44
|
-
/** Flair server URL. Default: http://localhost:
|
|
44
|
+
/** Flair server URL. Default: http://localhost:19926 */
|
|
45
45
|
url?: string;
|
|
46
46
|
/** Agent ID for authentication and data scoping. Falls back to FLAIR_AGENT_ID env var. */
|
|
47
47
|
agentId?: string;
|
|
@@ -49,4 +49,8 @@ export interface FlairClientConfig {
|
|
|
49
49
|
keyPath?: string;
|
|
50
50
|
/** Request timeout in ms. Default: 10000 */
|
|
51
51
|
timeoutMs?: number;
|
|
52
|
+
/** Admin username for Basic auth fallback (standalone deployments). Falls back to FLAIR_ADMIN_USER env var. */
|
|
53
|
+
adminUser?: string;
|
|
54
|
+
/** Admin password for Basic auth fallback (standalone deployments). Falls back to FLAIR_ADMIN_PASSWORD env var. */
|
|
55
|
+
adminPassword?: string;
|
|
52
56
|
}
|
package/package.json
CHANGED