@stamn/stamn-plugin 0.1.0-alpha.42 → 0.1.0-alpha.44
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 +25 -30
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -4600,7 +4600,7 @@ ${l}
|
|
|
4600
4600
|
}
|
|
4601
4601
|
} }).prompt();
|
|
4602
4602
|
|
|
4603
|
-
// node_modules/.pnpm/@stamn+sdk@0.1.0-alpha.
|
|
4603
|
+
// node_modules/.pnpm/@stamn+sdk@0.1.0-alpha.6/node_modules/@stamn/sdk/dist/index.js
|
|
4604
4604
|
var Resource = class {
|
|
4605
4605
|
constructor(client) {
|
|
4606
4606
|
this.client = client;
|
|
@@ -4977,15 +4977,19 @@ var StamnClient = class {
|
|
|
4977
4977
|
const body = await res.text();
|
|
4978
4978
|
try {
|
|
4979
4979
|
const parsed = JSON.parse(body);
|
|
4980
|
-
const
|
|
4981
|
-
if (
|
|
4980
|
+
const raw = parsed.error?.message ?? parsed.message;
|
|
4981
|
+
if (raw) {
|
|
4982
|
+
if (typeof raw === "string") return raw;
|
|
4983
|
+
if (Array.isArray(raw)) return raw.join(". ");
|
|
4984
|
+
return JSON.stringify(raw);
|
|
4985
|
+
}
|
|
4982
4986
|
} catch {
|
|
4983
4987
|
}
|
|
4984
4988
|
return body || `HTTP ${res.status}`;
|
|
4985
4989
|
}
|
|
4986
4990
|
};
|
|
4987
4991
|
|
|
4988
|
-
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.
|
|
4992
|
+
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.17/node_modules/@stamn/cli/dist/chunk-PLTDB3B6.js
|
|
4989
4993
|
import { execSync } from "child_process";
|
|
4990
4994
|
import { mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
4991
4995
|
import { join } from "path";
|
|
@@ -7006,7 +7010,7 @@ function resolveEscalation(ws) {
|
|
|
7006
7010
|
}
|
|
7007
7011
|
};
|
|
7008
7012
|
}
|
|
7009
|
-
function createBlogPost(
|
|
7013
|
+
function createBlogPost(client) {
|
|
7010
7014
|
return {
|
|
7011
7015
|
name: "stamn_blog_create_post",
|
|
7012
7016
|
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.",
|
|
@@ -7023,33 +7027,24 @@ function createBlogPost(apiKey, baseUrl) {
|
|
|
7023
7027
|
required: ["title", "content"]
|
|
7024
7028
|
},
|
|
7025
7029
|
execute: async (_id, args) => {
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
body: JSON.stringify(body)
|
|
7039
|
-
});
|
|
7040
|
-
const data = await res.json();
|
|
7041
|
-
if (!res.ok) {
|
|
7042
|
-
const msg = data?.message || data?.error || `HTTP ${res.status}`;
|
|
7030
|
+
try {
|
|
7031
|
+
const post = await client.blog.create({
|
|
7032
|
+
title: assertStr(args.title, "title", 200),
|
|
7033
|
+
content: assertStr(args.content, "content", 1e5),
|
|
7034
|
+
excerpt: args.excerpt ? assertStr(args.excerpt, "excerpt", 500) : void 0,
|
|
7035
|
+
publish: args.publish === "true"
|
|
7036
|
+
});
|
|
7037
|
+
return text(
|
|
7038
|
+
`Post created: "${post.title}" (${post.status}). Slug: ${post.slug}`
|
|
7039
|
+
);
|
|
7040
|
+
} catch (err) {
|
|
7041
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7043
7042
|
return text(`Failed to create post: ${msg}`);
|
|
7044
7043
|
}
|
|
7045
|
-
const post = data.data;
|
|
7046
|
-
return text(
|
|
7047
|
-
`Post created: "${post.title}" (${post.status}). Slug: ${post.slug}`
|
|
7048
|
-
);
|
|
7049
7044
|
}
|
|
7050
7045
|
};
|
|
7051
7046
|
}
|
|
7052
|
-
function allTools(ws, agentId, maxSpendCents,
|
|
7047
|
+
function allTools(ws, agentId, maxSpendCents, client) {
|
|
7053
7048
|
return [
|
|
7054
7049
|
worldStatus(ws),
|
|
7055
7050
|
getEvents(ws),
|
|
@@ -7077,7 +7072,7 @@ function allTools(ws, agentId, maxSpendCents, apiKey, baseUrl) {
|
|
|
7077
7072
|
addCredential(ws),
|
|
7078
7073
|
requestEscalation(ws),
|
|
7079
7074
|
resolveEscalation(ws),
|
|
7080
|
-
createBlogPost(
|
|
7075
|
+
createBlogPost(client)
|
|
7081
7076
|
];
|
|
7082
7077
|
}
|
|
7083
7078
|
function withAuthGuard(tool, ws) {
|
|
@@ -7100,13 +7095,13 @@ function withAuthGuard(tool, ws) {
|
|
|
7100
7095
|
function registerTools(api, pool, config) {
|
|
7101
7096
|
const maxSpendCents = config.maxSpendCentsPerCall ?? DEFAULT_MAX_SPEND_CENTS;
|
|
7102
7097
|
api.registerTool(ping());
|
|
7103
|
-
const baseUrl = getHttpUrl();
|
|
7104
7098
|
api.registerTool((ctx) => {
|
|
7105
7099
|
const binding = resolveBinding(config, ctx.agentId);
|
|
7106
7100
|
if (!binding) return null;
|
|
7107
7101
|
const ws = pool.resolve(ctx.agentId);
|
|
7108
7102
|
if (!ws) return null;
|
|
7109
|
-
const
|
|
7103
|
+
const client = new StamnClient({ apiKey: binding.apiKey });
|
|
7104
|
+
const tools = allTools(ws, binding.agentId, maxSpendCents, client);
|
|
7110
7105
|
return tools.map((tool) => withAuthGuard(tool, ws));
|
|
7111
7106
|
});
|
|
7112
7107
|
}
|