@tpsdev-ai/flair 0.3.8 → 0.3.10
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/cli.js +30 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -60,12 +60,36 @@ async function api(method, path, body) {
|
|
|
60
60
|
}
|
|
61
61
|
catch { /* ignore config read errors */ }
|
|
62
62
|
const base = process.env.FLAIR_URL || defaultUrl;
|
|
63
|
+
// Auth resolution order:
|
|
64
|
+
// 1. FLAIR_TOKEN env → Bearer token (backward compat)
|
|
65
|
+
// 2. FLAIR_AGENT_ID env + key file → Ed25519 signature (standard)
|
|
66
|
+
// 3. --agent flag extracted from body.agentId + key file → Ed25519 signature
|
|
67
|
+
// 4. No auth (will 401 on any authenticated endpoint)
|
|
68
|
+
let authHeader;
|
|
63
69
|
const token = process.env.FLAIR_TOKEN;
|
|
70
|
+
if (token) {
|
|
71
|
+
authHeader = `Bearer ${token}`;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const agentId = process.env.FLAIR_AGENT_ID || (body && typeof body === "object" ? body.agentId : undefined);
|
|
75
|
+
if (agentId) {
|
|
76
|
+
const keyPath = resolveKeyPath(agentId);
|
|
77
|
+
if (keyPath) {
|
|
78
|
+
try {
|
|
79
|
+
authHeader = buildEd25519Auth(agentId, method, path, keyPath);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
// Key exists but auth build failed — warn and continue without auth
|
|
83
|
+
console.error(`Warning: Ed25519 auth failed for agent '${agentId}': ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
64
88
|
const res = await fetch(`${base}${path}`, {
|
|
65
89
|
method,
|
|
66
90
|
headers: {
|
|
67
91
|
"content-type": "application/json",
|
|
68
|
-
...(
|
|
92
|
+
...(authHeader ? { authorization: authHeader } : {}),
|
|
69
93
|
},
|
|
70
94
|
body: body ? JSON.stringify(body) : undefined,
|
|
71
95
|
});
|
|
@@ -744,14 +768,16 @@ const memory = program.command("memory").description("Manage agent memories");
|
|
|
744
768
|
memory.command("add").requiredOption("--agent <id>").requiredOption("--content <text>")
|
|
745
769
|
.option("--durability <d>", "standard").option("--tags <csv>")
|
|
746
770
|
.action(async (opts) => {
|
|
747
|
-
const
|
|
748
|
-
|
|
771
|
+
const memId = `${opts.agent}-${Date.now()}`;
|
|
772
|
+
const out = await api("PUT", `/Memory/${memId}`, {
|
|
773
|
+
id: memId, agentId: opts.agent, content: opts.content, durability: opts.durability || "standard",
|
|
749
774
|
tags: opts.tags ? String(opts.tags).split(",").map((x) => x.trim()).filter(Boolean) : undefined,
|
|
775
|
+
type: "memory", createdAt: new Date().toISOString(),
|
|
750
776
|
});
|
|
751
777
|
console.log(JSON.stringify(out, null, 2));
|
|
752
778
|
});
|
|
753
779
|
memory.command("search").requiredOption("--agent <id>").requiredOption("--q <query>").option("--tag <tag>")
|
|
754
|
-
.action(async (opts) => console.log(JSON.stringify(await api("POST", "/
|
|
780
|
+
.action(async (opts) => console.log(JSON.stringify(await api("POST", "/SemanticSearch", { agentId: opts.agent, q: opts.q, tag: opts.tag }), null, 2)));
|
|
755
781
|
memory.command("list").requiredOption("--agent <id>").option("--tag <tag>")
|
|
756
782
|
.action(async (opts) => {
|
|
757
783
|
const q = new URLSearchParams({ agentId: opts.agent, ...(opts.tag ? { tag: opts.tag } : {}) }).toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpsdev-ai/flair",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|