@a2hmarket/a2hmarket 0.10.2 → 1.0.1
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/index.ts +12 -4
- package/openclaw.plugin.json +4 -1
- package/package.json +4 -1
- package/scripts/install.mjs +23 -14
- package/src/agent-service.ts +1 -1
- package/src/credentials.ts +7 -7
- package/src/tempo-key-manager.ts +1 -1
package/index.ts
CHANGED
|
@@ -172,11 +172,19 @@ export default {
|
|
|
172
172
|
api.registerService({
|
|
173
173
|
id: "a2hmarket-agent",
|
|
174
174
|
start: async (ctx) => {
|
|
175
|
-
// Initialize runtime data directory: ~/.
|
|
176
|
-
const
|
|
177
|
-
|
|
175
|
+
// Initialize runtime data directory: ~/.a2h_store/
|
|
176
|
+
const { homedir } = await import("node:os");
|
|
177
|
+
const storeDir = join(homedir(), ".a2h_store");
|
|
178
|
+
const configDir = join(storeDir, "a2h_config");
|
|
179
|
+
const dataDir = join(storeDir, "a2h_data");
|
|
180
|
+
const inboxDir = join(storeDir, "a2h_inbox");
|
|
181
|
+
const negotiationDir = join(storeDir, "a2h_negotiation");
|
|
182
|
+
const logsDir = join(storeDir, "a2h_logs");
|
|
183
|
+
for (const d of [configDir, dataDir, inboxDir, negotiationDir, logsDir]) {
|
|
184
|
+
mkdirSync(d, { recursive: true });
|
|
185
|
+
}
|
|
178
186
|
|
|
179
|
-
// Initialize stores
|
|
187
|
+
// Initialize stores
|
|
180
188
|
initReplyBridge(join(dataDir, "reply-bridge.json"));
|
|
181
189
|
initApprovalStore(join(dataDir, "approvals.json"));
|
|
182
190
|
setLastChannelStore(new LastChannelStore(join(dataDir, "last-channel.json")));
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a2hmarket/a2hmarket",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.ts",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"extensions": [
|
|
28
28
|
"./index.ts"
|
|
29
29
|
],
|
|
30
|
+
"build": {
|
|
31
|
+
"openclawVersion": "2026.3.24"
|
|
32
|
+
},
|
|
30
33
|
"install": {
|
|
31
34
|
"npmSpec": "@a2hmarket/openclaw-plugin",
|
|
32
35
|
"defaultChoice": "npm"
|
package/scripts/install.mjs
CHANGED
|
@@ -21,9 +21,13 @@ import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
|
21
21
|
import { networkInterfaces } from "node:os";
|
|
22
22
|
|
|
23
23
|
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
24
|
-
const
|
|
25
|
-
const CREDS_FILE = join(
|
|
26
|
-
const
|
|
24
|
+
const CREDS_DIR = join(OPENCLAW_DIR, "a2hmarket");
|
|
25
|
+
const CREDS_FILE = join(CREDS_DIR, "credentials.json");
|
|
26
|
+
const A2H_STORE_DIR = join(homedir(), ".a2h_store");
|
|
27
|
+
const A2H_CONFIG_DIR = join(A2H_STORE_DIR, "a2h_config");
|
|
28
|
+
const A2H_DATA_DIR = join(A2H_STORE_DIR, "a2h_data");
|
|
29
|
+
const NPM_SPEC = "@a2hmarket/a2hmarket"; // npm package name (for npx entry point)
|
|
30
|
+
const CLAWHUB_SPEC = "clawhub:a2hmarket"; // clawhub package name (for openclaw install)
|
|
27
31
|
|
|
28
32
|
const AUTH_API_URL = "https://web.a2hmarket.ai";
|
|
29
33
|
const LOGIN_URL = "https://a2hmarket.ai";
|
|
@@ -363,7 +367,7 @@ async function runUpdate() {
|
|
|
363
367
|
execSync(`rm -rf "${extDir}"`, { stdio: "pipe" });
|
|
364
368
|
}
|
|
365
369
|
log(` Installing new version...`);
|
|
366
|
-
execSync(`yes 2>/dev/null | openclaw plugins install ${
|
|
370
|
+
execSync(`yes 2>/dev/null | openclaw plugins install ${CLAWHUB_SPEC} 2>&1`, { encoding: "utf-8", stdio: "pipe" });
|
|
367
371
|
log(` ${CHECK} Update complete`);
|
|
368
372
|
} catch (err) {
|
|
369
373
|
log(` ${CROSS} Update failed: ${err.message}`);
|
|
@@ -372,7 +376,7 @@ async function runUpdate() {
|
|
|
372
376
|
|
|
373
377
|
// Restore credentials file
|
|
374
378
|
if (savedCreds) {
|
|
375
|
-
mkdirSync(
|
|
379
|
+
mkdirSync(CREDS_DIR, { recursive: true });
|
|
376
380
|
const fileData = {
|
|
377
381
|
agent_id: savedCreds.agentId ?? savedCreds.agent_id,
|
|
378
382
|
agent_key: savedCreds.agentKey ?? savedCreds.agent_key,
|
|
@@ -483,12 +487,14 @@ async function runUninstall() {
|
|
|
483
487
|
}
|
|
484
488
|
|
|
485
489
|
// 2. Remove runtime data
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
490
|
+
for (const dir of [CREDS_DIR, A2H_STORE_DIR]) {
|
|
491
|
+
if (existsSync(dir)) {
|
|
492
|
+
try {
|
|
493
|
+
execSync(`rm -rf "${dir}"`, { stdio: "pipe" });
|
|
494
|
+
log(` ${CHECK} Removed: ${dir}`);
|
|
495
|
+
} catch {
|
|
496
|
+
log(` ${WARN} Failed to remove: ${dir}`);
|
|
497
|
+
}
|
|
492
498
|
}
|
|
493
499
|
}
|
|
494
500
|
|
|
@@ -679,7 +685,7 @@ async function main() {
|
|
|
679
685
|
execSync(`rm -rf "${extDir}"`, { stdio: "pipe" });
|
|
680
686
|
}
|
|
681
687
|
log(` Installing...`);
|
|
682
|
-
execSync(`yes 2>/dev/null | openclaw plugins install ${
|
|
688
|
+
execSync(`yes 2>/dev/null | openclaw plugins install ${CLAWHUB_SPEC} 2>&1`, {
|
|
683
689
|
encoding: "utf-8",
|
|
684
690
|
stdio: "pipe",
|
|
685
691
|
});
|
|
@@ -747,7 +753,9 @@ async function main() {
|
|
|
747
753
|
|
|
748
754
|
// ── Step 4: Save credentials & configure openclaw.json ───────
|
|
749
755
|
logStep(4, "Save Configuration");
|
|
750
|
-
mkdirSync(
|
|
756
|
+
mkdirSync(CREDS_DIR, { recursive: true });
|
|
757
|
+
mkdirSync(A2H_CONFIG_DIR, { recursive: true });
|
|
758
|
+
mkdirSync(A2H_DATA_DIR, { recursive: true });
|
|
751
759
|
|
|
752
760
|
const credsData = {
|
|
753
761
|
agent_id: agentId,
|
|
@@ -901,7 +909,8 @@ async function main() {
|
|
|
901
909
|
// ── Done ───────────────────────────────────────────────────────
|
|
902
910
|
log(`\n${GREEN}${BOLD}🎉 Setup complete!${RESET}\n`);
|
|
903
911
|
log(` Agent ID: ${CYAN}${agentId}${RESET}`);
|
|
904
|
-
log(`
|
|
912
|
+
log(` Credentials: ${DIM}${CREDS_DIR}${RESET}`);
|
|
913
|
+
log(` Data dir: ${DIM}${A2H_STORE_DIR}${RESET}`);
|
|
905
914
|
if (credsData.notify) {
|
|
906
915
|
log(` Notify: ${CYAN}${credsData.notify.channel}:${credsData.notify.target}${RESET}`);
|
|
907
916
|
}
|
package/src/agent-service.ts
CHANGED
|
@@ -94,7 +94,7 @@ export async function startAgentService(ctx: AgentServiceContext): Promise<void>
|
|
|
94
94
|
const isSystemMessage = !event.senderId.startsWith("ag_");
|
|
95
95
|
const prefix = isSystemMessage
|
|
96
96
|
? `[收到 A2H Market 的消息]`
|
|
97
|
-
: `[收到对方 Agent (${event.senderId})
|
|
97
|
+
: `[收到对方 Agent (${event.senderId}) 的消息,参考a2hmarket skill进行回复]`;
|
|
98
98
|
const meta: string[] = [];
|
|
99
99
|
if (event.payload.worksId) meta.push(`[worksId: ${event.payload.worksId}] (可用 a2h_works_get 查看帖子详情作为协商上下文)`);
|
|
100
100
|
if (event.payload.orderId) meta.push(`[orderId: ${event.payload.orderId}]`);
|
package/src/credentials.ts
CHANGED
|
@@ -52,8 +52,8 @@ export function loadCredentialsFromConfig(
|
|
|
52
52
|
// ── Load from file — fallback for dev mode ─────────────────────────────
|
|
53
53
|
|
|
54
54
|
const PLUGIN_DIR = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
55
|
-
const
|
|
56
|
-
const
|
|
55
|
+
const OPENCLAW_CREDS_DIR = join(homedir(), ".openclaw", "a2hmarket");
|
|
56
|
+
const A2H_CONFIG_DIR = join(homedir(), ".a2h_store", "a2h_config");
|
|
57
57
|
const CREDENTIALS_FILE = "credentials.json";
|
|
58
58
|
|
|
59
59
|
interface RawCredentials {
|
|
@@ -74,14 +74,14 @@ export function loadCredentialsFromFile(configDir?: string): A2HCredentials {
|
|
|
74
74
|
if (configDir) {
|
|
75
75
|
dir = configDir;
|
|
76
76
|
} else {
|
|
77
|
-
// Priority:
|
|
78
|
-
const
|
|
77
|
+
// Priority: ~/.openclaw/a2hmarket/ > plugin dir > ~/.a2h_store/a2h_config/
|
|
78
|
+
const credsPath = join(OPENCLAW_CREDS_DIR, CREDENTIALS_FILE);
|
|
79
79
|
const pluginPath = join(PLUGIN_DIR, CREDENTIALS_FILE);
|
|
80
|
-
dir = existsSync(
|
|
81
|
-
?
|
|
80
|
+
dir = existsSync(credsPath)
|
|
81
|
+
? OPENCLAW_CREDS_DIR
|
|
82
82
|
: existsSync(pluginPath)
|
|
83
83
|
? PLUGIN_DIR
|
|
84
|
-
:
|
|
84
|
+
: A2H_CONFIG_DIR;
|
|
85
85
|
}
|
|
86
86
|
const filePath = join(dir, CREDENTIALS_FILE);
|
|
87
87
|
|
package/src/tempo-key-manager.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface TempoKeyResult {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// Fallback storage path for non-macOS environments
|
|
38
|
-
const FALLBACK_KEY_DIR = join(homedir(), ".
|
|
38
|
+
const FALLBACK_KEY_DIR = join(homedir(), ".a2h_store", "a2h_data");
|
|
39
39
|
const FALLBACK_KEY_FILE = join(FALLBACK_KEY_DIR, ".tempo-key");
|
|
40
40
|
|
|
41
41
|
// ── Internal: read/write fallback file ──────────────────────────────────────
|