@miadi/stateloom-mcp 0.3.0 → 0.3.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/server.js +28 -4
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -657,6 +657,11 @@ function renderStateSpec(s, lines, depthLevel) {
|
|
|
657
657
|
const indent = " ".repeat(depthLevel);
|
|
658
658
|
const kind = s.kind && s.kind !== "normal" ? ` *(${s.kind})*` : "";
|
|
659
659
|
lines.push(`${indent}- **${s.name}**${kind}${s.description ? ` — ${s.description}` : ""}`);
|
|
660
|
+
if (s.prompt?.trim()) {
|
|
661
|
+
lines.push(`${indent} - *the agent resolves here:*`);
|
|
662
|
+
for (const line of s.prompt.trim().split("\n"))
|
|
663
|
+
lines.push(`${indent} > ${line}`);
|
|
664
|
+
}
|
|
660
665
|
for (const t of s.transitions ?? []) {
|
|
661
666
|
lines.push(`${indent} - on \`${t.event}\` ${t.nextState ? `→ \`${t.nextState}\`` : "(internal)"}`);
|
|
662
667
|
}
|
|
@@ -737,12 +742,13 @@ function buildServer() {
|
|
|
737
742
|
],
|
|
738
743
|
};
|
|
739
744
|
});
|
|
740
|
-
server.tool("add_state", "Add a state to the state machine. Parent defaults to Root.", {
|
|
745
|
+
server.tool("add_state", "Add a state to the state machine. Parent defaults to Root. `prompt` is what an agent is asked to resolve while the machine is in this state (see set_prompt).", {
|
|
741
746
|
name: z.string(),
|
|
742
747
|
parent: z.string().optional(),
|
|
743
748
|
kind: z.enum(["normal", "final", "history"]).optional(),
|
|
744
749
|
description: z.string().optional(),
|
|
745
|
-
|
|
750
|
+
prompt: z.string().optional(),
|
|
751
|
+
}, async ({ name, parent, kind, description, prompt }) => {
|
|
746
752
|
const def = readDef();
|
|
747
753
|
if (!def)
|
|
748
754
|
return {
|
|
@@ -758,15 +764,33 @@ function buildServer() {
|
|
|
758
764
|
};
|
|
759
765
|
if (!parentState.states)
|
|
760
766
|
parentState.states = [];
|
|
761
|
-
|
|
767
|
+
const added = { name, kind: kind ?? "normal", description, ...(prompt?.trim() ? { prompt } : {}) };
|
|
768
|
+
parentState.states.push(added);
|
|
762
769
|
writeDef(def);
|
|
763
770
|
bridgeEmitPatch([
|
|
764
|
-
{ op: "state.add", parent: parentName, state: { name, kind: kind ?? "normal", description } },
|
|
771
|
+
{ op: "state.add", parent: parentName, state: { name, kind: kind ?? "normal", description, ...(added.prompt ? { prompt: added.prompt } : {}) } },
|
|
765
772
|
]);
|
|
766
773
|
return {
|
|
767
774
|
content: [{ type: "text", text: `Added state '${name}' under '${parentName}' (${kind ?? "normal"}).` }],
|
|
768
775
|
};
|
|
769
776
|
});
|
|
777
|
+
server.tool("set_prompt", "Say what an agent is asked to resolve while the machine is in a state: the instruction it receives when the state is entered — an opening message, the frame of every later turn. `description` says what the state is and notes are the conversation about it; the prompt is what to do in it. The text replaces what was there; an empty string clears it. Engines and code generation ignore it; get_definition and generate_rispec show it.", { state: z.string(), prompt: z.string() }, async ({ state, prompt }) => {
|
|
778
|
+
const def = readDef();
|
|
779
|
+
if (!def)
|
|
780
|
+
return { content: [{ type: "text", text: noMachine() }], isError: true };
|
|
781
|
+
const target = findState(def.state, state);
|
|
782
|
+
if (!target)
|
|
783
|
+
return { content: [{ type: "text", text: `State '${state}' not found.` }], isError: true };
|
|
784
|
+
if (prompt.trim())
|
|
785
|
+
target.prompt = prompt;
|
|
786
|
+
else
|
|
787
|
+
delete target.prompt;
|
|
788
|
+
writeDef(def);
|
|
789
|
+
bridgeEmitPatch([{ op: "state.update", name: state, patch: { prompt: prompt.trim() ? prompt : "" } }]);
|
|
790
|
+
return {
|
|
791
|
+
content: [{ type: "text", text: prompt.trim() ? `Prompt set on '${state}' (${prompt.length} characters).` : `Prompt cleared on '${state}'.` }],
|
|
792
|
+
};
|
|
793
|
+
});
|
|
770
794
|
server.tool("add_event", "Add an event to the state machine", { id: z.string(), description: z.string().optional() }, async ({ id, description }) => {
|
|
771
795
|
const def = readDef();
|
|
772
796
|
if (!def)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/stateloom-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "MCP server for miadi-stateloom (formerly smcraft-mcp) — lets LLM agents design state machines through conversation",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@miadi/stateloom-cli": "^0.1.3",
|
|
42
42
|
"@miadi/stateloom-client": "^0.1.3",
|
|
43
|
-
"@miadi/stateloom-protocol": "^0.1.
|
|
43
|
+
"@miadi/stateloom-protocol": "^0.1.10",
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
45
45
|
"zod": "^4.3.6"
|
|
46
46
|
},
|