@sixb/server 0.1.2 → 0.1.3

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.
Files changed (72) hide show
  1. package/dist/auth/experience.d.ts +33 -0
  2. package/dist/auth/experience.d.ts.map +1 -0
  3. package/dist/auth/public-routes.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1891 -1337
  7. package/dist/index.js.map +17 -14
  8. package/dist/openapi/tags.d.ts +6 -2
  9. package/dist/openapi/tags.d.ts.map +1 -1
  10. package/dist/registerRoutes.d.ts.map +1 -1
  11. package/dist/routes/action-runs.d.ts +6 -6
  12. package/dist/routes/actions.d.ts +3 -3
  13. package/dist/routes/agents.d.ts +149 -77
  14. package/dist/routes/agents.d.ts.map +1 -1
  15. package/dist/routes/ai-accounting.d.ts +31 -0
  16. package/dist/routes/ai-accounting.d.ts.map +1 -0
  17. package/dist/routes/auth.d.ts +110 -53
  18. package/dist/routes/auth.d.ts.map +1 -1
  19. package/dist/routes/connector-connection-runs.d.ts +56 -56
  20. package/dist/routes/connector-connections.d.ts +14 -14
  21. package/dist/routes/datasets.d.ts +12 -12
  22. package/dist/routes/events.d.ts +1 -1
  23. package/dist/routes/files.d.ts +8 -8
  24. package/dist/routes/links.d.ts +9 -9
  25. package/dist/routes/logs.d.ts +2 -2
  26. package/dist/routes/objects.d.ts +3 -3
  27. package/dist/routes/pipelines.d.ts +10 -10
  28. package/dist/routes/projections.d.ts +62 -50
  29. package/dist/routes/projections.d.ts.map +1 -1
  30. package/dist/routes/syncs.d.ts +6 -6
  31. package/dist/routes/telemetry.d.ts +7 -7
  32. package/dist/routes/webhook-runs.d.ts +2 -2
  33. package/dist/routes/workflows.d.ts +142 -57
  34. package/dist/routes/workflows.d.ts.map +1 -1
  35. package/dist/routes/ws/logs.d.ts +10 -10
  36. package/dist/schemas/actions.d.ts +16 -16
  37. package/dist/schemas/agents.d.ts +459 -142
  38. package/dist/schemas/agents.d.ts.map +1 -1
  39. package/dist/schemas/ai-accounting.d.ts +2393 -0
  40. package/dist/schemas/ai-accounting.d.ts.map +1 -0
  41. package/dist/schemas/auth.d.ts +96 -96
  42. package/dist/schemas/connectors.d.ts +24 -24
  43. package/dist/schemas/event-payloads.d.ts +6 -6
  44. package/dist/schemas/events.d.ts +6 -6
  45. package/dist/schemas/links.d.ts +2 -2
  46. package/dist/schemas/logs.d.ts +18 -18
  47. package/dist/schemas/pipelines.d.ts +20 -20
  48. package/dist/schemas/projections.d.ts +400 -288
  49. package/dist/schemas/projections.d.ts.map +1 -1
  50. package/dist/schemas/status.d.ts +2 -2
  51. package/dist/schemas/syncs.d.ts +10 -10
  52. package/dist/schemas/webhook-runs.d.ts +12 -12
  53. package/dist/schemas/workflows.d.ts +833 -162
  54. package/dist/schemas/workflows.d.ts.map +1 -1
  55. package/dist/server.d.ts +5 -0
  56. package/dist/server.d.ts.map +1 -1
  57. package/package.json +5 -5
  58. package/src/auth/experience.ts +190 -0
  59. package/src/auth/public-routes.ts +7 -0
  60. package/src/index.ts +1 -0
  61. package/src/openapi/tags.ts +4 -0
  62. package/src/registerRoutes.ts +2 -0
  63. package/src/routes/agents.ts +1 -0
  64. package/src/routes/ai-accounting.ts +166 -0
  65. package/src/routes/auth.ts +188 -32
  66. package/src/routes/projections.ts +18 -4
  67. package/src/routes/workflows.ts +16 -0
  68. package/src/schemas/agents.ts +4 -9
  69. package/src/schemas/ai-accounting.ts +182 -0
  70. package/src/schemas/projections.ts +6 -0
  71. package/src/schemas/workflows.ts +8 -3
  72. package/src/server.ts +10 -0
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,wBAAwB,+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AAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIjD,CAAA;AAEF,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGnD,CAAA;AAEF,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEnD,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;EAK3C,CAAA"}
package/dist/server.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import type { SixbHostView } from "@sixb/core";
2
2
  import { Elysia } from "elysia";
3
3
  import { type AuthInvitationDestinationOptions, type AuthInvitationRedirectContext, type AuthInvitationRedirectInput, type RequestAuthContext, type ResolveAuthRedirectContext, type ResolvedSixbApiBrowserPolicy, type SixbApiBrowserPolicy } from "./auth/browser-origin";
4
+ import type { SixbAuthExperienceOptions } from "./auth/experience";
4
5
  export interface SixbServerOptions {
5
6
  host: SixbHostView;
6
7
  port?: number;
7
8
  hostname?: string;
8
9
  quiet?: boolean;
9
10
  browser: SixbApiBrowserPolicy;
11
+ /** Optional custom-app auth bundle mounted under the API's `/auth` routes. */
12
+ authExperience?: SixbAuthExperienceOptions;
10
13
  }
11
14
  export declare function createSixbServer(options: SixbServerOptions): SixbServer;
12
15
  export declare class SixbServer {
@@ -17,6 +20,7 @@ export declare class SixbServer {
17
20
  private readonly apiBrowserPolicy;
18
21
  private readonly authContextResolver;
19
22
  private readonly authRedirectContextResolver;
23
+ private readonly authExperience?;
20
24
  private app;
21
25
  private bunServer;
22
26
  private maintenance;
@@ -29,6 +33,7 @@ export declare class SixbServer {
29
33
  getInvitationDestinationOptions(_request: Request): AuthInvitationDestinationOptions;
30
34
  resolveInvitationRedirectContext(request: Request, input: AuthInvitationRedirectInput): AuthInvitationRedirectContext;
31
35
  getApiBrowserPolicy(): ResolvedSixbApiBrowserPolicy;
36
+ getAuthExperience(): SixbAuthExperienceOptions | undefined;
32
37
  start(): Promise<void>;
33
38
  stop(): Promise<void>;
34
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,YAAY,CAAA;AAGzE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAMhC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAKjC,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAA;AAoB9B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,oBAAoB,CAAA;CAC9B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAEvE;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO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,0BAA0B,CACxB,OAAO,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAClD,KAAK,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,GAC/C,UAAU,CAAC,0BAA0B,CAAC;IAIzC,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAIlD,+BAA+B,CAAC,QAAQ,EAAE,OAAO,GAAG,gCAAgC;IAIpF,gCAAgC,CAC9B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,2BAA2B,GACjC,6BAA6B;IAIhC,mBAAmB,IAAI,4BAA4B;IAInD,iBAAiB,IAAI,yBAAyB,GAAG,SAAS;IAIpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAe5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiK/C;AAiED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/server",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "HTTP and WebSocket API server for Sixb",
5
5
  "keywords": [
6
6
  "sixb",
@@ -37,13 +37,13 @@
37
37
  "zod-to-json-schema": "^3.24.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@sixb/core": "0.1.2"
40
+ "@sixb/core": "0.1.3"
41
41
  },
42
42
  "devDependencies": {
43
- "@sixb/auth-magic-link": "0.1.1",
43
+ "@sixb/auth-magic-link": "0.1.2",
44
44
  "@sixb/auth-oidc": "0.1.1",
45
- "@sixb/core": "0.1.2",
46
- "@sixb/sqlite": "0.1.2",
45
+ "@sixb/core": "0.1.3",
46
+ "@sixb/sqlite": "0.1.3",
47
47
  "@types/bun": "latest",
48
48
  "typescript": "^5.7.0"
49
49
  },
@@ -0,0 +1,190 @@
1
+ import { resolve } from "node:path"
2
+ import type { AuthSessionAudience } from "@sixb/core"
3
+
4
+ const AUTH_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__"
5
+ const AUTH_ASSET_PREFIX = "/auth/assets/"
6
+
7
+ export interface SixbAuthExperienceOptions {
8
+ readonly outdir: string
9
+ readonly audience?: AuthSessionAudience
10
+ }
11
+
12
+ export type AuthExperiencePageState =
13
+ | { readonly kind: "signIn" }
14
+ | { readonly kind: "checkEmail" }
15
+ | { readonly kind: "confirm"; readonly email?: string }
16
+ | { readonly kind: "invalidLink" }
17
+ | { readonly kind: "error" }
18
+
19
+ export interface AuthExperienceSubmission {
20
+ readonly kind: "requestMagicLink" | "confirmSignIn"
21
+ readonly action: string
22
+ readonly fields: Readonly<Record<string, string>>
23
+ }
24
+
25
+ export async function customAuthExperienceResponse(
26
+ options: SixbAuthExperienceOptions | undefined,
27
+ input: {
28
+ readonly audience: AuthSessionAudience
29
+ readonly state: AuthExperiencePageState
30
+ readonly signInUrl: string
31
+ readonly submission?: AuthExperienceSubmission
32
+ readonly status?: number
33
+ readonly referrerPolicy?: "no-referrer" | "same-origin"
34
+ readonly formActionOrigins?: readonly string[]
35
+ }
36
+ ): Promise<Response | null> {
37
+ if (!options || input.audience !== (options.audience ?? "app")) {
38
+ return null
39
+ }
40
+
41
+ const template = Bun.file(resolve(options.outdir, "index.html"))
42
+ if (!(await template.exists())) {
43
+ return null
44
+ }
45
+
46
+ const html = await template.text()
47
+ if (!html.includes(AUTH_BOOTSTRAP_PLACEHOLDER)) {
48
+ console.warn(
49
+ `[SixbServer] Custom auth experience in ${options.outdir} is missing its bootstrap placeholder. Using the generic page.`
50
+ )
51
+ return null
52
+ }
53
+
54
+ const bootstrap = Buffer.from(
55
+ JSON.stringify({
56
+ state: input.state,
57
+ signInUrl: input.signInUrl,
58
+ ...(input.submission ? { submission: input.submission } : {}),
59
+ })
60
+ ).toString("base64url")
61
+ const formAction = ["'self'", ...(input.formActionOrigins ?? []).map(normalizeCspOrigin)].join(
62
+ " "
63
+ )
64
+
65
+ return new Response(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), {
66
+ status: input.status ?? 200,
67
+ headers: {
68
+ "content-type": "text/html; charset=utf-8",
69
+ "cache-control": "no-store",
70
+ "content-security-policy": [
71
+ "default-src 'none'",
72
+ "script-src 'self'",
73
+ "style-src 'self' 'unsafe-inline'",
74
+ "img-src 'self' data:",
75
+ "font-src 'self'",
76
+ "base-uri 'none'",
77
+ `form-action ${formAction}`,
78
+ "frame-ancestors 'none'",
79
+ ].join("; "),
80
+ "referrer-policy": input.referrerPolicy ?? "no-referrer",
81
+ "x-content-type-options": "nosniff",
82
+ },
83
+ })
84
+ }
85
+
86
+ function normalizeCspOrigin(value: string): string {
87
+ let url: URL
88
+ try {
89
+ url = new URL(value)
90
+ } catch {
91
+ throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`)
92
+ }
93
+
94
+ if ((url.protocol !== "http:" && url.protocol !== "https:") || url.origin !== value) {
95
+ throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`)
96
+ }
97
+ return url.origin
98
+ }
99
+
100
+ export async function customAuthExperienceAssetResponse(
101
+ options: SixbAuthExperienceOptions | undefined,
102
+ request: Request
103
+ ): Promise<Response> {
104
+ const method = request.method.toUpperCase()
105
+ if (!options || (method !== "GET" && method !== "HEAD")) {
106
+ return notFoundResponse()
107
+ }
108
+
109
+ const url = new URL(request.url)
110
+ if (!url.pathname.startsWith(AUTH_ASSET_PREFIX)) {
111
+ return notFoundResponse()
112
+ }
113
+
114
+ let fileName: string
115
+ try {
116
+ fileName = decodeURIComponent(url.pathname.slice(AUTH_ASSET_PREFIX.length))
117
+ } catch {
118
+ return notFoundResponse()
119
+ }
120
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(fileName)) {
121
+ return notFoundResponse()
122
+ }
123
+
124
+ const path = resolve(options.outdir, "assets", fileName)
125
+ const source = Bun.file(path)
126
+ if (!(await source.exists())) {
127
+ return notFoundResponse()
128
+ }
129
+
130
+ const encoding = await resolvePrecompressedAsset(request, path)
131
+ const body = encoding ? Bun.file(`${path}.${encoding === "br" ? "br" : "gz"}`) : source
132
+ const headers = new Headers({
133
+ "content-type": source.type || "application/octet-stream",
134
+ "cache-control": "public, max-age=31536000, immutable",
135
+ "x-content-type-options": "nosniff",
136
+ })
137
+ if (encoding) {
138
+ headers.set("content-encoding", encoding)
139
+ headers.set("vary", "Accept-Encoding")
140
+ }
141
+ return new Response(method === "HEAD" ? null : body, { headers })
142
+ }
143
+
144
+ async function resolvePrecompressedAsset(
145
+ request: Request,
146
+ sourcePath: string
147
+ ): Promise<"br" | "gzip" | null> {
148
+ for (const encoding of acceptedPrecompressedEncodings(request)) {
149
+ const suffix = encoding === "br" ? "br" : "gz"
150
+ if (await Bun.file(`${sourcePath}.${suffix}`).exists()) {
151
+ return encoding
152
+ }
153
+ }
154
+ return null
155
+ }
156
+
157
+ function acceptedPrecompressedEncodings(request: Request): ("br" | "gzip")[] {
158
+ const header = request.headers.get("accept-encoding")
159
+ if (!header) return []
160
+
161
+ const qualities = new Map<string, number>()
162
+ for (const item of header.split(",")) {
163
+ const [rawName, ...parameters] = item.trim().split(";")
164
+ const name = rawName.toLowerCase()
165
+ let quality = 1
166
+ for (const parameter of parameters) {
167
+ const match = parameter.trim().match(/^q=(0(?:\.\d+)?|1(?:\.0+)?)$/)
168
+ if (match) quality = Number(match[1])
169
+ }
170
+ qualities.set(name, quality)
171
+ }
172
+
173
+ const wildcard = qualities.get("*") ?? 0
174
+ return (["br", "gzip"] as const)
175
+ .map((encoding, preference) => ({
176
+ encoding,
177
+ preference,
178
+ quality: qualities.get(encoding) ?? wildcard,
179
+ }))
180
+ .filter((candidate) => candidate.quality > 0)
181
+ .sort((left, right) => right.quality - left.quality || left.preference - right.preference)
182
+ .map((candidate) => candidate.encoding)
183
+ }
184
+
185
+ function notFoundResponse(): Response {
186
+ return new Response("Not Found", {
187
+ status: 404,
188
+ headers: { "content-type": "text/plain; charset=utf-8" },
189
+ })
190
+ }
@@ -72,6 +72,13 @@ export function isPublicRoute(pathname: string, method: string): boolean {
72
72
  return true
73
73
  }
74
74
 
75
+ if (
76
+ pathname.startsWith("/auth/assets/") &&
77
+ (normalizedMethod === "GET" || normalizedMethod === "HEAD")
78
+ ) {
79
+ return true
80
+ }
81
+
75
82
  if (pathname === "/auth/sign-in" && (normalizedMethod === "GET" || normalizedMethod === "POST")) {
76
83
  return true
77
84
  }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export type { SixbApiBrowserPolicy, SixbBrowserOrigin } from "./auth/browser-origin"
2
+ export type { SixbAuthExperienceOptions } from "./auth/experience"
2
3
  export { createSixbServer, SixbServer, type SixbServerOptions } from "./server"
@@ -7,6 +7,10 @@ export const OPENAPI_TAGS = {
7
7
  name: "Status",
8
8
  description: "Runtime status",
9
9
  },
10
+ aiAccounting: {
11
+ name: "AI Accounting",
12
+ description: "Project AI token usage, cost analytics, and model-call accounting",
13
+ },
10
14
  ontology: {
11
15
  name: "Ontology",
12
16
  description: "Object type definitions",
@@ -4,6 +4,7 @@ import { registerActionRunRoutes } from "./routes/action-runs"
4
4
  import { registerActionRoutes } from "./routes/actions"
5
5
  import { registerAgentApiGatewayRoutes } from "./routes/agent-api-gateway"
6
6
  import { registerAgentRoutes } from "./routes/agents"
7
+ import { registerAiAccountingRoutes } from "./routes/ai-accounting"
7
8
  import {
8
9
  type ConnectorConnectionRouteOptions,
9
10
  registerConnectorConnectionRunRoutes,
@@ -33,6 +34,7 @@ export interface HttpRouteOptions {
33
34
 
34
35
  export function registerHttpRoutes(app: Elysia, host: SixbHostView, options: HttpRouteOptions) {
35
36
  registerAgentApiGatewayRoutes(app, host)
37
+ registerAiAccountingRoutes(app, host)
36
38
  registerProjectRoutes(app, host)
37
39
  registerStatusRoutes(app, host)
38
40
  registerConnectorRoutes(app, host)
@@ -127,6 +127,7 @@ export function serializeAgentRun(run: AgentRunView): ReturnType<typeof AgentRun
127
127
  modelId: run.modelId,
128
128
  finishReason: run.finishReason,
129
129
  usage: run.usage,
130
+ cost: run.cost,
130
131
  diagnostics: run.diagnostics,
131
132
  error: run.error,
132
133
  attempt: run.attempt,
@@ -0,0 +1,166 @@
1
+ import type { SixbHostView } from "@sixb/core"
2
+ import type {
3
+ AiAccountingAggregate,
4
+ AiAccountingOverview,
5
+ AiModelCallAccountingItem,
6
+ } from "@sixb/core/storage"
7
+ import type { Elysia } from "elysia"
8
+ import { OPENAPI_TAGS } from "../openapi/tags"
9
+ import {
10
+ AiAccountingOverviewQuerySchema,
11
+ AiAccountingOverviewResponseSchema,
12
+ AiModelCallAccountingListQuerySchema,
13
+ AiModelCallAccountingListResponseSchema,
14
+ } from "../schemas/ai-accounting"
15
+ import { ErrorResponseSchema } from "../schemas/common"
16
+ import { handleRouteError, parseOptionalInt, unconfiguredStorageResponse } from "../utils/http"
17
+
18
+ function serializeAggregate(aggregate: AiAccountingAggregate) {
19
+ return {
20
+ modelCallCount: aggregate.modelCallCount,
21
+ usage: aggregate.usage,
22
+ costs: aggregate.costs,
23
+ }
24
+ }
25
+
26
+ function serializeOverview(overview: AiAccountingOverview) {
27
+ return AiAccountingOverviewResponseSchema.parse({
28
+ range: {
29
+ from: overview.range.from.toISOString(),
30
+ to: overview.range.to.toISOString(),
31
+ },
32
+ bucket: overview.bucket,
33
+ totals: serializeAggregate(overview.totals),
34
+ series: overview.series.map((period) => ({
35
+ start: period.start.toISOString(),
36
+ end: period.end.toISOString(),
37
+ ...serializeAggregate(period),
38
+ })),
39
+ models: overview.models.map((model) => ({
40
+ providerId: model.providerId,
41
+ modelId: model.modelId,
42
+ ...serializeAggregate(model),
43
+ })),
44
+ agents: overview.agents.map((agent) => ({
45
+ agentId: agent.agentId,
46
+ ...serializeAggregate(agent),
47
+ })),
48
+ workflows: overview.workflows.map((workflow) => ({
49
+ workflowId: workflow.workflowId,
50
+ ...serializeAggregate(workflow),
51
+ })),
52
+ })
53
+ }
54
+
55
+ function serializeModelCall(item: AiModelCallAccountingItem) {
56
+ return AiModelCallAccountingListResponseSchema.shape.items.element.parse({
57
+ usage: {
58
+ id: item.usage.id,
59
+ executionId: item.usage.executionId,
60
+ attempt: item.usage.attempt,
61
+ callId: item.usage.callId,
62
+ providerId: item.usage.providerId,
63
+ requestedModelId: item.usage.requestedModelId,
64
+ responseModelId: item.usage.responseModelId,
65
+ responseId: item.usage.responseId,
66
+ usage: item.usage.usage,
67
+ occurredAt: item.usage.occurredAt.toISOString(),
68
+ recordedAt: item.usage.recordedAt.toISOString(),
69
+ },
70
+ attribution: item.attribution,
71
+ cost:
72
+ item.cost === undefined
73
+ ? undefined
74
+ : {
75
+ ...item.cost,
76
+ priceSource: {
77
+ ...item.cost.priceSource,
78
+ observedAt: item.cost.priceSource.observedAt.toISOString(),
79
+ },
80
+ ratedAt: item.cost.ratedAt.toISOString(),
81
+ },
82
+ valuationStatus: item.valuationStatus,
83
+ })
84
+ }
85
+
86
+ export function registerAiAccountingRoutes(app: Elysia, host: SixbHostView) {
87
+ app.get(
88
+ "/api/ai/accounting/overview",
89
+ async ({ query, set }) => {
90
+ try {
91
+ const parsed = AiAccountingOverviewQuerySchema.parse(query)
92
+ const storage = host.storage.aiCosts
93
+ if (!storage) return unconfiguredStorageResponse(set, "AI cost storage")
94
+ const overview = await storage.queryProjectOverview({
95
+ projectId: host.id,
96
+ from: new Date(parsed.from),
97
+ to: new Date(parsed.to),
98
+ bucket: parsed.bucket,
99
+ providerId: parsed.providerId,
100
+ modelId: parsed.modelId,
101
+ })
102
+ return serializeOverview(overview)
103
+ } catch (error) {
104
+ return handleRouteError(error, set)
105
+ }
106
+ },
107
+ {
108
+ query: AiAccountingOverviewQuerySchema,
109
+ response: {
110
+ 200: AiAccountingOverviewResponseSchema,
111
+ 400: ErrorResponseSchema,
112
+ 501: ErrorResponseSchema,
113
+ },
114
+ detail: {
115
+ summary: "Get project AI usage and cost analytics",
116
+ tags: [OPENAPI_TAGS.aiAccounting.name],
117
+ operationId: "getAiAccountingOverview",
118
+ },
119
+ }
120
+ )
121
+
122
+ app.get(
123
+ "/api/ai/model-calls",
124
+ async ({ query, set }) => {
125
+ try {
126
+ const parsed = AiModelCallAccountingListQuerySchema.parse(query)
127
+ const storage = host.storage.aiCosts
128
+ if (!storage) return unconfiguredStorageResponse(set, "AI cost storage")
129
+ const result = await storage.listModelCalls({
130
+ projectId: host.id,
131
+ from: new Date(parsed.from),
132
+ to: new Date(parsed.to),
133
+ providerId: parsed.providerId,
134
+ modelId: parsed.modelId,
135
+ executionId: parsed.executionId,
136
+ valuationStatus: parsed.valuationStatus,
137
+ limit: parseOptionalInt(parsed.limit),
138
+ offset: parseOptionalInt(parsed.offset),
139
+ })
140
+ const items = result.items.map(serializeModelCall)
141
+ return AiModelCallAccountingListResponseSchema.parse({
142
+ items,
143
+ hasMore: result.hasMore,
144
+ total: result.total,
145
+ })
146
+ } catch (error) {
147
+ return handleRouteError(error, set)
148
+ }
149
+ },
150
+ {
151
+ query: AiModelCallAccountingListQuerySchema,
152
+ response: {
153
+ 200: AiModelCallAccountingListResponseSchema,
154
+ 400: ErrorResponseSchema,
155
+ 501: ErrorResponseSchema,
156
+ },
157
+ detail: {
158
+ summary: "List project AI model-call accounting records",
159
+ tags: [OPENAPI_TAGS.aiAccounting.name],
160
+ operationId: "listAiModelCalls",
161
+ },
162
+ }
163
+ )
164
+
165
+ return app
166
+ }