@igorjpimenta/brayer 2026.11.3-beta.1 → 2026.11.7-beta.2
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/README.md +4 -1
- package/package.json +1 -1
- package/plugins/openclaw/brayer/meta.js +13 -1
- package/plugins/openclaw/brayer/package.json +2 -2
- package/src/cli/serve.js +6 -5
- package/src/identity.js +16 -14
- package/src/mcp.js +2 -1
package/README.md
CHANGED
|
@@ -193,7 +193,10 @@ An adapter attaches an existing order; it never creates work.
|
|
|
193
193
|
|
|
194
194
|
**OpenClaw** — `@igorjpimenta/brayer-openclaw` stamps `_meta.brayer`, checkpoints
|
|
195
195
|
on turn end, resumes from the latest checkpoint, and receives claim webhooks at
|
|
196
|
-
`POST /api/brayer/claimed`.
|
|
196
|
+
`POST /api/brayer/claimed`. The hook declares the stamp on `requestMeta`, which
|
|
197
|
+
current OpenClaw hoists to JSON-RPC request `_meta`
|
|
198
|
+
(openclaw/openclaw#193006), and mirrors it on `brayer_agent`/`brayer_session`
|
|
199
|
+
args for engines that predate the hoist.
|
|
197
200
|
|
|
198
201
|
```json
|
|
199
202
|
{
|
package/package.json
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// Identity goes out on every channel a consumer might read: `requestMeta` is
|
|
2
|
+
// the declared before_tool_call result field current OpenClaw hoists to
|
|
3
|
+
// JSON-RPC request `_meta` (openclaw/openclaw#193006); brayer_agent/
|
|
4
|
+
// brayer_session flat args and `params._meta.brayer` are mirrors for engines
|
|
5
|
+
// that predate the hoist (server picks protocol `_meta` first, args when it is
|
|
6
|
+
// lost). Unconditional overwrite on every channel: a model-supplied pair must
|
|
7
|
+
// never survive.
|
|
1
8
|
export function isBrayerTool(name) {
|
|
2
9
|
return typeof name === "string" && name.includes("brayer");
|
|
3
10
|
}
|
|
@@ -11,13 +18,18 @@ export function buildBrayerMeta(event, ctx) {
|
|
|
11
18
|
if (agent === null && session === null) return undefined;
|
|
12
19
|
|
|
13
20
|
const params = event?.params ?? {};
|
|
21
|
+
const brayer = { harness: "openclaw", agent, session };
|
|
14
22
|
return {
|
|
15
23
|
params: {
|
|
16
24
|
...params,
|
|
25
|
+
...(agent !== null && session !== null
|
|
26
|
+
? { brayer_agent: agent, brayer_session: session }
|
|
27
|
+
: {}),
|
|
17
28
|
_meta: {
|
|
18
29
|
...(params._meta ?? {}),
|
|
19
|
-
brayer
|
|
30
|
+
brayer,
|
|
20
31
|
},
|
|
21
32
|
},
|
|
33
|
+
requestMeta: { brayer },
|
|
22
34
|
};
|
|
23
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igorjpimenta/brayer-openclaw",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.7-beta.2",
|
|
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.
|
|
35
|
+
"@igorjpimenta/brayer": "2026.11.7-beta.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/cli/serve.js
CHANGED
|
@@ -3,27 +3,28 @@ import { startMcpHttpServer, startMcpServer } from "../mcp.js";
|
|
|
3
3
|
import { startEventServer } from "../events-ws.js";
|
|
4
4
|
import { flagValue } from "./args.js";
|
|
5
5
|
|
|
6
|
-
export async function runServe({ rest, env }) {
|
|
6
|
+
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 });
|
|
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,
|
|
27
|
+
logger,
|
|
27
28
|
});
|
|
28
29
|
return;
|
|
29
30
|
}
|
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() };
|
|
@@ -37,9 +39,9 @@ export function resolveIdentity({ meta, args, base } = {}) {
|
|
|
37
39
|
const aSession = usable(args?.brayer_session);
|
|
38
40
|
const pair =
|
|
39
41
|
mAgent && mSession
|
|
40
|
-
? { agent: mAgent, session: mSession }
|
|
42
|
+
? { agent: mAgent, session: mSession, via: "meta" }
|
|
41
43
|
: aAgent && aSession
|
|
42
|
-
? { agent: aAgent, session: aSession }
|
|
44
|
+
? { agent: aAgent, session: aSession, via: "args" }
|
|
43
45
|
: null;
|
|
44
46
|
if (!pair) {
|
|
45
47
|
if ((mAgent || aAgent) && (mSession || aSession)) {
|
|
@@ -51,7 +53,7 @@ export function resolveIdentity({ meta, args, base } = {}) {
|
|
|
51
53
|
throw new Error(`brayer: ${bad.join(" and ")} must be stamped on the call`);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
return { harness: declared.harness, agent: pair.agent, session: pair.session };
|
|
56
|
+
return { harness: declared.harness, agent: pair.agent, session: pair.session, via: pair.via };
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export function identityKey(identity) {
|
package/src/mcp.js
CHANGED
|
@@ -27,7 +27,8 @@ export function createMcpServer({ store, base, logger } = {}) {
|
|
|
27
27
|
async (args, extra) => {
|
|
28
28
|
try {
|
|
29
29
|
const identity = resolveIdentity({ meta: extra?._meta, args, base: declared });
|
|
30
|
-
|
|
30
|
+
const metaKeys = extra?._meta ? Object.keys(extra._meta).sort().join(",") : "-";
|
|
31
|
+
logger?.info?.(`brayer: ${def.name} from ${identity.harness}:${identity.agent}:${identity.session} via=${identity.via} metaKeys=${metaKeys}`);
|
|
31
32
|
const result = await handle(def.name, args, identity);
|
|
32
33
|
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
33
34
|
} catch (err) {
|