@agentistics/mcp 2.163.1 → 2.164.0
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/agentistics-mcp.js +119 -57
- package/package.json +1 -1
package/dist/agentistics-mcp.js
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// session-role-args.ts
|
|
4
|
-
function sessionRoleBody(a, session) {
|
|
5
|
-
const retire = typeof a?.retirePredecessor === "string" ? a.retirePredecessor.trim() : "";
|
|
6
|
-
return {
|
|
7
|
-
...a?.ref ? { ref: a.ref } : {},
|
|
8
|
-
...a?.role !== undefined ? { role: a.role } : {},
|
|
9
|
-
...retire ? { retirePredecessor: retire } : {},
|
|
10
|
-
session: session ?? null
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// orphan-guard.ts
|
|
15
|
-
function installOrphanGuard(d) {
|
|
16
|
-
const initial = d.getPpid();
|
|
17
|
-
let done = false;
|
|
18
|
-
const bye = () => {
|
|
19
|
-
if (done)
|
|
20
|
-
return;
|
|
21
|
-
done = true;
|
|
22
|
-
d.exit(0);
|
|
23
|
-
};
|
|
24
|
-
for (const ev of ["end", "close", "error"])
|
|
25
|
-
d.stdin.on(ev, bye);
|
|
26
|
-
d.stdout.on("error", bye);
|
|
27
|
-
for (const sig of ["SIGHUP", "SIGPIPE"])
|
|
28
|
-
d.proc.on(sig, bye);
|
|
29
|
-
const handle = d.setInterval(() => {
|
|
30
|
-
if (d.getPpid() !== initial)
|
|
31
|
-
bye();
|
|
32
|
-
}, d.intervalMs ?? 500);
|
|
33
|
-
handle?.unref?.();
|
|
34
|
-
return () => d.clearInterval(handle);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// orphan-guard-boot.ts
|
|
38
|
-
if (process.env.AGENTISTICS_MCP_NO_ORPHAN_GUARD !== "1") {
|
|
39
|
-
installOrphanGuard({
|
|
40
|
-
stdin: process.stdin,
|
|
41
|
-
stdout: process.stdout,
|
|
42
|
-
proc: process,
|
|
43
|
-
getPpid: () => process.ppid,
|
|
44
|
-
exit: (c) => process.exit(c),
|
|
45
|
-
setInterval: (f, ms) => setInterval(f, ms),
|
|
46
|
-
clearInterval: (h) => clearInterval(h)
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// agentistics-mcp.ts
|
|
51
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
52
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
53
|
-
import {
|
|
54
|
-
CallToolRequestSchema,
|
|
55
|
-
ListToolsRequestSchema
|
|
56
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
57
|
-
|
|
58
3
|
// ../core/src/local-models.ts
|
|
59
4
|
var LOCAL_RUNTIME_PREFIXES = [
|
|
60
5
|
"ollama",
|
|
@@ -1073,7 +1018,9 @@ var AGENT_TOOL_POLICY = {
|
|
|
1073
1018
|
agentistics_build_layout: { ...PREFS, risk: "W", routes: ["GET /api/preferences", "PUT /api/preferences"], reason: "writes a layout; reversible by another build or delete" },
|
|
1074
1019
|
agentistics_export_pdf: { ...DATA, risk: "R", routes: [], reason: "composes a local dashboard URL; calls nothing and exports nothing itself" },
|
|
1075
1020
|
agentistics_tags: { ...DATA, risk: "R", routes: ["GET /api/tags"], reason: "reads aggregate-only tag cards" },
|
|
1076
|
-
agentistics_tag_detail: { ...DATA, risk: "R", routes: ["GET /api/tags", "GET /api/tags/:id"], reason: "reads one tag aggregate (counts and sums only)" }
|
|
1021
|
+
agentistics_tag_detail: { ...DATA, risk: "R", routes: ["GET /api/tags", "GET /api/tags/:id"], reason: "reads one tag aggregate (counts and sums only)" },
|
|
1022
|
+
agentistics_flow_run: { ...DATA, capability: "localShell", host: true, risk: "R", routes: ["POST /api/flows/run"], reason: "runs only the built-in deterministic flow gates; it deletes nothing" },
|
|
1023
|
+
agentistics_flow_status: { ...DATA, capability: "localShell", host: true, risk: "R", routes: ["GET /api/flows/status/:runId"], reason: "reads a durable deterministic flow run" }
|
|
1077
1024
|
};
|
|
1078
1025
|
// ../core/src/dataPatch.ts
|
|
1079
1026
|
var blocked = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -1185,6 +1132,72 @@ function routeRecommendation(budgets, kind, authorHarness) {
|
|
|
1185
1132
|
}
|
|
1186
1133
|
var NEW_PERIOD_MS = 5 * 60000;
|
|
1187
1134
|
var DISCONTINUITY_RESET_MS = 60 * 60000;
|
|
1135
|
+
// ../core/src/flowRunId.ts
|
|
1136
|
+
function isFlowRunId(id) {
|
|
1137
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(id);
|
|
1138
|
+
}
|
|
1139
|
+
// flow-status.ts
|
|
1140
|
+
function flowStatusRunId(runId) {
|
|
1141
|
+
if (!isFlowRunId(runId))
|
|
1142
|
+
throw new Error("invalid flow run id");
|
|
1143
|
+
return runId;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// session-role-args.ts
|
|
1147
|
+
function sessionRoleBody(a, session) {
|
|
1148
|
+
const retire = typeof a?.retirePredecessor === "string" ? a.retirePredecessor.trim() : "";
|
|
1149
|
+
return {
|
|
1150
|
+
...a?.ref ? { ref: a.ref } : {},
|
|
1151
|
+
...a?.role !== undefined ? { role: a.role } : {},
|
|
1152
|
+
...retire ? { retirePredecessor: retire } : {},
|
|
1153
|
+
session: session ?? null
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// orphan-guard.ts
|
|
1158
|
+
function installOrphanGuard(d) {
|
|
1159
|
+
const initial = d.getPpid();
|
|
1160
|
+
let done = false;
|
|
1161
|
+
const bye = () => {
|
|
1162
|
+
if (done)
|
|
1163
|
+
return;
|
|
1164
|
+
done = true;
|
|
1165
|
+
d.exit(0);
|
|
1166
|
+
};
|
|
1167
|
+
for (const ev of ["end", "close", "error"])
|
|
1168
|
+
d.stdin.on(ev, bye);
|
|
1169
|
+
d.stdout.on("error", bye);
|
|
1170
|
+
for (const sig of ["SIGHUP", "SIGPIPE"])
|
|
1171
|
+
d.proc.on(sig, bye);
|
|
1172
|
+
const handle = d.setInterval(() => {
|
|
1173
|
+
if (d.getPpid() !== initial)
|
|
1174
|
+
bye();
|
|
1175
|
+
}, d.intervalMs ?? 500);
|
|
1176
|
+
handle?.unref?.();
|
|
1177
|
+
return () => d.clearInterval(handle);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// orphan-guard-boot.ts
|
|
1181
|
+
if (process.env.AGENTISTICS_MCP_NO_ORPHAN_GUARD !== "1") {
|
|
1182
|
+
installOrphanGuard({
|
|
1183
|
+
stdin: process.stdin,
|
|
1184
|
+
stdout: process.stdout,
|
|
1185
|
+
proc: process,
|
|
1186
|
+
getPpid: () => process.ppid,
|
|
1187
|
+
exit: (c) => process.exit(c),
|
|
1188
|
+
setInterval: (f, ms) => setInterval(f, ms),
|
|
1189
|
+
clearInterval: (h) => clearInterval(h)
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// agentistics-mcp.ts
|
|
1194
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
1195
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1196
|
+
import {
|
|
1197
|
+
CallToolRequestSchema,
|
|
1198
|
+
ListToolsRequestSchema
|
|
1199
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
1200
|
+
|
|
1188
1201
|
// session-tokens.ts
|
|
1189
1202
|
function sessionHarness(s) {
|
|
1190
1203
|
return s.harness ?? "claude";
|
|
@@ -1945,6 +1958,17 @@ async function nativeVisibleNow() {
|
|
|
1945
1958
|
return false;
|
|
1946
1959
|
}
|
|
1947
1960
|
}
|
|
1961
|
+
async function flowsVisibleNow() {
|
|
1962
|
+
try {
|
|
1963
|
+
const res = await fetch(`${API}/api/engine`, { signal: AbortSignal.timeout(2000) });
|
|
1964
|
+
if (!res.ok)
|
|
1965
|
+
return false;
|
|
1966
|
+
const body = await res.json();
|
|
1967
|
+
return body.flowsExperimental === true && body.flows === true;
|
|
1968
|
+
} catch {
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1948
1972
|
var CATALOG = [
|
|
1949
1973
|
{ id: "kpi.messages", label: "Messages", category: "kpi", defaultW: 3, defaultH: 3, minW: 2, minH: 2, description: "Total message count in selected period" },
|
|
1950
1974
|
{ id: "kpi.sessions", label: "Sessions", category: "kpi", defaultW: 3, defaultH: 3, minW: 2, minH: 2, description: "Session count + avg msgs/session" },
|
|
@@ -2675,10 +2699,35 @@ var TOOLS = [
|
|
|
2675
2699
|
name: "agentistics_repos",
|
|
2676
2700
|
description: "List repositories, grouped by normalized git remote (independent of local path or which machine produced the session), with session/message/token/cost totals and last-active date. Sessions with no linked repository are grouped under 'unlinked'. Optionally scope to a single harness. Rows tagged source \"projections\" (read from the journal) carry personTurns (the person's turns); there `messages` is a deprecated alias of personTurns, and subagent spend is reported apart (subagentTokens, subagentCostUSD).",
|
|
2677
2701
|
inputSchema: { type: "object", properties: { harness: HARNESS_PARAM }, required: [] }
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
name: "agentistics_flow_run",
|
|
2705
|
+
description: "Run an official deterministic flow. Flows are experimental and read-only host operations; the server refuses when AGENTISTICS_FLOWS is off or the official engine is absent.",
|
|
2706
|
+
inputSchema: {
|
|
2707
|
+
type: "object",
|
|
2708
|
+
properties: {
|
|
2709
|
+
name: { type: "string", description: "Built-in flow name, for example worker-checar or limpeza." },
|
|
2710
|
+
inputs: { type: "object", description: "Optional flow inputs." }
|
|
2711
|
+
},
|
|
2712
|
+
required: ["name"]
|
|
2713
|
+
}
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
name: "agentistics_flow_status",
|
|
2717
|
+
description: "Read the durable status of an official deterministic flow run.",
|
|
2718
|
+
inputSchema: {
|
|
2719
|
+
type: "object",
|
|
2720
|
+
properties: { runId: { type: "string", description: "Flow run id returned by agentistics_flow_run." } },
|
|
2721
|
+
required: ["runId"]
|
|
2722
|
+
}
|
|
2678
2723
|
}
|
|
2679
2724
|
];
|
|
2680
2725
|
var MCP_TOOL_NAMES = TOOLS.map((tool) => tool.name);
|
|
2681
|
-
server.setRequestHandler(ListToolsRequestSchema, async () =>
|
|
2726
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
2727
|
+
const tools = toolsForGate(TOOLS, await nativeVisibleNow());
|
|
2728
|
+
const flowsOn = await flowsVisibleNow();
|
|
2729
|
+
return { tools: flowsOn ? tools : tools.filter((tool) => !tool.name.startsWith("agentistics_flow_")) };
|
|
2730
|
+
});
|
|
2682
2731
|
var audit = createAgentAuditSink();
|
|
2683
2732
|
process.on("exit", () => audit.flush());
|
|
2684
2733
|
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
@@ -2715,6 +2764,19 @@ async function callTool(req) {
|
|
|
2715
2764
|
const body = await apiGet(`/api/tasks/${encodeURIComponent(ref)}`);
|
|
2716
2765
|
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
2717
2766
|
}
|
|
2767
|
+
case "agentistics_flow_run": {
|
|
2768
|
+
const a = args;
|
|
2769
|
+
const body = await apiSend("POST", "/api/flows/run", {
|
|
2770
|
+
name: a?.name,
|
|
2771
|
+
...a?.inputs && typeof a.inputs === "object" ? { inputs: a.inputs } : {}
|
|
2772
|
+
});
|
|
2773
|
+
return text(body);
|
|
2774
|
+
}
|
|
2775
|
+
case "agentistics_flow_status": {
|
|
2776
|
+
const runId = String(args?.runId ?? "");
|
|
2777
|
+
const body = await apiGet(`/api/flows/status/${flowStatusRunId(runId)}`);
|
|
2778
|
+
return text(body);
|
|
2779
|
+
}
|
|
2718
2780
|
case "agentistics_task_create": {
|
|
2719
2781
|
const a = args;
|
|
2720
2782
|
const body = await apiSend("POST", "/api/tasks", { title: a?.title, detail: a?.detail });
|
package/package.json
CHANGED