@sixb/server 0.1.21 → 0.1.23
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 +5 -0
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/auth/browser-origin.d.ts +5 -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/index.js +10093 -7553
- package/dist/index.js.map +51 -39
- 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 +14 -2
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +5 -5
- 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 +999 -80
- 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 +3 -3
- package/dist/routes/artifact-frames.d.ts.map +1 -1
- package/dist/routes/artifacts.d.ts +790 -134
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +116 -10
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connector-connection-runs.d.ts +50 -50
- package/dist/routes/connectors.d.ts +2 -2
- package/dist/routes/datasets.d.ts +20 -20
- package/dist/routes/events.d.ts +4 -4
- 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 +24 -24
- package/dist/routes/projections.d.ts +55 -55
- package/dist/routes/rules.d.ts +2 -2
- package/dist/routes/share-grants.d.ts +9 -9
- package/dist/routes/syncs.d.ts +46 -46
- 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 +118 -52
- 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/logs.d.ts +14 -14
- package/dist/schemas/actions.d.ts +15 -15
- package/dist/schemas/activity.d.ts +48 -28
- package/dist/schemas/activity.d.ts.map +1 -1
- 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 +5442 -369
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +1290 -411
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/ai-limits.d.ts +10 -10
- 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 +650 -98
- package/dist/schemas/artifacts.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +119 -46
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +22 -22
- package/dist/schemas/datasets.d.ts +98 -98
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +26 -26
- 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 +132 -132
- package/dist/schemas/projections.d.ts +314 -314
- package/dist/schemas/rules.d.ts +4 -4
- package/dist/schemas/share-grants.d.ts +30 -30
- package/dist/schemas/syncs.d.ts +49 -49
- 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 +701 -186
- 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 +6 -1
- package/src/auth/browser-origin.ts +8 -3
- package/src/auth/experience.ts +1 -1
- package/src/auth/guard.ts +2 -2
- package/src/auth/public-routes.ts +6 -0
- package/src/auth/responses.ts +7 -6
- package/src/auth/scope.ts +32 -3
- package/src/models/display.ts +61 -16
- package/src/openapi/components.ts +54 -0
- package/src/openapi/tags.ts +12 -0
- package/src/registerRoutes.ts +14 -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 +363 -142
- package/src/routes/ai-accounting.ts +4 -0
- package/src/routes/artifact-frames.ts +14 -8
- package/src/routes/artifacts.ts +297 -22
- package/src/routes/auth.ts +306 -13
- 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/schemas/activity.ts +2 -0
- package/src/schemas/agent-approvals.ts +129 -0
- package/src/schemas/agent-memory.ts +96 -0
- package/src/schemas/agents.ts +239 -0
- package/src/schemas/ai-accounting.ts +40 -4
- package/src/schemas/ai-usage.ts +10 -0
- package/src/schemas/artifacts.ts +91 -3
- 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 +9 -10
- package/src/utils/http.ts +2 -0
package/src/schemas/models.ts
CHANGED
|
@@ -1,17 +1,70 @@
|
|
|
1
|
-
import { MODEL_REASONING_LEVELS } from "@sixb/core/models"
|
|
1
|
+
import { LANGUAGE_MODEL_TIERS, MODEL_REASONING_LEVELS } from "@sixb/core/models"
|
|
2
2
|
import { z } from "zod"
|
|
3
|
+
import { FileRefSchema } from "./files"
|
|
3
4
|
|
|
4
5
|
export const LanguageModelRefSchema = z.object({
|
|
5
6
|
provider: z.string().trim().min(1),
|
|
6
7
|
modelId: z.string().trim().min(1),
|
|
7
8
|
})
|
|
8
9
|
|
|
10
|
+
const DecimalSchema = z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/)
|
|
11
|
+
|
|
12
|
+
const TokenPriceSchema = z.union([
|
|
13
|
+
DecimalSchema,
|
|
14
|
+
z.object({
|
|
15
|
+
default: DecimalSchema,
|
|
16
|
+
tiers: z.array(
|
|
17
|
+
z.object({
|
|
18
|
+
minTokens: z.number().int().nonnegative(),
|
|
19
|
+
maxTokens: z.number().int().positive().optional(),
|
|
20
|
+
price: DecimalSchema,
|
|
21
|
+
})
|
|
22
|
+
),
|
|
23
|
+
}),
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
const VariantPriceSchema = z.union([
|
|
27
|
+
DecimalSchema,
|
|
28
|
+
z.object({
|
|
29
|
+
default: DecimalSchema.optional(),
|
|
30
|
+
variants: z.array(
|
|
31
|
+
z.object({
|
|
32
|
+
size: z.string().optional(),
|
|
33
|
+
quality: z.string().optional(),
|
|
34
|
+
style: z.string().optional(),
|
|
35
|
+
voiceTier: z.string().optional(),
|
|
36
|
+
price: DecimalSchema,
|
|
37
|
+
})
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
/** The prices a binding bills by. Absent when the price is unknown. */
|
|
43
|
+
export const ModelRateCardSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
currency: z.literal("USD"),
|
|
46
|
+
input: TokenPriceSchema.optional(),
|
|
47
|
+
output: TokenPriceSchema.optional(),
|
|
48
|
+
cacheReadInput: TokenPriceSchema.optional(),
|
|
49
|
+
cacheWriteInput: TokenPriceSchema.optional(),
|
|
50
|
+
cacheWriteInput5m: TokenPriceSchema.optional(),
|
|
51
|
+
cacheWriteInput1h: TokenPriceSchema.optional(),
|
|
52
|
+
imageOutput: TokenPriceSchema.optional(),
|
|
53
|
+
audioOutput: TokenPriceSchema.optional(),
|
|
54
|
+
images: VariantPriceSchema.optional(),
|
|
55
|
+
characters: VariantPriceSchema.optional(),
|
|
56
|
+
audioInputSeconds: VariantPriceSchema.optional(),
|
|
57
|
+
})
|
|
58
|
+
.describe("USD. Token and character prices are per million; images per image; audio per second.")
|
|
59
|
+
|
|
9
60
|
export const LanguageModelSchema = LanguageModelRefSchema.extend({
|
|
10
61
|
/**
|
|
11
62
|
* The provider binding and model id the project configured. Together they identify the entry;
|
|
12
63
|
* there is no separate Sixb model id.
|
|
13
64
|
*/
|
|
14
65
|
isDefault: z.boolean(),
|
|
66
|
+
/** The tier the project configures this model in; absent when its models are a list. */
|
|
67
|
+
tier: z.enum(LANGUAGE_MODEL_TIERS).optional(),
|
|
15
68
|
name: z.string().min(1),
|
|
16
69
|
description: z.string().min(1).optional(),
|
|
17
70
|
publisher: z.object({
|
|
@@ -31,10 +84,60 @@ export const LanguageModelSchema = LanguageModelRefSchema.extend({
|
|
|
31
84
|
reasoningLevels: z.array(z.enum(MODEL_REASONING_LEVELS)),
|
|
32
85
|
/** Reasoning the project applies when a request selects this model without choosing one. */
|
|
33
86
|
defaultReasoning: z.enum(MODEL_REASONING_LEVELS).optional(),
|
|
87
|
+
rateCard: ModelRateCardSchema.optional(),
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const CatalogEntrySchema = LanguageModelRefSchema.extend({
|
|
91
|
+
isDefault: z.boolean(),
|
|
92
|
+
name: z.string().min(1),
|
|
93
|
+
description: z.string().min(1).optional(),
|
|
94
|
+
via: z.string().min(1).optional(),
|
|
95
|
+
rateCard: ModelRateCardSchema.optional(),
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const ListSchema = z.array(z.string().min(1)).optional()
|
|
99
|
+
|
|
100
|
+
export const ImageModelSchema = CatalogEntrySchema.extend({
|
|
101
|
+
maxImagesPerCall: z.number().int().positive().optional(),
|
|
102
|
+
sizes: ListSchema,
|
|
103
|
+
aspectRatios: ListSchema,
|
|
104
|
+
qualities: ListSchema,
|
|
105
|
+
styles: ListSchema,
|
|
106
|
+
inputImages: z
|
|
107
|
+
.object({
|
|
108
|
+
maxCount: z.number().int().positive(),
|
|
109
|
+
maxBytes: z.number().int().positive(),
|
|
110
|
+
mediaTypes: ListSchema,
|
|
111
|
+
})
|
|
112
|
+
.optional()
|
|
113
|
+
.describe("Reference images the model takes for edits; absent when it takes none."),
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
export const SpeechModelSchema = CatalogEntrySchema.extend({
|
|
117
|
+
defaultVoice: z.string().min(1).optional(),
|
|
118
|
+
voices: ListSchema,
|
|
119
|
+
outputMediaTypes: ListSchema,
|
|
120
|
+
maxInputCharacters: z.number().int().positive().optional(),
|
|
121
|
+
instructions: z.boolean().optional(),
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
export const TranscriptionModelSchema = CatalogEntrySchema.extend({
|
|
125
|
+
maxInputBytes: z.number().int().positive(),
|
|
126
|
+
mediaTypes: ListSchema,
|
|
34
127
|
})
|
|
35
128
|
|
|
36
129
|
export const ModelCatalogSchema = z.object({
|
|
37
130
|
language: z.array(LanguageModelSchema),
|
|
131
|
+
/**
|
|
132
|
+
* With tiers: whether a decision model picks the model of each chat message that names none.
|
|
133
|
+
* Without one, such a message runs on `standard`. Absent when `models.language` is a list.
|
|
134
|
+
*/
|
|
135
|
+
languageRouting: z.boolean().optional(),
|
|
136
|
+
image: z.array(ImageModelSchema),
|
|
137
|
+
audio: z.object({
|
|
138
|
+
speech: z.array(SpeechModelSchema),
|
|
139
|
+
transcription: z.array(TranscriptionModelSchema),
|
|
140
|
+
}),
|
|
38
141
|
})
|
|
39
142
|
|
|
40
143
|
export const ModelReasoningLevelSchema = z.enum(MODEL_REASONING_LEVELS)
|
|
@@ -43,3 +146,96 @@ export const ModelReasoningSchema = z.union([
|
|
|
43
146
|
ModelReasoningLevelSchema,
|
|
44
147
|
z.object({ budgetTokens: z.number().int().nonnegative() }).strict(),
|
|
45
148
|
])
|
|
149
|
+
|
|
150
|
+
export const ModelCallParamsSchema = z.object({
|
|
151
|
+
callId: z.string().min(1),
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
export const ModelCallFilesSchema = z.object({
|
|
155
|
+
callId: z.string(),
|
|
156
|
+
files: z.array(FileRefSchema),
|
|
157
|
+
recordedAt: z.string(),
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const ModelUsageSchema = z.object({
|
|
161
|
+
inputTokens: z.number().int().nonnegative().optional(),
|
|
162
|
+
outputTokens: z.number().int().nonnegative().optional(),
|
|
163
|
+
uncachedInputTokens: z.number().int().nonnegative().optional(),
|
|
164
|
+
cacheReadInputTokens: z.number().int().nonnegative().optional(),
|
|
165
|
+
cacheWriteInputTokens: z.number().int().nonnegative().optional(),
|
|
166
|
+
textOutputTokens: z.number().int().nonnegative().optional(),
|
|
167
|
+
reasoningOutputTokens: z.number().int().nonnegative().optional(),
|
|
168
|
+
imageOutputTokens: z.number().int().nonnegative().optional(),
|
|
169
|
+
audioOutputTokens: z.number().int().nonnegative().optional(),
|
|
170
|
+
outputImages: z.number().int().nonnegative().optional(),
|
|
171
|
+
inputCharacters: z.number().int().nonnegative().optional(),
|
|
172
|
+
audioDurationMs: z.number().int().nonnegative().optional(),
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
/** What the call cost: reported by the provider, rated from the binding's card, or unknown. */
|
|
176
|
+
const ModelCallCostSchema = z.object({
|
|
177
|
+
status: z.enum(["reported", "rated", "unpriceable"]),
|
|
178
|
+
money: z.object({ currency: z.literal("USD"), amountNanos: z.string() }).optional(),
|
|
179
|
+
reason: z.string().optional(),
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const GenerationBodyBase = z.object({
|
|
183
|
+
/** Omit for the kind's default model. */
|
|
184
|
+
model: LanguageModelRefSchema.optional(),
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
const GenerationResultBase = z.object({
|
|
188
|
+
callId: z.string(),
|
|
189
|
+
model: LanguageModelRefSchema,
|
|
190
|
+
usage: ModelUsageSchema,
|
|
191
|
+
cost: ModelCallCostSchema,
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
export const TextGenerationBodySchema = GenerationBodyBase.extend({
|
|
195
|
+
/** Omit for the default model; a tier answers with that tier's model. */
|
|
196
|
+
model: z.union([LanguageModelRefSchema, z.enum(LANGUAGE_MODEL_TIERS)]).optional(),
|
|
197
|
+
prompt: z.string().trim().min(1),
|
|
198
|
+
instructions: z.string().optional(),
|
|
199
|
+
maxOutputTokens: z.number().int().positive().optional(),
|
|
200
|
+
reasoning: ModelReasoningSchema.optional(),
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
export const TextGenerationSchema = GenerationResultBase.extend({
|
|
204
|
+
text: z.string(),
|
|
205
|
+
finishReason: z.string(),
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
export const ImageGenerationBodySchema = GenerationBodyBase.extend({
|
|
209
|
+
prompt: z.string().trim().min(1),
|
|
210
|
+
n: z.number().int().positive().optional(),
|
|
211
|
+
size: z.string().min(1).optional(),
|
|
212
|
+
aspectRatio: z.string().min(1).optional(),
|
|
213
|
+
quality: z.string().min(1).optional(),
|
|
214
|
+
style: z.string().min(1).optional(),
|
|
215
|
+
seed: z.number().int().optional(),
|
|
216
|
+
/** Reference images uploaded through /api/files. */
|
|
217
|
+
images: z.array(FileRefSchema).optional(),
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
export const SpeechGenerationBodySchema = GenerationBodyBase.extend({
|
|
221
|
+
text: z.string().trim().min(1),
|
|
222
|
+
voice: z.string().min(1).optional(),
|
|
223
|
+
instructions: z.string().optional(),
|
|
224
|
+
mediaType: z.string().min(1).optional(),
|
|
225
|
+
speed: z.number().positive().optional(),
|
|
226
|
+
language: z.string().min(1).optional(),
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
export const FileGenerationSchema = GenerationResultBase.extend({
|
|
230
|
+
files: z.array(FileRefSchema),
|
|
231
|
+
warnings: z.array(z.string()),
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
export const TranscriptionBodySchema = GenerationBodyBase.extend({
|
|
235
|
+
/** Audio uploaded through /api/files. */
|
|
236
|
+
audio: FileRefSchema,
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
export const TranscriptionSchema = GenerationResultBase.extend({
|
|
240
|
+
text: z.string(),
|
|
241
|
+
})
|
package/src/schemas/objects.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ElysiaOpenAPIConfig } from "@elysiajs/openapi"
|
|
2
|
+
import { ARTIFACT_LIMITS } from "@sixb/core/artifacts"
|
|
2
3
|
import { z } from "zod"
|
|
3
4
|
import { zodToJsonSchema } from "zod-to-json-schema"
|
|
5
|
+
import { ArtifactErrorResponseSchema } from "./artifacts"
|
|
6
|
+
import { UserProfileSchema } from "./auth"
|
|
4
7
|
import {
|
|
5
8
|
AiUsageLimitErrorResponseSchema,
|
|
9
|
+
codedErrorResponseSchema,
|
|
10
|
+
ErrorResponseSchema,
|
|
6
11
|
JsonValueSchema,
|
|
7
12
|
jsonValueOpenApiOverride,
|
|
8
13
|
RedactionsSchema,
|
|
@@ -120,6 +125,17 @@ export const UpsertObjectBodySchema = z.object({
|
|
|
120
125
|
properties: z.record(z.unknown()),
|
|
121
126
|
})
|
|
122
127
|
|
|
128
|
+
export const UniquePropertyParamsSchema = z.object({
|
|
129
|
+
objectTypeId: z.string().min(1),
|
|
130
|
+
propertyId: z.string().min(1),
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
export const GetObjectByUniquePropertyBodySchema = z.object({
|
|
134
|
+
value: z
|
|
135
|
+
.unknown()
|
|
136
|
+
.describe("A value of the unique property, as a write would give it: a date as an ISO string."),
|
|
137
|
+
})
|
|
138
|
+
|
|
123
139
|
export const ObjectQueryPredicateSchema: z.ZodType<unknown> = z.lazy(() =>
|
|
124
140
|
z.union([
|
|
125
141
|
z
|
|
@@ -190,6 +206,7 @@ export const ObjectExpansionSchema: z.ZodType<unknown> = z.lazy(() =>
|
|
|
190
206
|
limit: z.number().int().nonnegative().optional(),
|
|
191
207
|
orderBy: z.array(ObjectQuerySortFieldSchema).optional(),
|
|
192
208
|
expand: z.array(ObjectExpansionSchema).optional(),
|
|
209
|
+
users: z.array(z.string().min(1)).optional(),
|
|
193
210
|
})
|
|
194
211
|
.strict()
|
|
195
212
|
)
|
|
@@ -297,6 +314,7 @@ export const ObjectQuerySchema: z.ZodType<unknown> = z.lazy(() =>
|
|
|
297
314
|
kind: z.literal("expand"),
|
|
298
315
|
input: ObjectQuerySchema,
|
|
299
316
|
expansions: z.array(ObjectExpansionSchema),
|
|
317
|
+
users: z.array(z.string().min(1)).optional(),
|
|
300
318
|
})
|
|
301
319
|
.strict(),
|
|
302
320
|
])
|
|
@@ -378,6 +396,27 @@ const objectRefSchemaRef = { $ref: "#/components/schemas/ObjectRef" }
|
|
|
378
396
|
* OpenAPI config inlines refs. Keep the HTTP validator above in Zod, and provide
|
|
379
397
|
* the recursive request contract directly for generated clients and docs.
|
|
380
398
|
*/
|
|
399
|
+
/** What every artifact query result names: the types it returns, and every type it reads. */
|
|
400
|
+
const artifactQueryShape = {
|
|
401
|
+
resultObjectTypeIds: {
|
|
402
|
+
type: "array",
|
|
403
|
+
items: { type: "string" },
|
|
404
|
+
description: "The object types the query returns",
|
|
405
|
+
},
|
|
406
|
+
readObjectTypeIds: {
|
|
407
|
+
type: "array",
|
|
408
|
+
items: { type: "string" },
|
|
409
|
+
description:
|
|
410
|
+
"Every object type the query reads: where it starts, and what it traverses or expands",
|
|
411
|
+
},
|
|
412
|
+
} satisfies Record<string, OpenApi3Schema>
|
|
413
|
+
|
|
414
|
+
/** By property id: what each property holds. */
|
|
415
|
+
const artifactQueryProperties = {
|
|
416
|
+
type: "object",
|
|
417
|
+
additionalProperties: { $ref: "#/components/schemas/ArtifactQueryProperty" },
|
|
418
|
+
} satisfies OpenApi3Schema
|
|
419
|
+
|
|
381
420
|
export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
382
421
|
ErrorResponse: {
|
|
383
422
|
type: "object",
|
|
@@ -418,6 +457,12 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
418
457
|
additionalProperties: { $ref: "#/components/schemas/ObjectQueryLinkValue" },
|
|
419
458
|
},
|
|
420
459
|
linkProperties: { type: "object", additionalProperties: true },
|
|
460
|
+
// Populated only on the query route, by an `expand` node naming user properties: member
|
|
461
|
+
// profiles keyed by property id. Absent entries were not readable.
|
|
462
|
+
users: {
|
|
463
|
+
type: "object",
|
|
464
|
+
additionalProperties: { $ref: "#/components/schemas/ObjectQueryUserValue" },
|
|
465
|
+
},
|
|
421
466
|
},
|
|
422
467
|
},
|
|
423
468
|
// One expanded link value: a single child ("one" cardinality, or null when
|
|
@@ -429,6 +474,18 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
429
474
|
],
|
|
430
475
|
nullable: true,
|
|
431
476
|
},
|
|
477
|
+
// One expanded user property: a profile (or null) for a reference, an array for an array of them.
|
|
478
|
+
ObjectQueryUserValue: {
|
|
479
|
+
oneOf: [
|
|
480
|
+
{ $ref: "#/components/schemas/UserProfile" },
|
|
481
|
+
{ type: "array", items: { $ref: "#/components/schemas/UserProfile" } },
|
|
482
|
+
],
|
|
483
|
+
nullable: true,
|
|
484
|
+
},
|
|
485
|
+
UserProfile: zodToJsonSchema(UserProfileSchema, {
|
|
486
|
+
target: "openApi3",
|
|
487
|
+
$refStrategy: "none",
|
|
488
|
+
}) as OpenApi3Schema,
|
|
432
489
|
ObjectQueryIssue: {
|
|
433
490
|
type: "object",
|
|
434
491
|
required: ["path", "code", "message"],
|
|
@@ -535,6 +592,113 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
535
592
|
plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
|
|
536
593
|
},
|
|
537
594
|
},
|
|
595
|
+
ArtifactErrorResponse: zodToJsonSchema(ArtifactErrorResponseSchema, {
|
|
596
|
+
target: "openApi3",
|
|
597
|
+
$refStrategy: "none",
|
|
598
|
+
}) as OpenApi3Schema,
|
|
599
|
+
// A query an artifact version holds, run as the caller: its rows, typed as the query route
|
|
600
|
+
// types them, or its facets.
|
|
601
|
+
ArtifactQueryResponse: {
|
|
602
|
+
oneOf: [
|
|
603
|
+
{
|
|
604
|
+
type: "object",
|
|
605
|
+
required: [
|
|
606
|
+
"kind",
|
|
607
|
+
"objects",
|
|
608
|
+
"total",
|
|
609
|
+
"truncated",
|
|
610
|
+
"resultObjectTypeIds",
|
|
611
|
+
"readObjectTypeIds",
|
|
612
|
+
"schema",
|
|
613
|
+
],
|
|
614
|
+
additionalProperties: false,
|
|
615
|
+
properties: {
|
|
616
|
+
kind: { type: "string", enum: ["objects"] },
|
|
617
|
+
objects: {
|
|
618
|
+
type: "array",
|
|
619
|
+
items: { $ref: "#/components/schemas/ObjectQueryObject" },
|
|
620
|
+
description: `The rows as the caller reads them, at most ${ARTIFACT_LIMITS.maxQueryRows}: a marked property they are not cleared for is left out and listed in redactions`,
|
|
621
|
+
},
|
|
622
|
+
total: { type: "number", description: "Every row the query matches for the caller" },
|
|
623
|
+
truncated: { type: "boolean", description: "Whether rows past the cap are left out" },
|
|
624
|
+
...artifactQueryShape,
|
|
625
|
+
schema: { $ref: "#/components/schemas/ArtifactQuerySchema" },
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
type: "object",
|
|
630
|
+
required: ["kind", "total", "facets", "resultObjectTypeIds", "readObjectTypeIds", "schema"],
|
|
631
|
+
additionalProperties: false,
|
|
632
|
+
properties: {
|
|
633
|
+
kind: { type: "string", enum: ["facets"] },
|
|
634
|
+
total: { type: "number", description: "Every row the query matches for the caller" },
|
|
635
|
+
facets: {
|
|
636
|
+
type: "array",
|
|
637
|
+
items: { $ref: "#/components/schemas/ObjectQueryFacetResult" },
|
|
638
|
+
},
|
|
639
|
+
...artifactQueryShape,
|
|
640
|
+
schema: { $ref: "#/components/schemas/ArtifactQuerySchema" },
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
},
|
|
645
|
+
ArtifactQuerySchema: {
|
|
646
|
+
type: "object",
|
|
647
|
+
description:
|
|
648
|
+
"What each value of a row holds, from the ontology as the caller may view it: a property their view leaves out is absent",
|
|
649
|
+
required: ["properties", "links"],
|
|
650
|
+
additionalProperties: false,
|
|
651
|
+
properties: {
|
|
652
|
+
properties: {
|
|
653
|
+
...artifactQueryProperties,
|
|
654
|
+
description:
|
|
655
|
+
"The properties of the types the query returns, by id; the first type's when two disagree",
|
|
656
|
+
},
|
|
657
|
+
links: {
|
|
658
|
+
type: "object",
|
|
659
|
+
description:
|
|
660
|
+
"By link id, for each link the query expands on its rows: the properties of what it reaches",
|
|
661
|
+
additionalProperties: {
|
|
662
|
+
type: "object",
|
|
663
|
+
required: ["properties"],
|
|
664
|
+
additionalProperties: false,
|
|
665
|
+
properties: { properties: artifactQueryProperties },
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
ArtifactQueryProperty: {
|
|
671
|
+
type: "object",
|
|
672
|
+
required: ["type"],
|
|
673
|
+
additionalProperties: false,
|
|
674
|
+
properties: {
|
|
675
|
+
type: {
|
|
676
|
+
type: "string",
|
|
677
|
+
enum: [
|
|
678
|
+
"string",
|
|
679
|
+
"integer",
|
|
680
|
+
"double",
|
|
681
|
+
"decimal",
|
|
682
|
+
"boolean",
|
|
683
|
+
"date",
|
|
684
|
+
"timestamp",
|
|
685
|
+
"uuid",
|
|
686
|
+
"fileRef",
|
|
687
|
+
"userRef",
|
|
688
|
+
"enum",
|
|
689
|
+
"array",
|
|
690
|
+
"object",
|
|
691
|
+
"map",
|
|
692
|
+
],
|
|
693
|
+
description: "The property's type, a value type resolved to the schema it names",
|
|
694
|
+
},
|
|
695
|
+
valueType: {
|
|
696
|
+
type: "string",
|
|
697
|
+
enum: ["string", "integer"],
|
|
698
|
+
description: "What an enum's values are",
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
},
|
|
538
702
|
ObjectQueryLink: {
|
|
539
703
|
type: "object",
|
|
540
704
|
required: ["source", "linkId", "target", "createdAt", "updatedAt"],
|
|
@@ -812,6 +976,7 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
812
976
|
kind: { type: "string", enum: ["expand"] },
|
|
813
977
|
input: objectQueryRef,
|
|
814
978
|
expansions: { type: "array", items: objectExpansionRef },
|
|
979
|
+
users: stringArraySchema,
|
|
815
980
|
},
|
|
816
981
|
},
|
|
817
982
|
],
|
|
@@ -828,6 +993,7 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
828
993
|
limit: { type: "integer", minimum: 0 },
|
|
829
994
|
orderBy: { type: "array", items: objectQuerySortFieldRef },
|
|
830
995
|
expand: { type: "array", items: objectExpansionRef },
|
|
996
|
+
users: stringArraySchema,
|
|
831
997
|
},
|
|
832
998
|
},
|
|
833
999
|
ObjectQueryPredicate: {
|
|
@@ -918,3 +1084,18 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
|
|
|
918
1084
|
discriminator: { propertyName: "kind" },
|
|
919
1085
|
},
|
|
920
1086
|
}
|
|
1087
|
+
|
|
1088
|
+
/** A unique-property lookup's 404. Only the one that found no holder carries the code. */
|
|
1089
|
+
export const ObjectLookupNotFoundResponseSchema = ErrorResponseSchema.extend({
|
|
1090
|
+
code: z
|
|
1091
|
+
.enum(["object.not_found"])
|
|
1092
|
+
.optional()
|
|
1093
|
+
.describe(
|
|
1094
|
+
"`object.not_found` when no object visible to the caller holds the value. Other 404s, such as an unknown type, have no code."
|
|
1095
|
+
),
|
|
1096
|
+
})
|
|
1097
|
+
|
|
1098
|
+
/** A write would give a unique property's value to a second object of the type. */
|
|
1099
|
+
export const UniqueViolationErrorResponseSchema = codedErrorResponseSchema([
|
|
1100
|
+
"object.unique_violation",
|
|
1101
|
+
])
|
package/src/schemas/ontology.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const PropertyDefinitionSchema = z.object({
|
|
|
10
10
|
required: z.boolean().optional(),
|
|
11
11
|
nullable: z.boolean().optional(),
|
|
12
12
|
primary: z.boolean().optional(),
|
|
13
|
+
unique: z.boolean().optional(),
|
|
13
14
|
semanticType: z.string().optional(),
|
|
14
15
|
schema: z.unknown(),
|
|
15
16
|
query: z
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import { UserProfileSchema } from "./auth"
|
|
3
|
+
|
|
4
|
+
export const MAX_USERS_PAGE_LIMIT = 200
|
|
5
|
+
export const MAX_USERS_SEARCH_LENGTH = 200
|
|
6
|
+
|
|
7
|
+
export const ListUsersQuerySchema = z.object({
|
|
8
|
+
/** Which members to list. Defaults to `active`. */
|
|
9
|
+
status: z.enum(["active", "suspended", "all"]).optional(),
|
|
10
|
+
/** Part of a display name or email, matched ignoring case. */
|
|
11
|
+
search: z.string().max(MAX_USERS_SEARCH_LENGTH).optional(),
|
|
12
|
+
limit: z.coerce.number().int().min(1).max(MAX_USERS_PAGE_LIMIT).optional(),
|
|
13
|
+
offset: z.coerce.number().int().min(0).optional(),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const ListUsersResponseSchema = z.object({
|
|
17
|
+
users: z.array(UserProfileSchema),
|
|
18
|
+
hasMore: z.boolean(),
|
|
19
|
+
total: z.number(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const UserParamsSchema = z.object({
|
|
23
|
+
userId: z.string().min(1),
|
|
24
|
+
})
|
package/src/schemas/workflows.ts
CHANGED
|
@@ -71,6 +71,8 @@ export const WorkflowInterventionsQuerySchema = z.object({
|
|
|
71
71
|
export const RequestWorkflowRunBodySchema = z
|
|
72
72
|
.object({
|
|
73
73
|
input: WorkflowIOSnapshotSchema.optional(),
|
|
74
|
+
/** Names the run: a request repeated with the same id returns that run instead of another. */
|
|
75
|
+
runId: z.string().trim().min(1).optional(),
|
|
74
76
|
})
|
|
75
77
|
.default({})
|
|
76
78
|
|
package/src/server.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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"
|
|
4
5
|
import { ARTIFACT_FRAME_ROUTE_PREFIX } from "@sixb/core/internal/artifacts/frames"
|
|
5
6
|
import { CSRF_HEADER_NAME, setRequestClientAddress } from "@sixb/core/internal/auth"
|
|
6
7
|
import { bindRequestExecution } from "@sixb/core/internal/request-execution"
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
SharedAccessBoundary,
|
|
42
43
|
type SixbSharedAccessOptions,
|
|
43
44
|
} from "./auth/shared-access"
|
|
45
|
+
import { NamedOpenApiSchemas, openApiOverride } from "./openapi/components"
|
|
44
46
|
import {
|
|
45
47
|
SIXB_ACCESS_TOKEN_SECURITY_SCHEME,
|
|
46
48
|
SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID,
|
|
@@ -58,7 +60,6 @@ import { registerAuthRoutes } from "./routes/auth"
|
|
|
58
60
|
import { DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES } from "./routes/files"
|
|
59
61
|
import { registerWebhookRoutes } from "./routes/webhooks"
|
|
60
62
|
import { registerWebSocketRoutes } from "./routes/ws"
|
|
61
|
-
import { jsonValueOpenApiOverride } from "./schemas/common"
|
|
62
63
|
import { ObjectQueryOpenApiSchemas } from "./schemas/objects"
|
|
63
64
|
import { limitRequestBody, RequestBodyTooLargeError } from "./utils/request-body"
|
|
64
65
|
|
|
@@ -126,8 +127,9 @@ export class SixbServer {
|
|
|
126
127
|
return this.hostRuntime
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
/** The port the server listens on once started, so `port: 0` reports the one it bound. */
|
|
129
131
|
getPort(): number {
|
|
130
|
-
return this.port
|
|
132
|
+
return this.bunServer?.port ?? this.port
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
resolveAuthContext(request: Request): RequestAuthContext {
|
|
@@ -199,7 +201,7 @@ export class SixbServer {
|
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
if (!this.quiet) {
|
|
202
|
-
const base = `http://${this.hostname}:${this.
|
|
204
|
+
const base = `http://${this.hostname}:${this.getPort()}`
|
|
203
205
|
console.log(`Sixb server running at ${base}`)
|
|
204
206
|
console.log(`OpenAPI docs at ${base}/docs`)
|
|
205
207
|
}
|
|
@@ -316,15 +318,12 @@ export function createSixbApi(server: SixbServer) {
|
|
|
316
318
|
|
|
317
319
|
const internalAuthState = consumeInternalRequestAuthState(request)
|
|
318
320
|
if (internalAuthState) {
|
|
319
|
-
const {
|
|
321
|
+
const { runExecution, ...agentState } = internalAuthState
|
|
320
322
|
return {
|
|
321
323
|
auth: { kind: "allow" as const, session: null },
|
|
322
324
|
sharedAccessCookies: null,
|
|
323
325
|
...agentState,
|
|
324
|
-
sixb:
|
|
325
|
-
request,
|
|
326
|
-
authorization,
|
|
327
|
-
}),
|
|
326
|
+
sixb: bindAgentGatewayRequestExecution(host, { signal: request.signal, ...runExecution }),
|
|
328
327
|
}
|
|
329
328
|
}
|
|
330
329
|
|
|
@@ -422,7 +421,7 @@ export function createSixbApi(server: SixbServer) {
|
|
|
422
421
|
[SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID]: SIXB_ACCESS_TOKEN_SECURITY_SCHEME,
|
|
423
422
|
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: SIXB_SHARED_GRANT_SECURITY_SCHEME,
|
|
424
423
|
},
|
|
425
|
-
schemas: ObjectQueryOpenApiSchemas,
|
|
424
|
+
schemas: { ...ObjectQueryOpenApiSchemas, ...NamedOpenApiSchemas },
|
|
426
425
|
},
|
|
427
426
|
// Every operation needs a session unless it says otherwise; public ones declare `[]`.
|
|
428
427
|
security: SIXB_SESSION_SECURITY_REQUIREMENT,
|
|
@@ -436,7 +435,7 @@ export function createSixbApi(server: SixbServer) {
|
|
|
436
435
|
zodToJsonSchema(schema, {
|
|
437
436
|
$refStrategy: "none",
|
|
438
437
|
target: "openApi3",
|
|
439
|
-
override:
|
|
438
|
+
override: openApiOverride(),
|
|
440
439
|
}),
|
|
441
440
|
},
|
|
442
441
|
})
|
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,
|