@tpsdev-ai/flair-mcp 0.53.0 → 0.54.1
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/adapter-surface.d.ts +39 -48
- package/dist/adapter-surface.js +75 -64
- package/dist/adapter-tools.d.ts +35 -0
- package/dist/adapter-tools.js +381 -0
- package/dist/catchup.d.ts +58 -0
- package/dist/catchup.js +85 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +39 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +17 -479
- package/dist/json-schema-zod.d.ts +10 -0
- package/dist/json-schema-zod.js +43 -0
- package/dist/skills.d.ts +2 -1
- package/dist/skills.js +2 -1
- package/node_modules/@tpsdev-ai/flair-tool-descriptors/LICENSE +19 -0
- package/node_modules/@tpsdev-ai/flair-tool-descriptors/README.md +22 -0
- package/node_modules/@tpsdev-ai/flair-tool-descriptors/dist/index.d.ts +70 -0
- package/node_modules/@tpsdev-ai/flair-tool-descriptors/dist/index.js +665 -0
- package/node_modules/@tpsdev-ai/flair-tool-descriptors/package.json +46 -0
- package/package.json +7 -2
|
@@ -1,65 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* adapter-surface.ts — the stdio adapter's
|
|
2
|
+
* adapter-surface.ts — the stdio adapter's derived tool set (flair#1580).
|
|
3
3
|
*
|
|
4
|
-
* `@tpsdev-ai/flair-mcp` hand-wires
|
|
5
|
-
* index.ts. The
|
|
6
|
-
*
|
|
7
|
-
* TOOLS
|
|
8
|
-
*
|
|
4
|
+
* `@tpsdev-ai/flair-mcp` no longer hand-wires per-tool string literals in
|
|
5
|
+
* index.ts. The advertised set is STDIO_TOOL_DESCRIPTORS from the shared
|
|
6
|
+
* `@tpsdev-ai/flair-tool-descriptors` module — the same descriptors the
|
|
7
|
+
* server TOOLS registry binds to Harper impls. Drift is impossible by
|
|
8
|
+
* construction: a new both-surface descriptor appears here once a
|
|
9
|
+
* FlairClient handler is bound.
|
|
9
10
|
*
|
|
10
|
-
* This module
|
|
11
|
+
* This module remains the reviewed chokepoint for the stdio ↔ TOOLS seam:
|
|
11
12
|
*
|
|
12
|
-
* 1. `ADAPTER_TOOL_NAMES` is
|
|
13
|
-
* 2. `parseAdapterToolNames`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* 3. `STDIO_ADAPTER_EXEMPTIONS` is
|
|
17
|
-
*
|
|
18
|
-
* neither registered here nor exempted is a CI failure — silent drift
|
|
19
|
-
* of the class that hid skill_*.
|
|
20
|
-
*
|
|
21
|
-
* Deriving the adapter's handlers from TOOLS (so a new registry tool appears
|
|
22
|
-
* here for free) is the durable structural fix; it does not fit this chip
|
|
23
|
-
* because TOOLS is Harper-linked server code and this package talks HTTP via
|
|
24
|
-
* FlairClient. Detection + exemption list ships now; derive is a follow-on.
|
|
13
|
+
* 1. `ADAPTER_TOOL_NAMES` is DERIVED from STDIO_TOOL_DESCRIPTORS.
|
|
14
|
+
* 2. `parseAdapterToolNames` still scans for leftover string-literal
|
|
15
|
+
* tool names passed to the MCP SDK — hand-wiring is now a CI failure,
|
|
16
|
+
* not the registration path.
|
|
17
|
+
* 3. `STDIO_ADAPTER_EXEMPTIONS` is DERIVED from descriptor surface flags
|
|
18
|
+
* (the #1578 list, now structural rather than hand-synced).
|
|
25
19
|
*/
|
|
26
|
-
/** Tools registered on the stdio adapter
|
|
27
|
-
export declare const ADAPTER_TOOL_NAMES:
|
|
20
|
+
/** Tools registered on the stdio adapter — derived from the shared descriptor list. */
|
|
21
|
+
export declare const ADAPTER_TOOL_NAMES: string[];
|
|
28
22
|
export type AdapterToolName = (typeof ADAPTER_TOOL_NAMES)[number];
|
|
29
23
|
/**
|
|
30
|
-
* Reviewed
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* Adding or removing a name is the control: CI fails if an exemption is
|
|
34
|
-
* unused (the tool appeared on both sides, or vanished from the side it
|
|
35
|
-
* was excused on) or if a non-exempt name exists on only one side.
|
|
24
|
+
* Reviewed one-sided tools at the stdio-adapter ↔ server TOOLS seam.
|
|
25
|
+
* Derived from descriptor `native` / `stdio` flags (flair#1580) — the same
|
|
26
|
+
* names #1578 listed by hand (attention, archive verbs, relationship_store).
|
|
36
27
|
*/
|
|
37
28
|
export declare const STDIO_ADAPTER_EXEMPTIONS: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* - attention: native /mcp only (flair#677). mcp-tools.ts's module doc
|
|
42
|
-
* explicitly does not mirror it into this package.
|
|
43
|
-
* - memory_basement / memory_restore: archive verbs (flair#1472) landed
|
|
44
|
-
* on native /mcp; not yet forwarded over FlairClient.
|
|
45
|
-
*/
|
|
46
|
-
readonly registryOnly: readonly ["attention", "memory_basement", "memory_restore"];
|
|
47
|
-
/**
|
|
48
|
-
* Wired on the stdio adapter, absent from `TOOLS`.
|
|
49
|
-
*
|
|
50
|
-
* - relationship_store: the adapter predates the record-types mcp
|
|
51
|
-
* declaration. Relationship has no `RECORD_TYPES.mcp` field, so TOOLS
|
|
52
|
-
* ships zero relationship_* names. The adapter still exposes the triple
|
|
53
|
-
* write (FlairClient.relationship.write).
|
|
54
|
-
*/
|
|
55
|
-
readonly adapterOnly: readonly ["relationship_store"];
|
|
29
|
+
readonly registryOnly: string[];
|
|
30
|
+
readonly adapterOnly: string[];
|
|
56
31
|
};
|
|
57
32
|
/**
|
|
58
|
-
* Collect
|
|
59
|
-
*
|
|
33
|
+
* Collect leftover string-literal tool registrations from adapter source.
|
|
34
|
+
* After #1580 the derived registrar uses `server.tool(d.name, ...)`, so this
|
|
35
|
+
* scan should return empty. A new literal is a CI failure.
|
|
60
36
|
* Does not use `new RegExp` built from runtime input (CodeQL js/regex-injection).
|
|
61
37
|
*/
|
|
62
38
|
export declare function parseAdapterToolNames(source: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Handler keys from `STDIO_TOOL_HANDLERS` in adapter-tools.ts source.
|
|
41
|
+
* Root unit tests must not import adapter-tools.ts — that module loads
|
|
42
|
+
* `@tpsdev-ai/flair-client` (built later in the unit lane).
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseStdioHandlerNames(source: string): string[];
|
|
63
45
|
export interface AdapterRegistryParity {
|
|
64
46
|
/** TOOLS names the adapter neither registers nor exempts. */
|
|
65
47
|
missingFromAdapter: string[];
|
|
@@ -71,5 +53,14 @@ export interface AdapterRegistryParity {
|
|
|
71
53
|
/**
|
|
72
54
|
* Compare the stdio adapter's tool set to the server TOOLS registry.
|
|
73
55
|
* Equal after applying the reviewed exemption list — otherwise drift.
|
|
56
|
+
* Kept from #1578 as the migration tripwire; #1580 also asserts
|
|
57
|
+
* derived set == descriptor set structurally.
|
|
74
58
|
*/
|
|
75
59
|
export declare function adapterRegistryParity(registryNames: readonly string[], adapterNames: readonly string[]): AdapterRegistryParity;
|
|
60
|
+
/**
|
|
61
|
+
* Structural #1580 assert: the bound handler set equals the stdio descriptor set.
|
|
62
|
+
*/
|
|
63
|
+
export declare function derivedDescriptorParity(handlerNames: readonly string[], descriptorNamesList?: readonly string[]): {
|
|
64
|
+
missingHandlers: string[];
|
|
65
|
+
extraHandlers: string[];
|
|
66
|
+
};
|
package/dist/adapter-surface.js
CHANGED
|
@@ -1,77 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* adapter-surface.ts — the stdio adapter's
|
|
2
|
+
* adapter-surface.ts — the stdio adapter's derived tool set (flair#1580).
|
|
3
3
|
*
|
|
4
|
-
* `@tpsdev-ai/flair-mcp` hand-wires
|
|
5
|
-
* index.ts. The
|
|
6
|
-
*
|
|
7
|
-
* TOOLS
|
|
8
|
-
*
|
|
4
|
+
* `@tpsdev-ai/flair-mcp` no longer hand-wires per-tool string literals in
|
|
5
|
+
* index.ts. The advertised set is STDIO_TOOL_DESCRIPTORS from the shared
|
|
6
|
+
* `@tpsdev-ai/flair-tool-descriptors` module — the same descriptors the
|
|
7
|
+
* server TOOLS registry binds to Harper impls. Drift is impossible by
|
|
8
|
+
* construction: a new both-surface descriptor appears here once a
|
|
9
|
+
* FlairClient handler is bound.
|
|
9
10
|
*
|
|
10
|
-
* This module
|
|
11
|
+
* This module remains the reviewed chokepoint for the stdio ↔ TOOLS seam:
|
|
11
12
|
*
|
|
12
|
-
* 1. `ADAPTER_TOOL_NAMES` is
|
|
13
|
-
* 2. `parseAdapterToolNames`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* 3. `STDIO_ADAPTER_EXEMPTIONS` is
|
|
17
|
-
*
|
|
18
|
-
* neither registered here nor exempted is a CI failure — silent drift
|
|
19
|
-
* of the class that hid skill_*.
|
|
20
|
-
*
|
|
21
|
-
* Deriving the adapter's handlers from TOOLS (so a new registry tool appears
|
|
22
|
-
* here for free) is the durable structural fix; it does not fit this chip
|
|
23
|
-
* because TOOLS is Harper-linked server code and this package talks HTTP via
|
|
24
|
-
* FlairClient. Detection + exemption list ships now; derive is a follow-on.
|
|
13
|
+
* 1. `ADAPTER_TOOL_NAMES` is DERIVED from STDIO_TOOL_DESCRIPTORS.
|
|
14
|
+
* 2. `parseAdapterToolNames` still scans for leftover string-literal
|
|
15
|
+
* tool names passed to the MCP SDK — hand-wiring is now a CI failure,
|
|
16
|
+
* not the registration path.
|
|
17
|
+
* 3. `STDIO_ADAPTER_EXEMPTIONS` is DERIVED from descriptor surface flags
|
|
18
|
+
* (the #1578 list, now structural rather than hand-synced).
|
|
25
19
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"flair_orgevent",
|
|
30
|
-
"flair_workspace_set",
|
|
31
|
-
"memory_delete",
|
|
32
|
-
"memory_get",
|
|
33
|
-
"memory_search",
|
|
34
|
-
"memory_store",
|
|
35
|
-
"memory_update",
|
|
36
|
-
"record_usage",
|
|
37
|
-
"relationship_store",
|
|
38
|
-
"skill_get",
|
|
39
|
-
"skill_search",
|
|
40
|
-
"skill_store",
|
|
41
|
-
"soul_get",
|
|
42
|
-
"soul_set",
|
|
43
|
-
];
|
|
20
|
+
import { STDIO_TOOL_DESCRIPTORS, SURFACE_EXEMPTIONS, descriptorNames, } from "@tpsdev-ai/flair-tool-descriptors";
|
|
21
|
+
/** Tools registered on the stdio adapter — derived from the shared descriptor list. */
|
|
22
|
+
export const ADAPTER_TOOL_NAMES = descriptorNames(STDIO_TOOL_DESCRIPTORS);
|
|
44
23
|
/**
|
|
45
|
-
* Reviewed
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* Adding or removing a name is the control: CI fails if an exemption is
|
|
49
|
-
* unused (the tool appeared on both sides, or vanished from the side it
|
|
50
|
-
* was excused on) or if a non-exempt name exists on only one side.
|
|
24
|
+
* Reviewed one-sided tools at the stdio-adapter ↔ server TOOLS seam.
|
|
25
|
+
* Derived from descriptor `native` / `stdio` flags (flair#1580) — the same
|
|
26
|
+
* names #1578 listed by hand (attention, archive verbs, relationship_store).
|
|
51
27
|
*/
|
|
52
28
|
export const STDIO_ADAPTER_EXEMPTIONS = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* - attention: native /mcp only (flair#677). mcp-tools.ts's module doc
|
|
57
|
-
* explicitly does not mirror it into this package.
|
|
58
|
-
* - memory_basement / memory_restore: archive verbs (flair#1472) landed
|
|
59
|
-
* on native /mcp; not yet forwarded over FlairClient.
|
|
60
|
-
*/
|
|
61
|
-
registryOnly: ["attention", "memory_basement", "memory_restore"],
|
|
62
|
-
/**
|
|
63
|
-
* Wired on the stdio adapter, absent from `TOOLS`.
|
|
64
|
-
*
|
|
65
|
-
* - relationship_store: the adapter predates the record-types mcp
|
|
66
|
-
* declaration. Relationship has no `RECORD_TYPES.mcp` field, so TOOLS
|
|
67
|
-
* ships zero relationship_* names. The adapter still exposes the triple
|
|
68
|
-
* write (FlairClient.relationship.write).
|
|
69
|
-
*/
|
|
70
|
-
adapterOnly: ["relationship_store"],
|
|
29
|
+
registryOnly: SURFACE_EXEMPTIONS.registryOnly,
|
|
30
|
+
adapterOnly: SURFACE_EXEMPTIONS.adapterOnly,
|
|
71
31
|
};
|
|
72
32
|
/**
|
|
73
|
-
* Collect
|
|
74
|
-
*
|
|
33
|
+
* Collect leftover string-literal tool registrations from adapter source.
|
|
34
|
+
* After #1580 the derived registrar uses `server.tool(d.name, ...)`, so this
|
|
35
|
+
* scan should return empty. A new literal is a CI failure.
|
|
75
36
|
* Does not use `new RegExp` built from runtime input (CodeQL js/regex-injection).
|
|
76
37
|
*/
|
|
77
38
|
export function parseAdapterToolNames(source) {
|
|
@@ -82,9 +43,48 @@ export function parseAdapterToolNames(source) {
|
|
|
82
43
|
names.push(match[1]);
|
|
83
44
|
return names;
|
|
84
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Handler keys from `STDIO_TOOL_HANDLERS` in adapter-tools.ts source.
|
|
48
|
+
* Root unit tests must not import adapter-tools.ts — that module loads
|
|
49
|
+
* `@tpsdev-ai/flair-client` (built later in the unit lane).
|
|
50
|
+
*/
|
|
51
|
+
export function parseStdioHandlerNames(source) {
|
|
52
|
+
const marker = "export const STDIO_TOOL_HANDLERS";
|
|
53
|
+
const start = source.indexOf(marker);
|
|
54
|
+
if (start < 0)
|
|
55
|
+
return [];
|
|
56
|
+
const open = source.indexOf("{", start);
|
|
57
|
+
if (open < 0)
|
|
58
|
+
return [];
|
|
59
|
+
let depth = 0;
|
|
60
|
+
let close = -1;
|
|
61
|
+
for (let i = open; i < source.length; i++) {
|
|
62
|
+
const c = source[i];
|
|
63
|
+
if (c === "{")
|
|
64
|
+
depth++;
|
|
65
|
+
else if (c === "}") {
|
|
66
|
+
depth--;
|
|
67
|
+
if (depth === 0) {
|
|
68
|
+
close = i;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (close < 0)
|
|
74
|
+
return [];
|
|
75
|
+
const names = [];
|
|
76
|
+
for (const line of source.slice(open + 1, close).split("\n")) {
|
|
77
|
+
const m = line.match(/^\s*([a-z][a-z0-9_]*)\s*,?\s*$/);
|
|
78
|
+
if (m)
|
|
79
|
+
names.push(m[1]);
|
|
80
|
+
}
|
|
81
|
+
return names.sort();
|
|
82
|
+
}
|
|
85
83
|
/**
|
|
86
84
|
* Compare the stdio adapter's tool set to the server TOOLS registry.
|
|
87
85
|
* Equal after applying the reviewed exemption list — otherwise drift.
|
|
86
|
+
* Kept from #1578 as the migration tripwire; #1580 also asserts
|
|
87
|
+
* derived set == descriptor set structurally.
|
|
88
88
|
*/
|
|
89
89
|
export function adapterRegistryParity(registryNames, adapterNames) {
|
|
90
90
|
const registry = new Set(registryNames);
|
|
@@ -103,3 +103,14 @@ export function adapterRegistryParity(registryNames, adapterNames) {
|
|
|
103
103
|
].sort();
|
|
104
104
|
return { missingFromAdapter, extraOnAdapter, staleExemptions };
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Structural #1580 assert: the bound handler set equals the stdio descriptor set.
|
|
108
|
+
*/
|
|
109
|
+
export function derivedDescriptorParity(handlerNames, descriptorNamesList = ADAPTER_TOOL_NAMES) {
|
|
110
|
+
const handlers = new Set(handlerNames);
|
|
111
|
+
const descriptors = new Set(descriptorNamesList);
|
|
112
|
+
return {
|
|
113
|
+
missingHandlers: [...descriptors].filter((n) => !handlers.has(n)).sort(),
|
|
114
|
+
extraHandlers: [...handlers].filter((n) => !descriptors.has(n)).sort(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stdio adapter bindings (flair#1580).
|
|
3
|
+
*
|
|
4
|
+
* The tool SET is derived from STDIO_TOOL_DESCRIPTORS. This module only
|
|
5
|
+
* supplies FlairClient HTTP handlers — one per stdio descriptor. A new
|
|
6
|
+
* descriptor with no handler (or a handler with no descriptor) fails at
|
|
7
|
+
* registration, so the surfaces cannot drift by omission.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import type { FlairClient } from "@tpsdev-ai/flair-client";
|
|
11
|
+
import { type PresenceActivity } from "./presence.js";
|
|
12
|
+
export interface AdapterContext {
|
|
13
|
+
flair: FlairClient;
|
|
14
|
+
agentId: string;
|
|
15
|
+
heartbeat: (activity?: PresenceActivity) => void;
|
|
16
|
+
rememberTask: (task: string | undefined) => void;
|
|
17
|
+
}
|
|
18
|
+
type ToolResult = {
|
|
19
|
+
content: Array<{
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}>;
|
|
23
|
+
isError?: boolean;
|
|
24
|
+
structuredContent?: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
type StdioHandler = (args: Record<string, any>, ctx: AdapterContext) => Promise<ToolResult>;
|
|
27
|
+
/** FlairClient bindings keyed by descriptor name — the adapter-side impl map. */
|
|
28
|
+
export declare const STDIO_TOOL_HANDLERS: Record<string, StdioHandler>;
|
|
29
|
+
export declare function stdioHandlerNames(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Register every stdio descriptor on the MCP server. The advertised set is
|
|
32
|
+
* STDIO_TOOL_DESCRIPTORS — not a hand-written per-tool literal list.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerStdioTools(server: McpServer, ctx: AdapterContext): string[];
|
|
35
|
+
export {};
|