@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, init_package_version } from "../package-version.js";
|
|
2
|
-
import { SERVICE_VERSION_ENV_KEY } from "./constants.js";
|
|
2
|
+
import { SERVICE_VERSION_ENV_KEY, init_constants } from "./constants.js";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
//#region src/daemon/service-audit.ts
|
|
@@ -14,6 +14,7 @@ import { readFile } from "node:fs/promises";
|
|
|
14
14
|
* - Platform-specific configuration issues
|
|
15
15
|
*/
|
|
16
16
|
init_package_version();
|
|
17
|
+
init_constants();
|
|
17
18
|
/** Audit installed service configuration against current config and version */
|
|
18
19
|
async function auditGatewayServiceConfig(params) {
|
|
19
20
|
const { service, env = process.env, expectedToken, expectedPort, currentVersion = PACKAGE_VERSION } = params;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, init_package_version } from "../package-version.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
-
import { SERVICE_VERSION_ENV_KEY } from "./constants.js";
|
|
4
|
+
import { SERVICE_VERSION_ENV_KEY, init_constants } from "./constants.js";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
//#region src/daemon/service.ts
|
|
7
7
|
/**
|
|
@@ -14,6 +14,7 @@ import { existsSync } from "node:fs";
|
|
|
14
14
|
*/
|
|
15
15
|
init_logger();
|
|
16
16
|
init_package_version();
|
|
17
|
+
init_constants();
|
|
17
18
|
const log = createLogger("DaemonService");
|
|
18
19
|
let _isDaemonAvailable = null;
|
|
19
20
|
async function resolveGatewayService() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { resolveGatewaySystemdServiceName, resolveSystemdUnitPath } from "./constants.js";
|
|
3
|
+
import { init_constants, resolveGatewaySystemdServiceName, resolveSystemdUnitPath } from "./constants.js";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
@@ -17,6 +17,7 @@ import { access, constants as constants$1, mkdir, readFile, rm, writeFile } from
|
|
|
17
17
|
* - network-online.target dependency
|
|
18
18
|
*/
|
|
19
19
|
init_logger();
|
|
20
|
+
init_constants();
|
|
20
21
|
const log = createLogger("SystemdService");
|
|
21
22
|
function resolveProfileFromEnv(env) {
|
|
22
23
|
return env?.XOPC_PROFILE?.trim() || void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
2
1
|
import { PROVIDER_ENV_MAP, init_env_keys } from "../providers/env-keys.js";
|
|
2
|
+
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
3
|
import { init_providers, isProviderConfiguredSync } from "../providers/index.js";
|
|
4
4
|
import { collectSttProviderConfigEntries } from "../voice/stt/config-slice.js";
|
|
5
5
|
import { mergeSttConfigFromAppConfig } from "../voice/stt/config.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { isLoopbackHost } from "./host.js";
|
|
1
|
+
import { init_host, isLoopbackHost } from "./host.js";
|
|
2
2
|
import net from "node:net";
|
|
3
3
|
//#region src/gateway/client-ip.ts
|
|
4
|
+
init_host();
|
|
4
5
|
function stripIpv6Brackets(value) {
|
|
5
6
|
if (value.startsWith("[") && value.endsWith("]")) return value.slice(1, -1);
|
|
6
7
|
return value;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { init_host, resolveAllowedBrowserOrigins, resolveGatewayServiceListenPort } from "../host.js";
|
|
3
4
|
import { init_device_access_repository, listDevices } from "../../storage/sqlite/device-access-repository.js";
|
|
4
5
|
import { ENDPOINT_MAX_FILE_BYTES, init_src } from "../../../packages/endpoint-tools-protocol/src/index.js";
|
|
5
|
-
import { resolveAllowedBrowserOrigins, resolveGatewayServiceListenPort } from "../host.js";
|
|
6
6
|
import { resolveGatewayEffectiveHost } from "../../config/gateway-bind.js";
|
|
7
7
|
import { loadTunnelState } from "../../tunnel/tunnel-state.js";
|
|
8
8
|
import { resolveReverseProxyPublicUrl } from "../public-url.js";
|
|
@@ -34,6 +34,7 @@ import { getConnInfo } from "@hono/node-server/conninfo";
|
|
|
34
34
|
//#region src/gateway/hono/app.ts
|
|
35
35
|
init_src();
|
|
36
36
|
init_logger();
|
|
37
|
+
init_host();
|
|
37
38
|
init_device_access_repository();
|
|
38
39
|
const log = createLogger("Gateway:App");
|
|
39
40
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { normalizeAgentId } from "../../../agent-catalog/id.js";
|
|
2
2
|
import { AgentCatalogRepository, init_repository } from "../../../agent-catalog/repository.js";
|
|
3
3
|
import { init_agent_scope, listAgentEntries, resolveDefaultAgentId } from "../../../agent/agent-scope.js";
|
|
4
|
-
import { ContextPlanningConfigSchema, KnowledgeMemoryConfigSchema, UserModelConfigSchema, init_config } from "../../../user-context/config.js";
|
|
5
4
|
import { resolveModelsJsonPath } from "../../../config/paths.js";
|
|
6
|
-
import { init_models_json, loadModelsJson } from "../../../config/models-json.js";
|
|
7
5
|
import { CredentialResolver, init_credentials } from "../../../auth/credentials.js";
|
|
6
|
+
import { ContextPlanningConfigSchema, KnowledgeMemoryConfigSchema, UserModelConfigSchema, init_config } from "../../../user-context/config.js";
|
|
7
|
+
import { init_models_json, loadModelsJson } from "../../../config/models-json.js";
|
|
8
8
|
import { getProviderRegistry, init_plugin_registry } from "../../../providers/plugin-registry.js";
|
|
9
9
|
import { getAllProviders, init_providers, isProviderConfigured } from "../../../providers/index.js";
|
|
10
10
|
import { resolveShareConfig } from "../../../share/share-config.js";
|
|
@@ -13,12 +13,10 @@ export interface AuthConfig {
|
|
|
13
13
|
export declare function auth(config?: AuthConfig): import("hono").MiddlewareHandler<any, string, {}, (Response & import("hono").TypedResponse<{
|
|
14
14
|
error: string;
|
|
15
15
|
code: string;
|
|
16
|
-
|
|
17
|
-
retryAfter: number;
|
|
18
|
-
}, 429, "json">) | (Response & import("hono").TypedResponse<{
|
|
16
|
+
}, 401, "json">) | (Response & import("hono").TypedResponse<{
|
|
19
17
|
error: string;
|
|
20
18
|
code: string;
|
|
21
|
-
},
|
|
19
|
+
}, 403, "json">) | (Response & import("hono").TypedResponse<{
|
|
22
20
|
error: string;
|
|
23
21
|
code: string;
|
|
24
|
-
},
|
|
22
|
+
}, 429, "json">)>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { logAuthEvent } from "../../../utils/logger/audit.js";
|
|
2
2
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../../../utils/logger.js";
|
|
4
|
-
import { authenticateDeviceAccessToken, getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
5
|
-
import { safeEqualSecret } from "../../security/secret-equal.js";
|
|
6
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
7
4
|
import { authPolicyConfig, buckets, resolveAuthRateLimit } from "../../rate-limit/buckets.js";
|
|
8
5
|
import { resolveAuthTracking } from "../../rate-limit/auth-policy.js";
|
|
9
6
|
import { isAuthRateLimitGloballyDisabled } from "../../rate-limit/env-flags.js";
|
|
10
|
-
import "../../rate-limit/index.js";
|
|
7
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
8
|
+
import { authenticateDeviceAccessToken, getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
9
|
+
import { getOrCreateGatewayIdentity, init_gateway_identity_repository } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
10
|
+
import { safeEqualSecret } from "../../security/secret-equal.js";
|
|
11
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
11
12
|
import { authenticateBrowserSession } from "../../../storage/sqlite/browser-session-repository.js";
|
|
13
|
+
import { PROOF_HEADER, acquireProofBodyBudget, consumeRequestNonce, parseRequestProof, proofDigest, requestProofMessage, verifyRequestProofSignature } from "../../security/device-request-proof.js";
|
|
12
14
|
import { isChromeExtensionOrigin } from "../../security/origin-check.js";
|
|
13
15
|
import { browserCookieRequestAllowed, readBrowserSessionCookie, writeBrowserSessionCookie } from "../../security/browser-session.js";
|
|
14
16
|
import { authorizeTrustedProxy } from "../../trusted-proxy.js";
|
|
@@ -16,6 +18,8 @@ import { setGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
|
16
18
|
import { createMiddleware } from "hono/factory";
|
|
17
19
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
18
20
|
//#region src/gateway/hono/middleware/auth.ts
|
|
21
|
+
init_gateway_identity_repository();
|
|
22
|
+
init_rate_limit();
|
|
19
23
|
init_device_access_repository();
|
|
20
24
|
init_logger();
|
|
21
25
|
const log = createLogger("Gateway:Auth");
|
|
@@ -250,16 +254,54 @@ function auth(config) {
|
|
|
250
254
|
error: "Forbidden",
|
|
251
255
|
code: "extension_origin_mismatch"
|
|
252
256
|
}, 403);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
let releaseBodyBudget = () => {};
|
|
258
|
+
try {
|
|
259
|
+
const proofHeader = c.req.header(PROOF_HEADER);
|
|
260
|
+
if (device?.requestProofVersion || proofHeader) {
|
|
261
|
+
const proof = parseRequestProof(proofHeader);
|
|
262
|
+
const url = new URL(c.req.url);
|
|
263
|
+
if (!device || !proof || Math.abs(Date.now() - proof.timestamp) > 12e4 || !verifyRequestProofSignature(device, proof, requestProofMessage({
|
|
264
|
+
gatewayId: getOrCreateGatewayIdentity().id,
|
|
265
|
+
credential: providedCredential,
|
|
266
|
+
method: c.req.method,
|
|
267
|
+
target: url.pathname + url.search,
|
|
268
|
+
headers: (name) => c.req.header(name),
|
|
269
|
+
proof
|
|
270
|
+
}))) return c.json({
|
|
271
|
+
error: "Unauthorized",
|
|
272
|
+
code: "REQUEST_PROOF_INVALID"
|
|
273
|
+
}, 401);
|
|
274
|
+
const release = /^(multipart\/form-data|application\/octet-stream)/i.test(c.req.header("content-type") ?? "") || Number(c.req.header("content-length") ?? 0) > 65536 ? acquireProofBodyBudget(device.id) : () => {};
|
|
275
|
+
if (!release) {
|
|
276
|
+
c.header("Retry-After", "1");
|
|
277
|
+
return c.json({
|
|
278
|
+
error: "Too Many Requests",
|
|
279
|
+
code: "REQUEST_CONCURRENCY_LIMIT"
|
|
280
|
+
}, 429);
|
|
281
|
+
}
|
|
282
|
+
releaseBodyBudget = release;
|
|
283
|
+
if (proofDigest(Buffer.from(await c.req.raw.clone().arrayBuffer())) !== proof.digest) return c.json({
|
|
284
|
+
error: "Unauthorized",
|
|
285
|
+
code: "REQUEST_BODY_MISMATCH"
|
|
286
|
+
}, 401);
|
|
287
|
+
if (!consumeRequestNonce(device.id, proof)) return c.json({
|
|
288
|
+
error: "Unauthorized",
|
|
289
|
+
code: "REQUEST_REPLAYED"
|
|
290
|
+
}, 401);
|
|
291
|
+
}
|
|
292
|
+
recordSuccess(rl);
|
|
293
|
+
setGatewayPrincipal(c, {
|
|
294
|
+
kind: "device",
|
|
295
|
+
principalId: deviceIdentity.deviceId,
|
|
296
|
+
deviceId: deviceIdentity.deviceId,
|
|
297
|
+
accessSessionId: deviceIdentity.accessSessionId,
|
|
298
|
+
scopes: deviceIdentity.scopes
|
|
299
|
+
});
|
|
300
|
+
await next();
|
|
301
|
+
return;
|
|
302
|
+
} finally {
|
|
303
|
+
releaseBodyBudget();
|
|
304
|
+
}
|
|
263
305
|
}
|
|
264
306
|
const blocked = checkBlocked(rl);
|
|
265
307
|
if (blocked.blocked) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
+
import { getClientIpFromHeaders, init_loopback } from "../../security/loopback.js";
|
|
3
4
|
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
|
-
import { getClientIpFromHeaders } from "../../security/loopback.js";
|
|
5
5
|
import { createMiddleware } from "hono/factory";
|
|
6
6
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
7
7
|
//#region src/gateway/hono/middleware/logger.ts
|
|
8
|
+
init_loopback();
|
|
8
9
|
init_logger();
|
|
9
10
|
const log = createLogger("Gateway:HTTP");
|
|
10
11
|
function resolveRemoteAddress(c) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
export type PairingPublicRouteOptions = {
|
|
3
|
+
getTrustedProxyContext?: () => {
|
|
4
|
+
trustedProxies?: string[];
|
|
5
|
+
allowRealIpFallback?: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function pairingClientKey(c: Context, options?: PairingPublicRouteOptions): string;
|
|
9
|
+
/** Shared local-hop budgets allow normal mobile polling while bounding pre-auth work. */
|
|
10
|
+
export declare function publicDeviceRateLimit(family: string, options?: PairingPublicRouteOptions): import("hono").MiddlewareHandler<any, string, {}, Response & import("hono").TypedResponse<{
|
|
11
|
+
ok: false;
|
|
12
|
+
error: {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
}, 429, "json">>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { buckets } from "../../rate-limit/buckets.js";
|
|
2
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
3
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
|
+
import { createMiddleware } from "hono/factory";
|
|
5
|
+
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
6
|
+
//#region src/gateway/hono/middleware/public-device-rate-limit.ts
|
|
7
|
+
init_rate_limit();
|
|
8
|
+
function pairingClientKey(c, options) {
|
|
9
|
+
let remoteAddress;
|
|
10
|
+
try {
|
|
11
|
+
remoteAddress = getConnInfo(c).remote.address;
|
|
12
|
+
} catch {
|
|
13
|
+
remoteAddress = void 0;
|
|
14
|
+
}
|
|
15
|
+
const proxy = options?.getTrustedProxyContext?.();
|
|
16
|
+
return resolveClientIpFromRequest({
|
|
17
|
+
remoteAddress,
|
|
18
|
+
getHeader: (name) => c.req.header(name),
|
|
19
|
+
trustedProxies: proxy?.trustedProxies,
|
|
20
|
+
allowRealIpFallback: proxy?.allowRealIpFallback
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Shared local-hop budgets allow normal mobile polling while bounding pre-auth work. */
|
|
24
|
+
function publicDeviceRateLimit(family, options) {
|
|
25
|
+
return createMiddleware(async (c, next) => {
|
|
26
|
+
const source = buckets.publicDeviceSource().consume(`${family}:${pairingClientKey(c, options)}`);
|
|
27
|
+
const total = buckets.publicDeviceGlobal().consume(family);
|
|
28
|
+
if (!source.allowed || !total.allowed) {
|
|
29
|
+
const retry = Math.max(source.retryAfterMs, total.retryAfterMs);
|
|
30
|
+
c.header("Retry-After", String(Math.max(1, Math.ceil(retry / 1e3))));
|
|
31
|
+
return c.json({
|
|
32
|
+
ok: false,
|
|
33
|
+
error: {
|
|
34
|
+
code: "RATE_LIMITED",
|
|
35
|
+
message: "Too many requests"
|
|
36
|
+
}
|
|
37
|
+
}, 429);
|
|
38
|
+
}
|
|
39
|
+
return next();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { pairingClientKey, publicDeviceRateLimit };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
3
|
import { buckets } from "../../rate-limit/buckets.js";
|
|
5
|
-
import "../../rate-limit/index.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
6
6
|
import { createMiddleware } from "hono/factory";
|
|
7
7
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
8
8
|
//#region src/gateway/hono/middleware/strict-rate-limit.ts
|
|
@@ -10,6 +10,7 @@ import { getConnInfo } from "@hono/node-server/conninfo";
|
|
|
10
10
|
* Per-client request-rate gate for sensitive admin/mutation endpoints.
|
|
11
11
|
* Backed by `buckets.strictApi()` — see {@link ../../rate-limit/buckets.ts}.
|
|
12
12
|
*/
|
|
13
|
+
init_rate_limit();
|
|
13
14
|
init_logger();
|
|
14
15
|
const log = createLogger("Hono:StrictRateLimit");
|
|
15
16
|
function resolveClientIp(c, deps) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { init_host, isLoopbackHost } from "../host.js";
|
|
3
4
|
import { getOAuthProviderInterfaces, init_registry } from "../../auth/oauth/registry.js";
|
|
4
5
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
5
|
-
import { isLoopbackHost } from "../host.js";
|
|
6
6
|
import { resolveReverseProxyPublicUrl } from "../public-url.js";
|
|
7
7
|
import { buildCapabilityPlansForConfig } from "../../capabilities/readiness/from-config.js";
|
|
8
8
|
import "../../capabilities/readiness/index.js";
|
|
@@ -18,6 +18,7 @@ import { Hono } from "hono";
|
|
|
18
18
|
*/
|
|
19
19
|
init_registry();
|
|
20
20
|
init_credentials();
|
|
21
|
+
init_host();
|
|
21
22
|
init_logger();
|
|
22
23
|
const log = createLogger("OAuthAsync");
|
|
23
24
|
function buildOAuthCompletionReadiness(config, catalog) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { deleteBrowserTabBinding, getBrowserTabBinding, init_browser_tab_binding_repository, setBrowserTabBinding } from "../../../storage/sqlite/browser-tab-binding-repository.js";
|
|
2
2
|
import { browserTabBindingRequestSchema } from "../../../../packages/gateway-contract/src/browser-tab-binding.js";
|
|
3
3
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
4
|
+
import { init_loopback, isLoopbackClientIp } from "../../security/loopback.js";
|
|
4
5
|
import { getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
5
6
|
import "../../../../packages/browser-control-contract/src/index.js";
|
|
6
7
|
import { createBrowserDriver } from "../../../browser/drivers/create-driver.js";
|
|
7
8
|
import { checkBrowserReadiness } from "../../../browser/readiness.js";
|
|
8
|
-
import { isLoopbackClientIp } from "../../security/loopback.js";
|
|
9
9
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
10
10
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
11
11
|
//#region src/gateway/hono/routes/browser.ts
|
|
12
12
|
/** Browser Control status and driver diagnostics. */
|
|
13
13
|
init_src();
|
|
14
|
+
init_loopback();
|
|
14
15
|
init_device_access_repository();
|
|
15
16
|
init_browser_tab_binding_repository();
|
|
16
17
|
async function extensionStatus(service, includeLocalArtifacts) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BindingsSchema, init_binding_schema } from "../../../../routing/binding-schema.js";
|
|
2
2
|
import { AgentCatalogService } from "../../../../agent-catalog/service.js";
|
|
3
|
+
import { CredentialResolver, init_credentials } from "../../../../auth/credentials.js";
|
|
3
4
|
import { ComputerConfigSchema, init_config } from "../../../../computer/config.js";
|
|
4
5
|
import { ContextPlanningConfigSchema, HomeIntelligenceConfigSchema, KnowledgeMemoryConfigSchema, UserContextConfigSchema, UserModelConfigSchema, init_config as init_config$1 } from "../../../../user-context/config.js";
|
|
5
6
|
import { BrowserConfigSchema, McpConfigSchema, VoiceConfigSchema, init_schema } from "../../../../config/schema.js";
|
|
6
|
-
import { CredentialResolver, init_credentials } from "../../../../auth/credentials.js";
|
|
7
7
|
import { canonicalizeConfiguredMcpServer } from "../../../../config/mcp-config-normalize.js";
|
|
8
8
|
import { mergeGatewaySkillsMarketplacePatch, mergeSessionConfigPatch, mergeUpdateConfigPatch } from "../../../../config/web-patch.js";
|
|
9
9
|
import { assertGatewayAuthConfigured, resolveGatewayAuth } from "../../../auth.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { enumerateLanGatewayCandidates } from "../../host.js";
|
|
1
|
+
import { enumerateLanGatewayCandidates, init_host } from "../../host.js";
|
|
2
2
|
import { getTunnelService } from "../../../tunnel/tunnel-service.js";
|
|
3
3
|
import { buildSafeWebConfigPayload } from "../lib/config-payload.js";
|
|
4
4
|
import { applyChannelsPatch } from "./config-patch/channels.js";
|
|
@@ -6,6 +6,7 @@ import { applyGatewayPatch } from "./config-patch/gateway.js";
|
|
|
6
6
|
import { applyMiscPatch, validateGatewayAfterPatch } from "./config-patch/misc.js";
|
|
7
7
|
import "./config-patch/index.js";
|
|
8
8
|
//#region src/gateway/hono/routes/config.ts
|
|
9
|
+
init_host();
|
|
9
10
|
function localeFromRequest(c) {
|
|
10
11
|
return c.req.query("locale") ?? c.req.header("X-XOPC-Locale") ?? c.req.header("Accept-Language")?.split(",")[0];
|
|
11
12
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
trustedProxies?: string[];
|
|
5
|
-
allowRealIpFallback?: boolean;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare function pairingClientKey(c: Context, options?: PairingPublicRouteOptions): string;
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import { type PairingPublicRouteOptions } from '../middleware/public-device-rate-limit.js';
|
|
3
|
+
export { pairingClientKey, type PairingPublicRouteOptions } from '../middleware/public-device-rate-limit.js';
|
|
9
4
|
export declare function registerPairingApprovalPublicRoutes(app: Hono, options?: PairingPublicRouteOptions): void;
|
|
10
5
|
export declare function registerPairingApprovalAdminRoutes(app: Hono): void;
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
import { devicePairingCompleteSchema, devicePairingProofSchema, devicePairingRequestSchema } from "../../../../packages/gateway-contract/src/device-pairing.js";
|
|
2
2
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import { getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
4
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
5
3
|
import { buckets } from "../../rate-limit/buckets.js";
|
|
6
|
-
import "../../rate-limit/index.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
6
|
+
import { pairingClientKey, publicDeviceRateLimit } from "../middleware/public-device-rate-limit.js";
|
|
7
7
|
import { DevicePairingError, cancelDevicePairingSetup, decideDevicePairingRequest, operateDevicePairingRequest, readDevicePairingSetup, submitDevicePairingRequest } from "../../../storage/sqlite/device-pairing-approval.js";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { bodyLimit } from "hono/body-limit";
|
|
11
|
-
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
12
11
|
//#region src/gateway/hono/routes/device-pairing-approval.ts
|
|
13
12
|
init_src();
|
|
14
13
|
init_gateway_identity_repository();
|
|
15
|
-
|
|
16
|
-
let remoteAddress;
|
|
17
|
-
try {
|
|
18
|
-
remoteAddress = getConnInfo(c).remote.address;
|
|
19
|
-
} catch {
|
|
20
|
-
remoteAddress = void 0;
|
|
21
|
-
}
|
|
22
|
-
const proxy = options?.getTrustedProxyContext?.();
|
|
23
|
-
return resolveClientIpFromRequest({
|
|
24
|
-
remoteAddress,
|
|
25
|
-
getHeader: (name) => c.req.header(name),
|
|
26
|
-
trustedProxies: proxy?.trustedProxies,
|
|
27
|
-
allowRealIpFallback: proxy?.allowRealIpFallback
|
|
28
|
-
});
|
|
29
|
-
}
|
|
14
|
+
init_rate_limit();
|
|
30
15
|
function pairingBlocked(c, key) {
|
|
31
16
|
const blocked = buckets.pairingExchange().check(key);
|
|
32
17
|
if (!blocked.blocked) return void 0;
|
|
@@ -63,7 +48,7 @@ function registerPairingApprovalPublicRoutes(app, options) {
|
|
|
63
48
|
"cancel"
|
|
64
49
|
]) {
|
|
65
50
|
const path = action === "request" ? "/api/device-pairing/requests" : `/api/device-pairing/requests/:id/${action}`;
|
|
66
|
-
app.post(path, bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
51
|
+
app.post(path, publicDeviceRateLimit("pairing", options), bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
67
52
|
const clientKey = pairingClientKey(c, options);
|
|
68
53
|
const blocked = pairingBlocked(c, clientKey);
|
|
69
54
|
if (blocked) return blocked;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { browserPairingInvitationPayloadSchema, devicePairingTargetKindSchema, formatBrowserPairingInvitation, formatMobilePairingInvitation } from "../../../../packages/gateway-contract/src/device-pairing.js";
|
|
2
2
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buckets } from "../../rate-limit/buckets.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { DeviceRefreshRateLimitError, init_device_access_repository, listDevices, revokeDevice, rotateDeviceRefreshToken } from "../../../storage/sqlite/device-access-repository.js";
|
|
4
6
|
import { getGatewayIdentityPublicKeyRaw, getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
5
7
|
import { createDevicePairingSetup, init_device_pairing_repository, isDevicePairingSetupActive } from "../../../storage/sqlite/device-pairing-repository.js";
|
|
6
8
|
import { resolveSecureDeviceRoutes } from "../../device-routes.js";
|
|
7
|
-
import { buckets } from "../../rate-limit/buckets.js";
|
|
8
|
-
import "../../rate-limit/index.js";
|
|
9
9
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
10
|
-
import { pairingClientKey,
|
|
10
|
+
import { pairingClientKey, publicDeviceRateLimit } from "../middleware/public-device-rate-limit.js";
|
|
11
|
+
import { registerPairingApprovalAdminRoutes, registerPairingApprovalPublicRoutes } from "./device-pairing-approval.js";
|
|
11
12
|
import os from "node:os";
|
|
12
13
|
import { z } from "zod";
|
|
13
14
|
import { bodyLimit } from "hono/body-limit";
|
|
@@ -16,18 +17,20 @@ init_src();
|
|
|
16
17
|
init_device_access_repository();
|
|
17
18
|
init_device_pairing_repository();
|
|
18
19
|
init_gateway_identity_repository();
|
|
20
|
+
init_rate_limit();
|
|
19
21
|
const refreshRequestSchema = z.strictObject({
|
|
20
22
|
refreshToken: z.string().min(1).max(256),
|
|
21
23
|
timestamp: z.number().int().positive(),
|
|
22
24
|
nonce: z.string().min(16).max(128),
|
|
23
25
|
requestId: z.string().uuid(),
|
|
24
26
|
nextRefreshToken: z.string().min(80).max(256),
|
|
25
|
-
signature: z.string().min(1).max(256)
|
|
27
|
+
signature: z.string().min(1).max(256),
|
|
28
|
+
requestProofVersion: z.literal(1).optional()
|
|
26
29
|
});
|
|
27
30
|
const pairingProbeSchema = z.strictObject({ pairingId: z.string().uuid() });
|
|
28
31
|
const pairingSetupSchema = z.strictObject({ targetKind: devicePairingTargetKindSchema });
|
|
29
32
|
function registerDeviceAuthPublicRoutes(app, options) {
|
|
30
|
-
app.post("/api/gateway-identity/challenge", bodyLimit({ maxSize: 512 }), async (c) => {
|
|
33
|
+
app.post("/api/gateway-identity/challenge", publicDeviceRateLimit("challenge", options), bodyLimit({ maxSize: 512 }), async (c) => {
|
|
31
34
|
const budget = buckets.identityChallenge().consume("gateway");
|
|
32
35
|
if (!budget.allowed) {
|
|
33
36
|
c.header("Retry-After", String(Math.ceil(budget.retryAfterMs / 1e3)));
|
|
@@ -40,6 +43,8 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
40
43
|
purpose: "gateway-route-v1",
|
|
41
44
|
gatewayId: identity.id,
|
|
42
45
|
nonce: parsed.data.nonce,
|
|
46
|
+
serverTime: Date.now(),
|
|
47
|
+
requestProofVersion: 1,
|
|
43
48
|
expiresAt: Date.now() + 3e4
|
|
44
49
|
})).toString("base64url");
|
|
45
50
|
c.header("Cache-Control", "no-store");
|
|
@@ -49,7 +54,7 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
49
54
|
});
|
|
50
55
|
});
|
|
51
56
|
registerPairingApprovalPublicRoutes(app, options);
|
|
52
|
-
app.post("/api/device-auth/refresh", async (c) => {
|
|
57
|
+
app.post("/api/device-auth/refresh", publicDeviceRateLimit("refresh", options), bodyLimit({ maxSize: 4096 }), async (c) => {
|
|
53
58
|
const parsed = refreshRequestSchema.safeParse(await c.req.json().catch(() => null));
|
|
54
59
|
if (!parsed.success) return c.json({
|
|
55
60
|
ok: false,
|
|
@@ -66,6 +71,7 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
66
71
|
requestId: parsed.data.requestId,
|
|
67
72
|
nonce: parsed.data.nonce,
|
|
68
73
|
expiresAt: Date.now() + 3e4,
|
|
74
|
+
requestProofVersion: parsed.data.requestProofVersion ?? 0,
|
|
69
75
|
tokens
|
|
70
76
|
})).toString("base64url");
|
|
71
77
|
return c.json({
|
|
@@ -74,16 +80,26 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
74
80
|
signature: signGatewayPayload(signedPayload)
|
|
75
81
|
});
|
|
76
82
|
} catch (error) {
|
|
83
|
+
if (error instanceof DeviceRefreshRateLimitError) {
|
|
84
|
+
c.header("Retry-After", String(Math.max(1, Math.ceil(error.retryAfterMs / 1e3))));
|
|
85
|
+
return c.json({
|
|
86
|
+
ok: false,
|
|
87
|
+
error: {
|
|
88
|
+
code: "RATE_LIMITED",
|
|
89
|
+
message: "Too many requests"
|
|
90
|
+
}
|
|
91
|
+
}, 429);
|
|
92
|
+
}
|
|
77
93
|
return c.json({
|
|
78
94
|
ok: false,
|
|
79
95
|
error: {
|
|
80
96
|
code: "REFRESH_DENIED",
|
|
81
|
-
message:
|
|
97
|
+
message: "Refresh denied"
|
|
82
98
|
}
|
|
83
99
|
}, 401);
|
|
84
100
|
}
|
|
85
101
|
});
|
|
86
|
-
app.post("/api/device-pairing/probe", bodyLimit({ maxSize: 512 }), async (c) => {
|
|
102
|
+
app.post("/api/device-pairing/probe", publicDeviceRateLimit("pairing", options), bodyLimit({ maxSize: 512 }), async (c) => {
|
|
87
103
|
const clientKey = pairingClientKey(c, options);
|
|
88
104
|
const blocked = buckets.pairingExchange().check(clientKey);
|
|
89
105
|
if (blocked.blocked) {
|
|
@@ -71,6 +71,7 @@ function registerEndpointToolRoutes(authenticated, deps) {
|
|
|
71
71
|
...lastSeenAt ? { lastSeenAt } : {},
|
|
72
72
|
access: access ? {
|
|
73
73
|
scopes: access.scopes,
|
|
74
|
+
requestProofVersion: access.requestProofVersion,
|
|
74
75
|
createdAt: access.createdAt,
|
|
75
76
|
...access.lastSeenAt ? { lastSeenAt: access.lastSeenAt } : {},
|
|
76
77
|
...access.revokedAt ? { revokedAt: access.revokedAt } : {}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { init_resolve_config_value, testApiKeyResolution } from "../../../config/resolve-config-value.js";
|
|
2
1
|
import { resolveModelsJsonPath } from "../../../config/paths.js";
|
|
2
|
+
import { CredentialResolver, init_credentials } from "../../../auth/credentials.js";
|
|
3
|
+
import { resolveEffectiveAgentConfigForAgent } from "../../../config/agent-profile.js";
|
|
4
|
+
import { init_resolve_config_value, testApiKeyResolution } from "../../../config/resolve-config-value.js";
|
|
3
5
|
import { computerModelProfile, init_model_policy, isDedicatedComputerModel } from "../../../computer/model-policy.js";
|
|
4
6
|
import { init_models_json, loadModelsJson, saveModelsJson, validateModelsConfig } from "../../../config/models-json.js";
|
|
5
7
|
import { getModelCatalogStore, init_model_catalog_store } from "../../../providers/model-catalog-store.js";
|
|
6
8
|
import { getModelRegistry } from "../../../providers/model-registry.js";
|
|
7
|
-
import { CredentialResolver, init_credentials } from "../../../auth/credentials.js";
|
|
8
9
|
import "../../../providers/constants.js";
|
|
9
10
|
import { getProviderRegistry, init_plugin_registry } from "../../../providers/plugin-registry.js";
|
|
10
11
|
import { PROVIDER_META, getAllModels, getAllProviders, getAvailableModels, getProviderAuthState, init_providers, isProviderConfigured, isProviderConfiguredSync } from "../../../providers/index.js";
|
|
11
12
|
import { XopcCloudAccountError, XopcCloudAccountService } from "../../../providers/xopc-cloud-account-service.js";
|
|
12
|
-
import { resolveEffectiveAgentConfigForAgent } from "../../../config/agent-profile.js";
|
|
13
13
|
import { buildCapabilityPlansForConfig } from "../../../capabilities/readiness/from-config.js";
|
|
14
14
|
import "../../../capabilities/readiness/index.js";
|
|
15
15
|
import { getModelThinking } from "../../../providers/model-thinking.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TracingConfigSchema, init_config } from "../../../observability/config.js";
|
|
2
1
|
import { CredentialResolver, init_credentials } from "../../../auth/credentials.js";
|
|
2
|
+
import { TracingConfigSchema, init_config } from "../../../observability/config.js";
|
|
3
3
|
import { configureTracing, localStore, testLangfuse, tracingConfig, tracingStatus } from "../../../observability/runtime.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Hono } from "hono";
|
|
@@ -40,6 +40,7 @@ const OnboardingSchema = z.object({
|
|
|
40
40
|
draft: PersonalOnboardingDraftSchema
|
|
41
41
|
}).strict();
|
|
42
42
|
const ProfileSchema = z.object({
|
|
43
|
+
voiceCallPreferences: z.object({ openingGreetingEnabled: z.boolean() }).strict().optional(),
|
|
43
44
|
revision: z.number().int().positive(),
|
|
44
45
|
displayName: z.string().trim().min(1).max(60),
|
|
45
46
|
appearance: PersonalAppearanceSchema,
|
|
@@ -348,7 +349,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
348
349
|
ok: false,
|
|
349
350
|
error: "Invalid profile"
|
|
350
351
|
}, 400);
|
|
351
|
-
const { revision, displayName, appearance, preferences, voicePreference } = parsed.data;
|
|
352
|
+
const { revision, displayName, appearance, preferences, voicePreference, voiceCallPreferences } = parsed.data;
|
|
352
353
|
if (voicePreference) {
|
|
353
354
|
const { resolveStreamingTts } = await import("../../../voice/realtime/runtime.js");
|
|
354
355
|
const route = resolveStreamingTts(deps.service.currentConfig);
|
|
@@ -364,7 +365,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
364
365
|
error: "Selected voice is unavailable"
|
|
365
366
|
}, 400);
|
|
366
367
|
}
|
|
367
|
-
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, preferences, appearance, voicePreference);
|
|
368
|
+
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, preferences, appearance, voicePreference, voiceCallPreferences);
|
|
368
369
|
return updated ? c.json({
|
|
369
370
|
ok: true,
|
|
370
371
|
payload: updated
|
|
@@ -25,18 +25,18 @@ function secretsEqual(actual, expected) {
|
|
|
25
25
|
}
|
|
26
26
|
function registerPublicGatewayRoutes(app, service) {
|
|
27
27
|
app.get("/health", (c) => {
|
|
28
|
-
|
|
28
|
+
const health = service.getHealth();
|
|
29
|
+
return c.json({
|
|
30
|
+
status: health.ready ? "ok" : "starting",
|
|
31
|
+
ready: health.ready
|
|
32
|
+
});
|
|
29
33
|
});
|
|
30
34
|
/** Public liveness probe (no auth) — minimal payload for CLI / load balancers. */
|
|
31
35
|
app.get("/api/health", (c) => {
|
|
32
36
|
const health = service.getHealth();
|
|
33
37
|
return c.json({
|
|
34
38
|
status: health.ready ? "ok" : "starting",
|
|
35
|
-
ready: health.ready
|
|
36
|
-
httpListening: health.httpListening,
|
|
37
|
-
version: health.version,
|
|
38
|
-
uptime: health.uptime,
|
|
39
|
-
startupDurationMs: health.startupDurationMs
|
|
39
|
+
ready: health.ready
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
app.post("/api/connectors/composio/webhook", async (c) => {
|