@elizaos/plugin-elizacloud 2.0.0-beta.1 → 2.0.11-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -44
- package/auto-enable.ts +10 -5
- package/dist/browser/index.browser.js +2 -2
- package/dist/browser/index.browser.js.map +4 -4
- package/dist/cjs/index.node.cjs +2874 -5915
- package/dist/cjs/index.node.js.map +47 -116
- package/dist/cloud/auth-service-types.d.ts +8 -0
- package/dist/cloud/auth-service-types.d.ts.map +1 -0
- package/dist/cloud/auth-service-types.js +36 -0
- package/dist/cloud/auth-service-types.js.map +10 -0
- package/dist/cloud/auth.js +4 -51
- package/dist/cloud/auth.js.map +4 -4
- package/dist/cloud/base-url.d.ts +6 -2
- package/dist/cloud/base-url.d.ts.map +1 -1
- package/dist/cloud/base-url.js +3 -51
- package/dist/cloud/base-url.js.map +3 -3
- package/dist/cloud/bridge-client.d.ts +3 -3
- package/dist/cloud/bridge-client.d.ts.map +1 -1
- package/dist/cloud/bridge-client.js +3 -51
- package/dist/cloud/bridge-client.js.map +3 -3
- package/dist/cloud/clack-observer.d.ts +35 -0
- package/dist/cloud/clack-observer.d.ts.map +1 -0
- package/dist/cloud/clack-observer.js +143 -0
- package/dist/cloud/clack-observer.js.map +10 -0
- package/dist/cloud/cloud-manager.js +45 -92
- package/dist/cloud/cloud-manager.js.map +6 -6
- package/dist/cloud/cloud-wallet.js +2 -4835
- package/dist/cloud/cloud-wallet.js.map +3 -82
- package/dist/cloud/duffel-client.d.ts +181 -0
- package/dist/cloud/duffel-client.d.ts.map +1 -0
- package/dist/cloud/duffel-client.js +506 -0
- package/dist/cloud/duffel-client.js.map +11 -0
- package/dist/cloud/index.d.ts +6 -0
- package/dist/cloud/index.d.ts.map +1 -1
- package/dist/cloud/index.js +1782 -1
- package/dist/cloud/index.js.map +18 -3
- package/dist/cloud/lifeops-schedule-sync-client.d.ts +43 -0
- package/dist/cloud/lifeops-schedule-sync-client.d.ts.map +1 -0
- package/dist/cloud/lifeops-schedule-sync-client.js +180 -0
- package/dist/cloud/lifeops-schedule-sync-client.js.map +11 -0
- package/dist/cloud/lifeops-schedule-sync-contracts.d.ts +89 -0
- package/dist/cloud/lifeops-schedule-sync-contracts.d.ts.map +1 -0
- package/dist/cloud/lifeops-schedule-sync-contracts.js +39 -0
- package/dist/cloud/lifeops-schedule-sync-contracts.js.map +10 -0
- package/dist/cloud/managed-payment-clients.d.ts +166 -0
- package/dist/cloud/managed-payment-clients.d.ts.map +1 -0
- package/dist/cloud/managed-payment-clients.js +238 -0
- package/dist/cloud/managed-payment-clients.js.map +11 -0
- package/dist/cloud/null-observer.d.ts +35 -0
- package/dist/cloud/null-observer.d.ts.map +1 -0
- package/dist/cloud/null-observer.js +45 -0
- package/dist/cloud/null-observer.js.map +10 -0
- package/dist/cloud/setup-observer.d.ts +98 -0
- package/dist/cloud/setup-observer.d.ts.map +1 -0
- package/dist/cloud/setup-observer.js +2 -0
- package/dist/cloud/setup-observer.js.map +9 -0
- package/dist/cloud/validate-url.d.ts.map +1 -1
- package/dist/cloud/validate-url.js +2 -1
- package/dist/cloud/validate-url.js.map +3 -3
- package/dist/cloud/x402-payment-handler.d.ts +85 -0
- package/dist/cloud/x402-payment-handler.d.ts.map +1 -0
- package/dist/cloud/x402-payment-handler.js +119 -0
- package/dist/cloud/x402-payment-handler.js.map +10 -0
- package/dist/cloud-setup.d.ts +36 -0
- package/dist/cloud-setup.d.ts.map +1 -0
- package/dist/{onboarding.js → cloud-setup.js} +139 -139
- package/dist/cloud-setup.js.map +14 -0
- package/dist/cloud-voice-catalog.d.ts +65 -0
- package/dist/cloud-voice-catalog.d.ts.map +1 -0
- package/dist/cloud-voice-catalog.js +278 -0
- package/dist/cloud-voice-catalog.js.map +12 -0
- package/dist/index.browser.d.ts +11 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5416 -8405
- package/dist/index.js.map +48 -116
- package/dist/index.node.d.ts +8 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/init.js +17 -4
- package/dist/init.js.map +4 -4
- package/dist/lib/cloud-connection.d.ts +0 -1
- package/dist/lib/cloud-connection.d.ts.map +1 -1
- package/dist/lib/cloud-connection.js +14 -91
- package/dist/lib/cloud-connection.js.map +7 -7
- package/dist/lib/cloud-secrets.d.ts +5 -18
- package/dist/lib/cloud-secrets.d.ts.map +1 -1
- package/dist/lib/cloud-secrets.js +8 -36
- package/dist/lib/cloud-secrets.js.map +3 -3
- package/dist/lib/config-like.d.ts +1 -1
- package/dist/lib/config-like.d.ts.map +1 -1
- package/dist/lib/config-like.js +3 -3
- package/dist/lib/config-like.js.map +3 -3
- package/dist/lib/credential-type-map.d.ts +1 -1
- package/dist/lib/credential-type-map.js.map +1 -1
- package/dist/lib/http.d.ts +0 -11
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js.map +2 -2
- package/dist/lib/server-cloud-tts.d.ts +12 -25
- package/dist/lib/server-cloud-tts.d.ts.map +1 -1
- package/dist/lib/server-cloud-tts.js +31 -329
- package/dist/lib/server-cloud-tts.js.map +4 -7
- package/dist/lib/tts-debug.d.ts +5 -3
- package/dist/lib/tts-debug.d.ts.map +1 -1
- package/dist/lib/tts-debug.js +1 -34
- package/dist/lib/tts-debug.js.map +3 -4
- package/dist/models/embeddings.d.ts.map +1 -1
- package/dist/models/embeddings.js +79 -69
- package/dist/models/embeddings.js.map +6 -6
- package/dist/models/image.d.ts.map +1 -1
- package/dist/models/image.js +42 -15
- package/dist/models/image.js.map +6 -6
- package/dist/models/index.js +676 -166
- package/dist/models/index.js.map +11 -12
- package/dist/models/research.d.ts.map +1 -1
- package/dist/models/research.js +24 -7
- package/dist/models/research.js.map +6 -6
- package/dist/models/speech.d.ts +61 -3
- package/dist/models/speech.d.ts.map +1 -1
- package/dist/models/speech.js +173 -17
- package/dist/models/speech.js.map +5 -5
- package/dist/models/text.d.ts +106 -1
- package/dist/models/text.d.ts.map +1 -1
- package/dist/models/text.js +452 -82
- package/dist/models/text.js.map +7 -8
- package/dist/models/tokenization.d.ts.map +1 -1
- package/dist/models/tokenization.js.map +2 -2
- package/dist/models/transcription.d.ts.map +1 -1
- package/dist/models/transcription.js +20 -6
- package/dist/models/transcription.js.map +5 -5
- package/dist/node/index.node.js +2828 -5838
- package/dist/node/index.node.js.map +47 -116
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +376 -5050
- package/dist/plugin.js.map +16 -92
- package/dist/providers/openai.js +11 -2
- package/dist/providers/openai.js.map +3 -3
- package/dist/register-routes.js +376 -5050
- package/dist/register-routes.js.map +16 -92
- package/dist/routes/cloud-billing-routes.d.ts.map +1 -1
- package/dist/routes/cloud-billing-routes.js +17 -60
- package/dist/routes/cloud-billing-routes.js.map +8 -7
- package/dist/routes/cloud-coding-container-routes.d.ts +8 -0
- package/dist/routes/cloud-coding-container-routes.d.ts.map +1 -0
- package/dist/routes/cloud-coding-container-routes.js +214 -0
- package/dist/routes/cloud-coding-container-routes.js.map +11 -0
- package/dist/routes/cloud-compat-routes.d.ts.map +1 -1
- package/dist/routes/cloud-compat-routes.js +17 -60
- package/dist/routes/cloud-compat-routes.js.map +8 -7
- package/dist/routes/cloud-features-routes.js +2 -2
- package/dist/routes/cloud-features-routes.js.map +4 -4
- package/dist/routes/cloud-relay-routes.d.ts +2 -1
- package/dist/routes/cloud-relay-routes.d.ts.map +1 -1
- package/dist/routes/cloud-relay-routes.js +84 -2
- package/dist/routes/cloud-relay-routes.js.map +5 -4
- package/dist/routes/cloud-routes-autonomous.d.ts +3 -4
- package/dist/routes/cloud-routes-autonomous.d.ts.map +1 -1
- package/dist/routes/cloud-routes-autonomous.js +11 -4893
- package/dist/routes/cloud-routes-autonomous.js.map +8 -87
- package/dist/routes/cloud-routes.d.ts +2 -2
- package/dist/routes/cloud-routes.d.ts.map +1 -1
- package/dist/routes/cloud-routes.js +343 -5058
- package/dist/routes/cloud-routes.js.map +13 -90
- package/dist/routes/cloud-status-routes-autonomous.d.ts +1 -2
- package/dist/routes/cloud-status-routes-autonomous.d.ts.map +1 -1
- package/dist/routes/cloud-status-routes-autonomous.js +4 -51
- package/dist/routes/cloud-status-routes-autonomous.js.map +5 -5
- package/dist/routes/cloud-status-routes.js +14 -90
- package/dist/routes/cloud-status-routes.js.map +7 -7
- package/dist/routes/home-remote-runner-access-url.d.ts +16 -0
- package/dist/routes/home-remote-runner-access-url.d.ts.map +1 -0
- package/dist/routes/home-remote-runner-access-url.js +91 -0
- package/dist/routes/home-remote-runner-access-url.js.map +10 -0
- package/dist/routes/travel-provider-relay-routes.d.ts +9 -0
- package/dist/routes/travel-provider-relay-routes.d.ts.map +1 -0
- package/dist/routes/travel-provider-relay-routes.js +358 -0
- package/dist/routes/travel-provider-relay-routes.js.map +14 -0
- package/dist/services/cloud-auth.d.ts +1 -1
- package/dist/services/cloud-auth.d.ts.map +1 -1
- package/dist/services/cloud-auth.js +7 -2
- package/dist/services/cloud-auth.js.map +4 -4
- package/dist/services/cloud-backup.js.map +2 -2
- package/dist/services/cloud-bootstrap.d.ts.map +1 -1
- package/dist/services/cloud-bootstrap.js.map +2 -2
- package/dist/services/cloud-bridge.js.map +3 -3
- package/dist/services/cloud-container.d.ts +5 -1
- package/dist/services/cloud-container.d.ts.map +1 -1
- package/dist/services/cloud-container.js +52 -1
- package/dist/services/cloud-container.js.map +4 -4
- package/dist/services/cloud-credential-provider.js.map +2 -2
- package/dist/services/cloud-model-registry.js.map +2 -2
- package/dist/types/cloud.d.ts +1 -0
- package/dist/types/cloud.d.ts.map +1 -1
- package/dist/types/cloud.js.map +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/cloud-sdk/client.d.ts.map +1 -1
- package/dist/utils/cloud-sdk/client.js +136 -4
- package/dist/utils/cloud-sdk/client.js.map +5 -5
- package/dist/utils/cloud-sdk/http.js.map +1 -1
- package/dist/utils/cloud-sdk/public-routes.d.ts +186 -0
- package/dist/utils/cloud-sdk/public-routes.d.ts.map +1 -1
- package/dist/utils/cloud-sdk/public-routes.js +99 -1
- package/dist/utils/cloud-sdk/public-routes.js.map +3 -3
- package/dist/utils/cloud-sdk/types.d.ts +0 -2
- package/dist/utils/cloud-sdk/types.d.ts.map +1 -1
- package/dist/utils/cloud-sdk/types.js.map +1 -1
- package/dist/utils/config.d.ts +10 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +12 -2
- package/dist/utils/config.js.map +3 -3
- package/dist/utils/events.d.ts +23 -2
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/events.js +5 -3
- package/dist/utils/events.js.map +3 -3
- package/dist/utils/sdk-client.d.ts.map +1 -1
- package/dist/utils/sdk-client.js +17 -4
- package/dist/utils/sdk-client.js.map +4 -4
- package/dist/utils/waifu-metering.d.ts +108 -0
- package/dist/utils/waifu-metering.d.ts.map +1 -0
- package/dist/utils/waifu-metering.js +166 -0
- package/dist/utils/waifu-metering.js.map +10 -0
- package/package.json +51 -22
- package/src/cloud/auth-service-types.ts +24 -0
- package/src/cloud/base-url.ts +6 -62
- package/src/cloud/clack-observer.ts +189 -0
- package/src/cloud/duffel-client.ts +847 -0
- package/src/cloud/index.ts +10 -0
- package/src/cloud/lifeops-schedule-sync-client.ts +245 -0
- package/src/cloud/lifeops-schedule-sync-contracts.ts +124 -0
- package/src/cloud/managed-payment-clients.ts +374 -0
- package/src/cloud/null-observer.ts +45 -0
- package/src/cloud/setup-observer.ts +125 -0
- package/src/cloud/validate-url.ts +7 -1
- package/src/cloud/x402-payment-handler.ts +215 -0
- package/src/cloud-setup.ts +531 -0
- package/src/cloud-voice-catalog.test.ts +254 -0
- package/src/cloud-voice-catalog.ts +246 -0
- package/src/index.browser.ts +29 -0
- package/src/index.node.ts +31 -1
- package/src/index.ts +76 -4
- package/src/lib/cloud-connection.ts +2 -4
- package/src/lib/cloud-secrets.ts +10 -54
- package/src/lib/config-like.ts +1 -1
- package/src/lib/credential-type-map.ts +2 -2
- package/src/lib/http.ts +0 -17
- package/src/lib/server-cloud-tts.ts +33 -341
- package/src/lib/tts-debug.ts +5 -34
- package/src/models/embeddings.ts +140 -76
- package/src/models/image.ts +29 -14
- package/src/models/research.ts +11 -1
- package/src/models/speech.ts +269 -23
- package/src/models/text.ts +704 -110
- package/src/models/tokenization.ts +2 -2
- package/src/models/transcription.ts +7 -3
- package/src/plugin.ts +38 -0
- package/src/routes/cloud-billing-routes.ts +4 -14
- package/src/routes/cloud-coding-container-routes.ts +198 -0
- package/src/routes/cloud-compat-routes.ts +4 -14
- package/src/routes/cloud-features-routes.ts +1 -1
- package/src/routes/cloud-relay-routes.ts +47 -1
- package/src/routes/cloud-routes-autonomous.ts +7 -10
- package/src/routes/cloud-routes.ts +68 -7
- package/src/routes/cloud-status-routes-autonomous.ts +6 -2
- package/src/routes/home-remote-runner-access-url.ts +83 -0
- package/src/routes/travel-provider-relay-routes.ts +193 -0
- package/src/services/cloud-auth.ts +9 -2
- package/src/services/cloud-bootstrap.ts +1 -3
- package/src/services/cloud-bridge.ts +1 -1
- package/src/services/cloud-container.ts +93 -0
- package/src/services/cloud-credential-provider.ts +1 -1
- package/src/services/cloud-model-registry.ts +1 -1
- package/src/types/cloud.ts +22 -0
- package/src/types/index.ts +19 -0
- package/src/utils/cloud-sdk/client.ts +42 -3
- package/src/utils/cloud-sdk/public-routes.ts +168 -0
- package/src/utils/cloud-sdk/types.ts +0 -2
- package/src/utils/config.ts +20 -1
- package/src/utils/events.ts +30 -2
- package/src/utils/sdk-client.ts +5 -1
- package/src/utils/waifu-metering.ts +302 -0
- package/dist/onboarding.d.ts +0 -35
- package/dist/onboarding.d.ts.map +0 -1
- package/dist/onboarding.js.map +0 -14
- package/src/onboarding.ts +0 -396
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { normalizeCloudSiteUrl } from "@elizaos/shared";
|
|
2
|
+
|
|
3
|
+
export const HOME_REMOTE_RUNNER_ACCESS_SESSION_PARAM = "homeRemoteRunnerSession";
|
|
4
|
+
|
|
5
|
+
export interface HomeRemoteRunnerSshTunnel {
|
|
6
|
+
command: string;
|
|
7
|
+
localUrl: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function buildHomeRemoteRunnerAccessUrl(input: {
|
|
11
|
+
cloudBaseUrl?: string | null;
|
|
12
|
+
sessionId?: string | null;
|
|
13
|
+
}): string | null {
|
|
14
|
+
const sessionId = input.sessionId?.trim();
|
|
15
|
+
if (!sessionId) return null;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(normalizeCloudSiteUrl(input.cloudBaseUrl ?? undefined));
|
|
19
|
+
url.pathname = "/dashboard/app";
|
|
20
|
+
url.search = "";
|
|
21
|
+
url.hash = "";
|
|
22
|
+
url.searchParams.set(HOME_REMOTE_RUNNER_ACCESS_SESSION_PARAM, sessionId);
|
|
23
|
+
return url.toString();
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function buildHomeRemoteRunnerSshTunnel(input: {
|
|
30
|
+
remoteBaseUrl?: string | null;
|
|
31
|
+
sshTarget?: string | null;
|
|
32
|
+
sshIdentity?: string | null;
|
|
33
|
+
localPort?: string | number | null;
|
|
34
|
+
}): HomeRemoteRunnerSshTunnel | null {
|
|
35
|
+
const sshTarget = normalizeSshTarget(input.sshTarget);
|
|
36
|
+
if (!sshTarget) return null;
|
|
37
|
+
|
|
38
|
+
let parsed: URL;
|
|
39
|
+
try {
|
|
40
|
+
parsed = new URL(input.remoteBaseUrl?.trim() ?? "");
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (parsed.protocol !== "http:") {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const remotePort = parsed.port || "80";
|
|
50
|
+
const localPort = normalizePort(input.localPort) ?? remotePort;
|
|
51
|
+
const remoteHost =
|
|
52
|
+
parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1"
|
|
53
|
+
? "127.0.0.1"
|
|
54
|
+
: parsed.hostname;
|
|
55
|
+
const identityArg = input.sshIdentity?.trim()
|
|
56
|
+
? ` -i ${quoteShellArg(input.sshIdentity.trim())}`
|
|
57
|
+
: "";
|
|
58
|
+
const command = `ssh -N${identityArg} -L 127.0.0.1:${localPort}:${remoteHost}:${remotePort} ${sshTarget}`;
|
|
59
|
+
return {
|
|
60
|
+
command,
|
|
61
|
+
localUrl: `${parsed.protocol}//127.0.0.1:${localPort}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function normalizePort(value: string | number | null | undefined): string | null {
|
|
66
|
+
if (value === null || value === undefined) return null;
|
|
67
|
+
const raw = String(value).trim();
|
|
68
|
+
if (!/^\d+$/.test(raw)) return null;
|
|
69
|
+
const port = Number(raw);
|
|
70
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) return null;
|
|
71
|
+
return String(port);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function normalizeSshTarget(value: string | null | undefined): string | null {
|
|
75
|
+
const target = value?.trim();
|
|
76
|
+
if (!target) return null;
|
|
77
|
+
if (!/^[A-Za-z0-9._~%+-]+@[A-Za-z0-9.-]+$/.test(target)) return null;
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function quoteShellArg(value: string): string {
|
|
82
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
83
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import {
|
|
3
|
+
type IAgentRuntime,
|
|
4
|
+
type Service,
|
|
5
|
+
sendJson,
|
|
6
|
+
sendJsonError,
|
|
7
|
+
} from "@elizaos/core";
|
|
8
|
+
import {
|
|
9
|
+
isCloudAuthApiKeyService,
|
|
10
|
+
normalizeCloudApiKey,
|
|
11
|
+
} from "../cloud/auth-service-types.js";
|
|
12
|
+
import { normalizeCloudSiteUrl } from "../cloud/base-url.js";
|
|
13
|
+
import { resolveCloudApiKey } from "../cloud/cloud-api-key.js";
|
|
14
|
+
import { validateCloudBaseUrl } from "../cloud/validate-url.js";
|
|
15
|
+
import type { CloudProxyConfigLike } from "../lib/config-like";
|
|
16
|
+
|
|
17
|
+
export interface TravelProviderRelayRouteState {
|
|
18
|
+
config: CloudProxyConfigLike;
|
|
19
|
+
runtime?: IAgentRuntime | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const PROXY_TIMEOUT_MS = 30_000;
|
|
23
|
+
const MAX_BODY_BYTES = 1_048_576;
|
|
24
|
+
const TRAVEL_PROVIDER_PATH_RE =
|
|
25
|
+
/^\/api\/cloud\/travel-providers\/([a-z0-9][a-z0-9-]*)(\/.*)$/;
|
|
26
|
+
|
|
27
|
+
function resolveProxyApiKey(
|
|
28
|
+
state: TravelProviderRelayRouteState,
|
|
29
|
+
): string | null {
|
|
30
|
+
const cloudAuth = state.runtime?.getService<Service>("CLOUD_AUTH");
|
|
31
|
+
const runtimeApiKey =
|
|
32
|
+
isCloudAuthApiKeyService(cloudAuth) && cloudAuth.isAuthenticated() === true
|
|
33
|
+
? normalizeCloudApiKey(cloudAuth.getApiKey?.())
|
|
34
|
+
: null;
|
|
35
|
+
return runtimeApiKey ?? resolveCloudApiKey(state.config, state.runtime);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function buildAuthHeaders(
|
|
39
|
+
config: CloudProxyConfigLike,
|
|
40
|
+
apiKey: string,
|
|
41
|
+
): Record<string, string> {
|
|
42
|
+
const serviceKey = config.cloud?.serviceKey?.trim();
|
|
43
|
+
const headers: Record<string, string> = {
|
|
44
|
+
Accept: "application/json",
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
Authorization: `Bearer ${apiKey}`,
|
|
47
|
+
};
|
|
48
|
+
if (serviceKey) headers["X-Service-Key"] = serviceKey;
|
|
49
|
+
return headers;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function readBody(req: http.IncomingMessage): Promise<string | undefined> {
|
|
53
|
+
return new Promise<string | undefined>((resolve, reject) => {
|
|
54
|
+
const chunks: Buffer[] = [];
|
|
55
|
+
let size = 0;
|
|
56
|
+
req.on("data", (chunk: Buffer) => {
|
|
57
|
+
size += chunk.length;
|
|
58
|
+
if (size > MAX_BODY_BYTES) {
|
|
59
|
+
reject(new Error("Request body too large"));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
chunks.push(chunk);
|
|
63
|
+
});
|
|
64
|
+
req.on("end", () =>
|
|
65
|
+
resolve(
|
|
66
|
+
chunks.length > 0 ? Buffer.concat(chunks).toString("utf-8") : undefined,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
req.on("error", reject);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function readJsonResponse(response: Response): Promise<unknown> {
|
|
74
|
+
return response.json().catch(async () => ({
|
|
75
|
+
success: response.ok,
|
|
76
|
+
error: await response
|
|
77
|
+
.text()
|
|
78
|
+
.catch(() => "Travel-provider relay request failed"),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function buildUpstreamPath(localPath: string): string {
|
|
83
|
+
const parsed = parseTravelProviderPath(localPath);
|
|
84
|
+
if (!parsed) {
|
|
85
|
+
throw new Error("Invalid travel-provider relay path");
|
|
86
|
+
}
|
|
87
|
+
return `/api/v1/${parsed.provider}${parsed.providerPath}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const TRAVEL_PROVIDER_RELAY_ROUTES: ReadonlyArray<{
|
|
91
|
+
method: "GET" | "POST";
|
|
92
|
+
pattern: RegExp;
|
|
93
|
+
}> = [
|
|
94
|
+
{ method: "POST", pattern: /^\/offer-requests$/ },
|
|
95
|
+
{ method: "GET", pattern: /^\/offers\/[^/]+$/ },
|
|
96
|
+
{ method: "POST", pattern: /^\/orders$/ },
|
|
97
|
+
{ method: "GET", pattern: /^\/orders\/[^/]+$/ },
|
|
98
|
+
{ method: "POST", pattern: /^\/payments$/ },
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
function parseTravelProviderPath(
|
|
102
|
+
pathname: string,
|
|
103
|
+
): { provider: string; providerPath: string } | null {
|
|
104
|
+
const match = TRAVEL_PROVIDER_PATH_RE.exec(pathname);
|
|
105
|
+
if (!match) return null;
|
|
106
|
+
const [, provider, providerPath] = match;
|
|
107
|
+
return provider ? { provider, providerPath } : null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function matchRoute(method: string, pathname: string): boolean {
|
|
111
|
+
const parsed = parseTravelProviderPath(pathname);
|
|
112
|
+
if (!parsed) return false;
|
|
113
|
+
return TRAVEL_PROVIDER_RELAY_ROUTES.some(
|
|
114
|
+
(route) => route.method === method && route.pattern.test(parsed.providerPath),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function handleTravelProviderRelayRoute(
|
|
119
|
+
req: http.IncomingMessage,
|
|
120
|
+
res: http.ServerResponse,
|
|
121
|
+
pathname: string,
|
|
122
|
+
method: string,
|
|
123
|
+
state: TravelProviderRelayRouteState,
|
|
124
|
+
): Promise<boolean> {
|
|
125
|
+
const parsed = parseTravelProviderPath(pathname);
|
|
126
|
+
if (!parsed) return false;
|
|
127
|
+
|
|
128
|
+
if (!matchRoute(method, pathname)) {
|
|
129
|
+
sendJsonError(res, "Unknown travel-provider relay route", 404);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const apiKey = resolveProxyApiKey(state);
|
|
134
|
+
if (!apiKey) {
|
|
135
|
+
sendJsonError(
|
|
136
|
+
res,
|
|
137
|
+
"Not connected to Eliza Cloud. Sign in to use travel search.",
|
|
138
|
+
401,
|
|
139
|
+
);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const baseUrl = normalizeCloudSiteUrl(state.config.cloud?.baseUrl);
|
|
144
|
+
const urlError = await validateCloudBaseUrl(baseUrl);
|
|
145
|
+
if (urlError) {
|
|
146
|
+
sendJsonError(res, urlError, 502);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const headers = buildAuthHeaders(state.config, apiKey);
|
|
151
|
+
let body: string | undefined;
|
|
152
|
+
if (method === "POST") {
|
|
153
|
+
try {
|
|
154
|
+
body = await readBody(req);
|
|
155
|
+
} catch (err) {
|
|
156
|
+
const msg = err instanceof Error ? err.message : "Failed to read body";
|
|
157
|
+
sendJsonError(res, msg, 413);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const fullUrl = new URL(req.url ?? pathname, "http://localhost");
|
|
163
|
+
const upstreamUrl = `${baseUrl}${buildUpstreamPath(pathname)}${fullUrl.search}`;
|
|
164
|
+
const upstreamResponse = await fetch(upstreamUrl, {
|
|
165
|
+
method,
|
|
166
|
+
headers,
|
|
167
|
+
body,
|
|
168
|
+
redirect: "manual",
|
|
169
|
+
signal: AbortSignal.timeout(PROXY_TIMEOUT_MS),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (upstreamResponse.status === 402) {
|
|
173
|
+
await forward402(res, upstreamResponse);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const payload = await readJsonResponse(upstreamResponse);
|
|
178
|
+
sendJson(res, payload, upstreamResponse.status);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function forward402(
|
|
183
|
+
res: http.ServerResponse,
|
|
184
|
+
upstream: Response,
|
|
185
|
+
): Promise<void> {
|
|
186
|
+
const wwwAuth = upstream.headers.get("www-authenticate");
|
|
187
|
+
const contentType = upstream.headers.get("content-type") ?? "application/json";
|
|
188
|
+
const bodyText = await upstream.text();
|
|
189
|
+
res.statusCode = 402;
|
|
190
|
+
res.setHeader("Content-Type", contentType);
|
|
191
|
+
if (wwwAuth) res.setHeader("WWW-Authenticate", wwwAuth);
|
|
192
|
+
res.end(bodyText);
|
|
193
|
+
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
resolveApiSecurityConfig,
|
|
27
27
|
resolveDesktopApiPort,
|
|
28
28
|
} from "@elizaos/core";
|
|
29
|
+
import { isCloudReachable } from "@elizaos/shared";
|
|
29
30
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
30
31
|
import type { CloudCredentials, DeviceAuthResponse, DevicePlatform } from "../types/cloud";
|
|
31
32
|
import { DEFAULT_CLOUD_CONFIG } from "../types/cloud";
|
|
@@ -91,7 +92,7 @@ export interface CloudSsoSession {
|
|
|
91
92
|
export interface SsoRedirectArgs {
|
|
92
93
|
/**
|
|
93
94
|
* Local URL the user should land on after the SSO round-trip
|
|
94
|
-
* (e.g. `/
|
|
95
|
+
* (e.g. `/first-run/setup`). The dashboard's callback route forwards
|
|
95
96
|
* to this once the session cookie is set; it is NOT sent to the cloud
|
|
96
97
|
* issuer.
|
|
97
98
|
*/
|
|
@@ -474,9 +475,15 @@ export class CloudAuthService extends Service {
|
|
|
474
475
|
}
|
|
475
476
|
|
|
476
477
|
private async validateApiKey(key: string): Promise<boolean> {
|
|
478
|
+
if (!(await isCloudReachable())) {
|
|
479
|
+
logger.warn(
|
|
480
|
+
"[CloudAuth] Cloud unreachable at boot — skipping API key validation; key will be used as-is"
|
|
481
|
+
);
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
477
484
|
try {
|
|
478
485
|
const validationClient = new CloudApiClient(this.client.getBaseUrl(), key);
|
|
479
|
-
await validationClient.get("/models", { timeoutMs:
|
|
486
|
+
await validationClient.get("/models", { timeoutMs: 2_500 });
|
|
480
487
|
return true;
|
|
481
488
|
} catch (err) {
|
|
482
489
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* trusts a default URL.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { type IAgentRuntime, logger, Service } from "@elizaos/core";
|
|
18
|
+
import { type IAgentRuntime, logger, type ProcessEnvLike, Service } from "@elizaos/core";
|
|
19
19
|
|
|
20
20
|
export interface CloudBootstrapService {
|
|
21
21
|
/** Returns `${ELIZA_CLOUD_ISSUER}/.well-known/jwks.json`. */
|
|
@@ -28,8 +28,6 @@ export interface CloudBootstrapService {
|
|
|
28
28
|
getExpectedContainerId(): string | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
type ProcessEnvLike = Record<string, string | undefined>;
|
|
32
|
-
|
|
33
31
|
function readEnv(): ProcessEnvLike {
|
|
34
32
|
if (typeof process === "undefined") {
|
|
35
33
|
return {};
|
|
@@ -182,7 +182,7 @@ export class CloudBridgeService extends Service {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
ws.addEventListener("close", (event
|
|
185
|
+
ws.addEventListener("close", (event) => {
|
|
186
186
|
conn.state = "disconnected";
|
|
187
187
|
if (conn.heartbeatTimer) clearInterval(conn.heartbeatTimer);
|
|
188
188
|
|
|
@@ -15,6 +15,12 @@ import type {
|
|
|
15
15
|
ContainerListResponse,
|
|
16
16
|
CreateContainerRequest,
|
|
17
17
|
CreateContainerResponse,
|
|
18
|
+
PromoteVfsToCloudContainerRequest,
|
|
19
|
+
PromoteVfsToCloudContainerResponse,
|
|
20
|
+
RequestCodingAgentContainerRequest,
|
|
21
|
+
RequestCodingAgentContainerResponse,
|
|
22
|
+
SyncCloudCodingContainerRequest,
|
|
23
|
+
SyncCloudCodingContainerResponse,
|
|
18
24
|
} from "../types/cloud";
|
|
19
25
|
import { DEFAULT_CLOUD_CONFIG } from "../types/cloud";
|
|
20
26
|
import type { CloudApiClient } from "../utils/cloud-api";
|
|
@@ -277,6 +283,75 @@ export class CloudContainerService extends Service {
|
|
|
277
283
|
return client.get<ContainerHealthResponse>(`/containers/${containerId}/health`);
|
|
278
284
|
}
|
|
279
285
|
|
|
286
|
+
// ─── Coding Containers / VFS Promotion ────────────────────────────────
|
|
287
|
+
|
|
288
|
+
async promoteVfsToCloudContainer(
|
|
289
|
+
request: PromoteVfsToCloudContainerRequest,
|
|
290
|
+
): Promise<PromoteVfsToCloudContainerResponse> {
|
|
291
|
+
if (!this.isAuthenticated()) {
|
|
292
|
+
throw cloudCodingUnavailable("Cloud auth is not connected");
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
return await this.getClient().post<PromoteVfsToCloudContainerResponse>(
|
|
297
|
+
"/coding-containers/promotions",
|
|
298
|
+
request,
|
|
299
|
+
);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (isMissingCloudCodingEndpoint(error)) {
|
|
302
|
+
throw cloudCodingUnavailable(
|
|
303
|
+
"Eliza Cloud coding-container promotion endpoint is not deployed yet",
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
async requestCodingAgentContainer(
|
|
311
|
+
request: RequestCodingAgentContainerRequest,
|
|
312
|
+
): Promise<RequestCodingAgentContainerResponse> {
|
|
313
|
+
if (!this.isAuthenticated()) {
|
|
314
|
+
throw cloudCodingUnavailable("Cloud auth is not connected");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
return await this.getClient().post<RequestCodingAgentContainerResponse>(
|
|
319
|
+
"/coding-containers",
|
|
320
|
+
request,
|
|
321
|
+
);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (isMissingCloudCodingEndpoint(error)) {
|
|
324
|
+
throw cloudCodingUnavailable(
|
|
325
|
+
"Eliza Cloud coding-container endpoint is not deployed yet",
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async syncCodingContainerChanges(
|
|
333
|
+
containerId: string,
|
|
334
|
+
request: SyncCloudCodingContainerRequest,
|
|
335
|
+
): Promise<SyncCloudCodingContainerResponse> {
|
|
336
|
+
if (!this.isAuthenticated()) {
|
|
337
|
+
throw cloudCodingUnavailable("Cloud auth is not connected");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
try {
|
|
341
|
+
return await this.getClient().post<SyncCloudCodingContainerResponse>(
|
|
342
|
+
`/coding-containers/${encodeURIComponent(containerId)}/sync`,
|
|
343
|
+
request,
|
|
344
|
+
);
|
|
345
|
+
} catch (error) {
|
|
346
|
+
if (isMissingCloudCodingEndpoint(error)) {
|
|
347
|
+
throw cloudCodingUnavailable(
|
|
348
|
+
"Eliza Cloud coding-container sync endpoint is not deployed yet",
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
throw error;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
280
355
|
// ─── Accessors ─────────────────────────────────────────────────────────
|
|
281
356
|
|
|
282
357
|
getTrackedContainers(): CloudContainer[] {
|
|
@@ -294,4 +369,22 @@ export class CloudContainerService extends Service {
|
|
|
294
369
|
getContainerUrl(containerId: string): string | null {
|
|
295
370
|
return this.tracked.get(containerId)?.container.load_balancer_url ?? null;
|
|
296
371
|
}
|
|
372
|
+
|
|
373
|
+
private isAuthenticated(): boolean {
|
|
374
|
+
return this.authService?.isAuthenticated?.() === true;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function isMissingCloudCodingEndpoint(error: unknown): boolean {
|
|
379
|
+
const statusCode =
|
|
380
|
+
typeof (error as { statusCode?: unknown })?.statusCode === "number"
|
|
381
|
+
? (error as { statusCode: number }).statusCode
|
|
382
|
+
: undefined;
|
|
383
|
+
return statusCode === 404 || statusCode === 501;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function cloudCodingUnavailable(message: string): Error & { statusCode: number } {
|
|
387
|
+
const error = new Error(message) as Error & { statusCode: number };
|
|
388
|
+
error.statusCode = 503;
|
|
389
|
+
return error;
|
|
297
390
|
}
|
|
@@ -93,7 +93,7 @@ export class CloudCredentialProvider extends Service {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
override async stop(): Promise<void> {
|
|
96
|
-
//
|
|
96
|
+
// Holds no per-instance state.
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
async resolve(_userId: string, credType: string): Promise<CredentialProviderResult> {
|
|
@@ -111,7 +111,7 @@ export class CloudModelRegistryService extends Service {
|
|
|
111
111
|
const client = auth.getClient();
|
|
112
112
|
|
|
113
113
|
const response = await client.get<ModelListResponse>("/models");
|
|
114
|
-
const entries = response.data ?? [];
|
|
114
|
+
const entries: ModelListEntry[] = response.data ?? [];
|
|
115
115
|
|
|
116
116
|
this.models = entries.map((entry) => ({
|
|
117
117
|
id: entry.id,
|
package/src/types/cloud.ts
CHANGED
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
* for containers, auth, credits, bridge messaging, and agent state snapshots.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
export type {
|
|
9
|
+
CloudCodingAgent,
|
|
10
|
+
CloudCodingContainerSession,
|
|
11
|
+
CloudCodingContainerStatus,
|
|
12
|
+
CloudCodingPatch,
|
|
13
|
+
CloudCodingPatchFormat,
|
|
14
|
+
CloudCodingPromotion,
|
|
15
|
+
CloudCodingSyncDirection,
|
|
16
|
+
CloudCodingSyncResult,
|
|
17
|
+
CloudVfsBundle,
|
|
18
|
+
CloudVfsDeletedFile,
|
|
19
|
+
CloudVfsFile,
|
|
20
|
+
CloudVfsFileEncoding,
|
|
21
|
+
CloudVfsSourceKind,
|
|
22
|
+
PromoteVfsToCloudContainerRequest,
|
|
23
|
+
PromoteVfsToCloudContainerResponse,
|
|
24
|
+
RequestCodingAgentContainerRequest,
|
|
25
|
+
RequestCodingAgentContainerResponse,
|
|
26
|
+
SyncCloudCodingContainerRequest,
|
|
27
|
+
SyncCloudCodingContainerResponse,
|
|
28
|
+
} from "@elizaos/shared";
|
|
29
|
+
|
|
8
30
|
// ─── Container Types ────────────────────────────────────────────────────────
|
|
9
31
|
|
|
10
32
|
export type ContainerStatus =
|
package/src/types/index.ts
CHANGED
|
@@ -43,9 +43,22 @@ export type {
|
|
|
43
43
|
BridgeMessage,
|
|
44
44
|
BridgeMessageHandler,
|
|
45
45
|
CloudApiErrorBody,
|
|
46
|
+
CloudCodingAgent,
|
|
47
|
+
CloudCodingContainerSession,
|
|
48
|
+
CloudCodingContainerStatus,
|
|
49
|
+
CloudCodingPatch,
|
|
50
|
+
CloudCodingPatchFormat,
|
|
51
|
+
CloudCodingPromotion,
|
|
52
|
+
CloudCodingSyncDirection,
|
|
53
|
+
CloudCodingSyncResult,
|
|
46
54
|
CloudContainer,
|
|
47
55
|
CloudCredentials,
|
|
48
56
|
CloudPluginConfig,
|
|
57
|
+
CloudVfsBundle,
|
|
58
|
+
CloudVfsDeletedFile,
|
|
59
|
+
CloudVfsFile,
|
|
60
|
+
CloudVfsFileEncoding,
|
|
61
|
+
CloudVfsSourceKind,
|
|
49
62
|
ContainerArchitecture,
|
|
50
63
|
ContainerBillingStatus,
|
|
51
64
|
ContainerDeleteResponse,
|
|
@@ -69,11 +82,17 @@ export type {
|
|
|
69
82
|
GatewayRelaySession,
|
|
70
83
|
InferenceMode,
|
|
71
84
|
PollGatewayRelayResponse,
|
|
85
|
+
PromoteVfsToCloudContainerRequest,
|
|
86
|
+
PromoteVfsToCloudContainerResponse,
|
|
72
87
|
RegisterGatewayRelaySessionResponse,
|
|
88
|
+
RequestCodingAgentContainerRequest,
|
|
89
|
+
RequestCodingAgentContainerResponse,
|
|
73
90
|
RestoreSnapshotRequest,
|
|
74
91
|
RestoreSnapshotResponse,
|
|
75
92
|
SnapshotListResponse,
|
|
76
93
|
SnapshotType,
|
|
94
|
+
SyncCloudCodingContainerRequest,
|
|
95
|
+
SyncCloudCodingContainerResponse,
|
|
77
96
|
} from "./cloud";
|
|
78
97
|
|
|
79
98
|
export {
|
|
@@ -95,7 +95,45 @@ function normalizeBaseUrl(value: string | undefined, fallback: string): string {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
function apiOriginFromApiBaseUrl(value: string): string {
|
|
98
|
-
return value.
|
|
98
|
+
return new URL(value).origin;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function normalizeCloudApiBaseUrl(value: string | undefined, fallback: string): string {
|
|
102
|
+
const baseUrl = normalizeBaseUrl(value, fallback);
|
|
103
|
+
let url: URL;
|
|
104
|
+
try {
|
|
105
|
+
url = new URL(baseUrl);
|
|
106
|
+
} catch {
|
|
107
|
+
throw new Error(`Invalid Eliza Cloud API base URL: ${baseUrl}`);
|
|
108
|
+
}
|
|
109
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
110
|
+
throw new Error(`Invalid Eliza Cloud API base URL protocol: ${baseUrl}`);
|
|
111
|
+
}
|
|
112
|
+
if (url.search || url.hash) {
|
|
113
|
+
throw new Error(`Eliza Cloud API base URL must not include query or hash: ${baseUrl}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const pathname = trimTrailingSlash(url.pathname);
|
|
117
|
+
if (!pathname || pathname === "/") {
|
|
118
|
+
url.pathname = "/api/v1";
|
|
119
|
+
} else if (pathname === "/api/v1") {
|
|
120
|
+
url.pathname = "/api/v1";
|
|
121
|
+
} else {
|
|
122
|
+
throw new Error(`Eliza Cloud API base URL must be an origin or end at /api/v1: ${baseUrl}`);
|
|
123
|
+
}
|
|
124
|
+
return trimTrailingSlash(url.toString());
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function browserBaseUrlForCliLogin(baseUrl: string): string {
|
|
128
|
+
try {
|
|
129
|
+
const url = new URL(baseUrl);
|
|
130
|
+
if (url.hostname.toLowerCase() === "api.elizacloud.ai") {
|
|
131
|
+
return DEFAULT_ELIZA_CLOUD_BASE_URL;
|
|
132
|
+
}
|
|
133
|
+
} catch {
|
|
134
|
+
// Fall through to the configured base URL.
|
|
135
|
+
}
|
|
136
|
+
return baseUrl;
|
|
99
137
|
}
|
|
100
138
|
|
|
101
139
|
function encodePathParam(value: string | number): string {
|
|
@@ -129,7 +167,7 @@ export class ElizaCloudClient {
|
|
|
129
167
|
|
|
130
168
|
constructor(options: ElizaCloudClientOptions = {}) {
|
|
131
169
|
this.baseUrl = normalizeBaseUrl(options.baseUrl, DEFAULT_ELIZA_CLOUD_BASE_URL);
|
|
132
|
-
this.apiBaseUrl =
|
|
170
|
+
this.apiBaseUrl = normalizeCloudApiBaseUrl(
|
|
133
171
|
options.apiBaseUrl,
|
|
134
172
|
options.baseUrl ? `${this.baseUrl}/api/v1` : DEFAULT_ELIZA_CLOUD_API_BASE_URL,
|
|
135
173
|
);
|
|
@@ -192,7 +230,8 @@ export class ElizaCloudClient {
|
|
|
192
230
|
startCliLogin(options: CliLoginStartOptions = {}): Promise<CliLoginStartResponse> {
|
|
193
231
|
const sessionId = options.sessionId ?? getCryptoRandomUuid();
|
|
194
232
|
const query = options.returnTo ? `?returnTo=${encodeURIComponent(options.returnTo)}` : "";
|
|
195
|
-
const
|
|
233
|
+
const browserBaseUrl = browserBaseUrlForCliLogin(this.baseUrl);
|
|
234
|
+
const browserUrl = `${browserBaseUrl}/auth/cli-login?session=${encodeURIComponent(
|
|
196
235
|
sessionId,
|
|
197
236
|
)}${query}`;
|
|
198
237
|
|