@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
|
@@ -63,6 +63,10 @@ function serializeOverview(overview: AiAccountingOverview) {
|
|
|
63
63
|
modelId: model.modelId,
|
|
64
64
|
...serializeAggregate(model),
|
|
65
65
|
})),
|
|
66
|
+
kinds: overview.kinds.map((kind) => ({
|
|
67
|
+
...(kind.modelKind === undefined ? {} : { modelKind: kind.modelKind }),
|
|
68
|
+
...serializeAggregate(kind),
|
|
69
|
+
})),
|
|
66
70
|
agents: overview.agents.map((agent) => ({
|
|
67
71
|
kind: agent.kind,
|
|
68
72
|
...(agent.kind === "workflowAgent"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { SixbHostView } from "@sixb/core"
|
|
2
|
+
import { parseArtifactAddress } from "@sixb/core/artifacts"
|
|
3
|
+
import {
|
|
4
|
+
ARTIFACT_FRAME_ROUTE_PREFIX,
|
|
5
|
+
FRAME_ASSETS,
|
|
6
|
+
FRAME_REFERENCE_PREFIX,
|
|
7
|
+
frameEntries,
|
|
8
|
+
frameLayout,
|
|
9
|
+
injectFrameAssets,
|
|
10
|
+
resolveArtifactFrame,
|
|
11
|
+
rewriteFrameReferences,
|
|
12
|
+
} from "@sixb/core/internal/artifacts/frames"
|
|
13
|
+
import { openFileRef } from "@sixb/core/internal/blob-storage"
|
|
14
|
+
import type { Elysia } from "elysia"
|
|
15
|
+
import { frameContentSecurityPolicy } from "../artifacts/frame"
|
|
16
|
+
import type { ResolvedSixbApiBrowserPolicy } from "../auth/browser-origin"
|
|
17
|
+
import { createFileContentResponse } from "../files/content"
|
|
18
|
+
|
|
19
|
+
interface FrameContext {
|
|
20
|
+
readonly params: { readonly token: string; readonly "*": string }
|
|
21
|
+
readonly request: Request
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Serves a version's files to its sandboxed frame, under the token a frame link carries: the token
|
|
26
|
+
* is the credential, so the route is public. Each entry gets its layout's kit and the runtime,
|
|
27
|
+
* which are served beside the files. Hidden from OpenAPI: clients receive frame links, they
|
|
28
|
+
* never build them.
|
|
29
|
+
*/
|
|
30
|
+
export function registerArtifactFrameRoutes(
|
|
31
|
+
app: Elysia,
|
|
32
|
+
host: SixbHostView,
|
|
33
|
+
policy: ResolvedSixbApiBrowserPolicy
|
|
34
|
+
) {
|
|
35
|
+
const path = `${ARTIFACT_FRAME_ROUTE_PREFIX}:token/*`
|
|
36
|
+
return app
|
|
37
|
+
.get(path, (context) => frameResponse(host, policy, context), { detail: { hide: true } })
|
|
38
|
+
.head(path, (context) => frameResponse(host, policy, context, { head: true }), {
|
|
39
|
+
detail: { hide: true },
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function frameResponse(
|
|
44
|
+
host: SixbHostView,
|
|
45
|
+
policy: ResolvedSixbApiBrowserPolicy,
|
|
46
|
+
{ params, request }: FrameContext,
|
|
47
|
+
options: { readonly head?: boolean } = {}
|
|
48
|
+
): Promise<Response> {
|
|
49
|
+
const headers = new Headers({
|
|
50
|
+
"content-security-policy": frameContentSecurityPolicy({ policy, request, token: params.token }),
|
|
51
|
+
// The frame's origin is opaque, so its module scripts and fonts arrive with `Origin: null`.
|
|
52
|
+
// Nothing here depends on cookies: the token is the credential.
|
|
53
|
+
"access-control-allow-origin": "*",
|
|
54
|
+
"x-content-type-options": "nosniff",
|
|
55
|
+
"referrer-policy": "no-referrer",
|
|
56
|
+
})
|
|
57
|
+
const notFound = () => {
|
|
58
|
+
headers.set("content-type", "text/plain; charset=utf-8")
|
|
59
|
+
headers.set("cache-control", "no-store")
|
|
60
|
+
return new Response(options.head ? null : "Not found", { status: 404, headers })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// A frame link opens only in a frame. Opened as a page on the API's origin, its sandbox would
|
|
64
|
+
// still let it show dialogs under the API's address, with no app policy to hold where it goes.
|
|
65
|
+
if (request.headers.get("sec-fetch-dest") === "document") return notFound()
|
|
66
|
+
|
|
67
|
+
const storage = host.storage.artifacts
|
|
68
|
+
if (!storage) return notFound()
|
|
69
|
+
// An unknown or expired token, a deleted version, and a kind with no frame all answer one 404.
|
|
70
|
+
const frame = await resolveArtifactFrame({
|
|
71
|
+
projectId: host.id,
|
|
72
|
+
storage,
|
|
73
|
+
token: params.token,
|
|
74
|
+
})
|
|
75
|
+
if (!frame) return notFound()
|
|
76
|
+
let version = frame.version
|
|
77
|
+
|
|
78
|
+
let path = decodePath(params["*"])
|
|
79
|
+
const asset = path === null ? undefined : FRAME_ASSETS[path]
|
|
80
|
+
if (asset) {
|
|
81
|
+
headers.set("content-type", asset.type)
|
|
82
|
+
headers.set("cache-control", "private, max-age=3600")
|
|
83
|
+
return new Response(options.head ? null : asset.body, { headers })
|
|
84
|
+
}
|
|
85
|
+
let lent = false
|
|
86
|
+
if (path?.startsWith(FRAME_REFERENCE_PREFIX)) {
|
|
87
|
+
// A file another artifact lends this one: only one its frame was issued with, at that version.
|
|
88
|
+
const match = /^([^/@]+)@(\d+)\/(.+)$/.exec(path.slice(FRAME_REFERENCE_PREFIX.length))
|
|
89
|
+
const target = frame.targets.find(
|
|
90
|
+
(candidate) =>
|
|
91
|
+
candidate.artifactId === match?.[1] &&
|
|
92
|
+
candidate.version === Number(match?.[2]) &&
|
|
93
|
+
parseArtifactAddress(candidate.address)?.path === match?.[3]
|
|
94
|
+
)
|
|
95
|
+
const lender = target
|
|
96
|
+
? await storage.getVersion({
|
|
97
|
+
projectId: host.id,
|
|
98
|
+
artifactId: target.artifactId,
|
|
99
|
+
version: target.version,
|
|
100
|
+
})
|
|
101
|
+
: null
|
|
102
|
+
if (!lender || !match) return notFound()
|
|
103
|
+
version = lender
|
|
104
|
+
path = match[3] ?? null
|
|
105
|
+
lent = true
|
|
106
|
+
}
|
|
107
|
+
const file = version.files.find((candidate) => candidate.path === path)
|
|
108
|
+
if (!file) return notFound()
|
|
109
|
+
|
|
110
|
+
const layout = frameLayout(version.outline.kind)
|
|
111
|
+
if (!lent && layout && frameEntries(version).includes(file.path)) {
|
|
112
|
+
const opened = await openFileRef(host.blobStorage, file.file)
|
|
113
|
+
if (!opened) return notFound()
|
|
114
|
+
headers.set("content-type", "text/html; charset=utf-8")
|
|
115
|
+
headers.set("cache-control", "private, no-cache")
|
|
116
|
+
if (options.head) return new Response(null, { headers })
|
|
117
|
+
const text = await new Response(opened.body).text()
|
|
118
|
+
return new Response(
|
|
119
|
+
injectFrameAssets(rewriteFrameReferences(text, frame.targets, file.path), layout, file.path),
|
|
120
|
+
{ headers }
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const response = await createFileContentResponse({
|
|
125
|
+
blobStorage: host.blobStorage,
|
|
126
|
+
fileRef: file.file,
|
|
127
|
+
disposition: "inline",
|
|
128
|
+
head: options.head,
|
|
129
|
+
request,
|
|
130
|
+
})
|
|
131
|
+
if (!response) return notFound()
|
|
132
|
+
// A frame loads its files as the page's parts: inline, under the frame's own policy.
|
|
133
|
+
for (const [name, value] of headers) response.headers.set(name, value)
|
|
134
|
+
response.headers.set("content-disposition", "inline")
|
|
135
|
+
return response
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function decodePath(raw: string | undefined): string | null {
|
|
139
|
+
try {
|
|
140
|
+
return decodeURIComponent(raw ?? "")
|
|
141
|
+
} catch {
|
|
142
|
+
return null
|
|
143
|
+
}
|
|
144
|
+
}
|