@sixb/server 0.1.20 → 0.1.22
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/artifacts/frame.d.ts +18 -0
- package/dist/artifacts/frame.d.ts.map +1 -0
- package/dist/auth/browser-origin.d.ts +10 -1
- package/dist/auth/browser-origin.d.ts.map +1 -1
- package/dist/auth/experience.d.ts +1 -0
- package/dist/auth/experience.d.ts.map +1 -1
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/responses.d.ts +1 -1
- package/dist/auth/responses.d.ts.map +1 -1
- package/dist/auth/scope.d.ts +19 -3
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/files/content.d.ts +2 -3
- package/dist/files/content.d.ts.map +1 -1
- package/dist/index.js +10636 -7071
- package/dist/index.js.map +56 -38
- package/dist/models/display.d.ts +27 -0
- package/dist/models/display.d.ts.map +1 -1
- package/dist/openapi/components.d.ts +14 -0
- package/dist/openapi/components.d.ts.map +1 -0
- package/dist/openapi/tags.d.ts +22 -2
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts +3 -0
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +5 -5
- package/dist/routes/activity.d.ts +35 -0
- package/dist/routes/activity.d.ts.map +1 -0
- package/dist/routes/agent-api-gateway.d.ts.map +1 -1
- package/dist/routes/agent-approval-gate.d.ts +27 -0
- package/dist/routes/agent-approval-gate.d.ts.map +1 -0
- package/dist/routes/agent-approvals.d.ts +599 -0
- package/dist/routes/agent-approvals.d.ts.map +1 -0
- package/dist/routes/agent-children.d.ts +318 -0
- package/dist/routes/agent-children.d.ts.map +1 -0
- package/dist/routes/agent-memory.d.ts +267 -0
- package/dist/routes/agent-memory.d.ts.map +1 -0
- package/dist/routes/agents.d.ts +1008 -98
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/ai-accounting.d.ts.map +1 -1
- package/dist/routes/artifact-frames.d.ts +98 -0
- package/dist/routes/artifact-frames.d.ts.map +1 -0
- package/dist/routes/artifacts.d.ts +1508 -0
- package/dist/routes/artifacts.d.ts.map +1 -0
- package/dist/routes/auth.d.ts +117 -11
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connector-connection-runs.d.ts +84 -84
- package/dist/routes/connector-connections.d.ts +2 -2
- package/dist/routes/connectors.d.ts +2 -2
- package/dist/routes/datasets.d.ts +27 -27
- package/dist/routes/events.d.ts +5 -5
- package/dist/routes/files.d.ts +14 -14
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/links.d.ts +2 -2
- package/dist/routes/logs.d.ts +5 -5
- package/dist/routes/model-calls.d.ts +155 -0
- package/dist/routes/model-calls.d.ts.map +1 -0
- package/dist/routes/model-generations.d.ts +400 -0
- package/dist/routes/model-generations.d.ts.map +1 -0
- package/dist/routes/models.d.ts +434 -1
- package/dist/routes/models.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +71 -40
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +682 -0
- package/dist/routes/observed-agent-threads.d.ts.map +1 -0
- package/dist/routes/ontology.d.ts +66 -62
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +53 -53
- package/dist/routes/projections.d.ts +63 -63
- package/dist/routes/rules.d.ts +2 -2
- package/dist/routes/share-grants.d.ts +4 -4
- package/dist/routes/syncs.d.ts +18 -18
- package/dist/routes/users.d.ts +117 -0
- package/dist/routes/users.d.ts.map +1 -0
- package/dist/routes/webhook-runs.d.ts +1 -1
- package/dist/routes/workflows.d.ts +142 -76
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/agents.d.ts +7 -2
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/events.d.ts +6 -6
- package/dist/routes/ws/events.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +14 -14
- package/dist/routes/ws/subscription-hub.d.ts +8 -3
- package/dist/routes/ws/subscription-hub.d.ts.map +1 -1
- package/dist/schemas/actions.d.ts +15 -15
- package/dist/schemas/activity.d.ts +1298 -0
- package/dist/schemas/activity.d.ts.map +1 -0
- package/dist/schemas/agent-approvals.d.ts +1091 -0
- package/dist/schemas/agent-approvals.d.ts.map +1 -0
- package/dist/schemas/agent-memory.d.ts +250 -0
- package/dist/schemas/agent-memory.d.ts.map +1 -0
- package/dist/schemas/agents.d.ts +5485 -460
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +1315 -436
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/ai-limits.d.ts +36 -36
- package/dist/schemas/ai-usage.d.ts +12 -0
- package/dist/schemas/ai-usage.d.ts.map +1 -1
- package/dist/schemas/artifacts.d.ts +1857 -0
- package/dist/schemas/artifacts.d.ts.map +1 -0
- package/dist/schemas/auth.d.ts +125 -52
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +42 -42
- package/dist/schemas/datasets.d.ts +108 -108
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +32 -32
- package/dist/schemas/events.d.ts.map +1 -1
- package/dist/schemas/files.d.ts +24 -24
- package/dist/schemas/links.d.ts +2 -2
- package/dist/schemas/logs.d.ts +32 -32
- package/dist/schemas/models.d.ts +8889 -10
- package/dist/schemas/models.d.ts.map +1 -1
- package/dist/schemas/objects.d.ts +48 -12
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/ontology.d.ts +127 -104
- package/dist/schemas/ontology.d.ts.map +1 -1
- package/dist/schemas/pipelines.d.ts +166 -166
- package/dist/schemas/projections.d.ts +346 -346
- package/dist/schemas/rules.d.ts +4 -4
- package/dist/schemas/share-grants.d.ts +14 -14
- package/dist/schemas/syncs.d.ts +40 -40
- package/dist/schemas/users.d.ts +72 -0
- package/dist/schemas/users.d.ts.map +1 -0
- package/dist/schemas/webhook-runs.d.ts +6 -6
- package/dist/schemas/workflows.d.ts +769 -254
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/http.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/artifacts/frame.ts +51 -0
- package/src/auth/browser-origin.ts +20 -5
- package/src/auth/experience.ts +1 -1
- package/src/auth/guard.ts +2 -2
- package/src/auth/public-routes.ts +16 -0
- package/src/auth/responses.ts +7 -6
- package/src/auth/scope.ts +32 -3
- package/src/files/content.ts +9 -13
- package/src/models/display.ts +61 -16
- package/src/openapi/components.ts +54 -0
- package/src/openapi/tags.ts +20 -0
- package/src/registerRoutes.ts +23 -0
- package/src/routes/activity.ts +327 -0
- package/src/routes/agent-api-gateway.ts +115 -91
- package/src/routes/agent-approval-gate.ts +213 -0
- package/src/routes/agent-approvals.ts +299 -0
- package/src/routes/agent-children.ts +209 -0
- package/src/routes/agent-memory.ts +210 -0
- package/src/routes/agents.ts +364 -143
- package/src/routes/ai-accounting.ts +4 -0
- package/src/routes/artifact-frames.ts +144 -0
- package/src/routes/artifacts.ts +717 -0
- package/src/routes/auth.ts +306 -13
- package/src/routes/file-downloads.ts +1 -3
- package/src/routes/files.ts +6 -7
- package/src/routes/model-calls.ts +120 -0
- package/src/routes/model-generations.ts +245 -0
- package/src/routes/models.ts +116 -9
- package/src/routes/objects.ts +55 -61
- package/src/routes/observed-agent-threads.ts +253 -0
- package/src/routes/ontology.ts +1 -0
- package/src/routes/users.ts +73 -0
- package/src/routes/workflows.ts +6 -9
- package/src/routes/ws/agents.ts +10 -5
- package/src/routes/ws/events.ts +3 -2
- package/src/routes/ws/subscription-hub.ts +53 -20
- package/src/schemas/activity.ts +287 -0
- package/src/schemas/agent-approvals.ts +129 -0
- package/src/schemas/agent-memory.ts +96 -0
- package/src/schemas/agents.ts +240 -2
- package/src/schemas/ai-accounting.ts +40 -4
- package/src/schemas/ai-usage.ts +10 -0
- package/src/schemas/artifacts.ts +246 -0
- package/src/schemas/auth.ts +25 -0
- package/src/schemas/models.ts +197 -1
- package/src/schemas/objects.ts +181 -0
- package/src/schemas/ontology.ts +1 -0
- package/src/schemas/users.ts +24 -0
- package/src/schemas/workflows.ts +2 -0
- package/src/server.ts +34 -19
- package/src/utils/http.ts +2 -0
package/src/server.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { cors } from "@elysiajs/cors"
|
|
2
2
|
import { openapi } from "@elysiajs/openapi"
|
|
3
3
|
import type { OntologyMaintenanceHandle, SixbHostView } from "@sixb/core"
|
|
4
|
+
import { bindAgentGatewayRequestExecution } from "@sixb/core/internal/agent-execution"
|
|
5
|
+
import { ARTIFACT_FRAME_ROUTE_PREFIX } from "@sixb/core/internal/artifacts/frames"
|
|
4
6
|
import { CSRF_HEADER_NAME, setRequestClientAddress } from "@sixb/core/internal/auth"
|
|
5
7
|
import { bindRequestExecution } from "@sixb/core/internal/request-execution"
|
|
6
8
|
import { setApiPublicOrigin } from "@sixb/core/internal/runtime"
|
|
9
|
+
import { checkPipelineMarkings, warmAppliedMarkings } from "@sixb/core/internal/security"
|
|
7
10
|
import type { Server } from "bun"
|
|
8
11
|
import { Elysia, ParseError } from "elysia"
|
|
9
12
|
import { websocket as elysiaWebSocket } from "elysia/ws"
|
|
@@ -11,7 +14,6 @@ import { zodToJsonSchema } from "zod-to-json-schema"
|
|
|
11
14
|
import {
|
|
12
15
|
type AuthInvitationRedirectContext,
|
|
13
16
|
type AuthInvitationRedirectInput,
|
|
14
|
-
BrowserOriginError,
|
|
15
17
|
createApiBrowserAuthContextResolver,
|
|
16
18
|
createApiBrowserAuthRedirectContextResolver,
|
|
17
19
|
isAllowedApiBrowserOrigin,
|
|
@@ -40,6 +42,7 @@ import {
|
|
|
40
42
|
SharedAccessBoundary,
|
|
41
43
|
type SixbSharedAccessOptions,
|
|
42
44
|
} from "./auth/shared-access"
|
|
45
|
+
import { NamedOpenApiSchemas, openApiOverride } from "./openapi/components"
|
|
43
46
|
import {
|
|
44
47
|
SIXB_ACCESS_TOKEN_SECURITY_SCHEME,
|
|
45
48
|
SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID,
|
|
@@ -57,7 +60,6 @@ import { registerAuthRoutes } from "./routes/auth"
|
|
|
57
60
|
import { DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES } from "./routes/files"
|
|
58
61
|
import { registerWebhookRoutes } from "./routes/webhooks"
|
|
59
62
|
import { registerWebSocketRoutes } from "./routes/ws"
|
|
60
|
-
import { jsonValueOpenApiOverride } from "./schemas/common"
|
|
61
63
|
import { ObjectQueryOpenApiSchemas } from "./schemas/objects"
|
|
62
64
|
import { limitRequestBody, RequestBodyTooLargeError } from "./utils/request-body"
|
|
63
65
|
|
|
@@ -125,8 +127,9 @@ export class SixbServer {
|
|
|
125
127
|
return this.hostRuntime
|
|
126
128
|
}
|
|
127
129
|
|
|
130
|
+
/** The port the server listens on once started, so `port: 0` reports the one it bound. */
|
|
128
131
|
getPort(): number {
|
|
129
|
-
return this.port
|
|
132
|
+
return this.bunServer?.port ?? this.port
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
resolveAuthContext(request: Request): RequestAuthContext {
|
|
@@ -168,6 +171,16 @@ export class SixbServer {
|
|
|
168
171
|
throw new Error("[SixbServer] Server is already running.")
|
|
169
172
|
}
|
|
170
173
|
|
|
174
|
+
// Startup cannot see through SQL steps: check what they derive before serving any request.
|
|
175
|
+
await checkPipelineMarkings({
|
|
176
|
+
definitions: this.hostRuntime.definitions,
|
|
177
|
+
lakeStorage: this.hostRuntime.lakeStorage,
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
// Objects keep the markings of the versions they were projected from. The first read that
|
|
181
|
+
// needs them waits for them; reading them now spares that read the wait.
|
|
182
|
+
warmAppliedMarkings(this.hostRuntime)
|
|
183
|
+
|
|
171
184
|
const maintenance = await this.hostRuntime.startOntologyMaintenance()
|
|
172
185
|
this.maintenance = maintenance
|
|
173
186
|
|
|
@@ -188,7 +201,7 @@ export class SixbServer {
|
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
if (!this.quiet) {
|
|
191
|
-
const base = `http://${this.hostname}:${this.
|
|
204
|
+
const base = `http://${this.hostname}:${this.getPort()}`
|
|
192
205
|
console.log(`Sixb server running at ${base}`)
|
|
193
206
|
console.log(`OpenAPI docs at ${base}/docs`)
|
|
194
207
|
}
|
|
@@ -305,15 +318,12 @@ export function createSixbApi(server: SixbServer) {
|
|
|
305
318
|
|
|
306
319
|
const internalAuthState = consumeInternalRequestAuthState(request)
|
|
307
320
|
if (internalAuthState) {
|
|
308
|
-
const {
|
|
321
|
+
const { runExecution, ...agentState } = internalAuthState
|
|
309
322
|
return {
|
|
310
323
|
auth: { kind: "allow" as const, session: null },
|
|
311
324
|
sharedAccessCookies: null,
|
|
312
325
|
...agentState,
|
|
313
|
-
sixb:
|
|
314
|
-
request,
|
|
315
|
-
authorization,
|
|
316
|
-
}),
|
|
326
|
+
sixb: bindAgentGatewayRequestExecution(host, { signal: request.signal, ...runExecution }),
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
|
|
@@ -411,7 +421,7 @@ export function createSixbApi(server: SixbServer) {
|
|
|
411
421
|
[SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID]: SIXB_ACCESS_TOKEN_SECURITY_SCHEME,
|
|
412
422
|
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: SIXB_SHARED_GRANT_SECURITY_SCHEME,
|
|
413
423
|
},
|
|
414
|
-
schemas: ObjectQueryOpenApiSchemas,
|
|
424
|
+
schemas: { ...ObjectQueryOpenApiSchemas, ...NamedOpenApiSchemas },
|
|
415
425
|
},
|
|
416
426
|
// Every operation needs a session unless it says otherwise; public ones declare `[]`.
|
|
417
427
|
security: SIXB_SESSION_SECURITY_REQUIREMENT,
|
|
@@ -425,7 +435,7 @@ export function createSixbApi(server: SixbServer) {
|
|
|
425
435
|
zodToJsonSchema(schema, {
|
|
426
436
|
$refStrategy: "none",
|
|
427
437
|
target: "openApi3",
|
|
428
|
-
override:
|
|
438
|
+
override: openApiOverride(),
|
|
429
439
|
}),
|
|
430
440
|
},
|
|
431
441
|
})
|
|
@@ -442,6 +452,7 @@ export function createSixbApi(server: SixbServer) {
|
|
|
442
452
|
})
|
|
443
453
|
registerHttpRoutes(app, host, {
|
|
444
454
|
sharedAccess,
|
|
455
|
+
browserPolicy: apiBrowserPolicy,
|
|
445
456
|
connectorConnections: {
|
|
446
457
|
resolveReturnTo: (request, returnTo) =>
|
|
447
458
|
server.resolveAuthRedirectContext(request, { returnTo }).returnTo,
|
|
@@ -499,14 +510,18 @@ function rejectDisallowedBrowserOrigin(
|
|
|
499
510
|
return undefined
|
|
500
511
|
}
|
|
501
512
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
513
|
+
// A frame's page has an opaque origin, so what it loads arrives with `Origin: null`. Its token
|
|
514
|
+
// is the credential and no cookie counts there, so frames are the one place that is allowed, and
|
|
515
|
+
// only to read, as `classifyRoute` makes them public.
|
|
516
|
+
if (
|
|
517
|
+
(request.method === "GET" || request.method === "HEAD") &&
|
|
518
|
+
new URL(request.url).pathname.startsWith(ARTIFACT_FRAME_ROUTE_PREFIX)
|
|
519
|
+
) {
|
|
520
|
+
return undefined
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (isAllowedApiBrowserOrigin(policy, request)) {
|
|
524
|
+
return undefined
|
|
510
525
|
}
|
|
511
526
|
|
|
512
527
|
return new Response(JSON.stringify({ error: "Browser origin is not allowed" }), {
|
package/src/utils/http.ts
CHANGED
|
@@ -30,6 +30,8 @@ const HTTP_STATUS_BY_ERROR_CODE: Partial<Record<SixbErrorCode, number>> = {
|
|
|
30
30
|
"connector.revocation_pending": 409,
|
|
31
31
|
"dataset.not_found": 404,
|
|
32
32
|
"dataset.version_not_found": 404,
|
|
33
|
+
"object.not_found": 404,
|
|
34
|
+
"object.unique_violation": 409,
|
|
33
35
|
"runtime.stopping": 503,
|
|
34
36
|
"ai.usage_limit_exceeded": 429,
|
|
35
37
|
"ai.usage_limit_unavailable": 429,
|