Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions plugins/app/ralphx-mcp-server/build/learned-skill-tools.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";

import {
LEARNED_SKILL_TOOLS,
learnedSkillEndpoint,
learnedSkillTransportOptions,
} from "../learned-skill-tools.js";
Expand All @@ -14,7 +15,7 @@ describe("learned skill dispatch", () => {
expect(learnedSkillEndpoint("retire_project_skill")).toBe("project_skills/retire");
});

it("adds hidden runtime headers only to write calls", () => {
it("adds transport-owned read identity without changing model schemas", () => {
const runtime = {
filesystemEnforced: false,
agentType: "ralphx-memory-maintainer",
Expand All @@ -23,19 +24,44 @@ describe("learned skill dispatch", () => {
contextType: "project",
contextId: "project-1",
conversationId: "conversation-1",
agentRunId: "run-1",
};

expect(learnedSkillTransportOptions("list_project_skills", runtime)).toBeUndefined();
expect(learnedSkillTransportOptions("get_project_skill", runtime)).toBeUndefined();
for (const toolName of ["list_project_skills", "get_project_skill"]) {
expect(learnedSkillTransportOptions(toolName, runtime)).toEqual({
headers: {
"x-ralphx-conversation-id": "conversation-1",
"x-ralphx-agent-run-id": "run-1",
},
});
}
expect(learnedSkillTransportOptions("upsert_project_skill", runtime)).toEqual({
headers: {
"x-ralphx-agent-name": "ralphx-memory-maintainer",
"x-ralphx-agent-run-id": "run-1",
"x-ralphx-pipeline-role": "memory_maintainer",
"x-ralphx-project-id": "project-1",
"x-ralphx-context-type": "project",
"x-ralphx-context-id": "project-1",
"x-ralphx-conversation-id": "conversation-1",
},
});

for (const tool of LEARNED_SKILL_TOOLS) {
expect(tool.inputSchema.properties).not.toHaveProperty("conversation_id");
expect(tool.inputSchema.properties).not.toHaveProperty("agent_run_id");
expect(tool.inputSchema.properties).not.toHaveProperty("orchestration_id");
}
});

it("uses bounded conversation identity for read calls when no run exists", () => {
expect(
learnedSkillTransportOptions("get_project_skill", {
filesystemEnforced: false,
conversationId: "conversation-1",
})
).toEqual({
headers: { "x-ralphx-conversation-id": "conversation-1" },
});
});
});
10 changes: 9 additions & 1 deletion plugins/app/ralphx-mcp-server/src/learned-skill-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Tool } from "@modelcontextprotocol/sdk/types.js";

import {
buildProjectSkillPipelineTransportHeaders,
buildRuntimeIdentityTransportHeaders,
buildRuntimeTransportHeaders,
} from "./runtime-context.js";
import type { RuntimeContext } from "./runtime-context.js";
import type { TauriCallOptions } from "./tauri-client.js";
Expand Down Expand Up @@ -184,6 +186,7 @@ const WRITE_TOOLS = new Set([
"patch_project_skill",
"retire_project_skill",
]);
const READ_TOOLS = new Set(["list_project_skills", "get_project_skill"]);

export function learnedSkillEndpoint(toolName: string): string {
const endpoint = ENDPOINT_BY_TOOL[toolName];
Expand All @@ -198,7 +201,12 @@ export function learnedSkillTransportOptions(
runtimeContext: RuntimeContext
): TauriCallOptions | undefined {
if (!WRITE_TOOLS.has(toolName)) {
return undefined;
if (!READ_TOOLS.has(toolName)) return undefined;
const headers = {
...(buildRuntimeTransportHeaders(runtimeContext) ?? {}),
...(buildRuntimeIdentityTransportHeaders(runtimeContext) ?? {}),
};
return Object.keys(headers).length > 0 ? { headers } : undefined;
}
const headers = buildProjectSkillPipelineTransportHeaders(runtimeContext);
return headers ? { headers } : undefined;
Expand Down
Loading