@tpsdev-ai/flair-client 0.2.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/dist/client.d.ts CHANGED
@@ -17,6 +17,7 @@ export declare class FlairClient {
17
17
  private keyResolved;
18
18
  private keyPath;
19
19
  private timeoutMs;
20
+ private basicAuth;
20
21
  constructor(config: FlairClientConfig);
21
22
  private resolveKey;
22
23
  /** Make an authenticated request to Flair. */
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:9926";
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,
@@ -92,7 +102,7 @@ class MemoryApi {
92
102
  }
93
103
  }
94
104
  const id = opts.id ?? `${this.client.agentId}-${Date.now()}`;
95
- return this.client.request("PUT", `/Memory/${id}`, {
105
+ const record = {
96
106
  id,
97
107
  agentId: this.client.agentId,
98
108
  content,
@@ -101,7 +111,10 @@ class MemoryApi {
101
111
  tags: opts.tags ?? [],
102
112
  subject: opts.subject,
103
113
  createdAt: new Date().toISOString(),
104
- });
114
+ };
115
+ await this.client.request("PUT", `/Memory/${id}`, record);
116
+ // Harper PUT returns {} — return the record we constructed
117
+ return record;
105
118
  }
106
119
  /** Search memories by meaning. */
107
120
  async search(query, opts = {}) {
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:9926 */
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair-client",
3
- "version": "0.2.0",
4
- "description": "Lightweight client for Flair \u2014 identity, memory, and soul for AI agents. Zero heavy dependencies.",
3
+ "version": "0.4.0",
4
+ "description": "Lightweight client for Flair identity, memory, and soul for AI agents. Zero heavy dependencies.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -45,4 +45,4 @@
45
45
  "devDependencies": {
46
46
  "typescript": "5.9.3"
47
47
  }
48
- }
48
+ }