@tpsdev-ai/flair 0.4.8 → 0.4.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 +33 -4
- package/dist/resources/SemanticSearch.js +3 -7
- package/dist/resources/Soul.js +20 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -462,10 +462,39 @@ program
|
|
|
462
462
|
}
|
|
463
463
|
console.log(`\n Claude Code: Add to your CLAUDE.md:`);
|
|
464
464
|
console.log(` At the start of every session, run mcp__flair__bootstrap before responding.`);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
465
|
+
// Auto-wire MCP config into ~/.claude.json if Claude Code is installed
|
|
466
|
+
const claudeJsonPath = join(homedir(), ".claude.json");
|
|
467
|
+
const mcpEnv = { FLAIR_AGENT_ID: agentId, FLAIR_URL: httpUrl };
|
|
468
|
+
const flairMcpConfig = {
|
|
469
|
+
type: "stdio",
|
|
470
|
+
command: "flair-mcp",
|
|
471
|
+
args: [],
|
|
472
|
+
env: mcpEnv,
|
|
473
|
+
};
|
|
474
|
+
try {
|
|
475
|
+
if (existsSync(claudeJsonPath)) {
|
|
476
|
+
const claudeJson = JSON.parse(readFileSync(claudeJsonPath, "utf-8"));
|
|
477
|
+
const existing = claudeJson.mcpServers?.flair;
|
|
478
|
+
if (existing && existing.env?.FLAIR_URL === httpUrl && existing.env?.FLAIR_AGENT_ID === agentId) {
|
|
479
|
+
console.log(`\n MCP config already set in ~/.claude.json ✓`);
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
claudeJson.mcpServers = claudeJson.mcpServers || {};
|
|
483
|
+
claudeJson.mcpServers.flair = flairMcpConfig;
|
|
484
|
+
writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2));
|
|
485
|
+
console.log(`\n MCP config written to ~/.claude.json ✓`);
|
|
486
|
+
console.log(` Restart Claude Code to pick up the new config.`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
console.log(`\n MCP config (add to ~/.claude.json):`);
|
|
491
|
+
console.log(` { "mcpServers": { "flair": ${JSON.stringify(flairMcpConfig)} } }`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
catch {
|
|
495
|
+
console.log(`\n MCP config (add manually to ~/.claude.json):`);
|
|
496
|
+
console.log(` { "mcpServers": { "flair": ${JSON.stringify(flairMcpConfig)} } }`);
|
|
497
|
+
}
|
|
469
498
|
});
|
|
470
499
|
// ─── flair agent ─────────────────────────────────────────────────────────────
|
|
471
500
|
const agent = program.command("agent").description("Manage Flair agents");
|
|
@@ -89,12 +89,10 @@ export class SemanticSearch extends Resource {
|
|
|
89
89
|
if (!qEmb && q) {
|
|
90
90
|
// Always attempt embedding generation — getEmbedding() handles init internally.
|
|
91
91
|
// Don't gate on getMode() which may return "none" before init completes in worker threads.
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
qEmb = await getEmbedding(String(q).slice(0, 8000));
|
|
95
|
-
}
|
|
96
|
-
catch { }
|
|
92
|
+
try {
|
|
93
|
+
qEmb = await getEmbedding(String(q).slice(0, 8000));
|
|
97
94
|
}
|
|
95
|
+
catch { }
|
|
98
96
|
}
|
|
99
97
|
// ─── Temporal intent detection ────────────────────────────────────────────
|
|
100
98
|
let sinceDate = since ? new Date(since) : null;
|
|
@@ -145,8 +143,6 @@ export class SemanticSearch extends Resource {
|
|
|
145
143
|
agentConditions.push({ attribute: "visibility", comparator: "equals", value: "office" });
|
|
146
144
|
conditions.push({ operator: "or", conditions: agentConditions });
|
|
147
145
|
}
|
|
148
|
-
// Exclude archived records. Use "not equals true" instead of "equals false"
|
|
149
|
-
// so records without the archived field (default: not archived) are included.
|
|
150
146
|
// Exclude archived records. Use "not_equal" (Harper v5 comparator) instead of
|
|
151
147
|
// "equals false" so records without the archived field are included.
|
|
152
148
|
conditions.push({ attribute: "archived", comparator: "not_equal", value: true });
|
package/dist/resources/Soul.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { databases } from "@harperfast/harper";
|
|
2
|
+
function enforceAgentScope(self, data) {
|
|
3
|
+
const authenticatedAgent = self.request?.headers?.get?.("x-tps-agent");
|
|
4
|
+
const callerIsAdmin = self.request?.tpsAgentIsAdmin === true;
|
|
5
|
+
if (authenticatedAgent && !callerIsAdmin && data?.agentId && data.agentId !== authenticatedAgent) {
|
|
6
|
+
return new Response(JSON.stringify({
|
|
7
|
+
error: "forbidden: agentId must match authenticated agent",
|
|
8
|
+
}), { status: 403, headers: { "Content-Type": "application/json" } });
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
2
12
|
export class Soul extends databases.flair.Soul {
|
|
3
13
|
async post(content, context) {
|
|
14
|
+
const denied = enforceAgentScope(this, content);
|
|
15
|
+
if (denied)
|
|
16
|
+
return denied;
|
|
4
17
|
content.durability ||= "permanent";
|
|
5
18
|
content.createdAt = new Date().toISOString();
|
|
6
19
|
content.updatedAt = content.createdAt;
|
|
7
20
|
return super.post(content, context);
|
|
8
21
|
}
|
|
22
|
+
async put(content, context) {
|
|
23
|
+
const denied = enforceAgentScope(this, content);
|
|
24
|
+
if (denied)
|
|
25
|
+
return denied;
|
|
26
|
+
content.updatedAt = new Date().toISOString();
|
|
27
|
+
return super.put(content, context);
|
|
28
|
+
}
|
|
9
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpsdev-ai/flair",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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",
|