@sixb/server 0.1.5 → 0.1.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/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/scope.d.ts +6 -2
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/files/content.d.ts +8 -0
- package/dist/files/content.d.ts.map +1 -1
- package/dist/index.js +2507 -1573
- package/dist/index.js.map +22 -20
- package/dist/models/display.d.ts +22 -0
- package/dist/models/display.d.ts.map +1 -0
- package/dist/routes/action-runs.d.ts +2 -0
- package/dist/routes/action-runs.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +1 -0
- package/dist/routes/actions.d.ts.map +1 -1
- package/dist/routes/agent-api-gateway.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +99 -89
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/ai-accounting.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +139 -15
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/events.d.ts +3 -3
- package/dist/routes/files.d.ts +1 -0
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/models.d.ts +18 -1
- package/dist/routes/models.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +3 -1
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +2 -1
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/rules.d.ts +1 -1
- package/dist/routes/syncs.d.ts +1 -0
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +57 -54
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +4 -4
- package/dist/schemas/agents.d.ts +378 -215
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +1847 -295
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/ai-limits.d.ts +2210 -0
- package/dist/schemas/ai-limits.d.ts.map +1 -0
- package/dist/schemas/auth.d.ts +202 -72
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/events.d.ts +6 -6
- package/dist/schemas/files.d.ts +3 -0
- package/dist/schemas/files.d.ts.map +1 -1
- package/dist/schemas/models.d.ts +214 -14
- package/dist/schemas/models.d.ts.map +1 -1
- package/dist/schemas/objects.d.ts +4 -4
- package/dist/schemas/pipelines.d.ts +6 -6
- package/dist/schemas/rules.d.ts +6 -6
- package/dist/schemas/workflows.d.ts +196 -206
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/utils/http.d.ts +8 -4
- package/dist/utils/http.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/auth/public-routes.ts +18 -0
- package/src/auth/scope.ts +3 -2
- package/src/files/content.ts +39 -6
- package/src/models/display.ts +91 -0
- package/src/routes/agent-api-gateway.ts +137 -38
- package/src/routes/agents.ts +58 -83
- package/src/routes/ai-accounting.ts +414 -23
- package/src/routes/auth.ts +297 -2
- package/src/routes/models.ts +12 -4
- package/src/routes/workflows.ts +3 -5
- package/src/routes/ws/agents.ts +17 -6
- package/src/schemas/agents.ts +40 -49
- package/src/schemas/ai-accounting.ts +88 -19
- package/src/schemas/ai-limits.ts +116 -0
- package/src/schemas/auth.ts +39 -0
- package/src/schemas/files.ts +1 -0
- package/src/schemas/models.ts +33 -5
- package/src/schemas/workflows.ts +0 -2
- package/src/utils/http.ts +33 -2
package/src/routes/agents.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AgentDefinition,
|
|
3
|
-
AgentRequestError,
|
|
4
|
-
type AgentRunView,
|
|
5
|
-
type FileRef,
|
|
6
|
-
type SixbHostView,
|
|
7
|
-
} from "@sixb/core"
|
|
1
|
+
import { AgentRequestError, type AgentRunView, type FileRef, type SixbHostView } from "@sixb/core"
|
|
8
2
|
import { agentRunStreamId } from "@sixb/core/agents/streams"
|
|
9
3
|
import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/internal/agents"
|
|
10
4
|
import {
|
|
@@ -15,6 +9,7 @@ import {
|
|
|
15
9
|
type AgentStorage,
|
|
16
10
|
AgentStorageError,
|
|
17
11
|
type AgentThreadRecord,
|
|
12
|
+
type ConversationAgentRunRecord,
|
|
18
13
|
} from "@sixb/core/storage"
|
|
19
14
|
import type { Elysia } from "elysia"
|
|
20
15
|
import { ZodError, z } from "zod"
|
|
@@ -29,8 +24,7 @@ import {
|
|
|
29
24
|
import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
30
25
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
31
26
|
import {
|
|
32
|
-
|
|
33
|
-
AgentIdParamsSchema,
|
|
27
|
+
AgentDescriptorSchema,
|
|
34
28
|
AgentMessageFileContentParamsSchema,
|
|
35
29
|
AgentMessageListResponseSchema,
|
|
36
30
|
AgentMessageSchema,
|
|
@@ -51,7 +45,7 @@ import {
|
|
|
51
45
|
PostAgentMessageResponseSchema,
|
|
52
46
|
RetryAgentRunResponseSchema,
|
|
53
47
|
} from "../schemas/agents"
|
|
54
|
-
import { ErrorResponseSchema } from "../schemas/common"
|
|
48
|
+
import { codedErrorResponseSchema, ErrorResponseSchema, JsonValueSchema } from "../schemas/common"
|
|
55
49
|
import { FileContentQuerySchema } from "../schemas/files"
|
|
56
50
|
import {
|
|
57
51
|
handleRouteError,
|
|
@@ -67,23 +61,15 @@ const AgentMessageFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
|
67
61
|
.regex(/^\/parts(?:\/|$)/, "Agent message file content paths must start with /parts/"),
|
|
68
62
|
})
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
description: agent.description,
|
|
75
|
-
modelId: agent.model.modelId,
|
|
76
|
-
reasoning: agent.reasoning,
|
|
77
|
-
groupIds: agent.groupIds,
|
|
78
|
-
loop: agent.loop,
|
|
79
|
-
})
|
|
80
|
-
}
|
|
64
|
+
const AiUsageLimitErrorResponseSchema = codedErrorResponseSchema([
|
|
65
|
+
"ai.usage_limit_exceeded",
|
|
66
|
+
"ai.usage_limit_unavailable",
|
|
67
|
+
]).extend({ details: JsonValueSchema.optional() })
|
|
81
68
|
|
|
82
69
|
function serializeThread(thread: AgentThreadRecord): ReturnType<typeof AgentThreadSchema.parse> {
|
|
83
70
|
return AgentThreadSchema.parse({
|
|
84
71
|
id: thread.id,
|
|
85
72
|
projectId: thread.projectId,
|
|
86
|
-
agentId: thread.agentId,
|
|
87
73
|
ownerPrincipal: thread.ownerPrincipal,
|
|
88
74
|
title: thread.title,
|
|
89
75
|
status: thread.status,
|
|
@@ -129,10 +115,11 @@ export function serializeAgentRun(run: AgentRunView): ReturnType<typeof AgentRun
|
|
|
129
115
|
id: run.id,
|
|
130
116
|
projectId: run.projectId,
|
|
131
117
|
threadId: run.threadId,
|
|
132
|
-
agentId: run.agentId,
|
|
133
118
|
triggerMessageId: run.triggerMessageId,
|
|
134
119
|
requestedBy: run.requestedBy,
|
|
135
120
|
status: run.status,
|
|
121
|
+
model: run.spec?.model,
|
|
122
|
+
reasoning: run.spec?.reasoning,
|
|
136
123
|
modelId: run.modelId,
|
|
137
124
|
finishReason: run.finishReason,
|
|
138
125
|
usage: run.usage,
|
|
@@ -152,7 +139,7 @@ async function getAgentMessageFileContentThread(params: {
|
|
|
152
139
|
readonly storage: AgentStorage
|
|
153
140
|
readonly projectId: string
|
|
154
141
|
readonly threadId: string
|
|
155
|
-
}): Promise<AgentThreadRecord | null> {
|
|
142
|
+
}): Promise<Pick<AgentThreadRecord, "id"> | null> {
|
|
156
143
|
const { agentRun } = params.authState
|
|
157
144
|
if (agentRun) {
|
|
158
145
|
if (agentRun.projectId !== params.projectId || agentRun.threadId !== params.threadId) {
|
|
@@ -164,7 +151,7 @@ async function getAgentMessageFileContentThread(params: {
|
|
|
164
151
|
if (!params.authState.sixb) {
|
|
165
152
|
throw new Error("[SixbServer] Execution scope is not available for this route.")
|
|
166
153
|
}
|
|
167
|
-
return params.authState.sixb.
|
|
154
|
+
return params.authState.sixb.agent.threads.getById(params.threadId)
|
|
168
155
|
}
|
|
169
156
|
|
|
170
157
|
/** Publish the terminal record core owns; stream delivery stays best-effort at this boundary. */
|
|
@@ -181,8 +168,8 @@ async function publishQueuedRunCancellation(
|
|
|
181
168
|
|
|
182
169
|
function handleAgentRouteError(
|
|
183
170
|
error: unknown,
|
|
184
|
-
set: { status?: number | string }
|
|
185
|
-
):
|
|
171
|
+
set: { status?: number | string; headers?: unknown }
|
|
172
|
+
): ReturnType<typeof handleRouteError> {
|
|
186
173
|
// A duplicate id is a conflict, not a bad request. Map it to a generic 409 rather than echoing the
|
|
187
174
|
// provider's raw message (which leaks the id, project, and storage prefix).
|
|
188
175
|
if (error instanceof AgentStorageError && error.code === "duplicate_id") {
|
|
@@ -205,9 +192,14 @@ function handleAgentRouteError(
|
|
|
205
192
|
case "run_not_retryable":
|
|
206
193
|
set.status = 409
|
|
207
194
|
break
|
|
195
|
+
case "authority_not_inheritable":
|
|
196
|
+
set.status = 403
|
|
197
|
+
break
|
|
208
198
|
case "storage_unavailable":
|
|
209
|
-
case "
|
|
199
|
+
case "agent_selector_removed":
|
|
210
200
|
case "invalid_context":
|
|
201
|
+
case "invalid_model_selection":
|
|
202
|
+
case "model_not_found":
|
|
211
203
|
set.status = 400
|
|
212
204
|
break
|
|
213
205
|
}
|
|
@@ -292,36 +284,19 @@ async function agentMessageFileContentResponse(
|
|
|
292
284
|
export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
293
285
|
return app
|
|
294
286
|
.get(
|
|
295
|
-
"/api/
|
|
296
|
-
(context) => {
|
|
297
|
-
return requireRequestSixb(context).agents.list().map(serializeAgent)
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
response: { 200: AgentCatalogItemSchema.array() },
|
|
301
|
-
detail: {
|
|
302
|
-
summary: "List registered agents",
|
|
303
|
-
tags: [OPENAPI_TAGS.agents.name],
|
|
304
|
-
operationId: "listAgents",
|
|
305
|
-
},
|
|
306
|
-
}
|
|
307
|
-
)
|
|
308
|
-
.get(
|
|
309
|
-
"/api/agents/:agentId",
|
|
287
|
+
"/api/agent",
|
|
310
288
|
(context) => {
|
|
311
|
-
const
|
|
312
|
-
const agent = requireRequestSixb(context).agents.getById(params.agentId)
|
|
289
|
+
const agent = requireRequestSixb(context).agent.get()
|
|
313
290
|
if (!agent) {
|
|
314
|
-
set.status = 404
|
|
315
|
-
return { error: "Agent
|
|
291
|
+
context.set.status = 404
|
|
292
|
+
return { error: "Agent unavailable" }
|
|
316
293
|
}
|
|
317
|
-
|
|
318
|
-
return serializeAgent(agent)
|
|
294
|
+
return AgentDescriptorSchema.parse(agent)
|
|
319
295
|
},
|
|
320
296
|
{
|
|
321
|
-
|
|
322
|
-
response: { 200: AgentCatalogItemSchema, 404: ErrorResponseSchema },
|
|
297
|
+
response: { 200: AgentDescriptorSchema, 404: ErrorResponseSchema },
|
|
323
298
|
detail: {
|
|
324
|
-
summary: "Get
|
|
299
|
+
summary: "Get the project Agent",
|
|
325
300
|
tags: [OPENAPI_TAGS.agents.name],
|
|
326
301
|
operationId: "getAgent",
|
|
327
302
|
},
|
|
@@ -340,13 +315,12 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
340
315
|
|
|
341
316
|
const parsed = AgentThreadListQuerySchema.parse(query)
|
|
342
317
|
const listInput = {
|
|
343
|
-
agentId: parsed.agentId,
|
|
344
318
|
statuses: parsed.status ? [parsed.status] : undefined,
|
|
345
319
|
limit: parseOptionalInt(parsed.limit),
|
|
346
320
|
offset: parseOptionalInt(parsed.offset),
|
|
347
321
|
order: parsed.order,
|
|
348
322
|
}
|
|
349
|
-
const result = await sixb.
|
|
323
|
+
const result = await sixb.agent.threads.list(listInput)
|
|
350
324
|
|
|
351
325
|
return AgentThreadListResponseSchema.parse({
|
|
352
326
|
threads: result.threads.map(serializeThread),
|
|
@@ -383,9 +357,8 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
383
357
|
return missingAgentStorageResponse(set)
|
|
384
358
|
}
|
|
385
359
|
|
|
386
|
-
const thread = await sixb.
|
|
360
|
+
const thread = await sixb.agent.threads.create({
|
|
387
361
|
...(parsed.threadId === undefined ? {} : { id: parsed.threadId }),
|
|
388
|
-
agentId: parsed.agentId,
|
|
389
362
|
...(parsed.title === undefined ? {} : { title: parsed.title }),
|
|
390
363
|
})
|
|
391
364
|
|
|
@@ -400,8 +373,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
400
373
|
response: {
|
|
401
374
|
201: CreateAgentThreadResponseSchema,
|
|
402
375
|
400: ErrorResponseSchema,
|
|
403
|
-
//
|
|
404
|
-
// response never discloses that a forbidden id exists.
|
|
376
|
+
// Match the descriptor endpoint: an unavailable or forbidden Agent returns 404.
|
|
405
377
|
404: ErrorResponseSchema,
|
|
406
378
|
409: ErrorResponseSchema,
|
|
407
379
|
501: ErrorResponseSchema,
|
|
@@ -425,7 +397,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
425
397
|
return missingAgentStorageResponse(set)
|
|
426
398
|
}
|
|
427
399
|
|
|
428
|
-
const thread = await sixb.
|
|
400
|
+
const thread = await sixb.agent.threads.getById(params.threadId)
|
|
429
401
|
if (!thread) {
|
|
430
402
|
set.status = 404
|
|
431
403
|
return { error: "Agent thread not found" }
|
|
@@ -462,7 +434,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
462
434
|
return missingAgentStorageResponse(set)
|
|
463
435
|
}
|
|
464
436
|
|
|
465
|
-
const thread = await sixb.
|
|
437
|
+
const thread = await sixb.agent.threads.getById(params.threadId)
|
|
466
438
|
if (!thread) {
|
|
467
439
|
set.status = 404
|
|
468
440
|
return { error: "Agent thread not found" }
|
|
@@ -488,7 +460,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
488
460
|
])
|
|
489
461
|
const diagnosticsByRunId = new Map(
|
|
490
462
|
runs
|
|
491
|
-
.filter((run) => run.threadId === thread.id)
|
|
463
|
+
.filter((run) => run.kind === "conversation" && run.threadId === thread.id)
|
|
492
464
|
.map((run) => [run.id, run.diagnostics ?? []] as const)
|
|
493
465
|
)
|
|
494
466
|
const checkpointsByRunId = new Map(
|
|
@@ -570,7 +542,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
570
542
|
return missingAgentStorageResponse(set)
|
|
571
543
|
}
|
|
572
544
|
|
|
573
|
-
const thread = await sixb.
|
|
545
|
+
const thread = await sixb.agent.threads.getById(params.threadId)
|
|
574
546
|
if (!thread) {
|
|
575
547
|
set.status = 404
|
|
576
548
|
return { error: "Agent thread not found" }
|
|
@@ -578,14 +550,15 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
578
550
|
|
|
579
551
|
const parsed = PostAgentMessageBodySchema.parse(body)
|
|
580
552
|
const requestInput = {
|
|
581
|
-
agentId: thread.agentId,
|
|
582
553
|
threadId: thread.id,
|
|
583
554
|
text: parsed.text,
|
|
555
|
+
model: parsed.model,
|
|
556
|
+
reasoning: parsed.reasoning,
|
|
584
557
|
attachments: parsed.attachments as readonly FileRef[] | undefined,
|
|
585
558
|
context: parsed.context,
|
|
586
559
|
messageId: parsed.messageId,
|
|
587
560
|
}
|
|
588
|
-
const result = await sixb.
|
|
561
|
+
const result = await sixb.agent.runs.request(requestInput)
|
|
589
562
|
|
|
590
563
|
set.status = 202
|
|
591
564
|
return PostAgentMessageResponseSchema.parse({
|
|
@@ -604,6 +577,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
604
577
|
403: ErrorResponseSchema,
|
|
605
578
|
404: ErrorResponseSchema,
|
|
606
579
|
409: ErrorResponseSchema,
|
|
580
|
+
429: AiUsageLimitErrorResponseSchema,
|
|
607
581
|
501: ErrorResponseSchema,
|
|
608
582
|
},
|
|
609
583
|
detail: {
|
|
@@ -625,28 +599,32 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
625
599
|
return missingAgentStorageResponse(set)
|
|
626
600
|
}
|
|
627
601
|
|
|
628
|
-
const thread = await sixb.
|
|
602
|
+
const thread = await sixb.agent.threads.getById(params.threadId)
|
|
629
603
|
if (!thread) {
|
|
630
604
|
set.status = 404
|
|
631
605
|
return { error: "Agent thread not found" }
|
|
632
606
|
}
|
|
633
607
|
|
|
634
608
|
const parsed = CancelAgentRunBodySchema.parse(body)
|
|
635
|
-
const run = await sixb.
|
|
609
|
+
const run = await sixb.agent.runs.getById(parsed.runId)
|
|
636
610
|
if (!run || run.threadId !== thread.id) {
|
|
637
611
|
set.status = 404
|
|
638
612
|
return { error: "Agent run not found" }
|
|
639
613
|
}
|
|
640
614
|
let current = run
|
|
641
|
-
let
|
|
615
|
+
let cancelledRun: ConversationAgentRunRecord | undefined
|
|
642
616
|
if (current.status === "queued") {
|
|
643
617
|
try {
|
|
644
|
-
|
|
618
|
+
const cancelled = await storage.runs.finishQueued({
|
|
645
619
|
projectId: host.id,
|
|
646
620
|
id: current.id,
|
|
647
621
|
status: "cancelled",
|
|
648
622
|
})
|
|
649
|
-
|
|
623
|
+
if (cancelled.kind !== "conversation") {
|
|
624
|
+
throw new Error(`[SixbServer] Agent run '${cancelled.id}' changed kind.`)
|
|
625
|
+
}
|
|
626
|
+
current = cancelled
|
|
627
|
+
cancelledRun = cancelled
|
|
650
628
|
} catch (error) {
|
|
651
629
|
if (!(error instanceof AgentStorageError) || error.code !== "invalid_state") {
|
|
652
630
|
throw error
|
|
@@ -656,12 +634,8 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
656
634
|
// it. Re-read so that pickup race becomes a running-run cancellation instead of an
|
|
657
635
|
// invalid-state response. A retained control record is safe even if the worker has
|
|
658
636
|
// not attached its cancel subscription yet.
|
|
659
|
-
const refreshed = await
|
|
660
|
-
if (
|
|
661
|
-
!refreshed ||
|
|
662
|
-
refreshed.threadId !== thread.id ||
|
|
663
|
-
refreshed.agentId !== thread.agentId
|
|
664
|
-
) {
|
|
637
|
+
const refreshed = await sixb.agent.runs.getById(current.id)
|
|
638
|
+
if (!refreshed || refreshed.threadId !== thread.id) {
|
|
665
639
|
set.status = 404
|
|
666
640
|
return { error: "Agent run not found" }
|
|
667
641
|
}
|
|
@@ -669,8 +643,8 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
669
643
|
}
|
|
670
644
|
}
|
|
671
645
|
|
|
672
|
-
if (
|
|
673
|
-
await publishQueuedRunCancellation(host,
|
|
646
|
+
if (cancelledRun) {
|
|
647
|
+
await publishQueuedRunCancellation(host, cancelledRun)
|
|
674
648
|
} else if (current.status === "running") {
|
|
675
649
|
await publishAgentRunCancel(host.broker, { projectId: host.id, runId: current.id })
|
|
676
650
|
} else {
|
|
@@ -679,7 +653,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
679
653
|
}
|
|
680
654
|
|
|
681
655
|
set.status = 202
|
|
682
|
-
const currentView = await sixb.
|
|
656
|
+
const currentView = await sixb.agent.runs.getById(current.id)
|
|
683
657
|
if (!currentView) {
|
|
684
658
|
set.status = 404
|
|
685
659
|
return { error: "Agent run not found" }
|
|
@@ -720,13 +694,13 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
720
694
|
return missingAgentStorageResponse(set)
|
|
721
695
|
}
|
|
722
696
|
|
|
723
|
-
const thread = await sixb.
|
|
697
|
+
const thread = await sixb.agent.threads.getById(params.threadId)
|
|
724
698
|
if (!thread) {
|
|
725
699
|
set.status = 404
|
|
726
700
|
return { error: "Agent thread not found" }
|
|
727
701
|
}
|
|
728
702
|
|
|
729
|
-
const failedRun = await sixb.
|
|
703
|
+
const failedRun = await sixb.agent.runs.getById(params.runId)
|
|
730
704
|
if (!failedRun || failedRun.threadId !== thread.id) {
|
|
731
705
|
set.status = 404
|
|
732
706
|
return { error: "Agent run not found" }
|
|
@@ -736,7 +710,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
736
710
|
return { error: "Only failed agent runs can be retried" }
|
|
737
711
|
}
|
|
738
712
|
|
|
739
|
-
const { run } = await sixb.
|
|
713
|
+
const { run } = await sixb.agent.runs.retry(failedRun.id)
|
|
740
714
|
|
|
741
715
|
set.status = 202
|
|
742
716
|
return RetryAgentRunResponseSchema.parse({
|
|
@@ -753,6 +727,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
753
727
|
400: ErrorResponseSchema,
|
|
754
728
|
404: ErrorResponseSchema,
|
|
755
729
|
409: ErrorResponseSchema,
|
|
730
|
+
429: AiUsageLimitErrorResponseSchema,
|
|
756
731
|
501: ErrorResponseSchema,
|
|
757
732
|
},
|
|
758
733
|
detail: {
|
|
@@ -775,7 +750,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
775
750
|
}
|
|
776
751
|
|
|
777
752
|
const parsed = AgentRunListQuerySchema.parse(query)
|
|
778
|
-
const result = await sixb.
|
|
753
|
+
const result = await sixb.agent.runs.listForThread(params.threadId, {
|
|
779
754
|
statuses: parsed.status ? [parsed.status] : undefined,
|
|
780
755
|
limit: parseOptionalInt(parsed.limit),
|
|
781
756
|
offset: parseOptionalInt(parsed.offset),
|
|
@@ -822,7 +797,7 @@ export function registerAgentRoutes(app: Elysia, host: SixbHostView) {
|
|
|
822
797
|
return missingAgentStorageResponse(set)
|
|
823
798
|
}
|
|
824
799
|
|
|
825
|
-
const run = await sixb.
|
|
800
|
+
const run = await sixb.agent.runs.getById(params.runId)
|
|
826
801
|
if (!run) {
|
|
827
802
|
set.status = 404
|
|
828
803
|
return { error: "Agent run not found" }
|