@xopcai/xopc 0.0.373 → 0.0.374
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear--kDkSTqC.js → agent-avatar-dicebear-BrA20N2m.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-z4_2-Kn2.js → agent-defaults-settings-panel-BZrOdxou.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BYndK83K.js → agent-plugin-dialog-B3ux1AhY.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CVo96cx1.js → agents-CXlXFU6M.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D9oOJKiH.js → app-management-settings-panel-BXahEVPm.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B0-8Cdyv.js → appearance-settings-CE2qJMkD.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DasVc6i4.js → apps-page-DGVOnCxZ.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BlCNqy2i.js → automations-page-BWL7eT4_.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-C8ipDP05.js → automations-workspace-BxIShhkZ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cktlez6g.js → block-editor-3n446-mX.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-KRfDl8ej.js → browser-automations-page-BmTK7Gtn.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BraQ4wnh.js → browser-settings-page-DBQ-WETQ.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-B3m8xGzd.js → capabilities-page-D-nQ6Zzi.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-VQ4fHuBV.js → capabilities-settings-panel-Dx1fpBmH.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-f5Ido4Eg.js → capability-header-actions-BRMqvQVb.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-N4Vc2nEG.js → channels-DXfEP1FR.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BwvTKwsn.js → chat-terminal-dock-BRdzCjWO.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CAwUsKpw.js → computer-settings-page-BhCHMRpD.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-C0HuAMuH.js → connector-service-page-BXE8Z-Ll.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BcBmW8JT.js → connectors-page-D9RZjhw8.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DiQxRpe-.js → date-picker-BJ7N92wm.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Ds0_BJbN.js → dependency-picker-gyxCM-hb.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-ZMEOYwrR.js → desktop-pet-B-WM4l-L.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DkyTqD07.js → desktop-pet-settings-usJqcew5.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-CvaI5ZJZ.js → device-pairing-wizard-DoSR4DGk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Bfv93eK1.js → directory-picker-path-field-DqVlV2YH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-JXKGtIdM.js → extension-page-CUule9SU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-lsQ2xvbr.js → extension-settings-page-_OFukkEJ.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-7bG0AND1.js → fallback-models-CiSc3h8i.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BpbcoPx9.js → gateway-settings-qSUrpS1h.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BxctC0aJ.js → home-page-COjDsuzg.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Bq8CazCb.js → imports-page-DdvIj-ZL.js} +1 -1
- package/dist/gateway/static/root/assets/{index-B40-KDN8.js → index-DEaVabvo.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-kkAevkl2.js → keyboard-shortcuts-settings-DbqFlNsF.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-abLaf1hW.js → local-app-workbench-page-REowUzkp.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-nwsnwYjK.js → local-apps-page-DdCMNn_z.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BEgYS-Xg.js → logs-page-B_6fHDoi.js} +1 -1
- package/dist/gateway/static/root/assets/management-settings-D4vcSRE3.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-CCnfurBR.js → note-detail-panel-B7U6EbAi.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-D9u_znxM.js → notes-page-BzHVaH8j.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BO3FoRej.js → page-context-capture-button-D7Y4vFRN.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-E6huhFk4.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-Dso2_hyl.js → product-open-page-CK_czbBx.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-CkvVb3EA.js → product-preview-content-CU6KlaVP.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-UjrrzE3H.js → project-detail-page-c3ye2bdq.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C1h63P2M.js → projects-page-BA1UuuRF.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BJifH8AB.js → remote-access-hub-D_FLVZAm.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-vG1wqcEb.js → runtime-tools-settings-panel-Cxjmwdyf.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-CwoAoYMX.js → scenes-page-Av47PHdM.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BIsHdyz7.js → schema-form-IM7QeSm3.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BcCLp3yU.js → sessions-page-Bol3ScEc.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DpCanqrD.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-z9Jlk0BL.js → settings-page-BeVtwwVd.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CrpXECqe.js → setup-status-panel-zTmrMwMm.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-D9XpTJXP.js → shares-settings-Bkhkt_6M.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-DtPOf1aW.js → skill-api-Dgwc707w.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Bq9-2b9U.js → skills-page-CFIte-vM.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-P7T729uD.js → system-settings-panel-Ck6zGDHb.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CsB9AFx6.js → task-detail-page-C3ZPEZqw.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CuowqIZ7.js → tunnel-api-CjxMpAm2.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-avX3msoZ.js → usage-page-Dnhp9xQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-DGDBWw7P.js → user-model-page-sx1lNWKf.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BgJNz2tH.js → work-discovery-overlay-CVd_y3K2.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1I2q2J_U.js → workflow-run-setup-panel-Dwg40uGK.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DhJl9pnO.js → workflows-page-BQR4JdXB.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CnPBP1V_.js → xopc-cloud-account-card-CaKc_J7j.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/realtime-protocol/src/voice.js +11 -0
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +2 -2
- package/dist/src/agent/embedded/run-turn.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/service.js +3 -3
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent-config/schema.d.ts +9 -0
- package/dist/src/agent-config/schema.js +1 -0
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/model-credential-store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/image-providers.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/gateway/shared.js +2 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +3 -3
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/gateway-bind.js +2 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.d.ts +8 -8
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/schema.d.ts +13 -12
- package/dist/src/config/schema.js +7 -3
- package/dist/src/daemon/constants.js +14 -9
- package/dist/src/daemon/index.js +4 -1
- package/dist/src/daemon/install-plan.js +2 -1
- package/dist/src/daemon/launchd.js +2 -1
- package/dist/src/daemon/schtasks.js +2 -1
- package/dist/src/daemon/service-audit.js +2 -1
- package/dist/src/daemon/service.js +2 -1
- package/dist/src/daemon/systemd.js +2 -1
- package/dist/src/extensions/activation-context.js +1 -1
- package/dist/src/gateway/client-ip.js +2 -1
- package/dist/src/gateway/hono/app.js +2 -1
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/middleware/auth.d.ts +3 -5
- package/dist/src/gateway/hono/middleware/auth.js +56 -14
- package/dist/src/gateway/hono/middleware/logger.js +2 -1
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.d.ts +16 -0
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.js +43 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +3 -2
- package/dist/src/gateway/hono/oauth-async.js +2 -1
- package/dist/src/gateway/hono/routes/browser.js +2 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +2 -1
- package/dist/src/gateway/hono/routes/device-pairing-approval.d.ts +3 -8
- package/dist/src/gateway/hono/routes/device-pairing-approval.js +5 -20
- package/dist/src/gateway/hono/routes/devices.js +25 -9
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -0
- package/dist/src/gateway/hono/routes/models.js +3 -3
- package/dist/src/gateway/hono/routes/observability.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +6 -6
- package/dist/src/gateway/hono/routes/shares.js +2 -1
- package/dist/src/gateway/hono/routes/voice.js +2 -1
- package/dist/src/gateway/host.js +9 -4
- package/dist/src/gateway/index.js +8 -4
- package/dist/src/gateway/listen.js +2 -1
- package/dist/src/gateway/rate-limit/auth-policy.js +7 -11
- package/dist/src/gateway/rate-limit/buckets.d.ts +6 -0
- package/dist/src/gateway/rate-limit/buckets.js +211 -189
- package/dist/src/gateway/rate-limit/env-flags.js +4 -1
- package/dist/src/gateway/rate-limit/index.js +13 -4
- package/dist/src/gateway/runtime-config.js +5 -3
- package/dist/src/gateway/security/audit.js +3 -2
- package/dist/src/gateway/security/browser-session.js +2 -1
- package/dist/src/gateway/security/device-request-proof.d.ts +28 -0
- package/dist/src/gateway/security/device-request-proof.js +122 -0
- package/dist/src/gateway/security/loopback.js +7 -6
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/session-command-service.js +1 -1
- package/dist/src/gateway/service.js +12 -10
- package/dist/src/gateway/tailscale-auth.js +2 -1
- package/dist/src/gateway/ws-security.js +2 -1
- package/dist/src/home-intelligence/generator.js +1 -1
- package/dist/src/infra/rate-limit/failure-limiter.js +78 -90
- package/dist/src/infra/rate-limit/index.js +11 -3
- package/dist/src/infra/rate-limit/keyed-store.js +52 -47
- package/dist/src/infra/rate-limit/rate-limiter.js +55 -58
- package/dist/src/infra/update-service-refresh.js +2 -1
- package/dist/src/notes/service.js +1 -1
- package/dist/src/observability/runtime.js +1 -1
- package/dist/src/personal-agent/proactivity/service.js +2 -2
- package/dist/src/personal-agent/reply-composer.js +2 -2
- package/dist/src/personal-agent/repository.d.ts +3 -0
- package/dist/src/personal-agent/repository.js +1 -0
- package/dist/src/personal-agent/service.d.ts +6 -2
- package/dist/src/personal-agent/service.js +4 -3
- package/dist/src/platform/client.d.ts +1 -1
- package/dist/src/platform/contracts.d.ts +1 -1
- package/dist/src/platform/index.js +1 -1
- package/dist/src/providers/index.js +4 -4
- package/dist/src/providers/model-registry.js +2 -2
- package/dist/src/providers/provider-auth-service.js +1 -1
- package/dist/src/providers/provider-disconnect-core.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/providers/xopc-cloud-catalog-coordinator.js +1 -1
- package/dist/src/realtime/runtime.js +6 -0
- package/dist/src/realtime/tickets.d.ts +1 -0
- package/dist/src/realtime/tickets.js +4 -0
- package/dist/src/remote-access/exposure-guards.js +2 -1
- package/dist/src/share/share-rate-limit.js +2 -1
- package/dist/src/share/share-url.js +2 -1
- package/dist/src/share/site-share-router.js +2 -1
- package/dist/src/storage/sqlite/device-access-repository.d.ts +7 -0
- package/dist/src/storage/sqlite/device-access-repository.js +22 -4
- package/dist/src/storage/sqlite/migrations/243_voice_opening_greetings.sql +12 -0
- package/dist/src/storage/sqlite/migrations/244_device_request_proofs.sql +8 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/task-main-update-decision-service.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tunnel/broker-client.js +2 -0
- package/dist/src/tunnel/tunnel-config.js +2 -2
- package/dist/src/tunnel/tunnel-rate-limit.js +2 -1
- package/dist/src/utils/logger/redact.js +4 -1
- package/dist/src/voice/platform-streams.d.ts +6 -0
- package/dist/src/voice/platform-streams.js +43 -4
- package/dist/src/voice/realtime/agentEngine.js +138 -83
- package/dist/src/voice/realtime/engine.d.ts +6 -0
- package/dist/src/voice/realtime/opening-greeting.d.ts +12 -0
- package/dist/src/voice/realtime/opening-greeting.js +22 -0
- package/dist/src/voice/realtime/runtime.js +90 -1
- package/dist/src/voice/realtime/runtime.types.d.ts +4 -0
- package/dist/src/work-discovery/service.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/management-settings-D_JQ6_X0.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-BJn6UHAF.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D114UdRI.js +0 -1
|
@@ -12,7 +12,9 @@ import { ALIBABA_REALTIME_TTS_MODEL } from "../tts/providers/alibaba-speech.js";
|
|
|
12
12
|
import { resolveSpeechProviderChain } from "../tts/factory.js";
|
|
13
13
|
import { mergeTtsConfigFromAppConfig } from "../tts/merge-config.js";
|
|
14
14
|
import { voiceConversationInstructions } from "./conversation-context.js";
|
|
15
|
+
import { verifyDeviceConnectionProof } from "../../gateway/security/device-request-proof.js";
|
|
15
16
|
import { createPreauthConnectionBudget } from "../../gateway/security/preauth-connection-budget.js";
|
|
17
|
+
import { claimOpeningGreeting, finishOpeningGreeting, openingGreetingText } from "./opening-greeting.js";
|
|
16
18
|
import { createAgentVoiceEngine } from "./agentEngine.js";
|
|
17
19
|
import { resolveOmniRoute } from "./omniRoute.js";
|
|
18
20
|
import { createOmniVoiceEngine } from "./omniEngine.js";
|
|
@@ -225,12 +227,18 @@ var VoiceRealtimeRuntime = class {
|
|
|
225
227
|
async createSession(request, principalId, now = Date.now()) {
|
|
226
228
|
const { request: resolvedRequest, config, omni, conversationSessionId, stt, tts, inputMode } = await this.prepareSession(request, now);
|
|
227
229
|
request = resolvedRequest;
|
|
230
|
+
const personal = request.conversationId ? getPersonalAgentByConversation(request.conversationId) : null;
|
|
231
|
+
const openingGreeting = request.openingGreeting && request.openingGreeting.initiation === "user" && request.purpose === "conversation" && request.mode === "assistant" && personal?.state === "ready" && personal.voiceCallPreferences.openingGreetingEnabled ? {
|
|
232
|
+
responseId: `greeting_${crypto.randomUUID()}`,
|
|
233
|
+
text: openingGreetingText(personal.userCallName, request.language ?? "zh")
|
|
234
|
+
} : void 0;
|
|
228
235
|
const sessionId = crypto.randomUUID();
|
|
229
236
|
const ticket = crypto.randomBytes(32).toString("base64url");
|
|
230
237
|
const connectionEpoch = crypto.randomInt(1, 4294967296);
|
|
231
238
|
const maxSessionMs = request.purpose === "conversation" ? Math.min(config.voice.realtime.maxConversationMs, omni?.maxSessionSeconds ? omni.maxSessionSeconds * 1e3 : Number.MAX_SAFE_INTEGER) : config.voice.realtime.maxDictationMs;
|
|
232
239
|
const claim = {
|
|
233
240
|
conversationSessionId,
|
|
241
|
+
openingGreeting,
|
|
234
242
|
sessionId,
|
|
235
243
|
connectionEpoch,
|
|
236
244
|
principalId,
|
|
@@ -250,6 +258,10 @@ var VoiceRealtimeRuntime = class {
|
|
|
250
258
|
this.tickets.set(ticketKey(ticket), claim);
|
|
251
259
|
if (request.purpose === "conversation" && request.conversationId) this.conversationReservations.set(request.conversationId, sessionId);
|
|
252
260
|
return {
|
|
261
|
+
...request.openingGreeting ? { openingGreeting: {
|
|
262
|
+
accepted: Boolean(openingGreeting),
|
|
263
|
+
...openingGreeting ? { greetingResponseId: openingGreeting.responseId } : {}
|
|
264
|
+
} } : {},
|
|
253
265
|
sessionId,
|
|
254
266
|
ticket,
|
|
255
267
|
ticketExpiresAt: new Date(claim.expiresAt).toISOString(),
|
|
@@ -394,6 +406,20 @@ var VoiceRealtimeRuntime = class {
|
|
|
394
406
|
let context;
|
|
395
407
|
let unsubscribeMemory;
|
|
396
408
|
let unsubscribeSession;
|
|
409
|
+
let openingTimer;
|
|
410
|
+
let outputReady = false;
|
|
411
|
+
let pendingGreeting;
|
|
412
|
+
const finishGreeting = (identity, result, reason) => {
|
|
413
|
+
try {
|
|
414
|
+
finishOpeningGreeting(identity, result, reason);
|
|
415
|
+
} catch (err) {
|
|
416
|
+
log.warn({
|
|
417
|
+
err,
|
|
418
|
+
...identity,
|
|
419
|
+
phase: "opening_greeting_audit"
|
|
420
|
+
}, "Opening greeting audit failed");
|
|
421
|
+
}
|
|
422
|
+
};
|
|
397
423
|
let inputMutationTail = Promise.resolve();
|
|
398
424
|
const send = (type, payload) => {
|
|
399
425
|
if (!claim || socket.readyState !== WebSocketState.OPEN) return;
|
|
@@ -423,6 +449,11 @@ var VoiceRealtimeRuntime = class {
|
|
|
423
449
|
if (shutdownCompletion) return shutdownCompletion;
|
|
424
450
|
if (closed) return Promise.resolve();
|
|
425
451
|
closed = true;
|
|
452
|
+
clearTimeout(openingTimer);
|
|
453
|
+
if (pendingGreeting) {
|
|
454
|
+
finishGreeting(pendingGreeting, "skipped", "session_closed");
|
|
455
|
+
pendingGreeting = void 0;
|
|
456
|
+
}
|
|
426
457
|
shutdownCompletion = (async () => {
|
|
427
458
|
unsubscribeMemory?.();
|
|
428
459
|
unsubscribeSession?.();
|
|
@@ -476,6 +507,11 @@ var VoiceRealtimeRuntime = class {
|
|
|
476
507
|
shutdown("context_changed", true);
|
|
477
508
|
};
|
|
478
509
|
const authenticate = async (message) => {
|
|
510
|
+
const pendingClaim = this.tickets.get(ticketKey(message.payload.ticket));
|
|
511
|
+
if (pendingClaim && !verifyDeviceConnectionProof(pendingClaim.principalId, message.payload.ticket, new URL(request.url, "http://localhost").pathname + new URL(request.url, "http://localhost").search, typeof request.headers["x-xopc-proof"] === "string" ? request.headers["x-xopc-proof"] : void 0)) {
|
|
512
|
+
socket.close(4401, "Invalid voice session proof");
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
479
515
|
const consumed = this.consumeTicket(message.payload.ticket, message.payload.sessionId);
|
|
480
516
|
if (!consumed || this.options.isPrincipalActive?.(consumed.principalId) === false) {
|
|
481
517
|
if (consumed) this.releaseConversationReservation(consumed);
|
|
@@ -697,7 +733,60 @@ var VoiceRealtimeRuntime = class {
|
|
|
697
733
|
return;
|
|
698
734
|
}
|
|
699
735
|
if (message.type === "session.ping") send("session.pong", {});
|
|
700
|
-
else if (message.type === "session.
|
|
736
|
+
else if (message.type === "session.output_ready") {
|
|
737
|
+
if (!ready || !claim.request.openingGreeting || message.payload.connectionEpoch !== claim.connectionEpoch) {
|
|
738
|
+
socket.close(4400, "Invalid output readiness");
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (outputReady) return;
|
|
742
|
+
outputReady = true;
|
|
743
|
+
const greeting = claim.openingGreeting;
|
|
744
|
+
if (!greeting || !engine?.offerOpeningGreeting) return;
|
|
745
|
+
const identity = {
|
|
746
|
+
principalId: claim.principalId,
|
|
747
|
+
conversationId: claim.request.conversationId,
|
|
748
|
+
logicalCallId: claim.request.openingGreeting.logicalCallId,
|
|
749
|
+
responseId: greeting.responseId
|
|
750
|
+
};
|
|
751
|
+
try {
|
|
752
|
+
if (!claimOpeningGreeting(identity)) return;
|
|
753
|
+
} catch (err) {
|
|
754
|
+
log.warn({
|
|
755
|
+
err,
|
|
756
|
+
sessionId: claim.sessionId
|
|
757
|
+
}, "Opening greeting claim failed");
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const deadlineAt = Date.now() + 2e3;
|
|
761
|
+
pendingGreeting = identity;
|
|
762
|
+
openingTimer = setTimeout(() => {
|
|
763
|
+
openingTimer = void 0;
|
|
764
|
+
pendingGreeting = void 0;
|
|
765
|
+
if (closed) {
|
|
766
|
+
finishGreeting(identity, "skipped", "session_closed");
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
engine.offerOpeningGreeting({
|
|
770
|
+
...greeting,
|
|
771
|
+
deadlineAt
|
|
772
|
+
}).then((result) => {
|
|
773
|
+
finishGreeting(identity, result);
|
|
774
|
+
log.info({
|
|
775
|
+
...identity,
|
|
776
|
+
sessionId: claim?.sessionId,
|
|
777
|
+
phase: "opening_greeting",
|
|
778
|
+
result
|
|
779
|
+
}, "Opening greeting finished");
|
|
780
|
+
}).catch((err) => {
|
|
781
|
+
finishGreeting(identity, "failed");
|
|
782
|
+
log.warn({
|
|
783
|
+
err,
|
|
784
|
+
...identity,
|
|
785
|
+
phase: "opening_greeting"
|
|
786
|
+
}, "Opening greeting failed");
|
|
787
|
+
});
|
|
788
|
+
}, 300);
|
|
789
|
+
} else if (message.type === "session.stop") shutdown(message.payload.reason, true);
|
|
701
790
|
else if (message.type === "session.metric") {
|
|
702
791
|
const { responseId, metric, durationMs } = message.payload;
|
|
703
792
|
const key = `${responseId}:${metric}`;
|
|
@@ -18,6 +18,10 @@ export interface ResolvedStreamingStt {
|
|
|
18
18
|
route: VoiceProviderRoute;
|
|
19
19
|
}
|
|
20
20
|
export interface VoiceTicketClaim {
|
|
21
|
+
openingGreeting?: {
|
|
22
|
+
responseId: string;
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
21
25
|
sessionId: string;
|
|
22
26
|
connectionEpoch: number;
|
|
23
27
|
principalId: string;
|
|
@@ -8,15 +8,15 @@ import { ActivityService } from "../activity/service.js";
|
|
|
8
8
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
9
9
|
import { init_session_key, resolveConversationId } from "../routing/session-key.js";
|
|
10
10
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
11
|
-
import { init_providers, resolveModel } from "../providers/index.js";
|
|
12
|
-
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
13
11
|
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
12
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
14
13
|
import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
|
|
15
14
|
import "../knowledge-memory/index.js";
|
|
16
15
|
import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
|
|
17
16
|
import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
|
|
18
17
|
import "../user-model/index.js";
|
|
19
18
|
import { createWorkDiscoveryRun, getProjectUnderstandingRun, getWorkDiscoveryOnboardingState, getWorkDiscoveryRun, getWorkDiscoveryRunByIdempotencyKey, listPendingProjectUnderstandingRuns, setWorkDiscoveryFeedback, setWorkDiscoveryOnboardingState, updateWorkDiscoveryRun } from "./repository.js";
|
|
19
|
+
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
20
20
|
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
|
|
21
21
|
import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
|
|
22
22
|
import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
|
|
@@ -2,8 +2,8 @@ import { TaskRepository, init_task_repository } from "../../tasks/task-repositor
|
|
|
2
2
|
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
3
3
|
import { init_conversation_repository, resolveRoutedConversation } from "../../storage/sqlite/conversation-repository.js";
|
|
4
4
|
import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
|
|
5
|
-
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
6
5
|
import { extractProfileAgentId, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
7
7
|
import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
8
8
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
9
9
|
import { automationEventPublisher, getAutomationEventForRun } from "../../automations/events/event-repository.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.374",
|
|
4
4
|
"description": "Local-first personal AI with Ada, task delegation, files, projects, workflows, and automations. Use cloud or local models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -165,12 +165,12 @@
|
|
|
165
165
|
"vitepress": "^1.6.4",
|
|
166
166
|
"vitest": "4.1.5",
|
|
167
167
|
"vue": "^3.5.35",
|
|
168
|
-
"@xopcai/browser-control-contract": "0.1.0",
|
|
169
168
|
"@xopcai/computer-control-contract": "0.1.0",
|
|
170
169
|
"@xopcai/endpoint-tools-client": "0.0.0",
|
|
170
|
+
"@xopcai/browser-control-contract": "0.1.0",
|
|
171
171
|
"@xopcai/endpoint-tools-protocol": "0.0.0",
|
|
172
|
-
"@xopcai/gateway-contract": "0.0.0",
|
|
173
172
|
"@xopcai/image-providers": "0.1.0",
|
|
173
|
+
"@xopcai/gateway-contract": "0.0.0",
|
|
174
174
|
"@xopcai/realtime-client": "0.0.0",
|
|
175
175
|
"@xopcai/realtime-protocol": "0.0.0"
|
|
176
176
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./activity-YogQEteU.js";import{t as o}from"./chevron-left-DqFhpbvK.js";import{t as s}from"./chevron-right-BweFrslA.js";import{t as c}from"./popover-select-BgSdSbCL.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./search-DA7gz22f.js";import{t as d}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-C1SUo4gG.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p,n as m,r as h}from"./locale-store-rWFLl-p4.js";import{a as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{s as S}from"./session-api-u_4_kFQt.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as te,o as ne}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as E}from"./index.module-Cd9ENXfk.js";import{Ao as D,No as re,ci as O,ds as ie,js as k,li as A}from"./index-B40-KDN8.js";import{t as j}from"./page-tabs-D2xpUV26.js";import{n as M,r as N,t as P}from"./settings-page-layout-X1x-2Cp9.js";import{t as F}from"./device-pairing-wizard-CvaI5ZJZ.js";import{n as I}from"./settings-loading-skeleton-CAmWMaOT.js";var L=n(),R=e(t(),1),z=r();async function B(e=`GET`,t,n){let r=await p(h(`/api/endpoint-tools/target-authorizations`+(n?`/`+encodeURIComponent(n):``)),{method:e,...t?{body:JSON.stringify(t)}:{}});if(!r.ok)throw Error(r.status===403?`owner`:`unavailable`);return(await r.json()).payload}function ae({devices:e,zh:t}){let n=C(`device-single-call-grants`,()=>B(),{refreshInterval:5e3,shouldRetryOnError:!1}),r=C(n.error?null:`device-grant-conversations`,()=>S({limit:100}),{shouldRetryOnError:!1}),[i,a]=(0,R.useState)(``),[o,s]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),[d,ee]=(0,R.useState)(`weather`),[f,p]=(0,R.useState)(`approximate`),[m,h]=(0,R.useState)(`restaurant`),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1);if(n.error)return null;let b=e.flatMap(e=>e.endpoints.map(t=>({...t,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))),x=b.find(e=>e.endpointId===l)?.tools.find(e=>e.descriptor.name.endsWith(`.device.get_location`))?.descriptor.name,te=async()=>{if(!(!x||!i||!o)){_(!0),y(!1);try{await B(`POST`,{conversationId:i,requestorPrincipalId:o,targetEndpointId:l,toolName:x,arguments:{purpose:d,precision:f,...d===`nearby`?{category:m}:{}}}),await n.mutate()}catch{y(!0)}finally{_(!1)}}};return(0,z.jsxs)(`section`,{className:`mb-5 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,z.jsx)(`h3`,{className:`font-semibold text-fg`,children:t?`跨设备单次授权`:`Single-call device authorization`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t?`为指定会话和来源设备授权一次定位查询,60 秒后失效。目标设备仍需确认;授权后请在来源设备继续请求。`:`Authorize one location query for a conversation and source device. Expires in 60 seconds; target-device consent is still required. Continue the request from the source device.`}),n.isLoading||r.isLoading?(0,z.jsx)(T,{className:`mt-3 h-28`}):(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(c,{value:i,onChange:a,placeholder:t?`选择会话`:`Conversation`,ariaLabel:t?`会话`:`Conversation`,options:(r.data?.items??[]).map(e=>({value:e.key,label:e.name||e.key}))}),(0,z.jsx)(c,{value:o,onChange:s,placeholder:t?`消息来源设备`:`Source device`,ariaLabel:t?`消息来源设备`:`Source device`,options:e.filter(e=>e.endpoints.length>0).map(e=>({value:e.id,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))}),(0,z.jsx)(c,{value:l,onChange:u,placeholder:t?`使用哪台设备的位置`:`Location device`,ariaLabel:t?`目标设备`:`Target device`,options:b.filter(e=>e.tools.some(e=>e.descriptor.name.endsWith(`.device.get_location`))).map(e=>({value:e.endpointId,label:e.label}))}),(0,z.jsx)(c,{placeholder:t?`用途`:`Purpose`,value:d,onChange:e=>ee(e),ariaLabel:t?`用途`:`Purpose`,options:[{value:`weather`,label:t?`查询天气`:`Weather`},{value:`nearby`,label:t?`附近地点`:`Nearby places`}],allowEmpty:!1}),(0,z.jsx)(c,{placeholder:t?`精度`:`Precision`,value:f,onChange:e=>p(e),ariaLabel:t?`精度`:`Precision`,options:[{value:`approximate`,label:t?`大致位置`:`Approximate`},{value:`precise`,label:t?`精确位置`:`Precise`}],allowEmpty:!1}),d===`nearby`?(0,z.jsx)(c,{placeholder:t?`地点类型`:`Category`,value:m,onChange:h,ariaLabel:t?`附近地点类型`:`Place category`,options:[`restaurant`,`cafe`,`pharmacy`,`park`].map((e,n)=>({value:e,label:t?[`餐厅`,`咖啡馆`,`药店`,`公园`][n]:e})),allowEmpty:!1}):null,(0,z.jsx)(w,{variant:`primary`,disabled:g||!i||!o||!x,onClick:()=>void te(),children:t?`允许一次`:`Allow once`})]}),v?(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-fg-muted`,children:t?`授权失败,请检查设备连接后重试。`:`Authorization failed. Check the device connection.`}):null,(0,z.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.data?.map(r=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm text-fg-muted`,children:[(0,z.jsxs)(`span`,{children:[e.find(e=>e.endpoints.some(e=>e.endpointId===r.targetEndpointId))?.displayName??(t?`设备`:`Device`),` · `,r.state===`running`?t?`执行中`:`Running`:t?`等待本次调用`:`Awaiting one call`]}),(0,z.jsx)(w,{disabled:g,onClick:()=>{_(!0),B(`DELETE`,void 0,r.id).then(()=>n.mutate()).catch(()=>y(!0)).finally(()=>_(!1))},children:t?`撤销`:`Revoke`})]},r.id))})]})}var V=720*60*60*1e3;function H(e){let t=[e.access,e.principal].filter(e=>e!==null);return t.length>0&&t.every(e=>e.revokedAt!==void 0)}function U(e){return H(e)?`revoked`:e.endpoints.length>0?`online`:`offline`}function oe(e){return new Set(e.endpoints.flatMap(e=>e.tools.map(({descriptor:e})=>e.name))).size}function se(e,t=Date.now()){return U(e)===`offline`?(e.lastSeenAt??e.createdAt)<t-V:!1}function ce(e,t,n=Date.now()){let r=t.query.trim().toLocaleLowerCase();return e.filter(e=>{let i=U(e),a=t.status===`all`||(t.status===`active`?i!==`revoked`:t.status===`stale`?se(e,n):i===t.status),o=!t.platform||e.platform===t.platform,s=!r||[e.displayName,e.id,e.kind,e.platform].some(e=>e.toLocaleLowerCase().includes(r));return a&&o&&s})}function le(e){return e.length>8?e.slice(-8):e}function ue(e){let t=(0,L.c)(61),{device:n,busy:r,onClose:i,onRevoke:a,onRename:o}=e,s=m(de),c;t[0]===s?c=t[1]:(c=ee(s),t[0]=s,t[1]=c);let l=c.endpointToolsSettings,u=s===`zh`?`zh-CN`:`en`,p;t[2]===u?p=t[3]:(p=new Intl.DateTimeFormat(u,{dateStyle:`medium`,timeStyle:`short`}),t[2]=u,t[3]=p);let h=p,S;t[4]===n?S=t[5]:(S=n?U(n):`offline`,t[4]=n,t[5]=S);let C=S,T=n!==null,E;t[6]===i?E=t[7]:(E=e=>!e&&i(),t[6]=i,t[7]=E);let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,z.jsx)(g,{className:f(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),t[8]=D):D=t[8];let O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=f(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,te),t[9]=O):O=t[9];let ie=n?.displayName??l.deviceDetails,k;t[10]===ie?k=t[11]:(k=(0,z.jsx)(b,{className:`truncate text-base font-semibold text-fg`,children:ie}),t[10]=ie,t[11]=k);let A;t[12]===n?A=t[13]:(A=n?(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[n.kind,` · `,n.platform,` · `,le(n.id)]}):null,t[12]=n,t[13]=A);let j;t[14]!==k||t[15]!==A?(j=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(d,{className:`size-5`,"aria-hidden":!0}),t[17]=M):M=t[17];let N;t[18]===l.close?N=t[19]:(N=(0,z.jsx)(_,{asChild:!0,children:(0,z.jsx)(w,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l.close,children:M})}),t[18]=l.close,t[19]=N);let P;t[20]!==j||t[21]!==N?(P=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[j,N]}),t[20]=j,t[21]=N,t[22]=P):P=t[22];let F;t[23]!==l.accessActive||t[24]!==l.accessRevoked||t[25]!==l.accessTitle||t[26]!==l.createdAt||t[27]!==l.endpointCount||t[28]!==l.endpointsTitle||t[29]!==l.identityId||t[30]!==l.identityTitle||t[31]!==l.lastSeen||t[32]!==l.never||t[33]!==l.noAccessIdentity||t[34]!==l.noOnlineEndpoints||t[35]!==l.noPermissions||t[36]!==l.permissions||t[37]!==l.status||t[38]!==l.statusLabel||t[39]!==l.toolCount||t[40]!==n||t[41]!==h||t[42]!==s||t[43]!==o||t[44]!==C?(F=n?(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[n.principal&&C!==`revoked`&&o?(0,z.jsx)(fe,{device:n,zh:s===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 rounded-xl bg-surface-hover/40 p-4`,children:[(0,z.jsx)(W,{label:l.statusLabel,value:l.status[C]}),(0,z.jsx)(W,{label:l.lastSeen,value:n.lastSeenAt?h.format(n.lastSeenAt):l.never}),(0,z.jsx)(W,{label:l.endpointCount,value:String(n.endpoints.length)}),(0,z.jsx)(W,{label:l.toolCount,value:String(oe(n))})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.accessTitle}),(0,z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs text-fg-muted`,children:n.access?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{children:n.access.revokedAt?l.accessRevoked:l.accessActive}),(0,z.jsxs)(`p`,{className:`mt-1 break-words`,children:[l.permissions,`: `,n.access.scopes.join(`, `)||l.noPermissions]})]}):(0,z.jsx)(`p`,{children:l.noAccessIdentity})})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.endpointsTitle}),(0,z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n.endpoints.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.noOnlineEndpoints}):null,n.endpoints.map(e=>(0,z.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`min-w-0 break-all text-xs font-medium text-fg`,children:e.endpointId}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[l.status[e.availability],` · v`,e.appVersion]})]}),(0,z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.tools.map(e=>{let{descriptor:t}=e;return(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover/50 px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`break-all text-xs font-medium text-fg`,children:t.title}),(0,z.jsxs)(`p`,{className:`mt-0.5 break-words text-xs text-fg-subtle`,children:[t.requiresForeground?s===`zh`?`需要设备在前台 · `:`Requires foreground · `:``,t.confirmation===`always`?s===`zh`?`每次确认`:`Confirm each time`:s===`zh`?`按已授权范围调用`:`Uses the authorized scope`]})]},t.name)})})]},e.connectionId))]})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.identityTitle}),n.principal&&C!==`revoked`&&o?(0,z.jsx)(fe,{device:n,zh:s===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,z.jsxs)(`dl`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs`,children:[(0,z.jsx)(W,{label:l.identityId,value:n.id,breakAll:!0}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{label:l.createdAt,value:h.format(n.createdAt)})})]})]})]}):null,t[23]=l.accessActive,t[24]=l.accessRevoked,t[25]=l.accessTitle,t[26]=l.createdAt,t[27]=l.endpointCount,t[28]=l.endpointsTitle,t[29]=l.identityId,t[30]=l.identityTitle,t[31]=l.lastSeen,t[32]=l.never,t[33]=l.noAccessIdentity,t[34]=l.noOnlineEndpoints,t[35]=l.noPermissions,t[36]=l.permissions,t[37]=l.status,t[38]=l.statusLabel,t[39]=l.toolCount,t[40]=n,t[41]=h,t[42]=s,t[43]=o,t[44]=C,t[45]=F):F=t[45];let I;t[46]!==r||t[47]!==l.removeDevice||t[48]!==l.revoking||t[49]!==n||t[50]!==a||t[51]!==C?(I=n&&C!==`revoked`?(0,z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,z.jsxs)(w,{variant:`secondary`,className:`w-full text-danger`,disabled:r,onClick:()=>a(n),children:[(0,z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),r?l.revoking:l.removeDevice]})}):null,t[46]=r,t[47]=l.removeDevice,t[48]=l.revoking,t[49]=n,t[50]=a,t[51]=C,t[52]=I):I=t[52];let R;t[53]!==P||t[54]!==F||t[55]!==I?(R=(0,z.jsxs)(v,{children:[D,(0,z.jsxs)(y,{className:O,"aria-describedby":void 0,children:[P,F,I]})]}),t[53]=P,t[54]=F,t[55]=I,t[56]=R):R=t[56];let B;return t[57]!==R||t[58]!==T||t[59]!==E?(B=(0,z.jsx)(x,{open:T,onOpenChange:E,children:R}),t[57]=R,t[58]=T,t[59]=E,t[60]=B):B=t[60],B}function de(e){return e.language}function W(e){let t=(0,L.c)(10),{label:n,value:r,breakAll:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`break-all font-mono text-xs`,c;t[2]===s?c=t[3]:(c=f(`mt-1 text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,z.jsx)(`dd`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function fe({device:e,zh:t,onRename:n}){let[r,i]=(0,R.useState)(e.displayName),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1);return(0,z.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{if(t.preventDefault(),!(a||!r.trim())){o(!0),c(!1);try{await n(e,r.trim())}catch{c(!0)}finally{o(!1)}}},children:[(0,z.jsxs)(`label`,{className:`block text-sm text-fg`,children:[t?`设备名称`:`Device name`,(0,z.jsx)(`input`,{value:r,maxLength:80,onChange:e=>i(e.target.value),className:`mt-2 h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-fg`})]}),(0,z.jsx)(w,{type:`submit`,variant:`secondary`,disabled:a||!r.trim()||r.trim()===e.displayName,children:a?t?`保存中…`:`Saving…`:t?`保存名称`:`Save name`}),s?(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`保存失败,请刷新设备信息后重试。`:`Unable to save. Refresh device information and retry.`}):null]})}function pe(e){let t=(0,L.c)(19),{onPaired:n}=e,[r,a]=i(),o=m(he),s;t[0]===o?s=t[1]:(s=ee(o),t[0]=o,t[1]=s);let c=s.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={open:!1},t[2]=u):u=t[2];let[d,f]=(0,R.useState)(u),p,h;t[3]!==r||t[4]!==a?(p=()=>{let e=r.get(`startDevicePairing`);e!==`mobile`&&e!==`browser`||(f({open:!0,target:e}),a(me,{replace:!0}))},h=[r,a],t[3]=r,t[4]=a,t[5]=p,t[6]=h):(p=t[5],h=t[6]),(0,R.useEffect)(p,h);let g,_;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>f({open:!0}),_=(0,z.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[7]=g,t[8]=_):(g=t[7],_=t[8]);let v;t[9]===c.addDevice?v=t[10]:(v=(0,z.jsxs)(w,{variant:`primary`,onClick:g,children:[_,c.addDevice]}),t[9]=c.addDevice,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>f(t=>({...t,open:e})),t[11]=y):y=t[11];let b;t[12]!==d.open||t[13]!==d.target||t[14]!==n?(b=(0,z.jsx)(F,{open:d.open,onOpenChange:y,onPaired:n,targetKind:d.target}),t[12]=d.open,t[13]=d.target,t[14]=n,t[15]=b):b=t[15];let x;return t[16]!==v||t[17]!==b?(x=(0,z.jsxs)(z.Fragment,{children:[v,b]}),t[16]=v,t[17]=b,t[18]=x):x=t[18],x}function me(e){let t=new URLSearchParams(e);return t.delete(`startDevicePairing`),t}function he(e){return e.language}async function G(e){let t=await e.json().catch(()=>null);if(!e.ok||t?.payload===void 0)throw Error(t?.error?.message??`Endpoint management request failed: ${e.status}`);return t.payload}function ge(){return h(`/api/endpoint-tools/devices`)}function _e(e){let t=new URLSearchParams({page:String(e.page),pageSize:String(e.pageSize)});return e.query.trim()&&t.set(`query`,e.query.trim()),e.principalId&&t.set(`principalId`,e.principalId),e.status&&t.set(`status`,e.status),e.effect&&t.set(`effect`,e.effect),h(`/api/endpoint-tools/invocations?${t}`)}async function ve(){return G(await p(ge()))}async function ye(e){let t=Array.from({length:Math.ceil(e.length/100)},(t,n)=>e.slice(n*100,(n+1)*100));await Promise.all(t.map(async e=>{await G(await p(h(`/api/endpoint-tools/devices/revoke`),{method:`POST`,body:JSON.stringify({ids:e})}))}))}async function be(e){return G(await p(_e(e)))}async function xe(e,t,n){await G(await p(h(`/api/endpoint-tools/devices/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({nickname:t,expectedRevision:n})}))}var Se=5e3,K=20,Ce=20;function we(e){return e===`online`||e===`succeeded`?`bg-success-soft text-success`:e===`running`?`bg-accent-soft text-accent-fg`:e===`failed`||e===`revoked`?`bg-danger-soft text-danger`:`bg-surface-hover text-fg-muted`}function Te(e){let t=(0,L.c)(5),{status:n,label:r}=e,i;t[0]===n?i=t[1]:(i=f(`rounded-full px-2 py-0.5 text-xs font-medium`,we(n)),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`span`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Ee(){let e=m(e=>e.language),t=ee(e).endpointToolsSettings,[n,r]=i(),l=n.get(`view`)===`activity`?`activity`:`devices`,[d,p]=(0,R.useState)(null),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(``),[T,te]=(0,R.useState)(`active`),[ne,F]=(0,R.useState)(``),[L,B]=(0,R.useState)(1),[V,H]=(0,R.useState)(()=>new Set),[de,W]=(0,R.useState)(``),[fe]=E(de,250),[me,he]=(0,R.useState)(``),[G,we]=(0,R.useState)(``),[Ee,De]=(0,R.useState)(``),[Oe,q]=(0,R.useState)(1),ke={page:Oe,pageSize:Ce,query:fe,principalId:me,status:G,effect:Ee},J=C(ge(),ve,{refreshInterval:Se}),Y=C(l===`activity`?_e(ke):null,()=>be(ke),{refreshInterval:Se,keepPreviousData:!0}),Ae=(0,R.useMemo)(()=>new Intl.DateTimeFormat(e===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),[e]);if(J.isLoading&&!J.data)return(0,z.jsx)(N,{children:(0,z.jsx)(I,{sections:2})});let X=J.data??[],je=Y.data?.items??[],Me=X.filter(e=>U(e)===`online`).length,Ne=X.filter(e=>U(e)!==`revoked`).length,Pe=X.filter(e=>se(e)).length,Fe=[...new Set(X.map(e=>e.platform))].toSorted(),Z=ce(X,{query:x,status:T,platform:ne}),Ie=Math.max(1,Math.ceil(Z.length/K)),Q=Math.min(L,Ie),Le=Z.slice((Q-1)*K,Q*K),$=Le.reduce((e,t)=>(U(t)!==`revoked`&&e.push(t.id),e),[]),Re=$.length>0&&$.every(e=>V.has(e)),ze=e=>{r(t=>{let n=new URLSearchParams(t);return e===`devices`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})},Be=async()=>{await Promise.all([J.mutate(),l===`activity`?Y.mutate():Promise.resolve()])},Ve=async()=>{if(!(h.length===0||_)){v(!0),b(!1);try{await ye(h.map(e=>e.id)),g([]),H(new Set),await J.mutate()}catch{b(!0)}finally{v(!1)}}},He=e=>{e(),B(1),H(new Set)};return(0,z.jsxs)(N,{children:[(0,z.jsx)(M,{title:t.title,subtitle:t.subtitle,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(O,{className:`size-9 shrink-0 p-0`,label:t.refresh,onClick:Be}),(0,z.jsx)(pe,{onPaired:()=>void J.mutate()})]})}),J.error||Y.error?(0,z.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger`,children:t.loadError}):null,(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{label:t.activeDevices,value:Ne,filter:`active`},{label:t.onlineDevices,value:Me,filter:`online`},{label:t.staleDevices,value:Pe,filter:`stale`}].map(({label:e,value:t,filter:n})=>(0,z.jsxs)(`button`,{type:`button`,className:f(`touch-target rounded-xl px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,T===n?`bg-surface-active`:`bg-surface-hover/20 hover:bg-surface-hover/50`),"aria-pressed":T===n,onClick:()=>{He(()=>te(n)),ze(`devices`)},children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e}),(0,z.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold text-fg`,children:t})]},n))}),(0,z.jsx)(j,{items:[{id:`devices`,label:t.devicesTab,icon:ie,count:Ne},{id:`activity`,label:t.activityTab,icon:a,count:Y.data?.total}],activeTab:l,onChange:ze,ariaLabel:t.viewsAria,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`}),(0,z.jsxs)(P,{id:`devices`,activeTab:l,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.devicesTitle,hint:t.devicesHint,children:[(0,z.jsx)(ae,{devices:X,zh:e===`zh`}),(0,z.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-[minmax(0,1fr)_11rem_11rem]`,children:[(0,z.jsxs)(`label`,{className:`relative block`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:t.searchDevices}),(0,z.jsx)(u,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":t.searchDevices,value:x,placeholder:t.searchDevices,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>He(()=>S(e.target.value))})]}),(0,z.jsx)(c,{value:T,options:[{value:`active`,label:t.filterActive},{value:`online`,label:t.status.online},{value:`offline`,label:t.status.offline},{value:`stale`,label:t.filterStale},{value:`revoked`,label:t.status.revoked},{value:`all`,label:t.filterAll}],placeholder:t.statusLabel,allowEmpty:!1,ariaLabel:t.statusLabel,onChange:e=>He(()=>te(e))}),(0,z.jsx)(c,{value:ne,options:Fe.map(e=>({value:e,label:e})),placeholder:t.allPlatforms,emptyLabel:t.allPlatforms,ariaLabel:t.platformLabel,onChange:e=>He(()=>F(e))})]}),V.size>0?(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-accent-fg`,children:t.selectedCount.replace(`{{count}}`,String(V.size))}),(0,z.jsxs)(w,{variant:`secondary`,className:`text-danger`,onClick:()=>{b(!1),g(X.filter(e=>V.has(e.id)))},children:[(0,z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t.removeSelected]})]}):null,X.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noDevices}):Z.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingDevices}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-edge-subtle px-1`,children:(0,z.jsxs)(`label`,{className:f(`touch-target flex items-center gap-2 text-xs text-fg-muted`,$.length>0?`cursor-pointer`:`cursor-not-allowed opacity-50`),children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":t.selectPage,checked:Re,disabled:$.length===0,className:`size-4 accent-accent`,onChange:e=>{H(t=>{let n=new Set(t);for(let t of $)e.target.checked?n.add(t):n.delete(t);return n})}}),t.selectPage]})}),(0,z.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:Le.map(e=>{let n=U(e),r=e.kind===`mobile`?D:k;return(0,z.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`label`,{className:f(`touch-target flex size-10 shrink-0 items-center justify-center`,n===`revoked`?`cursor-not-allowed opacity-40`:`cursor-pointer`),children:(0,z.jsx)(`input`,{type:`checkbox`,checked:V.has(e.id),disabled:n===`revoked`,"aria-label":t.selectDevice.replace(`{{name}}`,e.displayName),className:`size-4 accent-accent`,onChange:t=>{H(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}})}),(0,z.jsxs)(`button`,{type:`button`,className:`touch-target flex min-w-0 flex-1 items-center gap-3 py-3 text-left hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>p(e),children:[(0,z.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-inset text-fg-muted`,children:(0,z.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),(0,z.jsx)(Te,{status:n,label:t.status[n]})]}),(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[e.platform,` · `,le(e.id),` · `,t.lastSeen,`: `,e.lastSeenAt?Ae.format(e.lastSeenAt):t.never]})]}),(0,z.jsx)(`span`,{className:`hidden shrink-0 text-right text-xs text-fg-muted sm:block`,children:t.endpointSummary.replace(`{{endpoints}}`,String(e.endpoints.length)).replace(`{{tools}}`,String(oe(e)))}),(0,z.jsx)(s,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]},e.id)})}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Q-1)*K+1)).replace(`{{to}}`,String(Math.min(Q*K,Z.length))).replace(`{{total}}`,String(Z.length))}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Q<=1,onClick:()=>B(e=>Math.max(1,e-1)),children:(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Q>=Ie,onClick:()=>B(e=>Math.min(Ie,e+1)),children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]})]})]})]}),(0,z.jsxs)(P,{id:`activity`,activeTab:l,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.callsTitle,hint:t.callsHint,children:[(0,z.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,z.jsxs)(`label`,{className:`relative block sm:col-span-2 lg:col-span-1`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:t.searchActivity}),(0,z.jsx)(u,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":t.searchActivity,value:de,placeholder:t.searchActivity,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>{W(e.target.value),q(1)}})]}),(0,z.jsx)(c,{value:me,options:X.map(e=>({value:e.id,label:`${e.displayName} · ${le(e.id)}`})),placeholder:t.allDevices,emptyLabel:t.allDevices,ariaLabel:t.deviceLabel,onChange:e=>{he(e),q(1)}}),(0,z.jsx)(c,{value:G,options:[{value:`running`,label:t.status.running},{value:`succeeded`,label:t.status.succeeded},{value:`failed`,label:t.status.failed}],placeholder:t.allStatuses,emptyLabel:t.allStatuses,ariaLabel:t.statusLabel,onChange:e=>{we(e),q(1)}}),(0,z.jsx)(c,{value:Ee,options:[{value:`read`,label:t.effects.read},{value:`write`,label:t.effects.write},{value:`destructive`,label:t.effects.destructive}],placeholder:t.allEffects,emptyLabel:t.allEffects,ariaLabel:t.effectLabel,onChange:e=>{De(e),q(1)}})]}),Y.isLoading&&!Y.data?(0,z.jsx)(I,{sections:1}):null,je.length===0&&!Y.isLoading?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingCalls}):null,(0,z.jsx)(`div`,{className:`space-y-2`,children:je.map(e=>(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`break-all text-sm font-medium text-fg`,children:e.toolName}),(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[Ae.format(e.startedAt),` · `,t.effects[e.effect],` · `,e.endpointId]}),e.errorMessage?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.errorMessage}):null]}),(0,z.jsx)(Te,{status:e.status,label:t.status[e.status]})]},e.id))}),Y.data&&Y.data.total>0?(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Y.data.page-1)*Y.data.pageSize+1)).replace(`{{to}}`,String(Math.min(Y.data.page*Y.data.pageSize,Y.data.total))).replace(`{{total}}`,String(Y.data.total))}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Y.data.page<=1,onClick:()=>q(e=>Math.max(1,e-1)),children:(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Y.data.page>=Y.data.totalPages,onClick:()=>q(e=>Math.min(Y.data.totalPages,e+1)),children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]})]}):null]}),(0,z.jsx)(ue,{device:d,busy:_,onRename:async(e,t)=>{await xe(e.id,t,e.settingsRevision??0),p((await J.mutate())?.find(t=>t.id===e.id)??null)},onClose:()=>p(null),onRevoke:e=>{p(null),b(!1),g([e])}}),(0,z.jsx)(A,{open:h.length>0,title:h.length>1?t.removeManyTitle:t.removeTitle,description:`${h.length>1?t.removeManyDescription.replace(`{{count}}`,String(h.length)):t.removeDescription.replace(`{{name}}`,h[0]?.displayName??``)}${y?`\n\n${t.revokeError}`:``}`,confirmLabel:_?t.revoking:t.removeDevice,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Ve(),onCancel:()=>{_||g([])}})]})}export{Ee as EndpointToolsManagementSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./popover-select-BgSdSbCL.js";import{x as s}from"./markdown-view-BHFFusQs.js";import{t as c}from"./play-kxZvpBg8.js";import{t as l}from"./settings-2-D-csvaET.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./messages-C1SUo4gG.js";import{a as f,n as p,r as m}from"./locale-store-rWFLl-p4.js";import{rt as h,t as g,u as _,w as v}from"./session-manager-B06ZCie_.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-C3DSFZCi.js";import{t as T}from"./skeleton-BwbyijEw.js";import{t as E}from"./date-formatters-CUZAyDEg.js";import{$i as ee,$o as D,Eo as O,Ji as k,Jr as A,K as j,Lc as M,Q as te,Rc as ne,Sa as re,bs as ie,da as N,do as ae,ea as P,ha as oe,n as se,q as ce,wa as F,zc as le}from"./index-B40-KDN8.js";import{l as I,n as ue,t as de}from"./voice-config-api-6MINytQl.js";var L=n(),R=e(t(),1),z=r();function B(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var fe=B();function pe({zh:e}){let[t,n]=(0,R.useState)(),[r,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=c.trim().toLowerCase().replaceAll(`_`,` `),d=[...new Set([...fe,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(u)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,R.useEffect)(()=>{let e=!0;return f(m(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(h.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){s(!0),i(``);try{let r=await f(m(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(h.parse(r.payload))}catch(e){i(String(e));let t=await f(m(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(h.parse(t.payload))}finally{s(!1)}}}return(0,z.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,z.jsx)(T,{className:`h-9 w-full`}):t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(o,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:a,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void p({mode:e})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,z.jsx)(o,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietStart:Number(e)})})]}),(0,z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,z.jsx)(o,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietEnd:Number(e)})})]})]}),(0,z.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,z.jsx)(o,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:d,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:c,onSearchChange:l,statusMessage:d.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{l(``),e!==t.timezone&&p({timezone:e})}})]}),(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var V=[`intro`,`identity`,`voice`,`connections`],me=[{id:`loopi`,zh:`小环`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function he(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function ge(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await f(m(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),ee(e)}function _e({modelsAvailable:e,onCreated:t}){let n=p(e=>e.language)===`zh`,r=p(e=>e.language),[o,s]=(0,R.useState)(`intro`),[l,u]=(0,R.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[h,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null),[x,S]=(0,R.useState)(null),[C,w]=(0,R.useState)(null),[E,ee]=(0,R.useState)(null),[D,O]=(0,R.useState)(!0),[A,M]=(0,R.useState)([]),[ie,N]=(0,R.useState)(null),P=(0,R.useRef)(null),se=(0,R.useRef)(null),[L,B]=(0,R.useState)([]),[fe,pe]=(0,R.useState)(!0),[_e,ve]=(0,R.useState)([]),[H,U]=(0,R.useState)(null);(0,R.useEffect)(()=>{let e=!1;return f(m(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),u(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!0)}),()=>{e=!0}},[]),(0,R.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>{f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:l})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[l,h,o]),(0,R.useEffect)(()=>{let e=!1;return de().then(t=>{e||(t.tts&&t.enabled?ee({provider:t.tts.provider,model:t.tts.model,enabled:!0}):O(!1))}).catch(()=>{e||O(!1)}),()=>{e=!0}},[]),(0,R.useEffect)(()=>{if(!E?.enabled)return;let e=!1;return ue(E.provider,E.model,`realtime`).then(t=>{e||M(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||O(!1)}),()=>{e=!0}},[E]),(0,R.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return pe(!0),Promise.allSettled([re({page:1,pageSize:24,verification:`verified`}),F()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];B(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&ve(n.value),pe(!1)}}),()=>{e=!0}},[o]),(0,R.useEffect)(()=>()=>{se.current?.abort(),P.current?.close()},[]),(0,R.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let W=async(e,t=l)=>{await f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},ye=async e=>{b(null);let t=V[Math.max(0,Math.min(V.length-1,V.indexOf(o)+e))];try{await W(t)}catch(e){b(e instanceof Error?e.message:String(e))}},G=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:l,r=e.voice&&E?.enabled&&A.some(t=>t.id===e.voice)?{provider:E.provider,model:E.model,voice:e.voice}:void 0,i=(await f(m(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await ge(i.agentId,x),i=(await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,R.useCallback)(async e=>{se.current?.abort(),P.current?.close();let t=new AbortController;se.current=t,N(e),b(null);try{let n=new oe;P.current=n,await n.start();let r=await I(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>N(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),N(null)}},[]);if(!h)return(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,z.jsx)(T,{className:`h-10 w-2/3`}),(0,z.jsx)(T,{className:`h-64 w-full rounded-2xl`}),(0,z.jsx)(T,{className:`h-12 w-full rounded-xl`})]});let K=V.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,z.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,z.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void ye(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,z.jsx)(le,{className:`size-4`}),n?`上一步`:`Back`]}):(0,z.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,z.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,z.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":V.length,children:V.map((e,t)=>(0,z.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,z.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,z.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,z.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,z.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,z.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,z.jsx)(k,{appearance:l.appearance,className:`size-14`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,z.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:l.displayName||`Ada`})]})]}),(0,z.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${V.length} 步`:`Step ${K+1} of ${V.length}`}),(0,z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,z.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,z.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,z.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,z.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,z.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,z.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,z.jsx)(`input`,{value:l.displayName,maxLength:60,onChange:e=>u(t=>({...t,displayName:e.target.value})),onBlur:()=>u(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[me.map(e=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&l.appearance===e.id,onClick:()=>{S(null),w(null),u(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&l.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,z.jsx)(k,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,z.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,z.jsx)(ae,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,z.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}S(t),w(URL.createObjectURL(t))}}})]})]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,z.jsxs)(`div`,{className:`mt-5`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),D?(0,z.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(T,{className:`h-20 rounded-xl`}),(0,z.jsx)(T,{className:`h-20 rounded-xl`})]}):E?.enabled&&A.length>0?(0,z.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-pressed":!l.voice,onClick:()=>u(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${l.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),A.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${l.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":l.voice===e.id,onClick:()=>u(t=>({...t,voice:e.id})),children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,z.jsx)(c,{className:`size-4 ${ie===e.id?`text-accent`:``}`})})]},e.id))]}):(0,z.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,z.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,z.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,z.jsxs)(`div`,{className:`mt-5`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),fe?(0,z.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,z.jsx)(T,{className:`h-18 rounded-xl`}),(0,z.jsx)(T,{className:`h-18 rounded-xl`})]}):(0,z.jsx)(`div`,{className:`mt-5 space-y-2`,children:L.length?L.map(e=>{let t=he(_e.find(t=>t.connectorId===e.id));return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,z.jsx)(te,{connector:e,size:`sm`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,z.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,z.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,z.jsx)(`button`,{type:`button`,onClick:()=>U(j(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,z.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,z.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,z.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,z.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,z.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void G(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let e={...l,voice:null};u(e),b(null),W(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,z.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void G():void ye(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,z.jsx)(ne,{className:`size-4`})]})]})]})}),H&&(0,z.jsx)(ce,{draft:H,onChange:U,onClose:()=>U(null),t:d(r).connectorsSettings,onInstalled:async()=>{ve(await F()),U(null)}})]})}function ve({record:e,zh:t,onSelectVoice:n}){let[r,a]=(0,R.useState)(!0),[s,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)([]),[m,h]=(0,R.useState)(e.voicePreference?.voice??``),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),S=(0,R.useRef)(null),C=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await de();if(e||!t.enabled||!t.tts)return;let n={provider:t.tts.provider,model:t.tts.model};d(n);let r=await ue(n.provider,n.model,`realtime`);e||p(r)}catch(t){e||y(t instanceof Error?t.message:String(t))}finally{e||a(!1)}})(),()=>{e=!0}},[]),(0,R.useEffect)(()=>()=>{C.current?.abort(),S.current?.close()},[]);let w=()=>{C.current?.abort(),C.current=null,S.current?.close(),S.current=null,x(null)},E=async e=>{if(b!==null){w();return}w(),y(null);let t=new AbortController;C.current=t,x(e);try{let n=new oe;S.current=n,await n.start();let r=await I(t.signal,e);t.signal.aborted||n.enqueue(r,()=>{C.current===t&&(x(null),C.current=null,S.current=null,n.close())})}catch(e){t.signal.aborted||y(e instanceof Error?e.message:String(e)),C.current===t&&w()}},ee=async e=>{if(g||e===m)return;w();let t=m;h(e),l(``),_(!0),y(null);try{await n(e&&u?{provider:u.provider,model:u.model,voice:e}:null)||h(t)}catch(e){h(t),y(e instanceof Error?e.message:String(e))}finally{_(!1)}},D=f.find(e=>e.id===m),k=t?`默认声音`:`Default voice`,A=D?.name||(m?t?`当前音色不可用`:`Current voice unavailable`:k),j=s.trim().toLocaleLowerCase(),M=f.filter(e=>!j||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(j)).map(e=>({value:e.id,label:e.name}));return(0,z.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),r?(0,z.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,z.jsx)(T,{className:`h-10 w-full`})}):u&&f.length?(0,z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(o,{value:m,selectedLabel:A,options:M,placeholder:k,emptyLabel:k,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:g,onChange:e=>void ee(e),searchPlaceholder:f.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:s,onSearchChange:l,statusMessage:j&&!M.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,z.jsxs)(`button`,{type:`button`,disabled:g||!!(m&&!D),onClick:()=>void E(m),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:b===null?t?`试听${A}`:`Preview ${A}`:t?`停止试听`:`Stop preview`,"aria-label":b===null?t?`试听${A}`:`Preview ${A}`:t?`停止试听`:`Stop preview`,children:[b===null?(0,z.jsx)(c,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),b===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:D?.description||D?.style||(m?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,z.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,z.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),v&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:v})]})}var H=new g;function U({conversationId:e,zh:t,onSaved:n}){let r=v(t=>t.sessions[e]),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(``);(0,R.useEffect)(()=>{let t=!0;return H.loadSessionAgentConfig(e).then(n=>{t&&_(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let c=!!(r?.sending||r?.streaming||r?.modelConfigSaving);async function l(t,i){v.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{_(e,await H.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await H.loadSessionAgentConfig(e).catch(()=>null);throw n&&_(e,n),t}finally{v.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,z.jsx)(T,{className:`h-9 w-full`}):(0,z.jsx)(A,{chat:d(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:c,thinkingDisabled:c,onModelChange:l,onThinkingChange:e=>l(r?.model??``,e)}),o&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var W=5;function ye(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function G(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function be(e){let t=(0,L.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=G(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,c;t[3]===n.id?c=t[4]:(c=s(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,u;t[5]===l?u=t[6]:(u=(0,z.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ye(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,z.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===o.label?p=t[12]:(p=(0,z.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=E(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,z.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,z.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,z.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,z.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var K=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],xe=[{id:`loopi`,zh:`小环`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Se(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function Ce(e){return K.find(t=>t.warmth===e.warmth)?.id??`natural`}function we(){let e=N(),t=(0,R.useRef)(e);t.current=e;let n=p(e=>e.language)===`zh`,r=P(e=>e.setPageHeader),i=P(e=>e.clearPageHeader),[a,s]=(0,R.useState)(null),c=(0,R.useRef)(null),d=(0,R.useRef)(Promise.resolve()),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(!0),[E,O]=(0,R.useState)(0),[A,j]=(0,R.useState)(null),[M,te]=(0,R.useState)(!0),[ne,re]=(0,R.useState)(!1),[oe,ce]=(0,R.useState)(`natural`),[F,le]=(0,R.useState)(`loopi`),[I,ue]=(0,R.useState)(!1),de=(0,R.useRef)(null),L=(0,R.useRef)(null),B=(0,R.useRef)(null),[fe,V]=(0,R.useState)(``),[me,he]=(0,R.useState)(`untangle`),[ge,H]=(0,R.useState)(`none`),[ye,G]=(0,R.useState)(`balanced`),[we,Te]=(0,R.useState)(`decisions`),[Ee,De]=(0,R.useState)(!1),[Oe,q]=(0,R.useState)(!1),[J,ke]=(0,R.useState)(!1),[Y,Ae]=(0,R.useState)(null),[je,Me]=(0,R.useState)(!1),[X,Ne]=(0,R.useState)(!1),[Pe,Fe]=(0,R.useState)(!1),[Z,Ie]=(0,R.useState)(0),Q=(0,R.useRef)(0),Le=(0,R.useCallback)(()=>{ke(!1),q(!1),De(!0)},[]),Re=(0,R.useCallback)(()=>{ke(!1),q(!1),De(e=>!e)},[]),ze=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(m(`/api/personal-agent`)),f(m(`/api/personal-agent/models`))]);if(c.current=e.payload,s(e.payload),e.payload?.state===`ready`){let e=await f(m(`/api/personal-agent/onboarding`));te(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),g(t.payload),e.payload&&(V(e.payload.displayName),le(e.payload.appearance),ce(Ce(e.payload.preferences)),he(e.payload.preferences.supportMode??`untangle`),H(e.payload.preferences.humor??`none`),G(e.payload.preferences.detailLevel??`balanced`),Te(e.payload.preferences.proactivity??`decisions`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{v(!1)}},[]);(0,R.useEffect)(()=>{ze()},[ze]);let $=(0,R.useCallback)(e=>{O(e=>e+1),j(null);let t=d.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference))return!0;try{let o=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a}})});return c.current=o.payload,s(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return j(e instanceof Error?e.message:String(e)),!1}}).finally(()=>O(e=>e-1));return d.current=t,t},[]),Be=async e=>{if(a){j(null);try{if(e){let t=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,s(t.payload)}await f(m(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),te(!0)}catch(e){j(e instanceof Error?e.message:String(e))}}},Ve=(0,R.useCallback)(async()=>{let e=++Q.current;ke(!0),Ae(null),Me(!1),Ne(!1),Fe(!1),Ie(0);try{let t=await f(m(`/api/personal-agent/activity?limit=${W}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{e===Q.current&&Me(!0)}},[]),He=(0,R.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Ne(!0),Fe(!1);try{let t=await f(m(`/api/personal-agent/activity?limit=${W}&offset=${Z}`));if(e!==Q.current)return;Ae(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Ie(e=>e+t.payload.items.length)}catch{e===Q.current&&Fe(!0)}finally{e===Q.current&&Ne(!1)}},[Y,Z,X]);(0,R.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await f(m(`/api/personal-agent/activity?limit=${Math.max(W,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let Ue=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){j(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){j(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ue(!0),j(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await f(m(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),ee(a.agentId),le(`custom`),q(!1),await $({appearance:`custom`})}catch(e){j(e instanceof Error?e.message:String(e))}finally{ue(!1)}};(0,R.useLayoutEffect)(()=>{let o=a?.state===`ready`,s=o?a.appearance:F,c=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,z.jsx)(`button`,{ref:B,type:`button`,onClick:Re,"aria-expanded":Ee,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${c}的资料`:`Edit ${c}'s profile`,title:n?`资料`:`Profile`,children:(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,z.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})})}):(0,z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,z.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})}),(0,z.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:c})]}),end:o?(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,z.jsx)(D,{className:`size-5`})}),(0,z.jsxs)(x,{open:J,onOpenChange:e=>{e?Ve():ke(!1)},children:[(0,z.jsx)(C,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,z.jsx)(ie,{className:`size-5`})})}),(0,z.jsx)(y,{children:(0,z.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-inset shadow-xl focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,z.jsx)(S,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,z.jsx)(u,{className:`size-4`})})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!je&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(T,{className:`h-18 rounded-2xl`}),(0,z.jsx)(T,{className:`h-18 rounded-2xl`}),(0,z.jsx)(T,{className:`h-18 rounded-2xl`})]}),je&&(0,z.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Ve(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,z.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,z.jsx)(ie,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,z.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,z.jsx)(be,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,z.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void He(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Pe&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,z.jsx)(`button`,{ref:L,type:`button`,onClick:Re,"aria-expanded":Ee,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,z.jsx)(l,{className:`size-5`})})]}):null}),()=>i()},[Y,je,Z,X,Pe,F,i,He,Ve,a,r,J,Ee,Re,e.active,n]);function We(){return a?(0,z.jsxs)(x,{open:Ee,onOpenChange:e=>{De(e),e||q(!1)},children:[(0,z.jsx)(w,{virtualRef:L}),(0,z.jsx)(y,{children:(0,z.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(L.current?.contains(e.target)||B.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,z.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>q(e=>!e),"aria-expanded":Oe,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,z.jsx)(k,{appearance:F,agentId:a.agentId,className:`size-20`})}),(0,z.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:fe,onChange:e=>V(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(V(t),$({displayName:t})):V(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,V(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),E>0&&(0,z.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[A&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:A}),Oe&&(0,z.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[xe.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{le(e.id),q(!1),$({appearance:e.id})},"aria-pressed":F===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${F===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,z.jsx)(k,{appearance:e.id,className:`size-8`})}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,z.jsx)(`input`,{ref:de,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&Ue(t),e.currentTarget.value=``}}),(0,z.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>de.current?.click(),"aria-pressed":F===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${F===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:F===`custom`?(0,z.jsx)(k,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,z.jsx)(ae,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:I?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,z.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:K.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{ce(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":oe===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${oe===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":me===e,onClick:()=>{he(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${me===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,z.jsx)(o,{value:ye??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;G(t),$({preferences:{detailLevel:t}})}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,z.jsx)(o,{value:we??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;Te(t),$({preferences:{proactivity:t}})}})]})]}),(0,z.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,z.jsx)(o,{value:ge??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;H(t),$({preferences:{humor:t}})}})]})]}),(0,z.jsx)(pe,{zh:n}),(0,z.jsx)(ve,{record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,z.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,z.jsx)(U,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await f(m(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}})})]})]})})]}):null}return _?(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,z.jsx)(T,{className:`h-20 w-20 rounded-full`}),(0,z.jsx)(T,{className:`h-9 w-72`}),(0,z.jsx)(T,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ne&&(0,z.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,z.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{re(!1),Le()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(se,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,z.jsx)(k,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:Se(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Be(e),onSkipSupport:()=>void Be(),supportChoiceError:A},conversationId:a.conversationId})})}),We()]}):(0,z.jsx)(_e,{modelsAvailable:h.length>0,onCreated:(e,t)=>{c.current=e,s(e),V(e.displayName),te(!1),re(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{we as PersonalPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Sn as e}from"./index-B40-KDN8.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|