@gholl-studio/pier-connector 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +48 -14
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gholl-studio/pier-connector",
3
3
  "author": "gholl",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "OpenClaw plugin that connects to the Pier job marketplace. Automatically fetches, executes, and reports distributed tasks for rewards.",
6
6
  "type": "module",
7
7
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -43,18 +43,27 @@ export default function register(api) {
43
43
  // ── resolve plugin config ──────────────────────────────────────────
44
44
 
45
45
  function resolveConfig() {
46
- const cfg = api.config?.plugins?.entries?.['pier-connector']?.config ?? {};
46
+ const rawAccounts = api.config?.channels?.['pier']?.accounts || {};
47
+ const firstAccount = Object.values(rawAccounts)[0] || {};
48
+
49
+ const legacyCfg = api.config?.plugins?.entries?.['pier-connector']?.config || {};
50
+
51
+ const mergedCfg = {
52
+ ...legacyCfg,
53
+ ...firstAccount
54
+ };
55
+
47
56
  return {
48
- pierApiUrl: cfg.pierApiUrl || DEFAULTS.PIER_API_URL,
49
- nodeId: cfg.nodeId || DEFAULTS.NODE_ID,
50
- secretKey: cfg.secretKey || DEFAULTS.SECRET_KEY,
51
- privateKey: cfg.privateKey || process.env.PIER_PRIVATE_KEY || DEFAULTS.PRIVATE_KEY,
52
- natsUrl: cfg.natsUrl || DEFAULTS.NATS_URL,
53
- subject: cfg.subject || DEFAULTS.PIER_SUBJECT,
54
- publishSubject: cfg.publishSubject || DEFAULTS.PUBLISH_SUBJECT,
55
- queueGroup: cfg.queueGroup || DEFAULTS.QUEUE_GROUP,
56
- agentId: cfg.agentId || DEFAULTS.AGENT_ID,
57
- walletAddress: cfg.walletAddress || DEFAULTS.WALLET_ADDRESS,
57
+ pierApiUrl: mergedCfg.pierApiUrl || DEFAULTS.PIER_API_URL,
58
+ nodeId: mergedCfg.nodeId || DEFAULTS.NODE_ID,
59
+ secretKey: mergedCfg.secretKey || DEFAULTS.SECRET_KEY,
60
+ privateKey: mergedCfg.privateKey || process.env.PIER_PRIVATE_KEY || DEFAULTS.PRIVATE_KEY,
61
+ natsUrl: mergedCfg.natsUrl || DEFAULTS.NATS_URL,
62
+ subject: mergedCfg.subject || DEFAULTS.PIER_SUBJECT,
63
+ publishSubject: mergedCfg.publishSubject || DEFAULTS.PUBLISH_SUBJECT,
64
+ queueGroup: mergedCfg.queueGroup || DEFAULTS.QUEUE_GROUP,
65
+ agentId: mergedCfg.agentId || DEFAULTS.AGENT_ID,
66
+ walletAddress: mergedCfg.walletAddress || DEFAULTS.WALLET_ADDRESS,
58
67
  };
59
68
  }
60
69
 
@@ -121,11 +130,36 @@ export default function register(api) {
121
130
  },
122
131
 
123
132
  config: {
124
- listAccountIds: () => ['default'],
125
- resolveAccount: (_cfg, accountId) => ({
133
+ listAccountIds: (cfg) => Object.keys(cfg.channels?.pier?.accounts ?? {}),
134
+ resolveAccount: (cfg, accountId) => cfg.channels?.pier?.accounts?.[accountId ?? 'default'] ?? {
126
135
  accountId: accountId ?? 'default',
127
136
  enabled: true,
128
- }),
137
+ },
138
+ },
139
+
140
+ setup: {
141
+ applyAccountConfig: ({ cfg, accountId, input }) => {
142
+ const draft = structuredClone(cfg);
143
+ draft.channels = draft.channels || {};
144
+ draft.channels.pier = draft.channels.pier || {};
145
+ draft.channels.pier.accounts = draft.channels.pier.accounts || {};
146
+
147
+ const acct = draft.channels.pier.accounts[accountId] || { enabled: true };
148
+
149
+ if (input.token) {
150
+ const parts = input.token.split(':');
151
+ if (parts.length >= 2) {
152
+ acct.nodeId = parts[0];
153
+ acct.secretKey = parts.slice(1).join(':');
154
+ } else {
155
+ // fallback if user just pasted one string
156
+ acct.nodeId = parts[0];
157
+ }
158
+ }
159
+
160
+ draft.channels.pier.accounts[accountId] = acct;
161
+ return draft;
162
+ }
129
163
  },
130
164
 
131
165
  outbound: {