@bolloon/bolloon-agent 0.3.44 → 0.3.46
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/README.md +135 -135
- package/bin/bolloon-cli.cjs +183 -183
- package/bin/bolloon-daemon.sh +207 -0
- package/bin/bolloon.cjs +0 -0
- package/dist/agents/agent-identity.js +17 -0
- package/dist/agents/constraint-layer.js +19 -19
- package/dist/agents/judgment-protocol.js +14 -14
- package/dist/agents/loop-review.js +21 -5
- package/dist/agents/pi-sdk-types.js +12 -12
- package/dist/agents/pi-sdk.js +197 -102
- package/dist/agents/skill-writer.js +19 -0
- package/dist/agents/workflow-pivot-loop.js +3 -3
- package/dist/bollharness/src/scripts/deploy-guard.js +8 -8
- package/dist/bollharness-integration/context-router-judgment.js +4 -4
- package/dist/bollharness-integration/context-router.js +292 -292
- package/dist/bollharness-integration/gate-state-machine.js +13 -13
- package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
- package/dist/bollharness-integration/skill-adapter.js +21 -21
- package/dist/bootstrap/chat-archiver.js +14 -14
- package/dist/bootstrap/context-os.js +21 -21
- package/dist/bootstrap/memory-compressor.js +29 -13
- package/dist/cli-entry.js +47 -37
- package/dist/constraint-runtime/reference_data/archive_surface_snapshot.json +63 -0
- package/dist/constraint-runtime/reference_data/commands_snapshot.json +1037 -0
- package/dist/constraint-runtime/reference_data/subsystems/assistant.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bootstrap.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bridge.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/buddy.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/cli.json +26 -0
- package/dist/constraint-runtime/reference_data/subsystems/components.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/constants.json +28 -0
- package/dist/constraint-runtime/reference_data/subsystems/coordinator.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/entrypoints.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/hooks.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/keybindings.json +21 -0
- package/dist/constraint-runtime/reference_data/subsystems/memdir.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/migrations.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/moreright.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/native_ts.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/outputStyles.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/plugins.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/remote.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/schemas.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/screens.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/server.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/services.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/skills.json +27 -0
- package/dist/constraint-runtime/reference_data/subsystems/state.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/types.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/upstreamproxy.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/utils.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/vim.json +12 -0
- package/dist/constraint-runtime/reference_data/subsystems/voice.json +8 -0
- package/dist/constraint-runtime/reference_data/tools_snapshot.json +922 -0
- package/dist/constraint-runtime/setup.js +1 -1
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.d.ts +13 -3
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.js +16 -4
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.d.ts +50 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.js +78 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.d.ts +24 -3
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.js +31 -4
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.d.ts +1 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.js +14 -3
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.d.ts +11 -2
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.js +23 -4
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.d.ts +4 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.js +22 -2
- package/dist/context-compaction/auto-compact.js +7 -7
- package/dist/electron/config.js.map +1 -0
- package/dist/electron/dialogs.js.map +1 -0
- package/dist/electron/first-run.js +54 -54
- package/dist/electron/first-run.js.map +1 -0
- package/dist/electron/ipc.js.map +1 -0
- package/dist/electron/logger.js.map +1 -0
- package/dist/electron/main.js.map +1 -0
- package/dist/electron/menu.js.map +1 -0
- package/dist/electron/paths.js.map +1 -0
- package/dist/electron/server.js.map +1 -0
- package/dist/electron/tray.js.map +1 -0
- package/dist/electron/window.js.map +1 -0
- package/dist/electron-build/electron/first-run.js +54 -54
- package/dist/electron-preload.js.map +1 -1
- package/dist/electron.js.map +1 -1
- package/dist/index.js +113 -113
- package/dist/llm/llm-judgment-client.js +102 -102
- package/dist/llm/pi-ai.js +48 -48
- package/dist/llm/system-prompt/layers/channel/human-async.md +41 -41
- package/dist/llm/system-prompt/layers/channel/local.md +14 -14
- package/dist/llm/system-prompt/layers/channel/p2p-agent.md +18 -18
- package/dist/llm/system-prompt/layers/channel/p2p-peer-sync.md +51 -51
- package/dist/llm/system-prompt/layers/channel/p2p-proactive.md +43 -43
- package/dist/llm/system-prompt/layers/channel/p2p-visitor.md +19 -19
- package/dist/llm/system-prompt/layers/channel/session-handoff.md +61 -61
- package/dist/llm/system-prompt/layers/core/artifacts_storage.md +89 -89
- package/dist/llm/system-prompt/layers/core/evenhandedness.md +21 -21
- package/dist/llm/system-prompt/layers/core/external-engagement.md +73 -73
- package/dist/llm/system-prompt/layers/core/hibs_reminders.md +15 -15
- package/dist/llm/system-prompt/layers/core/identity.md +48 -48
- package/dist/llm/system-prompt/layers/core/knowledge.md +17 -17
- package/dist/llm/system-prompt/layers/core/memory_system.md +12 -12
- package/dist/llm/system-prompt/layers/core/network_filesystem.md +28 -28
- package/dist/llm/system-prompt/layers/core/refusal.md +37 -37
- package/dist/llm/system-prompt/layers/core/tone.md +31 -31
- package/dist/llm/system-prompt/layers/core/tools.thin.md +13 -13
- package/dist/llm/system-prompt/layers/core/wellbeing.md +41 -41
- package/dist/llm/system-prompt/layers/role/architect.md +20 -20
- package/dist/llm/system-prompt/layers/role/expert.md +19 -19
- package/dist/llm/system-prompt/layers/role/implementer.md +15 -15
- package/dist/llm/system-prompt/layers/role/security.md +15 -15
- package/dist/llm/system-prompt/layers/tool/artifacts.md +72 -72
- package/dist/llm/system-prompt/layers/tool/bash.md +25 -25
- package/dist/llm/system-prompt/layers/tool/goal_handoff.md +77 -77
- package/dist/llm/system-prompt/layers/tool/hibs_api.md +171 -171
- package/dist/llm/system-prompt/layers/tool/image_search.md +70 -70
- package/dist/llm/system-prompt/layers/tool/manifest.md +89 -89
- package/dist/llm/system-prompt/layers/tool/mcp_apps.md +53 -53
- package/dist/llm/system-prompt/layers/tool/p2p_request.md +61 -61
- package/dist/llm/system-prompt/layers/tool/web_search.md +83 -83
- package/dist/llm/tool-manifest/ask_user_input.js +1 -1
- package/dist/llm/tool-manifest/bash.js +3 -3
- package/dist/llm/tool-manifest/create_file.js +4 -4
- package/dist/llm/tool-manifest/fetch_sports_data.js +3 -3
- package/dist/llm/tool-manifest/image_search.js +2 -2
- package/dist/llm/tool-manifest/index.js +59 -0
- package/dist/llm/tool-manifest/mcp.js +2 -2
- package/dist/llm/tool-manifest/message_compose.js +3 -3
- package/dist/llm/tool-manifest/places.js +2 -2
- package/dist/llm/tool-manifest/present_files.js +1 -1
- package/dist/llm/tool-manifest/recipe.js +2 -2
- package/dist/llm/tool-manifest/str_replace.js +5 -5
- package/dist/llm/tool-manifest/view.js +3 -3
- package/dist/llm/tool-manifest/weather.js +4 -4
- package/dist/llm/tool-manifest/web.js +4 -4
- package/dist/orbitdb/cid-database.js +41 -0
- package/dist/orbitdb/did-catalog-replication.js +199 -0
- package/dist/orbitdb/trajectory-store.js +150 -0
- package/dist/pi-ecosystem-judgment/causal-judge.js +51 -51
- package/dist/pi-ecosystem-judgment/distill-prompt.js +42 -42
- package/dist/pi-ecosystem-judgment/distillation.js +14 -14
- package/dist/pi-ecosystem-judgment/monitor-gate.js +28 -28
- package/dist/pi-ecosystem-judgment/value-injection.js +102 -102
- package/dist/security/context-router-tool.js +15 -15
- package/dist/storage/did-catalog-bridge.js +271 -0
- package/dist/utils/auto-update.js.map +1 -0
- package/dist/web/api-config.html +779 -779
- package/dist/web/client-hearth.js +10 -10
- package/dist/web/client.js +141 -0
- package/dist/web/client.js.map +7 -0
- package/dist/web/components/wallet-viem.mjs +118 -118
- package/dist/web/index.html +472 -424
- package/dist/web/manifest.json +20 -20
- package/dist/web/server.js +290 -13
- package/dist/web/style.css +4946 -4914
- package/package.json +193 -193
- package/scripts/build-cli.js +215 -215
- package/scripts/build-web.ts +130 -130
- package/scripts/postinstall.js +152 -152
- package/bin/bolloon.js +0 -157
- package/dist/pi-ecosystem-colony/index.js +0 -365
- package/dist/social/ant-colony/AdaptiveHeartbeat.js +0 -101
- package/dist/social/ant-colony/PheromoneEngine.js +0 -227
- package/dist/social/ant-colony/index.js +0 -6
- package/dist/social/ant-colony/types.js +0 -24
- package/dist/test/ai-judgment-test.js +0 -80
- package/dist/test/bollharness-integration.test.js +0 -318
- package/dist/test/channel-agent-multi-dialogue.js +0 -205
- package/dist/test/channel-heartbeat-agent-test.js +0 -201
- package/dist/test/constraint-layer.test.js +0 -164
- package/dist/test/diap-identity-test.js +0 -172
- package/dist/test/diap-quick-test.js +0 -62
- package/dist/test/global-shared-context.test.js +0 -315
- package/dist/test/harness-judgment-injection.test.js +0 -246
- package/dist/test/harness-workflow-integrator-test.js +0 -228
- package/dist/test/human-value-store.test.js +0 -243
- package/dist/test/hybrid-integration-test.js +0 -118
- package/dist/test/hybrid-messenger-verify.js +0 -55
- package/dist/test/iroh-bistream-debug.js +0 -38
- package/dist/test/iroh-communication.test.js +0 -66
- package/dist/test/iroh-debug-test.js +0 -57
- package/dist/test/iroh-diap-test.js +0 -71
- package/dist/test/iroh-direct-connect.js +0 -55
- package/dist/test/iroh-e2e-fixed.js +0 -89
- package/dist/test/iroh-e2e-same-process.js +0 -63
- package/dist/test/iroh-e2e.js +0 -66
- package/dist/test/iroh-final-e2e.js +0 -72
- package/dist/test/iroh-relay-test.js +0 -37
- package/dist/test/iroh-simple-test.js +0 -41
- package/dist/test/iroh-transport-verify.js +0 -54
- package/dist/test/iroh-transport.test.js +0 -37
- package/dist/test/iroh-two-nodes.js +0 -70
- package/dist/test/iroh-verify.js +0 -44
- package/dist/test/judgment-decision.test.js +0 -219
- package/dist/test/llm-judgment-integration.test.js +0 -220
- package/dist/test/p2p-agent-complex-dialogue.js +0 -385
- package/dist/test/p2p-agent-dialogue.js +0 -341
- package/dist/test/p2p-agent-full-bidirectional.js +0 -510
- package/dist/test/p2p-agent-harness-flow.js +0 -437
- package/dist/test/p2p-agent-harness-single.js +0 -143
- package/dist/test/p2p-ai-dialogue-test.js +0 -318
- package/dist/test/p2p-cid-connect-test.js +0 -195
- package/dist/test/p2p-connect-receiver.js +0 -69
- package/dist/test/p2p-doc-transfer.js +0 -110
- package/dist/test/p2p-identity-page-test.js +0 -77
- package/dist/test/p2p-iroh-test.js +0 -171
- package/dist/test/p2p-minimal-test.js +0 -241
- package/dist/test/p2p-node-1.js +0 -148
- package/dist/test/p2p-node-2.js +0 -148
- package/dist/test/p2p-server.js +0 -281
- package/dist/test/p2p-two-nodes-test.js +0 -438
- package/dist/test/pi-sdk.test.js +0 -44
- package/dist/test/set-persona.js +0 -40
- package/dist/test/simple.test.js +0 -9
- package/dist/test/storage-integration.test.js +0 -150
- package/dist/test/subagent-manager.test.js +0 -276
- package/dist/test/test-gate-flow.test.js +0 -81
- package/dist/test/workflow-engine.test.js +0 -87
- package/dist/test/workflow-pivot-loop.test.js +0 -246
|
@@ -20,16 +20,16 @@ export async function renderMyHearth(root) {
|
|
|
20
20
|
root.innerHTML = '<h1>My Hearth</h1><p>Loading…</p>';
|
|
21
21
|
try {
|
|
22
22
|
const data = await fetchHearth('/api/hearth');
|
|
23
|
-
root.innerHTML = `
|
|
24
|
-
<h1>My Hearth</h1>
|
|
25
|
-
<dl>
|
|
26
|
-
<dt>Service</dt><dd>${data.service} v${data.version}</dd>
|
|
27
|
-
<dt>Root</dt><dd><code>${data.rootPath}</code></dd>
|
|
28
|
-
<dt>Description count</dt><dd>${data.descriptionCount}</dd>
|
|
29
|
-
<dt>Visibility channels</dt><dd>${data.visibilityChannels}</dd>
|
|
30
|
-
<dt>Allowlist count</dt><dd>${data.allowlistCount}</dd>
|
|
31
|
-
<dt>Defense mode</dt><dd>${data.defenseMode ? 'ON (write APIs disabled)' : 'OFF (反攻期)'}</dd>
|
|
32
|
-
</dl>
|
|
23
|
+
root.innerHTML = `
|
|
24
|
+
<h1>My Hearth</h1>
|
|
25
|
+
<dl>
|
|
26
|
+
<dt>Service</dt><dd>${data.service} v${data.version}</dd>
|
|
27
|
+
<dt>Root</dt><dd><code>${data.rootPath}</code></dd>
|
|
28
|
+
<dt>Description count</dt><dd>${data.descriptionCount}</dd>
|
|
29
|
+
<dt>Visibility channels</dt><dd>${data.visibilityChannels}</dd>
|
|
30
|
+
<dt>Allowlist count</dt><dd>${data.allowlistCount}</dd>
|
|
31
|
+
<dt>Defense mode</dt><dd>${data.defenseMode ? 'ON (write APIs disabled)' : 'OFF (反攻期)'}</dd>
|
|
32
|
+
</dl>
|
|
33
33
|
<p>视图: <a href="#/hearth/discover">Discover</a> · <a href="#/hearth/visit/__self__">Visit self</a></p>`;
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
package/dist/web/client.js
CHANGED
|
@@ -3791,6 +3791,13 @@ ${data.error || "channel not found"}`, "error");
|
|
|
3791
3791
|
if (nameEl) nameEl.textContent = identity.name || "\u533F\u540D";
|
|
3792
3792
|
if (didEl) didEl.textContent = identity.didShort ? `did:key:${identity.didShort}` : "";
|
|
3793
3793
|
if (letterEl) letterEl.textContent = letter;
|
|
3794
|
+
const avatarEl = document.getElementById("user-avatar");
|
|
3795
|
+
if (avatarEl) {
|
|
3796
|
+
avatarEl.style.cursor = "pointer";
|
|
3797
|
+
avatarEl.onclick = () => {
|
|
3798
|
+
openAuthModal();
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3794
3801
|
if (nameEl) {
|
|
3795
3802
|
nameEl.onclick = () => {
|
|
3796
3803
|
const current = nameEl.textContent || "";
|
|
@@ -3841,6 +3848,140 @@ ${data.error || "channel not found"}`, "error");
|
|
|
3841
3848
|
} catch (e) {
|
|
3842
3849
|
}
|
|
3843
3850
|
}
|
|
3851
|
+
function getEl(id) {
|
|
3852
|
+
return document.getElementById(id);
|
|
3853
|
+
}
|
|
3854
|
+
function showAuthMsg(text, isError = false) {
|
|
3855
|
+
const msg = getEl("auth-msg");
|
|
3856
|
+
if (!msg) return;
|
|
3857
|
+
msg.textContent = text;
|
|
3858
|
+
msg.style.display = "block";
|
|
3859
|
+
msg.style.color = isError ? "#ef4444" : "#22c55e";
|
|
3860
|
+
}
|
|
3861
|
+
async function refreshAuthAccounts() {
|
|
3862
|
+
try {
|
|
3863
|
+
const res = await fetch("/api/auth/status");
|
|
3864
|
+
if (!res.ok) return;
|
|
3865
|
+
const data = await res.json();
|
|
3866
|
+
const statusLine = getEl("auth-status-line");
|
|
3867
|
+
if (statusLine) {
|
|
3868
|
+
statusLine.innerHTML = `\u5F53\u524D\u7528\u6237 DID: <code style="font-size:11px;">${escapeHtml2(data.did || "")}</code><br><span style="color:var(--text-muted);">\u6240\u6709\u767B\u5F55\u8D26\u53F7\u4E0E DIAP \u667A\u80FD\u4F53\u8EAB\u4EFD\u5747\u5F52\u5C5E\u6B64 DID\u3002</span>`;
|
|
3869
|
+
}
|
|
3870
|
+
const listEl = getEl("auth-accounts-list");
|
|
3871
|
+
if (listEl) {
|
|
3872
|
+
const accs = data.accounts || [];
|
|
3873
|
+
if (accs.length === 0) {
|
|
3874
|
+
listEl.innerHTML = '<div class="form-info" style="margin-top:4px;color:var(--text-muted);">\u5C1A\u672A\u7ED1\u5B9A\u4EFB\u4F55\u8D26\u53F7</div>';
|
|
3875
|
+
} else {
|
|
3876
|
+
listEl.innerHTML = '<div class="form-info" style="margin-bottom:4px;"><b>\u5DF2\u7ED1\u5B9A\u8D26\u53F7</b></div>' + accs.map((a) => `<div style="display:flex;justify-content:space-between;align-items:center;padding:4px 8px;border:1px solid var(--border);border-radius:6px;margin-bottom:4px;font-size:12px;">
|
|
3877
|
+
<span>${escapeHtml2(a.provider)}${a.identifier ? " \xB7 " + escapeHtml2(a.identifier) : ""}${a.skeleton ? ' <span style="color:#f59e0b;">(\u9AA8\u67B6)</span>' : ""}</span>
|
|
3878
|
+
<button class="btn-secondary btn-sm auth-unbind-btn" data-provider="${escapeHtml2(a.provider)}" style="padding:1px 8px;font-size:11px;">\u89E3\u7ED1</button>
|
|
3879
|
+
</div>`).join("");
|
|
3880
|
+
listEl.querySelectorAll(".auth-unbind-btn").forEach((btn) => {
|
|
3881
|
+
btn.addEventListener("click", async () => {
|
|
3882
|
+
const provider = btn.dataset.provider || "";
|
|
3883
|
+
try {
|
|
3884
|
+
const r = await fetch("/api/auth/logout", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider }) });
|
|
3885
|
+
if (r.ok) {
|
|
3886
|
+
showAuthMsg(`\u2713 \u5DF2\u89E3\u7ED1 ${provider}`);
|
|
3887
|
+
refreshAuthAccounts();
|
|
3888
|
+
} else {
|
|
3889
|
+
showAuthMsg(`\u89E3\u7ED1\u5931\u8D25: ${(await r.json()).error || ""}`, true);
|
|
3890
|
+
}
|
|
3891
|
+
} catch {
|
|
3892
|
+
showAuthMsg("\u89E3\u7ED1\u5931\u8D25", true);
|
|
3893
|
+
}
|
|
3894
|
+
});
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
} catch {
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
async function openAuthModal() {
|
|
3902
|
+
const modal = getEl("auth-modal");
|
|
3903
|
+
if (!modal) return;
|
|
3904
|
+
modal.style.display = "flex";
|
|
3905
|
+
const msg = getEl("auth-msg");
|
|
3906
|
+
if (msg) msg.style.display = "none";
|
|
3907
|
+
const emailEl = getEl("auth-email");
|
|
3908
|
+
const phoneEl = getEl("auth-phone");
|
|
3909
|
+
if (emailEl) emailEl.value = "";
|
|
3910
|
+
if (phoneEl) phoneEl.value = "";
|
|
3911
|
+
await refreshAuthAccounts();
|
|
3912
|
+
}
|
|
3913
|
+
function closeAuthModal() {
|
|
3914
|
+
const modal = getEl("auth-modal");
|
|
3915
|
+
if (modal) modal.style.display = "none";
|
|
3916
|
+
}
|
|
3917
|
+
async function authLogin(provider, identifier) {
|
|
3918
|
+
try {
|
|
3919
|
+
const res = await fetch("/api/auth/login", {
|
|
3920
|
+
method: "POST",
|
|
3921
|
+
headers: { "Content-Type": "application/json" },
|
|
3922
|
+
body: JSON.stringify({ provider, identifier })
|
|
3923
|
+
});
|
|
3924
|
+
const data = await res.json();
|
|
3925
|
+
if (!res.ok) {
|
|
3926
|
+
showAuthMsg(data.error || "\u767B\u5F55\u5931\u8D25", true);
|
|
3927
|
+
return;
|
|
3928
|
+
}
|
|
3929
|
+
showAuthMsg(`\u2713 ${data.message || "\u5DF2\u7ED1\u5B9A"}`);
|
|
3930
|
+
await refreshAuthAccounts();
|
|
3931
|
+
loadUserIdentity();
|
|
3932
|
+
} catch {
|
|
3933
|
+
showAuthMsg("\u767B\u5F55\u8BF7\u6C42\u5931\u8D25", true);
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
function bindAuthModalEvents() {
|
|
3937
|
+
const closeBtn = getEl("auth-modal-close");
|
|
3938
|
+
if (closeBtn) closeBtn.onclick = closeAuthModal;
|
|
3939
|
+
document.querySelectorAll(".auth-oauth-btn").forEach((btn) => {
|
|
3940
|
+
btn.addEventListener("click", () => {
|
|
3941
|
+
const provider = btn.dataset.provider || "";
|
|
3942
|
+
authLogin(provider);
|
|
3943
|
+
});
|
|
3944
|
+
});
|
|
3945
|
+
const emailBtn = getEl("auth-email-btn");
|
|
3946
|
+
if (emailBtn) emailBtn.onclick = () => {
|
|
3947
|
+
const emailEl = getEl("auth-email");
|
|
3948
|
+
const val = emailEl?.value?.trim() || "";
|
|
3949
|
+
if (!val) {
|
|
3950
|
+
showAuthMsg("\u8BF7\u586B\u5199\u90AE\u7BB1", true);
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
authLogin("email", val);
|
|
3954
|
+
};
|
|
3955
|
+
const phoneBtn = getEl("auth-phone-btn");
|
|
3956
|
+
if (phoneBtn) phoneBtn.onclick = () => {
|
|
3957
|
+
const phoneEl = getEl("auth-phone");
|
|
3958
|
+
const val = phoneEl?.value?.trim() || "";
|
|
3959
|
+
if (!val) {
|
|
3960
|
+
showAuthMsg("\u8BF7\u586B\u5199\u624B\u673A\u53F7", true);
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
authLogin("phone", val);
|
|
3964
|
+
};
|
|
3965
|
+
const emailInput = getEl("auth-email");
|
|
3966
|
+
if (emailInput) emailInput.addEventListener("keydown", (e) => {
|
|
3967
|
+
if (e.key === "Enter") getEl("auth-email-btn")?.click();
|
|
3968
|
+
});
|
|
3969
|
+
const phoneInput = getEl("auth-phone");
|
|
3970
|
+
if (phoneInput) phoneInput.addEventListener("keydown", (e) => {
|
|
3971
|
+
if (e.key === "Enter") getEl("auth-phone-btn")?.click();
|
|
3972
|
+
});
|
|
3973
|
+
const modal = getEl("auth-modal");
|
|
3974
|
+
if (modal) modal.addEventListener("click", (e) => {
|
|
3975
|
+
if (e.target === modal) closeAuthModal();
|
|
3976
|
+
});
|
|
3977
|
+
}
|
|
3978
|
+
if (typeof document !== "undefined") {
|
|
3979
|
+
if (document.readyState === "loading") {
|
|
3980
|
+
document.addEventListener("DOMContentLoaded", bindAuthModalEvents);
|
|
3981
|
+
} else {
|
|
3982
|
+
bindAuthModalEvents();
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3844
3985
|
async function init() {
|
|
3845
3986
|
const themeData = await loadTheme();
|
|
3846
3987
|
currentAgentId = themeData.agentId || `agent_${generateId().substring(0, 8)}`;
|