@tpsdev-ai/flair 0.3.9 → 0.3.11
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 +26 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -71,12 +71,20 @@ async function api(method, path, body) {
|
|
|
71
71
|
authHeader = `Bearer ${token}`;
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
|
|
74
|
+
// Extract agentId from body (POST/PUT) or URL query params (GET)
|
|
75
|
+
let agentId = process.env.FLAIR_AGENT_ID || (body && typeof body === "object" ? body.agentId : undefined);
|
|
76
|
+
if (!agentId && path.includes("agentId=")) {
|
|
77
|
+
const match = path.match(/agentId=([^&]+)/);
|
|
78
|
+
if (match)
|
|
79
|
+
agentId = decodeURIComponent(match[1]);
|
|
80
|
+
}
|
|
75
81
|
if (agentId) {
|
|
76
82
|
const keyPath = resolveKeyPath(agentId);
|
|
77
83
|
if (keyPath) {
|
|
78
84
|
try {
|
|
79
|
-
|
|
85
|
+
// Sign the path without query params — auth middleware verifies the clean path
|
|
86
|
+
const signPath = path.split("?")[0];
|
|
87
|
+
authHeader = buildEd25519Auth(agentId, method, signPath, keyPath);
|
|
80
88
|
}
|
|
81
89
|
catch (err) {
|
|
82
90
|
// Key exists but auth build failed — warn and continue without auth
|
|
@@ -93,10 +101,18 @@ async function api(method, path, body) {
|
|
|
93
101
|
},
|
|
94
102
|
body: body ? JSON.stringify(body) : undefined,
|
|
95
103
|
});
|
|
96
|
-
|
|
104
|
+
// Handle 204 No Content (e.g., PUT upsert returns empty body)
|
|
105
|
+
if (res.status === 204 || res.headers.get("content-length") === "0") {
|
|
106
|
+
if (!res.ok)
|
|
107
|
+
throw new Error(`HTTP ${res.status}`);
|
|
108
|
+
return { ok: true };
|
|
109
|
+
}
|
|
110
|
+
const text = await res.text();
|
|
97
111
|
if (!res.ok)
|
|
98
|
-
throw new Error(
|
|
99
|
-
|
|
112
|
+
throw new Error(text || `HTTP ${res.status}`);
|
|
113
|
+
if (!text)
|
|
114
|
+
return { ok: true };
|
|
115
|
+
return JSON.parse(text);
|
|
100
116
|
}
|
|
101
117
|
/** Find the agent's private key file from standard locations. */
|
|
102
118
|
function resolveKeyPath(agentId) {
|
|
@@ -768,14 +784,16 @@ const memory = program.command("memory").description("Manage agent memories");
|
|
|
768
784
|
memory.command("add").requiredOption("--agent <id>").requiredOption("--content <text>")
|
|
769
785
|
.option("--durability <d>", "standard").option("--tags <csv>")
|
|
770
786
|
.action(async (opts) => {
|
|
771
|
-
const
|
|
772
|
-
|
|
787
|
+
const memId = `${opts.agent}-${Date.now()}`;
|
|
788
|
+
const out = await api("PUT", `/Memory/${memId}`, {
|
|
789
|
+
id: memId, agentId: opts.agent, content: opts.content, durability: opts.durability || "standard",
|
|
773
790
|
tags: opts.tags ? String(opts.tags).split(",").map((x) => x.trim()).filter(Boolean) : undefined,
|
|
791
|
+
type: "memory", createdAt: new Date().toISOString(),
|
|
774
792
|
});
|
|
775
793
|
console.log(JSON.stringify(out, null, 2));
|
|
776
794
|
});
|
|
777
795
|
memory.command("search").requiredOption("--agent <id>").requiredOption("--q <query>").option("--tag <tag>")
|
|
778
|
-
.action(async (opts) => console.log(JSON.stringify(await api("POST", "/
|
|
796
|
+
.action(async (opts) => console.log(JSON.stringify(await api("POST", "/SemanticSearch", { agentId: opts.agent, q: opts.q, tag: opts.tag }), null, 2)));
|
|
779
797
|
memory.command("list").requiredOption("--agent <id>").option("--tag <tag>")
|
|
780
798
|
.action(async (opts) => {
|
|
781
799
|
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.11",
|
|
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",
|