@stamn/stamn-plugin 0.1.0-alpha.39 → 0.1.0-alpha.40
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 +102 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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.4/node_modules/@stamn/sdk/dist/index.js
|
|
4604
4604
|
var Resource = class {
|
|
4605
4605
|
constructor(client) {
|
|
4606
4606
|
this.client = client;
|
|
@@ -4840,6 +4840,38 @@ var RuntimeResource = class extends Resource {
|
|
|
4840
4840
|
return res.data;
|
|
4841
4841
|
}
|
|
4842
4842
|
};
|
|
4843
|
+
var BlogResource = class extends Resource {
|
|
4844
|
+
async create(options) {
|
|
4845
|
+
const res = await this.client.request(
|
|
4846
|
+
"POST",
|
|
4847
|
+
"/v1/blog/posts",
|
|
4848
|
+
options
|
|
4849
|
+
);
|
|
4850
|
+
return res.data;
|
|
4851
|
+
}
|
|
4852
|
+
async get(postId) {
|
|
4853
|
+
const res = await this.client.request(
|
|
4854
|
+
"GET",
|
|
4855
|
+
`/v1/blog/posts/${postId}`
|
|
4856
|
+
);
|
|
4857
|
+
return res.data;
|
|
4858
|
+
}
|
|
4859
|
+
async list(participantId) {
|
|
4860
|
+
const res = await this.client.request(
|
|
4861
|
+
"GET",
|
|
4862
|
+
`/v1/blog/manage/${participantId}`
|
|
4863
|
+
);
|
|
4864
|
+
return res.data;
|
|
4865
|
+
}
|
|
4866
|
+
async update(postId, options) {
|
|
4867
|
+
const res = await this.client.request(
|
|
4868
|
+
"PATCH",
|
|
4869
|
+
`/v1/blog/posts/${postId}`,
|
|
4870
|
+
options
|
|
4871
|
+
);
|
|
4872
|
+
return res.data;
|
|
4873
|
+
}
|
|
4874
|
+
};
|
|
4843
4875
|
var StamnApiError = class extends Error {
|
|
4844
4876
|
constructor(message, status) {
|
|
4845
4877
|
super(message);
|
|
@@ -4867,6 +4899,7 @@ var StamnClient = class {
|
|
|
4867
4899
|
health;
|
|
4868
4900
|
services;
|
|
4869
4901
|
runtime;
|
|
4902
|
+
blog;
|
|
4870
4903
|
constructor(options = {}) {
|
|
4871
4904
|
this.apiKey = options.apiKey;
|
|
4872
4905
|
this.retryOptions = { ...DEFAULT_RETRY, ...options.retry };
|
|
@@ -4879,6 +4912,7 @@ var StamnClient = class {
|
|
|
4879
4912
|
this.health = new HealthResource(this);
|
|
4880
4913
|
this.services = new ServicesResource(this);
|
|
4881
4914
|
this.runtime = new RuntimeResource(this);
|
|
4915
|
+
this.blog = new BlogResource(this);
|
|
4882
4916
|
}
|
|
4883
4917
|
setApiKey(apiKey) {
|
|
4884
4918
|
this.apiKey = apiKey;
|
|
@@ -4906,7 +4940,11 @@ var StamnClient = class {
|
|
|
4906
4940
|
headers["Content-Type"] = "application/json";
|
|
4907
4941
|
}
|
|
4908
4942
|
if (this.apiKey) {
|
|
4909
|
-
|
|
4943
|
+
if (this.apiKey.startsWith("sk_")) {
|
|
4944
|
+
headers["X-API-Key"] = this.apiKey;
|
|
4945
|
+
} else {
|
|
4946
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
4947
|
+
}
|
|
4910
4948
|
}
|
|
4911
4949
|
const res = await fetch(`${this.serverUrl}${path}`, {
|
|
4912
4950
|
method,
|
|
@@ -4947,13 +4985,16 @@ var StamnClient = class {
|
|
|
4947
4985
|
}
|
|
4948
4986
|
};
|
|
4949
4987
|
|
|
4950
|
-
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.
|
|
4988
|
+
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.15/node_modules/@stamn/cli/dist/chunk-PLTDB3B6.js
|
|
4951
4989
|
import { execSync } from "child_process";
|
|
4952
4990
|
import { mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
4953
4991
|
import { join } from "path";
|
|
4954
4992
|
import { tmpdir } from "os";
|
|
4955
4993
|
import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
4956
4994
|
import { dirname, join as join2 } from "path";
|
|
4995
|
+
function cmd(adapter) {
|
|
4996
|
+
return adapter.commandPrefix ?? "stamn";
|
|
4997
|
+
}
|
|
4957
4998
|
async function handleLogin(_opts, adapter) {
|
|
4958
4999
|
Wt2("Stamn Login");
|
|
4959
5000
|
const existing = adapter.readConfig();
|
|
@@ -4965,7 +5006,7 @@ async function handleLogin(_opts, adapter) {
|
|
|
4965
5006
|
await client2.participants.list();
|
|
4966
5007
|
s2.stop("Session valid.");
|
|
4967
5008
|
R2.info("Already logged in.");
|
|
4968
|
-
Gt(
|
|
5009
|
+
Gt(`Run \`${cmd(adapter)} agent register\` to create an agent, or \`${cmd(adapter)} agent list\` to see existing ones.`);
|
|
4969
5010
|
process.exit(0);
|
|
4970
5011
|
} catch {
|
|
4971
5012
|
s2.stop("Session expired.");
|
|
@@ -4990,7 +5031,7 @@ ${label("Code:")} ${flow.userCode}`,
|
|
|
4990
5031
|
adapter.writeConfig({ apiKey });
|
|
4991
5032
|
R2.success("Logged in successfully.");
|
|
4992
5033
|
R2.info(`Config written to ${adapter.getConfigPath()}`);
|
|
4993
|
-
Gt(
|
|
5034
|
+
Gt(`Now run \`${cmd(adapter)} agent register\` to create or reconnect an agent.`);
|
|
4994
5035
|
process.exit(0);
|
|
4995
5036
|
} catch (err) {
|
|
4996
5037
|
s.stop("Failed.");
|
|
@@ -5002,7 +5043,7 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
5002
5043
|
Wt2("Stamn Agent Register");
|
|
5003
5044
|
const config = adapter.readConfig();
|
|
5004
5045
|
if (!config?.apiKey) {
|
|
5005
|
-
Nt(
|
|
5046
|
+
Nt(`Not logged in. Run \`${cmd(adapter)} login\` first.`);
|
|
5006
5047
|
process.exit(1);
|
|
5007
5048
|
}
|
|
5008
5049
|
let name = opts.name;
|
|
@@ -5014,7 +5055,7 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
5014
5055
|
message: `Found ${hostAgents.length} agent(s) in your OpenClaw config. Which one should this Stamn agent be bound to?`,
|
|
5015
5056
|
options: [
|
|
5016
5057
|
...hostAgents.map((a) => ({ value: a.id, label: a.id })),
|
|
5017
|
-
{ value: "__none__", label: "None
|
|
5058
|
+
{ value: "__none__", label: "None - use as default (single-agent)" }
|
|
5018
5059
|
]
|
|
5019
5060
|
});
|
|
5020
5061
|
if (typeof chosen === "symbol") {
|
|
@@ -5023,25 +5064,56 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
5023
5064
|
}
|
|
5024
5065
|
if (chosen !== "__none__") {
|
|
5025
5066
|
bindTo = chosen;
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5069
|
+
const client2 = new StamnClient({ apiKey: config.apiKey });
|
|
5070
|
+
const s = be();
|
|
5071
|
+
s.start("Checking existing agents...");
|
|
5072
|
+
let existingAgents = [];
|
|
5073
|
+
try {
|
|
5074
|
+
existingAgents = await client2.participants.list();
|
|
5075
|
+
s.stop(existingAgents.length > 0 ? `${existingAgents.length} existing agent(s) found.` : "No existing agents.");
|
|
5076
|
+
} catch {
|
|
5077
|
+
s.stop("Could not fetch agents.");
|
|
5078
|
+
}
|
|
5079
|
+
if (existingAgents.length > 0) {
|
|
5080
|
+
const action = await Jt({
|
|
5081
|
+
message: "Would you like to create a new agent or use an existing one?",
|
|
5082
|
+
options: [
|
|
5083
|
+
{ value: "new", label: "Create a new agent" },
|
|
5084
|
+
{ value: "existing", label: "Use an existing agent" }
|
|
5085
|
+
]
|
|
5086
|
+
});
|
|
5087
|
+
if (typeof action === "symbol") {
|
|
5088
|
+
Nt("Cancelled.");
|
|
5089
|
+
return;
|
|
5090
|
+
}
|
|
5091
|
+
if (action === "existing") {
|
|
5092
|
+
const chosen = await Jt({
|
|
5093
|
+
message: "Select an agent:",
|
|
5094
|
+
options: existingAgents.map((a) => ({
|
|
5095
|
+
value: a.id,
|
|
5096
|
+
label: `${a.name} (${a.id})`
|
|
5097
|
+
}))
|
|
5033
5098
|
});
|
|
5034
|
-
if (typeof
|
|
5099
|
+
if (typeof chosen === "symbol") {
|
|
5035
5100
|
Nt("Cancelled.");
|
|
5036
5101
|
return;
|
|
5037
5102
|
}
|
|
5038
|
-
|
|
5103
|
+
const selected = existingAgents.find((a) => a.id === chosen);
|
|
5104
|
+
writeResult(adapter, selected.name, selected.id, selected.name, config.apiKey, bindTo);
|
|
5105
|
+
R2.success(`Agent "${selected.name}" (${selected.id}) selected.`);
|
|
5106
|
+
if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
|
|
5107
|
+
Gt("Done!");
|
|
5108
|
+
process.exit(0);
|
|
5039
5109
|
}
|
|
5040
5110
|
}
|
|
5041
5111
|
if (!name) {
|
|
5112
|
+
const defaultName = bindTo && bindTo !== "__none__" ? bindTo : void 0;
|
|
5042
5113
|
const input = await Zt({
|
|
5043
5114
|
message: "What should we call this agent?",
|
|
5044
|
-
placeholder: "my-agent",
|
|
5115
|
+
placeholder: defaultName ?? "my-agent",
|
|
5116
|
+
...defaultName ? { initialValue: defaultName } : {},
|
|
5045
5117
|
validate: (value) => {
|
|
5046
5118
|
if (!value?.trim()) return "Name is required.";
|
|
5047
5119
|
}
|
|
@@ -5054,29 +5126,18 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
5054
5126
|
}
|
|
5055
5127
|
}
|
|
5056
5128
|
const client = new StamnClient({ apiKey: config.apiKey });
|
|
5057
|
-
const
|
|
5129
|
+
const s2 = be();
|
|
5058
5130
|
try {
|
|
5059
|
-
|
|
5060
|
-
const agents = await client.participants.list();
|
|
5061
|
-
const match = agents.find((a) => a.name === name);
|
|
5062
|
-
if (match) {
|
|
5063
|
-
s.stop("Agent found.");
|
|
5064
|
-
writeResult(adapter, name, match.id, match.name, config.apiKey, bindTo);
|
|
5065
|
-
R2.success(`Agent "${match.name}" (${match.id}) already exists. Selected as active.`);
|
|
5066
|
-
if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
|
|
5067
|
-
Gt("Done!");
|
|
5068
|
-
process.exit(0);
|
|
5069
|
-
}
|
|
5070
|
-
s.start("Registering agent...");
|
|
5131
|
+
s2.start("Registering agent...");
|
|
5071
5132
|
const participant = await client.participants.create({ name });
|
|
5072
|
-
|
|
5133
|
+
s2.stop("Agent registered.");
|
|
5073
5134
|
writeResult(adapter, name, participant.id, participant.name, config.apiKey, bindTo);
|
|
5074
5135
|
R2.success(`Agent "${participant.name}" (${participant.id})`);
|
|
5075
5136
|
if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
|
|
5076
5137
|
Gt("Done!");
|
|
5077
5138
|
process.exit(0);
|
|
5078
5139
|
} catch (err) {
|
|
5079
|
-
|
|
5140
|
+
s2.stop("Failed.");
|
|
5080
5141
|
Nt(`Registration failed: ${err.message}`);
|
|
5081
5142
|
process.exit(1);
|
|
5082
5143
|
}
|
|
@@ -5091,7 +5152,7 @@ async function handleAgentList(_opts, adapter) {
|
|
|
5091
5152
|
Wt2("Stamn Agents");
|
|
5092
5153
|
const config = adapter.readConfig();
|
|
5093
5154
|
if (!config?.apiKey) {
|
|
5094
|
-
Nt(
|
|
5155
|
+
Nt(`Not logged in. Run \`${cmd(adapter)} login\` first.`);
|
|
5095
5156
|
process.exit(1);
|
|
5096
5157
|
}
|
|
5097
5158
|
const client = new StamnClient({ apiKey: config.apiKey });
|
|
@@ -5101,12 +5162,12 @@ async function handleAgentList(_opts, adapter) {
|
|
|
5101
5162
|
const agents = await client.participants.list();
|
|
5102
5163
|
s.stop(`${agents.length} agent${agents.length === 1 ? "" : "s"} found.`);
|
|
5103
5164
|
if (agents.length === 0) {
|
|
5104
|
-
R2.info(
|
|
5165
|
+
R2.info(`No agents found. Run \`${cmd(adapter)} agent register\` to create one.`);
|
|
5105
5166
|
process.exit(0);
|
|
5106
5167
|
}
|
|
5107
5168
|
for (const agent of agents) {
|
|
5108
5169
|
const active = agent.id === config.agentId ? " (active)" : "";
|
|
5109
|
-
R2.info(` ${agent.name}
|
|
5170
|
+
R2.info(` ${agent.name} - ${agent.id}${active}`);
|
|
5110
5171
|
}
|
|
5111
5172
|
process.exit(0);
|
|
5112
5173
|
} catch (err) {
|
|
@@ -5119,7 +5180,7 @@ async function handleAgentSelect(opts, adapter) {
|
|
|
5119
5180
|
Wt2("Stamn Agent Select");
|
|
5120
5181
|
const config = adapter.readConfig();
|
|
5121
5182
|
if (!config?.apiKey) {
|
|
5122
|
-
Nt(
|
|
5183
|
+
Nt(`Not logged in. Run \`${cmd(adapter)} login\` first.`);
|
|
5123
5184
|
process.exit(1);
|
|
5124
5185
|
}
|
|
5125
5186
|
const client = new StamnClient({ apiKey: config.apiKey });
|
|
@@ -5130,7 +5191,7 @@ async function handleAgentSelect(opts, adapter) {
|
|
|
5130
5191
|
s.stop(`${agents.length} agent${agents.length === 1 ? "" : "s"} found.`);
|
|
5131
5192
|
const match = agents.find((a) => a.id === opts.nameOrId || a.name === opts.nameOrId);
|
|
5132
5193
|
if (!match) {
|
|
5133
|
-
Nt(`Agent "${opts.nameOrId}" not found. Run
|
|
5194
|
+
Nt(`Agent "${opts.nameOrId}" not found. Run \`${cmd(adapter)} agent list\` to see available agents.`);
|
|
5134
5195
|
process.exit(1);
|
|
5135
5196
|
return;
|
|
5136
5197
|
}
|
|
@@ -5166,7 +5227,7 @@ async function handleLogout(_opts, adapter) {
|
|
|
5166
5227
|
}
|
|
5167
5228
|
adapter.writeConfig({ apiKey: "", agentId: "", agentName: "" });
|
|
5168
5229
|
R2.success("Logged out.");
|
|
5169
|
-
Gt(
|
|
5230
|
+
Gt(`Run \`${cmd(adapter)} login\` to authenticate again.`);
|
|
5170
5231
|
process.exit(0);
|
|
5171
5232
|
}
|
|
5172
5233
|
function openEditor(initial) {
|
|
@@ -5191,7 +5252,7 @@ function handleConfig(opts, adapter) {
|
|
|
5191
5252
|
if (!opts.name && !opts.personality) {
|
|
5192
5253
|
const config = adapter.readConfig();
|
|
5193
5254
|
if (!config) {
|
|
5194
|
-
R2.warn(
|
|
5255
|
+
R2.warn(`No config found. Run \`${cmd(adapter)} login\` first.`);
|
|
5195
5256
|
return;
|
|
5196
5257
|
}
|
|
5197
5258
|
R2.info(`Name: ${config.agentName ?? "(not set)"}`);
|
|
@@ -5337,6 +5398,7 @@ function ensureToolsAllowed() {
|
|
|
5337
5398
|
}
|
|
5338
5399
|
function createOpenclawAdapter() {
|
|
5339
5400
|
return {
|
|
5401
|
+
commandPrefix: "openclaw stamn",
|
|
5340
5402
|
getConfigPath,
|
|
5341
5403
|
readConfig() {
|
|
5342
5404
|
const raw = readOpenclawConfig();
|
|
@@ -7138,7 +7200,7 @@ var index_default = {
|
|
|
7138
7200
|
registerCli(api);
|
|
7139
7201
|
ensureToolsAllowed();
|
|
7140
7202
|
if (!config?.apiKey || !config?.agentId) {
|
|
7141
|
-
api.logger.warn('Stamn not configured. Run "stamn login" then "stamn agent register" first.');
|
|
7203
|
+
api.logger.warn('Stamn not configured. Run "openclaw stamn login" then "openclaw stamn agent register" first.');
|
|
7142
7204
|
return;
|
|
7143
7205
|
}
|
|
7144
7206
|
const pool = new StamnWsPool({
|