Skip to content

Commit 013c258

Browse files
author
lalalune
committed
Merge branch 'develop' of https://github.com/elizaOS/eliza into develop
2 parents 1d9bfe9 + df446aa commit 013c258

6 files changed

Lines changed: 75 additions & 47 deletions

File tree

.github/workflows/cloud-deploy-backend.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ jobs:
7676
run: |
7777
for attempt in 1 2 3; do
7878
if [ "$attempt" -eq 3 ]; then
79-
bun install --no-save --verbose && git diff --exit-code -- bun.lock && exit 0
79+
bun install --frozen-lockfile --ignore-scripts --verbose && exit 0
8080
else
81-
bun install --no-save && git diff --exit-code -- bun.lock && exit 0
81+
bun install --frozen-lockfile --ignore-scripts && exit 0
8282
fi
8383
84-
echo "bun install attempt $attempt failed or changed bun.lock; retrying in 10s..."
84+
echo "bun install attempt $attempt failed; retrying in 10s..."
8585
sleep 10
8686
done
8787
@@ -148,12 +148,12 @@ jobs:
148148
run: |
149149
for attempt in 1 2 3; do
150150
if [ "$attempt" -eq 3 ]; then
151-
bun install --no-save --verbose && git diff --exit-code -- bun.lock && exit 0
151+
bun install --frozen-lockfile --ignore-scripts --verbose && exit 0
152152
else
153-
bun install --no-save && git diff --exit-code -- bun.lock && exit 0
153+
bun install --frozen-lockfile --ignore-scripts && exit 0
154154
fi
155155
156-
echo "bun install attempt $attempt failed or changed bun.lock; retrying in 10s..."
156+
echo "bun install attempt $attempt failed; retrying in 10s..."
157157
sleep 10
158158
done
159159
@@ -294,7 +294,7 @@ jobs:
294294
export PATH="$BUN_INSTALL/bin:$PATH"
295295
fi
296296
for attempt in 1 2 3; do
297-
if bun install --frozen-lockfile; then
297+
if bun install --frozen-lockfile --ignore-scripts; then
298298
break
299299
fi
300300

.github/workflows/deploy-eliza-provisioning-worker.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ jobs:
8787
rm -f .git/index.lock
8888
8989
# Discard local drift, preserve env files.
90-
git clean -fdx -e .env -e .env.local -e .env.* -e node_modules || true
90+
git clean -fdx \
91+
-e .env \
92+
-e .env.local \
93+
-e .env.* \
94+
-e cloud/.env.local \
95+
-e cloud/.env.* \
96+
-e node_modules || true
9197
git checkout -- . 2>/dev/null || true
9298
9399
# bun.lock became tracked at 4ae092dcda; the host's previous deploy
@@ -120,31 +126,20 @@ jobs:
120126
export PATH="$BUN_INSTALL/bin:$PATH"
121127
fi
122128
123-
# cloud/ is a separate bun project (not a sub-workspace of the
124-
# outer monorepo, whose `workspaces` is `packages/*`). Install from
125-
# /opt/eliza/cloud so the worker's deps end up in cloud/node_modules.
126-
#
127-
# No --frozen-lockfile: cloud/bun.lock currently has a duplicate
128-
# package path for @elizaos/plugin-workflow (workspace + registry
129-
# entries for the same name) that bun rejects under frozen mode.
130-
# Cloud-CF deploys hit the same upstream bug; until the lockfile is
131-
# cleaned at source, allow bun to recompute the deps tree.
132-
cd /opt/eliza/cloud
129+
cd /opt/eliza
133130
for attempt in 1 2 3; do
134-
if bun install; then
131+
if bun install --frozen-lockfile --ignore-scripts; then
135132
break
136133
fi
137134
if [ "$attempt" -eq 3 ]; then exit 1; fi
138135
echo "bun install attempt $attempt failed; retrying in 10s..."
139136
sleep 10
140137
done
141-
cd /opt/eliza
142138
143139
# The daemons run under Node/tsx rather than Bun. Node resolves
144140
# linked workspace packages through their built `node` exports, so
145141
# refresh linked package dist files after installing dependencies.
146-
bun run --cwd cloud build:linked-core
147-
bun run --cwd cloud build:linked-billing
142+
bun run build:core
148143
mkdir -p plugins/plugin-sql/node_modules/@elizaos
149144
rm -rf plugins/plugin-sql/node_modules/@elizaos/core
150145
ln -s ../../../../packages/core plugins/plugin-sql/node_modules/@elizaos/core

packages/scripts/cloud/admin/daemons/agent-router.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import * as path from "node:path";
1818
import { fileURLToPath } from "node:url";
1919
import { loadLocalEnv } from "./shared/load-env";
2020

21-
type Logger = typeof import("../../lib/utils/logger").logger;
22-
type Repo = typeof import("../../db/repositories/agent-sandboxes").agentSandboxesRepository;
21+
type Logger = typeof import("@elizaos/cloud-shared/lib/utils/logger").logger;
22+
type Repo =
23+
typeof import("@elizaos/cloud-shared/db/repositories/agent-sandboxes").agentSandboxesRepository;
2324

2425
interface RouterDeps {
2526
logger: Logger;
@@ -40,7 +41,9 @@ function parsePositiveInt(value: string | undefined, fallback: number): number {
4041
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
4142
}
4243

43-
export function readRouterConfig(env: NodeJS.ProcessEnv = process.env): AgentRouterConfig {
44+
export function readRouterConfig(
45+
env: NodeJS.ProcessEnv = process.env,
46+
): AgentRouterConfig {
4447
return {
4548
port: parsePositiveInt(env.AGENT_ROUTER_PORT, DEFAULT_PORT),
4649
bindHost: env.AGENT_ROUTER_BIND_HOST?.trim() || DEFAULT_BIND_HOST,
@@ -52,8 +55,8 @@ let depsPromise: Promise<RouterDeps> | null = null;
5255
async function loadDeps(): Promise<RouterDeps> {
5356
if (!depsPromise) {
5457
depsPromise = Promise.all([
55-
import("../../db/repositories/agent-sandboxes"),
56-
import("../../lib/utils/logger"),
58+
import("@elizaos/cloud-shared/db/repositories/agent-sandboxes"),
59+
import("@elizaos/cloud-shared/lib/utils/logger"),
5760
]).then(([repoModule, loggerModule]) => ({
5861
agentSandboxesRepository: repoModule.agentSandboxesRepository,
5962
logger: loggerModule.logger,
@@ -69,7 +72,9 @@ interface RoutingResponse {
6972
target: string;
7073
}
7174

72-
export async function resolveAgentRouting(agentId: string): Promise<RoutingResponse | null> {
75+
export async function resolveAgentRouting(
76+
agentId: string,
77+
): Promise<RoutingResponse | null> {
7378
const { agentSandboxesRepository } = await loadDeps();
7479
const sandbox = await agentSandboxesRepository.findById(agentId);
7580
if (!sandbox || sandbox.status !== "running") return null;
@@ -95,15 +100,18 @@ export async function resolveAgentRouting(agentId: string): Promise<RoutingRespo
95100
};
96101
}
97102

98-
const AGENT_ID_RE = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
103+
const AGENT_ID_RE =
104+
/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
99105

100106
async function handleRequest(url: URL): Promise<Response> {
101107
if (url.pathname === "/healthz") {
102108
return Response.json({ ok: true }, { status: 200 });
103109
}
104110
// /headscale-ip is the path nginx Lua already calls; /routing is the alias
105111
// for new callers.
106-
const match = url.pathname.match(/^\/agents\/([^/]+)\/(headscale-ip|routing)$/);
112+
const match = url.pathname.match(
113+
/^\/agents\/([^/]+)\/(headscale-ip|routing)$/,
114+
);
107115
if (!match) {
108116
return Response.json({ error: "not found" }, { status: 404 });
109117
}
@@ -113,7 +121,10 @@ async function handleRequest(url: URL): Promise<Response> {
113121
}
114122
const routing = await resolveAgentRouting(agentId);
115123
if (!routing) {
116-
return Response.json({ error: "agent not found or not running" }, { status: 404 });
124+
return Response.json(
125+
{ error: "agent not found or not running" },
126+
{ status: 404 },
127+
);
117128
}
118129
return Response.json(routing, { status: 200 });
119130
}
@@ -127,11 +138,16 @@ async function main(): Promise<void> {
127138

128139
const { createServer } = await import("node:http");
129140
server = createServer((req, res) => {
130-
const url = new URL(req.url ?? "/", `http://${req.headers.host || "localhost"}`);
141+
const url = new URL(
142+
req.url ?? "/",
143+
`http://${req.headers.host || "localhost"}`,
144+
);
131145
handleRequest(url)
132146
.then((response) => {
133147
res.statusCode = response.status;
134-
response.headers.forEach((v, k) => res.setHeader(k, v));
148+
response.headers.forEach((v, k) => {
149+
res.setHeader(k, v);
150+
});
135151
return response.text();
136152
})
137153
.then((body) => {
@@ -206,7 +222,8 @@ process.on("unhandledRejection", (reason) => {
206222
});
207223

208224
function isMainModule(): boolean {
209-
return path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
225+
const entry = process.argv[1];
226+
return entry ? path.resolve(entry) === fileURLToPath(import.meta.url) : false;
210227
}
211228

212229
if (isMainModule()) {

packages/scripts/cloud/admin/daemons/provisioning-worker.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414

1515
import * as path from "node:path";
1616
import { fileURLToPath } from "node:url";
17-
import type { HeartbeatResult, ProcessingResult } from "../../lib/services/provisioning-jobs";
17+
import type {
18+
HeartbeatResult,
19+
ProcessingResult,
20+
} from "@elizaos/cloud-shared/lib/services/provisioning-jobs";
1821
import { loadLocalEnv } from "./shared/load-env";
1922

20-
type WorkerLogger = typeof import("../../lib/utils/logger").logger;
21-
type WorkerService = typeof import("../../lib/services/provisioning-jobs").provisioningJobService;
23+
type WorkerLogger =
24+
typeof import("@elizaos/cloud-shared/lib/utils/logger").logger;
25+
type WorkerService =
26+
typeof import("@elizaos/cloud-shared/lib/services/provisioning-jobs").provisioningJobService;
2227

2328
interface WorkerDeps {
2429
logger: WorkerLogger;
@@ -49,7 +54,10 @@ export function readWorkerConfig(
4954
argv: readonly string[] = process.argv.slice(2),
5055
): ProvisioningWorkerConfig {
5156
return {
52-
pollIntervalMs: parsePositiveInt(env.WORKER_POLL_INTERVAL, DEFAULT_POLL_INTERVAL_MS),
57+
pollIntervalMs: parsePositiveInt(
58+
env.WORKER_POLL_INTERVAL,
59+
DEFAULT_POLL_INTERVAL_MS,
60+
),
5361
batchSize: parsePositiveInt(env.WORKER_BATCH_SIZE, DEFAULT_BATCH_SIZE),
5462
runOnce: env.WORKER_RUN_ONCE === "1" || hasFlag(argv, "--once"),
5563
};
@@ -60,8 +68,8 @@ let depsPromise: Promise<WorkerDeps> | null = null;
6068
async function loadDeps(): Promise<WorkerDeps> {
6169
if (!depsPromise) {
6270
depsPromise = Promise.all([
63-
import("../../lib/services/provisioning-jobs"),
64-
import("../../lib/utils/logger"),
71+
import("@elizaos/cloud-shared/lib/services/provisioning-jobs"),
72+
import("@elizaos/cloud-shared/lib/utils/logger"),
6573
]).then(([jobsModule, loggerModule]) => ({
6674
provisioningJobService: jobsModule.provisioningJobService,
6775
logger: loggerModule.logger,
@@ -86,7 +94,9 @@ export async function processProvisioningWorkerCycle(
8694
return provisioningJobService.processPendingJobs(batchSize);
8795
}
8896

89-
export async function processHeartbeatCycle(concurrency = 5): Promise<HeartbeatResult> {
97+
export async function processHeartbeatCycle(
98+
concurrency = 5,
99+
): Promise<HeartbeatResult> {
90100
const { provisioningJobService } = await loadDeps();
91101
return provisioningJobService.processRunningHeartbeats(concurrency);
92102
}
@@ -97,11 +107,17 @@ async function sleep(ms: number): Promise<void> {
97107
return new Promise((resolve) => setTimeout(resolve, ms));
98108
}
99109

100-
async function pollCycle(logger: WorkerLogger, config: ProvisioningWorkerConfig): Promise<void> {
110+
async function pollCycle(
111+
logger: WorkerLogger,
112+
config: ProvisioningWorkerConfig,
113+
): Promise<void> {
101114
try {
102115
const result = await processProvisioningWorkerCycle(config.batchSize);
103116
if (result.claimed > 0 || result.failed > 0) {
104-
logger.info("[provisioning-worker] cycle complete", resultContext(result));
117+
logger.info(
118+
"[provisioning-worker] cycle complete",
119+
resultContext(result),
120+
);
105121
}
106122
} catch (error) {
107123
logger.error("[provisioning-worker] cycle failed", {

packages/scripts/cloud/admin/eliza-agent-router.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Wants=network-online.target
88
Type=simple
99
User=deploy
1010
Group=deploy
11-
WorkingDirectory=/opt/eliza/cloud
11+
WorkingDirectory=/opt/eliza
1212
EnvironmentFile=/opt/eliza/cloud/.env.local
1313
# Use the installed workspace binary directly to avoid `npx` startup overhead.
1414
Environment=NODE_OPTIONS=--max-old-space-size=512
15-
ExecStart=/opt/eliza/cloud/node_modules/.bin/tsx packages/scripts/cloud/admin/daemons/agent-router.ts
15+
ExecStart=/opt/eliza/node_modules/.bin/tsx --tsconfig /opt/eliza/packages/cloud-shared/tsconfig.json /opt/eliza/packages/scripts/cloud/admin/daemons/agent-router.ts
1616

1717
Restart=always
1818
RestartSec=5

packages/scripts/cloud/admin/eliza-provisioning-worker.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Wants=network-online.target
88
Type=simple
99
User=deploy
1010
Group=deploy
11-
WorkingDirectory=/opt/eliza/cloud
11+
WorkingDirectory=/opt/eliza
1212
EnvironmentFile=/opt/eliza/cloud/.env.local
1313
# ssh2 + dockerode are Node-only, so the daemon runs under tsx (not bun).
1414
# Use the installed workspace binary directly; `npx tsx` adds npm/esbuild
1515
# startup overhead and has hit Node worker heap limits on the deploy host.
1616
Environment=NODE_OPTIONS=--max-old-space-size=1024
17-
ExecStart=/opt/eliza/cloud/node_modules/.bin/tsx packages/scripts/cloud/admin/daemons/provisioning-worker.ts
17+
ExecStart=/opt/eliza/node_modules/.bin/tsx --tsconfig /opt/eliza/packages/cloud-shared/tsconfig.json /opt/eliza/packages/scripts/cloud/admin/daemons/provisioning-worker.ts
1818

1919
Restart=always
2020
RestartSec=5

0 commit comments

Comments
 (0)