@a2hmarket/a2hmarket 0.10.2 → 1.0.0
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 +19 -11
- 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.0",
|
|
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,8 +21,11 @@ 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(
|
|
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");
|
|
26
29
|
const NPM_SPEC = "@a2hmarket/a2hmarket";
|
|
27
30
|
|
|
28
31
|
const AUTH_API_URL = "https://web.a2hmarket.ai";
|
|
@@ -372,7 +375,7 @@ async function runUpdate() {
|
|
|
372
375
|
|
|
373
376
|
// Restore credentials file
|
|
374
377
|
if (savedCreds) {
|
|
375
|
-
mkdirSync(
|
|
378
|
+
mkdirSync(CREDS_DIR, { recursive: true });
|
|
376
379
|
const fileData = {
|
|
377
380
|
agent_id: savedCreds.agentId ?? savedCreds.agent_id,
|
|
378
381
|
agent_key: savedCreds.agentKey ?? savedCreds.agent_key,
|
|
@@ -483,12 +486,14 @@ async function runUninstall() {
|
|
|
483
486
|
}
|
|
484
487
|
|
|
485
488
|
// 2. Remove runtime data
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
489
|
+
for (const dir of [CREDS_DIR, A2H_STORE_DIR]) {
|
|
490
|
+
if (existsSync(dir)) {
|
|
491
|
+
try {
|
|
492
|
+
execSync(`rm -rf "${dir}"`, { stdio: "pipe" });
|
|
493
|
+
log(` ${CHECK} Removed: ${dir}`);
|
|
494
|
+
} catch {
|
|
495
|
+
log(` ${WARN} Failed to remove: ${dir}`);
|
|
496
|
+
}
|
|
492
497
|
}
|
|
493
498
|
}
|
|
494
499
|
|
|
@@ -747,7 +752,9 @@ async function main() {
|
|
|
747
752
|
|
|
748
753
|
// ── Step 4: Save credentials & configure openclaw.json ───────
|
|
749
754
|
logStep(4, "Save Configuration");
|
|
750
|
-
mkdirSync(
|
|
755
|
+
mkdirSync(CREDS_DIR, { recursive: true });
|
|
756
|
+
mkdirSync(A2H_CONFIG_DIR, { recursive: true });
|
|
757
|
+
mkdirSync(A2H_DATA_DIR, { recursive: true });
|
|
751
758
|
|
|
752
759
|
const credsData = {
|
|
753
760
|
agent_id: agentId,
|
|
@@ -901,7 +908,8 @@ async function main() {
|
|
|
901
908
|
// ── Done ───────────────────────────────────────────────────────
|
|
902
909
|
log(`\n${GREEN}${BOLD}🎉 Setup complete!${RESET}\n`);
|
|
903
910
|
log(` Agent ID: ${CYAN}${agentId}${RESET}`);
|
|
904
|
-
log(`
|
|
911
|
+
log(` Credentials: ${DIM}${CREDS_DIR}${RESET}`);
|
|
912
|
+
log(` Data dir: ${DIM}${A2H_STORE_DIR}${RESET}`);
|
|
905
913
|
if (credsData.notify) {
|
|
906
914
|
log(` Notify: ${CYAN}${credsData.notify.channel}:${credsData.notify.target}${RESET}`);
|
|
907
915
|
}
|
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 ──────────────────────────────────────
|