@igorjpimenta/brayer 2026.11.7-beta.1 → 2026.11.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igorjpimenta/brayer-openclaw",
|
|
3
|
-
"version": "2026.11.7
|
|
3
|
+
"version": "2026.11.7",
|
|
4
4
|
"description": "OpenClaw companion for Brayer: stamps caller identity on Brayer MCP tool calls.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"openclaw": ">=2026.5.18"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@igorjpimenta/brayer": "2026.11.7
|
|
35
|
+
"@igorjpimenta/brayer": "2026.11.7"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/cli/serve.js
CHANGED
|
@@ -7,20 +7,20 @@ export async function runServe({ rest, env, logger }) {
|
|
|
7
7
|
const mcpIndex = rest.indexOf("--mcp");
|
|
8
8
|
const transport = mcpIndex >= 0 ? rest[mcpIndex + 1] : null;
|
|
9
9
|
if (transport) {
|
|
10
|
-
const base = env.BRAYER_HARNESS ? { harness: env.BRAYER_HARNESS } : undefined;
|
|
11
10
|
const store = createStore({ dbPath: env.BRAYER_DB || undefined });
|
|
12
11
|
if (transport === "stdio") {
|
|
13
|
-
if (!
|
|
14
|
-
await startMcpServer({ store, base, logger });
|
|
12
|
+
if (!env.BRAYER_HARNESS) throw new Error("brayer: BRAYER_HARNESS is required for stdio MCP");
|
|
13
|
+
await startMcpServer({ store, base: { harness: env.BRAYER_HARNESS }, logger });
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
17
16
|
if (transport === "http") {
|
|
18
17
|
if (!env.BRAYER_MCP_BEARER) throw new Error("brayer: BRAYER_MCP_BEARER is required for HTTP");
|
|
19
18
|
const port = Number(flagValue(rest, "--port") ?? env.BRAYER_HTTP_PORT ?? 38293);
|
|
20
19
|
const host = flagValue(rest, "--host") ?? "127.0.0.1";
|
|
20
|
+
// No harness base crosses into HTTP minting: the header alone declares
|
|
21
|
+
// each session's harness, so a shared server stays construction-agnostic.
|
|
21
22
|
await startMcpHttpServer({
|
|
22
23
|
store,
|
|
23
|
-
base,
|
|
24
24
|
port,
|
|
25
25
|
host,
|
|
26
26
|
bearer: env.BRAYER_MCP_BEARER,
|
package/src/identity.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
// A usable layer names something: non-empty, and neither of the
|
|
2
|
-
//
|
|
1
|
+
// A usable layer names something: non-empty, and neither of the tokens no
|
|
2
|
+
// key may carry ("unknown", "any", "instance:*" — "any" was the shared-HTTP
|
|
3
|
+
// env sentinel; the header mint makes it meaningless as a harness name).
|
|
3
4
|
function isUsableLayer(v) {
|
|
4
5
|
return (
|
|
5
6
|
typeof v === "string" &&
|
|
6
7
|
v.trim() !== "" &&
|
|
7
|
-
!/^(unknown|instance:.*)$/i.test(v.trim())
|
|
8
|
+
!/^(unknown|any|instance:.*)$/i.test(v.trim())
|
|
8
9
|
);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
// The
|
|
12
|
-
//
|
|
13
|
-
// X-Brayer-Harness header at session creation
|
|
14
|
-
//
|
|
15
|
-
// harness
|
|
12
|
+
// The declaration arrives only from the caller side — never from process env.
|
|
13
|
+
// serve() injects BRAYER_HARNESS as the stdio base (one-to-one pipe); the
|
|
14
|
+
// shared HTTP mint passes the X-Brayer-Harness header at session creation.
|
|
15
|
+
// Keeping the env read out of here is what stops a streaming session from
|
|
16
|
+
// ever minting a construction-time harness. Agent and session are never
|
|
17
|
+
// declared: they arrive per call, stamped by the calling harness's plugin.
|
|
16
18
|
export function assertDeclaration(base = {}) {
|
|
17
|
-
const harness = base
|
|
19
|
+
const harness = base?.harness;
|
|
18
20
|
if (typeof harness !== "string" || !harness.trim()) {
|
|
19
|
-
throw new Error("brayer: BRAYER_HARNESS
|
|
21
|
+
throw new Error("brayer: harness must be declared (BRAYER_HARNESS env for stdio serve, X-Brayer-Harness header for HTTP)");
|
|
20
22
|
}
|
|
21
|
-
if (
|
|
23
|
+
if (!isUsableLayer(harness)) {
|
|
22
24
|
throw new Error(`brayer: refused declaration (reserved: harness). "${harness}" cannot identify a consumer — declare the real harness name.`);
|
|
23
25
|
}
|
|
24
26
|
return { ...base, harness: harness.trim() };
|