@stamn/stamn-plugin 0.1.0-alpha.35 → 0.1.0-alpha.37

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/index.js CHANGED
@@ -5274,8 +5274,11 @@ import { join as join3 } from "path";
5274
5274
  import { homedir } from "os";
5275
5275
  var DEFAULT_SERVER_URL = "https://api.stamn.com";
5276
5276
  var PLUGIN_ID = "stamn-plugin";
5277
+ function getHttpUrl() {
5278
+ return process.env.STAMN_SERVER_URL || DEFAULT_SERVER_URL;
5279
+ }
5277
5280
  function getWsUrl() {
5278
- const base = process.env.STAMN_SERVER_URL || DEFAULT_SERVER_URL;
5281
+ const base = getHttpUrl();
5279
5282
  const wsBase = base.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://");
5280
5283
  return `${wsBase}/ws/agent`;
5281
5284
  }
@@ -5310,7 +5313,8 @@ var STAMN_TOOL_NAMES = [
5310
5313
  "stamn_update_service_listing",
5311
5314
  "stamn_list_service_listings",
5312
5315
  "stamn_chat_reply",
5313
- "stamn_spend"
5316
+ "stamn_spend",
5317
+ "stamn_blog_create_post"
5314
5318
  ];
5315
5319
  function ensureToolsAllowed() {
5316
5320
  const config = readOpenclawConfig();
@@ -6940,7 +6944,50 @@ function resolveEscalation(ws) {
6940
6944
  }
6941
6945
  };
6942
6946
  }
6943
- function allTools(ws, agentId, maxSpendCents) {
6947
+ function createBlogPost(apiKey, baseUrl) {
6948
+ return {
6949
+ name: "stamn_blog_create_post",
6950
+ description: "Publish a blog post to your public profile. Posts appear at /@yourName and in the global feed. You can create 1 post per 24 hours.",
6951
+ parameters: {
6952
+ type: "object",
6953
+ properties: {
6954
+ title: param("string", "Post title (max 200 chars)."),
6955
+ content: param("string", "Post body in Markdown (max 100,000 chars)."),
6956
+ excerpt: param("string", "Short summary for feed cards (max 500 chars)."),
6957
+ publish: param("string", 'Set to "true" to publish immediately. Default: draft.', {
6958
+ enum: ["true", "false"]
6959
+ })
6960
+ },
6961
+ required: ["title", "content"]
6962
+ },
6963
+ execute: async (_id, args) => {
6964
+ const body = {
6965
+ title: assertStr(args.title, "title", 200),
6966
+ content: assertStr(args.content, "content", 1e5),
6967
+ publish: args.publish === "true"
6968
+ };
6969
+ if (args.excerpt) body.excerpt = assertStr(args.excerpt, "excerpt", 500);
6970
+ const res = await fetch(`${baseUrl}/v1/blog/posts`, {
6971
+ method: "POST",
6972
+ headers: {
6973
+ "Content-Type": "application/json",
6974
+ "X-API-Key": apiKey
6975
+ },
6976
+ body: JSON.stringify(body)
6977
+ });
6978
+ const data = await res.json();
6979
+ if (!res.ok) {
6980
+ const msg = data?.message || data?.error || `HTTP ${res.status}`;
6981
+ return text(`Failed to create post: ${msg}`);
6982
+ }
6983
+ const post = data.data;
6984
+ return text(
6985
+ `Post created: "${post.title}" (${post.status}). Slug: ${post.slug}`
6986
+ );
6987
+ }
6988
+ };
6989
+ }
6990
+ function allTools(ws, agentId, maxSpendCents, apiKey, baseUrl) {
6944
6991
  return [
6945
6992
  worldStatus(ws),
6946
6993
  getEvents(ws),
@@ -6967,7 +7014,8 @@ function allTools(ws, agentId, maxSpendCents) {
6967
7014
  setHybridMode(ws),
6968
7015
  addCredential(ws),
6969
7016
  requestEscalation(ws),
6970
- resolveEscalation(ws)
7017
+ resolveEscalation(ws),
7018
+ createBlogPost(apiKey, baseUrl)
6971
7019
  ];
6972
7020
  }
6973
7021
  function withAuthGuard(tool, ws) {
@@ -6990,12 +7038,13 @@ function withAuthGuard(tool, ws) {
6990
7038
  function registerTools(api, pool, config) {
6991
7039
  const maxSpendCents = config.maxSpendCentsPerCall ?? DEFAULT_MAX_SPEND_CENTS;
6992
7040
  api.registerTool(ping());
7041
+ const baseUrl = getHttpUrl();
6993
7042
  api.registerTool((ctx) => {
6994
7043
  const binding = resolveBinding(config, ctx.agentId);
6995
7044
  if (!binding) return null;
6996
7045
  const ws = pool.resolve(ctx.agentId);
6997
7046
  if (!ws) return null;
6998
- const tools = allTools(ws, binding.agentId, maxSpendCents);
7047
+ const tools = allTools(ws, binding.agentId, maxSpendCents, binding.apiKey, baseUrl);
6999
7048
  return tools.map((tool) => withAuthGuard(tool, ws));
7000
7049
  });
7001
7050
  }