@tpsdev-ai/flair 0.3.10 → 0.3.12
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 +20 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -71,11 +71,19 @@ 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 {
|
|
85
|
+
// Sign the path without query params — auth middleware verifies the clean path
|
|
86
|
+
// Auth middleware verifies the full request path including query params
|
|
79
87
|
authHeader = buildEd25519Auth(agentId, method, path, keyPath);
|
|
80
88
|
}
|
|
81
89
|
catch (err) {
|
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpsdev-ai/flair",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
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",
|