@a2hmarket/a2hmarket 0.6.1 → 0.6.3
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/package.json +1 -1
- package/scripts/install.mjs +73 -40
- package/src/agent-service.ts +2 -2
package/package.json
CHANGED
package/scripts/install.mjs
CHANGED
|
@@ -468,11 +468,32 @@ async function main() {
|
|
|
468
468
|
log(`\n${BOLD}A2H Market — OpenClaw Plugin${RESET}\n`);
|
|
469
469
|
log(` 安装: npx -y ${NPM_SPEC} install`);
|
|
470
470
|
log(` 快速: npx -y ${NPM_SPEC} install --agent ag_xxx:key`);
|
|
471
|
+
log(` 非交互: npx -y ${NPM_SPEC} install --agent ag_xxx:key --notify feishu:ou_xxx`);
|
|
471
472
|
log(` 更新: npx -y ${NPM_SPEC} update`);
|
|
472
473
|
log(` 卸载: npx -y ${NPM_SPEC} uninstall\n`);
|
|
474
|
+
log(` 选项:`);
|
|
475
|
+
log(` --agent <id:key> 跳过浏览器授权,直接使用凭证`);
|
|
476
|
+
log(` --notify <channel:id> 指定通知渠道(如 feishu:ou_xxx, discord:123456)`);
|
|
477
|
+
log(` --yes 跳过所有确认提示\n`);
|
|
473
478
|
process.exit(0);
|
|
474
479
|
}
|
|
475
480
|
|
|
481
|
+
// Parse global flags
|
|
482
|
+
const autoYes = args.includes("--yes") || args.includes("-y");
|
|
483
|
+
|
|
484
|
+
const notifyFlag = args.find((a) => a.startsWith("--notify"));
|
|
485
|
+
const notifyValue = notifyFlag
|
|
486
|
+
? args[args.indexOf(notifyFlag) + 1] ?? notifyFlag.split("=")[1]
|
|
487
|
+
: null;
|
|
488
|
+
let presetNotify = null;
|
|
489
|
+
if (notifyValue && notifyValue.includes(":")) {
|
|
490
|
+
const colonIdx = notifyValue.indexOf(":");
|
|
491
|
+
presetNotify = {
|
|
492
|
+
channel: notifyValue.slice(0, colonIdx),
|
|
493
|
+
target: notifyValue.slice(colonIdx + 1),
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
476
497
|
log(`\n${BOLD}🏪 A2H Market — OpenClaw Plugin Installer${RESET}\n`);
|
|
477
498
|
|
|
478
499
|
// ── Step 1: Check OpenClaw ─────────────────────────────────────
|
|
@@ -507,9 +528,14 @@ async function main() {
|
|
|
507
528
|
const existingId = existing.agent_id ?? existing.agentId ?? "";
|
|
508
529
|
if (existingId) {
|
|
509
530
|
log(` 已有凭证: ${CYAN}${existingId}${RESET}`);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
531
|
+
let reuse = "Y";
|
|
532
|
+
if (!autoYes) {
|
|
533
|
+
const prompt = createPrompt();
|
|
534
|
+
reuse = await prompt.ask("使用现有凭证? (Y/n)", "Y");
|
|
535
|
+
prompt.close();
|
|
536
|
+
} else {
|
|
537
|
+
log(` ${DIM}--yes: 自动使用现有凭证${RESET}`);
|
|
538
|
+
}
|
|
513
539
|
if (reuse.toLowerCase() !== "n") {
|
|
514
540
|
agentId = existingId;
|
|
515
541
|
agentKey = existing.agent_key ?? existing.agentKey ?? "";
|
|
@@ -663,52 +689,59 @@ async function main() {
|
|
|
663
689
|
mqtt_url: mqttUrl,
|
|
664
690
|
};
|
|
665
691
|
|
|
666
|
-
//
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
692
|
+
// Configure notification channel
|
|
693
|
+
if (presetNotify) {
|
|
694
|
+
// --notify flag: skip interactive selection
|
|
695
|
+
credsData.notify = presetNotify;
|
|
696
|
+
log(` ${CHECK} 通知渠道已配置: ${presetNotify.channel} → ${presetNotify.target}`);
|
|
697
|
+
} else {
|
|
698
|
+
// Interactive channel selection
|
|
699
|
+
const channels = detectChannels();
|
|
700
|
+
if (channels.length > 0) {
|
|
701
|
+
log(` 检测到 ${channels.length} 个可用渠道:`);
|
|
702
|
+
channels.forEach((ch, i) => {
|
|
703
|
+
log(` ${CYAN}${i + 1}${RESET}. ${ch.name}`);
|
|
704
|
+
});
|
|
679
705
|
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
706
|
+
const prompt2 = createPrompt();
|
|
707
|
+
const choice = await prompt2.ask(
|
|
708
|
+
`选择通知渠道 (1-${channels.length},回车跳过)`,
|
|
709
|
+
"",
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
if (choice) {
|
|
713
|
+
const idx = parseInt(choice, 10) - 1;
|
|
714
|
+
if (idx >= 0 && idx < channels.length) {
|
|
715
|
+
const chosen = channels[idx];
|
|
716
|
+
let target = "";
|
|
717
|
+
|
|
718
|
+
if (chosen.name === "feishu") {
|
|
719
|
+
target = detectFeishuTarget() || "";
|
|
720
|
+
if (target) {
|
|
721
|
+
log(` 检测到飞书用户: ${CYAN}${target}${RESET}`);
|
|
722
|
+
} else {
|
|
723
|
+
target = await prompt2.ask("输入飞书 open_id (ou_xxx) 或 chat_id (oc_xxx)", "");
|
|
724
|
+
}
|
|
725
|
+
} else if (chosen.name === "discord") {
|
|
726
|
+
target = await prompt2.ask("输入 Discord 频道 ID", "");
|
|
727
|
+
} else {
|
|
728
|
+
target = await prompt2.ask(`输入 ${chosen.name} 目标 ID`, "");
|
|
729
|
+
}
|
|
685
730
|
|
|
686
|
-
if (chosen.name === "feishu") {
|
|
687
|
-
target = detectFeishuTarget() || "";
|
|
688
731
|
if (target) {
|
|
689
|
-
|
|
732
|
+
credsData.notify = { channel: chosen.name, target };
|
|
733
|
+
log(` ${CHECK} 通知渠道已配置: ${chosen.name} → ${target}`);
|
|
690
734
|
} else {
|
|
691
|
-
|
|
735
|
+
log(` ${WARN} 未输入目标 ID,跳过通知配置`);
|
|
692
736
|
}
|
|
693
|
-
} else if (chosen.name === "discord") {
|
|
694
|
-
target = await prompt2.ask("输入 Discord 频道 ID", "");
|
|
695
|
-
} else {
|
|
696
|
-
target = await prompt2.ask(`输入 ${chosen.name} 目标 ID`, "");
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
if (target) {
|
|
700
|
-
credsData.notify = { channel: chosen.name, target };
|
|
701
|
-
log(` ${CHECK} 通知渠道已配置: ${chosen.name} → ${target}`);
|
|
702
|
-
} else {
|
|
703
|
-
log(` ${WARN} 未输入目标 ID,跳过通知配置`);
|
|
704
737
|
}
|
|
738
|
+
} else {
|
|
739
|
+
log(` ${DIM}跳过通知配置${RESET}`);
|
|
705
740
|
}
|
|
741
|
+
prompt2.close();
|
|
706
742
|
} else {
|
|
707
|
-
log(` ${DIM}
|
|
743
|
+
log(` ${DIM}未检测到可用渠道,跳过通知配置${RESET}`);
|
|
708
744
|
}
|
|
709
|
-
prompt2.close();
|
|
710
|
-
} else {
|
|
711
|
-
log(` ${DIM}未检测到可用渠道,跳过通知配置${RESET}`);
|
|
712
745
|
}
|
|
713
746
|
|
|
714
747
|
// Save credentials file (fallback for dev mode)
|
package/src/agent-service.ts
CHANGED
|
@@ -45,7 +45,7 @@ async function mqttSendText(
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// ── Re-export
|
|
48
|
+
// ── Re-export for external callers ──────────────────────────────────────
|
|
49
49
|
|
|
50
50
|
export { notifyHuman as notifyHumanCard } from "./notify.js";
|
|
51
51
|
|
|
@@ -81,7 +81,7 @@ export async function startAgentService(ctx: AgentServiceContext): Promise<void>
|
|
|
81
81
|
ctx.log.info(`inbound from ${event.senderId}: ${event.text.slice(0, 80)}`);
|
|
82
82
|
|
|
83
83
|
// ① Custom notification: notify human about incoming message
|
|
84
|
-
|
|
84
|
+
notifyHuman("inbound", event.senderId, event.text.slice(0, 500), creds.agentId, notifyLog);
|
|
85
85
|
|
|
86
86
|
// ② Dispatch to OpenClaw Agent via Channel Plugin SDK
|
|
87
87
|
// Agent has full access to a2h_* tools
|