@stamn/stamn-plugin 0.1.0-alpha.2 → 0.1.0-alpha.4

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
@@ -975,14 +975,87 @@ var AgentsResource = class extends Resource {
975
975
  return res.data;
976
976
  }
977
977
  };
978
- var HealthResource = class extends Resource {
979
- async check() {
980
- try {
981
- await this.client.request("GET", "/v1/health");
982
- return { ok: true };
983
- } catch {
984
- return { ok: false };
985
- }
978
+ var ParticipantsResource = class extends Resource {
979
+ async create(options) {
980
+ const res = await this.client.request(
981
+ "POST",
982
+ "/v1/participants",
983
+ {
984
+ name: options?.name || void 0,
985
+ description: options?.description || void 0
986
+ }
987
+ );
988
+ return res.data;
989
+ }
990
+ async list() {
991
+ const res = await this.client.request(
992
+ "GET",
993
+ "/v1/participants"
994
+ );
995
+ return res.data;
996
+ }
997
+ async get(participantId) {
998
+ const res = await this.client.request(
999
+ "GET",
1000
+ `/v1/participants/${participantId}`
1001
+ );
1002
+ return res.data;
1003
+ }
1004
+ async update(participantId, data) {
1005
+ const res = await this.client.request(
1006
+ "PATCH",
1007
+ `/v1/participants/${participantId}`,
1008
+ data
1009
+ );
1010
+ return res.data;
1011
+ }
1012
+ async getBalance(participantId) {
1013
+ const res = await this.client.request(
1014
+ "GET",
1015
+ `/v1/participants/${participantId}/balance`
1016
+ );
1017
+ return res.data;
1018
+ }
1019
+ async getOnchainBalance(participantId) {
1020
+ const res = await this.client.request(
1021
+ "GET",
1022
+ `/v1/participants/${participantId}/onchain-balance`
1023
+ );
1024
+ return res.data;
1025
+ }
1026
+ async getLedgerEntries(participantId) {
1027
+ const res = await this.client.request(
1028
+ "GET",
1029
+ `/v1/participants/${participantId}/ledger-entries`
1030
+ );
1031
+ return res.data;
1032
+ }
1033
+ async deposit(participantId, data) {
1034
+ const res = await this.client.request(
1035
+ "POST",
1036
+ `/v1/participants/${participantId}/deposits`,
1037
+ data
1038
+ );
1039
+ return res.data;
1040
+ }
1041
+ };
1042
+ var ApiKeysResource = class extends Resource {
1043
+ async create() {
1044
+ const res = await this.client.request(
1045
+ "POST",
1046
+ "/v1/api-keys"
1047
+ );
1048
+ return res.data;
1049
+ }
1050
+ async list() {
1051
+ const res = await this.client.request(
1052
+ "GET",
1053
+ "/v1/api-keys"
1054
+ );
1055
+ return res.data;
1056
+ }
1057
+ async revoke(id) {
1058
+ await this.client.request("DELETE", `/v1/api-keys/${id}`);
986
1059
  }
987
1060
  };
988
1061
  var DirectoryResource = class extends Resource {
@@ -991,7 +1064,7 @@ var DirectoryResource = class extends Resource {
991
1064
  if (options?.serviceTag) params.set("serviceTag", options.serviceTag);
992
1065
  if (options?.name) params.set("name", options.name);
993
1066
  const query = params.toString();
994
- const path = `/v1/directory${query ? `?${query}` : ""}`;
1067
+ const path = query ? `/v1/directory?${query}` : "/v1/directory";
995
1068
  const res = await this.client.request(
996
1069
  "GET",
997
1070
  path
@@ -999,6 +1072,25 @@ var DirectoryResource = class extends Resource {
999
1072
  return res.data;
1000
1073
  }
1001
1074
  };
1075
+ var LeaderboardResource = class extends Resource {
1076
+ async get() {
1077
+ const res = await this.client.request(
1078
+ "GET",
1079
+ "/v1/leaderboard"
1080
+ );
1081
+ return res.data;
1082
+ }
1083
+ };
1084
+ var HealthResource = class extends Resource {
1085
+ async check() {
1086
+ try {
1087
+ await this.client.request("GET", "/v1/health");
1088
+ return { ok: true };
1089
+ } catch {
1090
+ return { ok: false };
1091
+ }
1092
+ }
1093
+ };
1002
1094
  var StamnApiError = class extends Error {
1003
1095
  constructor(message, status) {
1004
1096
  super(message);
@@ -1019,15 +1111,21 @@ var StamnClient = class {
1019
1111
  retryOptions;
1020
1112
  auth;
1021
1113
  agents;
1022
- health;
1114
+ participants;
1115
+ apiKeys;
1023
1116
  directory;
1117
+ leaderboard;
1118
+ health;
1024
1119
  constructor(options = {}) {
1025
1120
  this.apiKey = options.apiKey;
1026
1121
  this.retryOptions = { ...DEFAULT_RETRY, ...options.retry };
1027
1122
  this.auth = new AuthResource(this);
1028
1123
  this.agents = new AgentsResource(this);
1029
- this.health = new HealthResource(this);
1124
+ this.participants = new ParticipantsResource(this);
1125
+ this.apiKeys = new ApiKeysResource(this);
1030
1126
  this.directory = new DirectoryResource(this);
1127
+ this.leaderboard = new LeaderboardResource(this);
1128
+ this.health = new HealthResource(this);
1031
1129
  }
1032
1130
  setApiKey(apiKey) {
1033
1131
  this.apiKey = apiKey;
@@ -1096,18 +1194,16 @@ var StamnClient = class {
1096
1194
  }
1097
1195
  };
1098
1196
 
1099
- // ../stamn-cli/dist/chunk-CAVP3V47.js
1197
+ // ../stamn-cli/dist/chunk-C2EJQ4DZ.js
1100
1198
  import { execSync } from "child_process";
1101
1199
  import { mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
1102
1200
  import { join } from "path";
1103
1201
  import { tmpdir } from "os";
1104
- import { rmSync } from "fs";
1105
- import { dirname } from "path";
1106
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
1107
- import { dirname as dirname2, join as join2 } from "path";
1202
+ import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
1203
+ import { dirname, join as join2 } from "path";
1108
1204
  async function handleLogin(opts, adapter) {
1109
1205
  const client = new StamnClient();
1110
- We("Stamn Agent Login");
1206
+ We("Stamn Device Login");
1111
1207
  let name = opts.name;
1112
1208
  if (!name) {
1113
1209
  const input = await Ze({
@@ -1139,14 +1235,14 @@ ${label("Code:")} ${flow.userCode}`,
1139
1235
  s.stop("Approved!");
1140
1236
  client.setApiKey(apiKey);
1141
1237
  s.start("Registering agent...");
1142
- const agent = await client.agents.create({ name });
1238
+ const participant = await client.participants.create({ name });
1143
1239
  s.stop("Agent registered.");
1144
1240
  adapter.writeConfig({
1145
1241
  apiKey,
1146
- agentId: agent.id,
1147
- agentName: agent.name
1242
+ agentId: participant.id,
1243
+ agentName: participant.name
1148
1244
  });
1149
- R2.success(`Agent "${agent.name}" (${agent.id})`);
1245
+ R2.success(`Agent "${participant.name}" (${participant.id})`);
1150
1246
  R2.info(`Config written to ${adapter.getConfigPath()}`);
1151
1247
  Le("Done! You can now use stamn commands.");
1152
1248
  } catch (err) {
@@ -1223,17 +1319,16 @@ async function handleStatus(adapter) {
1223
1319
  }
1224
1320
  async function handleUninstall(adapter) {
1225
1321
  We("Stamn Uninstall");
1226
- const configDir = dirname(adapter.getConfigPath());
1227
1322
  const shouldContinue = await Re({
1228
- message: `This will delete all config at ${configDir}. Continue?`
1323
+ message: "This will remove all Stamn config and data. Continue?"
1229
1324
  });
1230
1325
  if (!shouldContinue || typeof shouldContinue === "symbol") {
1231
1326
  Ne("Uninstall cancelled.");
1232
1327
  return;
1233
1328
  }
1234
1329
  try {
1235
- rmSync(configDir, { recursive: true, force: true });
1236
- R2.success(`Removed ${configDir}`);
1330
+ adapter.uninstall();
1331
+ R2.success("Removed Stamn config");
1237
1332
  Le("Stamn config removed.");
1238
1333
  } catch (err) {
1239
1334
  Ne(`Failed to remove config: ${err.message}`);
@@ -1249,12 +1344,12 @@ function readJsonFile(filePath) {
1249
1344
  }
1250
1345
  }
1251
1346
  function writeJsonFile(filePath, data) {
1252
- mkdirSync2(dirname2(filePath), { recursive: true });
1347
+ mkdirSync2(dirname(filePath), { recursive: true });
1253
1348
  writeFileSync2(filePath, JSON.stringify(data, null, 2) + "\n", "utf-8");
1254
1349
  }
1255
1350
 
1256
1351
  // src/config.ts
1257
- import { existsSync, rmSync as rmSync2 } from "fs";
1352
+ import { existsSync as existsSync2, rmSync as rmSync2 } from "fs";
1258
1353
  import { join as join3 } from "path";
1259
1354
  import { homedir } from "os";
1260
1355
  var DEFAULT_SERVER_URL = "https://api.stamn.com";
@@ -1309,7 +1404,7 @@ function createOpenclawAdapter() {
1309
1404
  writeJsonFile(getConfigPath(), config);
1310
1405
  }
1311
1406
  const statusPath = join3(homedir(), ".openclaw", "stamn-status.json");
1312
- if (existsSync(statusPath)) {
1407
+ if (existsSync2(statusPath)) {
1313
1408
  rmSync2(statusPath);
1314
1409
  }
1315
1410
  }