Skip to content

Commit a997418

Browse files
author
Shaw
committed
Merge PR #7845: chore(cloud): post-merge /clean follow-up on lifecycle job code
2 parents cb7df8f + 773511d commit a997418

5 files changed

Lines changed: 13 additions & 18 deletions

File tree

packages/cloud-api/v1/agents/[agentId]/logs/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ app.get("/", async (c) => {
3737
identity.organizationId,
3838
);
3939
if (!agent) {
40-
return c.json({ error: "Agent not found" }, 404);
40+
return c.json({ success: false, error: "Agent not found" }, 404);
4141
}
4242

4343
const rawTail = parseInt(c.req.query("tail") ?? "100", 10);

packages/cloud-api/v1/eliza/agents/[agentId]/resume/route.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,9 @@ async function __hono_POST(
174174
}
175175

176176
try {
177-
// Distinct from `agent_provision` so the daemon can tell a user-
178-
// initiated resume from a fresh provision in audit logs, and so a
179-
// future `docker start` fast path can hook in without touching
180-
// the route. Today executeResume always re-provisions to restore
181-
// bridge/health URLs via the sandbox handle.
177+
// Distinct job type from `agent_provision` so the daemon can
178+
// tell a user-initiated resume from a fresh provision in audit
179+
// logs.
182180
const { job, created } =
183181
await provisioningJobService.enqueueAgentResumeOnce({
184182
agentId,

packages/cloud-api/v1/eliza/agents/[agentId]/route.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,6 @@ app.delete("/", async (c) => {
355355
202,
356356
);
357357
} catch (error) {
358-
if (error instanceof Error && error.message === "Agent not found") {
359-
return c.json({ success: false, error: "Agent not found" }, 404);
360-
}
361358
logger.error("[agent-api] DELETE /agents/:agentId error", { error });
362359
return failureResponse(c, error);
363360
}

packages/cloud-shared/src/lib/services/__tests__/provisioning-job-types.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ describe("JOB_TYPES", () => {
2222
expect(JOB_TYPES.AGENT_RESTART).toBe("agent_restart");
2323
expect(JOB_TYPES.AGENT_LOGS).toBe("agent_logs");
2424
expect(JOB_TYPES.AGENT_SNAPSHOT).toBe("agent_snapshot");
25+
// Lock the size so a new entry without a matching assertion above
26+
// fails CI instead of being silently under-covered by tests below.
27+
expect(Object.keys(JOB_TYPES)).toHaveLength(7);
2528
});
2629

2730
test("wire values are unique (no two symbols share a string)", () => {

packages/cloud-shared/src/lib/services/provisioning-jobs.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ export class ProvisioningJobService {
977977
await agentSandboxesRepository.update(data.agentId, {
978978
status: "error",
979979
error_message: `Provisioning permanently failed after ${job.max_attempts} attempts: ${errorMsg}`,
980-
} as Parameters<typeof agentSandboxesRepository.update>[1]);
980+
});
981981
logger.warn("[provisioning-jobs] Marked sandbox as error after permanent failure", {
982982
jobId: job.id,
983983
agentId: data.agentId,
@@ -1001,7 +1001,7 @@ export class ProvisioningJobService {
10011001
await agentSandboxesRepository.update(data.agentId, {
10021002
status: "deletion_failed",
10031003
error_message: `Deletion permanently failed after ${job.max_attempts} attempts: ${errorMsg}`,
1004-
} as Parameters<typeof agentSandboxesRepository.update>[1]);
1004+
});
10051005
logger.warn(
10061006
"[provisioning-jobs] Marked sandbox as deletion_failed after permanent failure",
10071007
{ jobId: job.id, agentId: data.agentId },
@@ -1387,18 +1387,16 @@ export class ProvisioningJobService {
13871387
const provResult = await elizaSandboxService.provision(data.agentId, data.organizationId);
13881388

13891389
if (!provResult.success) {
1390-
// Store partial result for debugging
13911390
await jobsRepository.update(job.id, {
1392-
result: {
1391+
result: agentProvisionJobResultToRecord({
13931392
cloudAgentId: data.agentId,
13941393
status: provResult.sandboxRecord?.status ?? "error",
13951394
error: provResult.error,
1396-
},
1395+
}),
13971396
});
13981397
throw new Error(provResult.error);
13991398
}
14001399

1401-
// Mark completed with result
14021400
const jobResult: AgentProvisionJobResult = {
14031401
cloudAgentId: data.agentId,
14041402
status: provResult.sandboxRecord.status,
@@ -1411,7 +1409,6 @@ export class ProvisioningJobService {
14111409
completed_at: new Date(),
14121410
});
14131411

1414-
// Fire webhook if configured
14151412
if (job.webhook_url) {
14161413
await this.fireWebhook(job, jobResult);
14171414
}
@@ -1508,7 +1505,7 @@ export class ProvisioningJobService {
15081505

15091506
await jobsRepository.update(job.id, {
15101507
webhook_status: response.ok ? "delivered" : `failed_${response.status}`,
1511-
} as Partial<Job>);
1508+
});
15121509

15131510
if (!response.ok) {
15141511
logger.warn("[provisioning-jobs] Webhook delivery failed", {
@@ -1525,7 +1522,7 @@ export class ProvisioningJobService {
15251522

15261523
await jobsRepository.update(job.id, {
15271524
webhook_status: "error",
1528-
} as Partial<Job>);
1525+
});
15291526
}
15301527
}
15311528
}

0 commit comments

Comments
 (0)