@sixb/server 0.1.26 → 0.2.1
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/README.md +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2495 -1845
- package/dist/index.js.map +29 -27
- package/dist/routes/actions.d.ts +1 -1
- package/dist/routes/agent-approvals.d.ts +11 -5
- package/dist/routes/agent-approvals.d.ts.map +1 -1
- package/dist/routes/agent-children.d.ts +2 -2
- package/dist/routes/agent-computers.d.ts +214 -10
- package/dist/routes/agent-computers.d.ts.map +1 -1
- package/dist/routes/agent-runners.d.ts +1 -1
- package/dist/routes/agent-runners.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +230 -24
- 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 +9 -0
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/datasets.d.ts +93 -17
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/events.d.ts +1 -1
- package/dist/routes/links.d.ts +121 -81
- package/dist/routes/links.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +3 -3
- package/dist/routes/objects.d.ts +149 -58
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +23 -5
- package/dist/routes/observed-agent-threads.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +2 -2
- package/dist/routes/projections.d.ts +122 -122
- package/dist/routes/rules.d.ts +2 -2
- package/dist/routes/telemetry.d.ts +0 -50
- package/dist/routes/telemetry.d.ts.map +1 -1
- package/dist/routes/webhook-runs.d.ts +1 -1
- package/dist/routes/workflows.d.ts +21 -10
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/agents.d.ts +4 -1
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/schemas/actions.d.ts +3 -3
- package/dist/schemas/activity.d.ts +4 -4
- package/dist/schemas/agent-approvals.d.ts +21 -21
- package/dist/schemas/agents.d.ts +760 -107
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +1114 -6
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +47 -0
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/datasets.d.ts +303 -60
- package/dist/schemas/datasets.d.ts.map +1 -1
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +8 -8
- package/dist/schemas/lineage.d.ts +1272 -0
- package/dist/schemas/lineage.d.ts.map +1 -0
- package/dist/schemas/links.d.ts +4 -27
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/logs.d.ts +22 -22
- package/dist/schemas/objects.d.ts +7 -26
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/pipelines.d.ts +12 -12
- package/dist/schemas/projections.d.ts +733 -733
- package/dist/schemas/rules.d.ts +4 -4
- package/dist/schemas/telemetry.d.ts +0 -13
- package/dist/schemas/telemetry.d.ts.map +1 -1
- package/dist/schemas/webhook-runs.d.ts +2 -2
- package/dist/schemas/workflows.d.ts +133 -44
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/request-body.d.ts +5 -0
- package/dist/utils/request-body.d.ts.map +1 -1
- package/dist/utils/request-timing.d.ts +18 -0
- package/dist/utils/request-timing.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/index.ts +1 -0
- package/src/routes/agent-approvals.ts +2 -2
- package/src/routes/agent-computers.ts +309 -87
- package/src/routes/agent-runners.ts +30 -6
- package/src/routes/agents.ts +187 -25
- package/src/routes/ai-accounting.ts +149 -12
- package/src/routes/auth.ts +24 -2
- package/src/routes/datasets.ts +55 -5
- package/src/routes/links.ts +43 -76
- package/src/routes/objects.ts +49 -42
- package/src/routes/observed-agent-threads.ts +2 -2
- package/src/routes/telemetry.ts +1 -42
- package/src/routes/ws/agents.ts +10 -1
- package/src/schemas/agents.ts +121 -6
- package/src/schemas/ai-accounting.ts +78 -15
- package/src/schemas/auth.ts +19 -0
- package/src/schemas/datasets.ts +36 -0
- package/src/schemas/lineage.ts +115 -0
- package/src/schemas/links.ts +3 -11
- package/src/schemas/objects.ts +6 -10
- package/src/schemas/telemetry.ts +0 -6
- package/src/server.ts +18 -2
- package/src/utils/request-body.ts +10 -4
- package/src/utils/request-timing.ts +136 -0
package/src/routes/datasets.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DatasetDefinition, SixbHostView } from "@sixb/core"
|
|
1
|
+
import type { DatasetDefinition, DatasetLineage, SixbHostView } from "@sixb/core"
|
|
2
2
|
import { createSixbError } from "@sixb/core/internal/errors"
|
|
3
3
|
import type {
|
|
4
4
|
DatasetCatalogState,
|
|
@@ -12,6 +12,8 @@ import { OPENAPI_TAGS } from "../openapi/tags"
|
|
|
12
12
|
import { codedErrorResponseSchema, ErrorResponseSchema } from "../schemas/common"
|
|
13
13
|
import {
|
|
14
14
|
DatasetCatalogItemSchema,
|
|
15
|
+
DatasetLineageQuerySchema,
|
|
16
|
+
DatasetLineageResponseSchema,
|
|
15
17
|
DatasetParamsSchema,
|
|
16
18
|
DatasetRowsQuerySchema,
|
|
17
19
|
DatasetRowsResponseSchema,
|
|
@@ -64,6 +66,15 @@ function serializeDatasetVersion(version: DatasetVersion) {
|
|
|
64
66
|
})
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
function serializeDatasetLineage(lineage: DatasetLineage) {
|
|
70
|
+
return DatasetLineageResponseSchema.parse({
|
|
71
|
+
...lineage,
|
|
72
|
+
nodes: lineage.nodes.map((node) =>
|
|
73
|
+
"expired" in node ? node : { ...node, createdAt: toIsoString(node.createdAt) }
|
|
74
|
+
),
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
interface DatasetReferences {
|
|
68
79
|
readonly syncIds: string[]
|
|
69
80
|
readonly sourcePipelineIds: string[]
|
|
@@ -253,10 +264,10 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
253
264
|
const { params, query, set } = context
|
|
254
265
|
const sixb = requireRequestSixb(context)
|
|
255
266
|
try {
|
|
256
|
-
requireDataset(sixb, params.datasetId)
|
|
267
|
+
const dataset = requireDataset(sixb, params.datasetId)
|
|
257
268
|
const parsed = DatasetVersionsQuerySchema.parse(query)
|
|
258
269
|
const limit = parseLimit(parsed.limit, DEFAULT_VERSION_LIMIT, MAX_VERSION_LIMIT)
|
|
259
|
-
const versions = await
|
|
270
|
+
const versions = await sixb.datasets.listVersions(dataset, { limit })
|
|
260
271
|
|
|
261
272
|
return DatasetVersionListResponseSchema.parse({
|
|
262
273
|
versions: versions.map(serializeDatasetVersion),
|
|
@@ -288,8 +299,8 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
288
299
|
const { params, set } = context
|
|
289
300
|
const sixb = requireRequestSixb(context)
|
|
290
301
|
try {
|
|
291
|
-
requireDataset(sixb, params.datasetId)
|
|
292
|
-
const version = await
|
|
302
|
+
const dataset = requireDataset(sixb, params.datasetId)
|
|
303
|
+
const version = await sixb.datasets.getVersion(dataset, params.versionId)
|
|
293
304
|
if (!version) {
|
|
294
305
|
throw datasetVersionNotFound(params.datasetId, params.versionId)
|
|
295
306
|
}
|
|
@@ -313,6 +324,45 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
313
324
|
},
|
|
314
325
|
}
|
|
315
326
|
)
|
|
327
|
+
.get(
|
|
328
|
+
"/api/datasets/:datasetId/versions/:versionId/lineage",
|
|
329
|
+
async (context) => {
|
|
330
|
+
const { params, query, set } = context
|
|
331
|
+
const sixb = requireRequestSixb(context)
|
|
332
|
+
try {
|
|
333
|
+
const dataset = requireDataset(sixb, params.datasetId)
|
|
334
|
+
const parsed = DatasetLineageQuerySchema.parse(query)
|
|
335
|
+
const lineage = await sixb.datasets.lineage(dataset, {
|
|
336
|
+
versionId: params.versionId,
|
|
337
|
+
depth: parseOptionalInt(parsed.depth),
|
|
338
|
+
})
|
|
339
|
+
if (!lineage) {
|
|
340
|
+
throw datasetVersionNotFound(params.datasetId, params.versionId)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return serializeDatasetLineage(lineage)
|
|
344
|
+
} catch (error) {
|
|
345
|
+
return handleRouteError(error, set)
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
params: DatasetVersionParamsSchema,
|
|
350
|
+
query: DatasetLineageQuerySchema,
|
|
351
|
+
response: {
|
|
352
|
+
200: DatasetLineageResponseSchema,
|
|
353
|
+
400: ErrorResponseSchema,
|
|
354
|
+
404: DatasetVersionNotFoundErrorResponseSchema,
|
|
355
|
+
},
|
|
356
|
+
detail: {
|
|
357
|
+
summary: "Get the versions a dataset version is computed from",
|
|
358
|
+
description:
|
|
359
|
+
"Walks the version's inputs upstream, `depth` steps (1 to 20, default 5). A version whose dataset the caller cannot view is left out with everything upstream of it, and counted in `restricted`.",
|
|
360
|
+
tags: [OPENAPI_TAGS.datasetVersions.name],
|
|
361
|
+
operationId: "getDatasetVersionLineage",
|
|
362
|
+
security: accessTokenSecurityRequirement("getDatasetVersionLineage"),
|
|
363
|
+
},
|
|
364
|
+
}
|
|
365
|
+
)
|
|
316
366
|
.get(
|
|
317
367
|
"/api/datasets/:datasetId/rows",
|
|
318
368
|
async (context) => {
|
package/src/routes/links.ts
CHANGED
|
@@ -3,87 +3,54 @@ import type { Elysia } from "elysia"
|
|
|
3
3
|
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
4
4
|
import { requireRequestSixb } from "../auth/scope"
|
|
5
5
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
6
|
-
import { ErrorResponseSchema
|
|
7
|
-
import {
|
|
6
|
+
import { ErrorResponseSchema } from "../schemas/common"
|
|
7
|
+
import { LinkLineageSchema } from "../schemas/lineage"
|
|
8
|
+
import { LinkLineageQuerySchema, LinkParamsSchema } from "../schemas/links"
|
|
8
9
|
import { handleRouteError } from "../utils/http"
|
|
9
10
|
|
|
10
11
|
export function registerLinkRoutes(app: Elysia, _host: SixbHostView) {
|
|
11
|
-
return app
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
targetTypeId: parsedBody.targetTypeId,
|
|
24
|
-
targetId: parsedBody.targetId,
|
|
25
|
-
properties: parsedBody.properties,
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return { success: true }
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return handleRouteError(error, set)
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
params: LinkParamsSchema,
|
|
36
|
-
body: UpsertLinkBodySchema,
|
|
37
|
-
response: {
|
|
38
|
-
200: SuccessResponseSchema,
|
|
39
|
-
400: ErrorResponseSchema,
|
|
40
|
-
403: ErrorResponseSchema,
|
|
41
|
-
404: ErrorResponseSchema,
|
|
42
|
-
},
|
|
43
|
-
detail: {
|
|
44
|
-
summary: "Create or update object link",
|
|
45
|
-
tags: [OPENAPI_TAGS.links.name],
|
|
46
|
-
operationId: "upsertObjectLink",
|
|
47
|
-
security: accessTokenSecurityRequirement("upsertObjectLink"),
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
.delete(
|
|
52
|
-
"/api/objects/:objectTypeId/:objectId/links/:linkId",
|
|
53
|
-
async (context) => {
|
|
54
|
-
const { params, query, set } = context
|
|
55
|
-
try {
|
|
56
|
-
const parsedQuery = RemoveLinkQuerySchema.parse(query)
|
|
57
|
-
await requireRequestSixb(context).objects.removeLink(
|
|
58
|
-
params.objectTypeId,
|
|
59
|
-
params.objectId,
|
|
60
|
-
params.linkId,
|
|
61
|
-
{
|
|
12
|
+
return app.get(
|
|
13
|
+
"/api/objects/:objectTypeId/:objectId/links/:linkId/lineage",
|
|
14
|
+
async (context) => {
|
|
15
|
+
const { params, query, set } = context
|
|
16
|
+
const sixb = requireRequestSixb(context)
|
|
17
|
+
try {
|
|
18
|
+
const parsedQuery = LinkLineageQuerySchema.parse(query)
|
|
19
|
+
const objectType = sixb.objects.getTypeById(params.objectTypeId)
|
|
20
|
+
const lineage = objectType
|
|
21
|
+
? await sixb.objects(objectType).linkLineage({
|
|
22
|
+
sourceId: params.objectId,
|
|
23
|
+
linkId: params.linkId,
|
|
62
24
|
targetTypeId: parsedQuery.targetTypeId,
|
|
63
25
|
targetId: parsedQuery.targetId,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return handleRouteError(error, set)
|
|
26
|
+
})
|
|
27
|
+
: null
|
|
28
|
+
if (!lineage) {
|
|
29
|
+
set.status = 404
|
|
30
|
+
return { error: "Link not found" }
|
|
70
31
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
response: {
|
|
76
|
-
200: SuccessResponseSchema,
|
|
77
|
-
400: ErrorResponseSchema,
|
|
78
|
-
403: ErrorResponseSchema,
|
|
79
|
-
404: ErrorResponseSchema,
|
|
80
|
-
},
|
|
81
|
-
detail: {
|
|
82
|
-
summary: "Remove object link",
|
|
83
|
-
tags: [OPENAPI_TAGS.links.name],
|
|
84
|
-
operationId: "removeObjectLink",
|
|
85
|
-
security: accessTokenSecurityRequirement("removeObjectLink"),
|
|
86
|
-
},
|
|
32
|
+
|
|
33
|
+
return LinkLineageSchema.parse(lineage)
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return handleRouteError(error, set)
|
|
87
36
|
}
|
|
88
|
-
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
params: LinkParamsSchema,
|
|
40
|
+
query: LinkLineageQuerySchema,
|
|
41
|
+
response: {
|
|
42
|
+
200: LinkLineageSchema,
|
|
43
|
+
400: ErrorResponseSchema,
|
|
44
|
+
404: ErrorResponseSchema,
|
|
45
|
+
},
|
|
46
|
+
detail: {
|
|
47
|
+
summary: "Get where an object link comes from",
|
|
48
|
+
description:
|
|
49
|
+
"What makes the link exist, for the current state. Steps the caller cannot view are left out and counted in `restricted`.",
|
|
50
|
+
tags: [OPENAPI_TAGS.links.name],
|
|
51
|
+
operationId: "getObjectLinkLineage",
|
|
52
|
+
security: accessTokenSecurityRequirement("getObjectLinkLineage"),
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
)
|
|
89
56
|
}
|
package/src/routes/objects.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
23
23
|
import { ErrorResponseSchema } from "../schemas/common"
|
|
24
24
|
import { FileContentQuerySchema } from "../schemas/files"
|
|
25
|
+
import { ObjectLineageSchema } from "../schemas/lineage"
|
|
25
26
|
import {
|
|
26
27
|
GetObjectByUniquePropertyBodySchema,
|
|
27
28
|
ObjectListResponseSchema,
|
|
@@ -37,10 +38,9 @@ import {
|
|
|
37
38
|
ObjectsQuerySchema,
|
|
38
39
|
TwinObjectSchema,
|
|
39
40
|
UniquePropertyParamsSchema,
|
|
40
|
-
UniqueViolationErrorResponseSchema,
|
|
41
|
-
UpsertObjectBodySchema,
|
|
42
41
|
} from "../schemas/objects"
|
|
43
42
|
import { handleRouteError, parseOptionalInt, toIsoString } from "../utils/http"
|
|
43
|
+
import { noteRequestSubject } from "../utils/request-timing"
|
|
44
44
|
|
|
45
45
|
// Only object files are served to shared sessions. The boundary reads `shareGrant` before routing;
|
|
46
46
|
// declaring it here keeps it in the OpenAPI contract and through query validation.
|
|
@@ -89,11 +89,20 @@ function serializeObjectLink(link: {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/** The type a query starts from, which names it in logs without repeating any of its values. */
|
|
93
|
+
function queryStartObjectType(query: ObjectQuery): string | undefined {
|
|
94
|
+
if (query.kind === "start") return query.objectTypeId
|
|
95
|
+
if (query.kind === "refs") return query.refs[0]?.objectTypeId
|
|
96
|
+
if (query.kind === "set") return query.inputs[0] && queryStartObjectType(query.inputs[0])
|
|
97
|
+
return "input" in query ? queryStartObjectType(query.input) : undefined
|
|
98
|
+
}
|
|
99
|
+
|
|
92
100
|
function serializePlan(plan: {
|
|
93
101
|
readonly mode: string
|
|
94
102
|
readonly providerIssues: readonly unknown[]
|
|
95
103
|
readonly fallbackIssues: readonly unknown[]
|
|
96
104
|
readonly issues: readonly unknown[]
|
|
105
|
+
readonly readObjectTypeIds?: readonly string[]
|
|
97
106
|
readonly fallback?: { readonly maxRows: number; readonly requiresExplicitBound: boolean }
|
|
98
107
|
}) {
|
|
99
108
|
return {
|
|
@@ -102,6 +111,7 @@ function serializePlan(plan: {
|
|
|
102
111
|
fallbackIssues: plan.fallbackIssues,
|
|
103
112
|
issues: plan.issues,
|
|
104
113
|
fallback: plan.fallback,
|
|
114
|
+
readObjectTypeIds: plan.readObjectTypeIds,
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
|
|
@@ -375,6 +385,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
375
385
|
query: ObjectQuery
|
|
376
386
|
includeTotal?: boolean
|
|
377
387
|
}
|
|
388
|
+
noteRequestSubject(queryStartObjectType(parsed.query))
|
|
378
389
|
const result = await requireRequestSixb(context).objects.executeQuery({
|
|
379
390
|
query: parsed.query,
|
|
380
391
|
includeTotal: parsed.includeTotal,
|
|
@@ -541,6 +552,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
541
552
|
const parsed = ObjectQueryCountRequestSchema.parse(body) as {
|
|
542
553
|
query: ObjectQuery
|
|
543
554
|
}
|
|
555
|
+
noteRequestSubject(queryStartObjectType(parsed.query))
|
|
544
556
|
const result = await requireRequestSixb(context).objects.count({ query: parsed.query })
|
|
545
557
|
|
|
546
558
|
return {
|
|
@@ -624,6 +636,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
624
636
|
const parsed = ObjectQueryExistsRequestSchema.parse(body) as {
|
|
625
637
|
query: ObjectQuery
|
|
626
638
|
}
|
|
639
|
+
noteRequestSubject(queryStartObjectType(parsed.query))
|
|
627
640
|
const result = await requireRequestSixb(context).objects.exists({ query: parsed.query })
|
|
628
641
|
|
|
629
642
|
return {
|
|
@@ -708,6 +721,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
708
721
|
query: ObjectQuery
|
|
709
722
|
facets: { propertyId: string; limit: number }[]
|
|
710
723
|
}
|
|
724
|
+
noteRequestSubject(queryStartObjectType(parsed.query))
|
|
711
725
|
const result = await requireRequestSixb(context).objects.facet({
|
|
712
726
|
query: parsed.query,
|
|
713
727
|
facets: parsed.facets,
|
|
@@ -850,6 +864,39 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
850
864
|
},
|
|
851
865
|
}
|
|
852
866
|
)
|
|
867
|
+
.get(
|
|
868
|
+
"/api/objects/:objectTypeId/:objectId/lineage",
|
|
869
|
+
async (context) => {
|
|
870
|
+
const { params, set } = context
|
|
871
|
+
const sixb = requireRequestSixb(context)
|
|
872
|
+
|
|
873
|
+
try {
|
|
874
|
+
const objectType = sixb.objects.getTypeById(params.objectTypeId)
|
|
875
|
+
const lineage = objectType
|
|
876
|
+
? await sixb.objects(objectType).lineage(params.objectId)
|
|
877
|
+
: null
|
|
878
|
+
if (lineage) return ObjectLineageSchema.parse(lineage)
|
|
879
|
+
} catch (error) {
|
|
880
|
+
// Identity reads hide existence: forbidden and missing look the same.
|
|
881
|
+
if (!(error instanceof AuthorizationError)) throw error
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
set.status = 404
|
|
885
|
+
return { error: "Object not found" }
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
params: ObjectParamsSchema,
|
|
889
|
+
response: { 200: ObjectLineageSchema, 404: ErrorResponseSchema },
|
|
890
|
+
detail: {
|
|
891
|
+
summary: "Get where an object's values come from",
|
|
892
|
+
description:
|
|
893
|
+
"What makes the object exist and what decided each property it holds, for the current state. Steps the caller cannot view are left out and counted in `restricted`.",
|
|
894
|
+
tags: [OPENAPI_TAGS.objects.name],
|
|
895
|
+
operationId: "getObjectLineage",
|
|
896
|
+
security: accessTokenSecurityRequirement("getObjectLineage"),
|
|
897
|
+
},
|
|
898
|
+
}
|
|
899
|
+
)
|
|
853
900
|
.post(
|
|
854
901
|
"/api/objects/:objectTypeId/by/:propertyId",
|
|
855
902
|
async (context) => {
|
|
@@ -893,44 +940,4 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
|
|
|
893
940
|
},
|
|
894
941
|
}
|
|
895
942
|
)
|
|
896
|
-
.put(
|
|
897
|
-
"/api/objects/:objectTypeId/:objectId",
|
|
898
|
-
async (context) => {
|
|
899
|
-
const { params, body, set } = context
|
|
900
|
-
const sixb = requireRequestSixb(context)
|
|
901
|
-
try {
|
|
902
|
-
const parsedBody = UpsertObjectBodySchema.parse(body)
|
|
903
|
-
// The same bound SDK performs the primary-property lookup and the write. Otherwise an
|
|
904
|
-
// ambient host lookup could answer 404 for an unregistered type before the principal's
|
|
905
|
-
// grant is checked, distinguishing it from a registered but ungranted type (403) and
|
|
906
|
-
// leaking the type universe that `listObjectTypes` filters out.
|
|
907
|
-
const primaryPropertyId = sixb.objects.getPrimaryPropertyId(params.objectTypeId)
|
|
908
|
-
const properties = { ...parsedBody.properties, [primaryPropertyId]: params.objectId }
|
|
909
|
-
const object = await sixb.objects.upsert(params.objectTypeId, properties)
|
|
910
|
-
return serializeObject(object)
|
|
911
|
-
} catch (error) {
|
|
912
|
-
// Was a local catch mapping every error to 404/400, which turned a missing grant into
|
|
913
|
-
// "bad request". `handleRouteError` answers 403 for AuthorizationError, like the link and
|
|
914
|
-
// telemetry writes already did.
|
|
915
|
-
return handleRouteError(error, set)
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
{
|
|
919
|
-
params: ObjectParamsSchema,
|
|
920
|
-
body: UpsertObjectBodySchema,
|
|
921
|
-
response: {
|
|
922
|
-
200: TwinObjectSchema,
|
|
923
|
-
400: ErrorResponseSchema,
|
|
924
|
-
403: ErrorResponseSchema,
|
|
925
|
-
404: ErrorResponseSchema,
|
|
926
|
-
409: UniqueViolationErrorResponseSchema,
|
|
927
|
-
},
|
|
928
|
-
detail: {
|
|
929
|
-
summary: "Create or update object",
|
|
930
|
-
tags: [OPENAPI_TAGS.objects.name],
|
|
931
|
-
operationId: "upsertObject",
|
|
932
|
-
security: accessTokenSecurityRequirement("upsertObject"),
|
|
933
|
-
},
|
|
934
|
-
}
|
|
935
|
-
)
|
|
936
943
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentThreadView, SixbHostView } from "@sixb/core"
|
|
2
2
|
import type { Elysia } from "elysia"
|
|
3
|
-
import { requireRequestSixb } from "../auth/scope"
|
|
3
|
+
import { requestActor, requireRequestSixb } from "../auth/scope"
|
|
4
4
|
import { fileContentGetResponses, handleFileContentQueryValidationError } from "../files/content"
|
|
5
5
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
6
6
|
import {
|
|
@@ -59,7 +59,7 @@ export function registerObservedAgentThreadRoutes(app: Elysia, host: SixbHostVie
|
|
|
59
59
|
return threadNotFound(context.set)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
return await serializeThread(host, thread)
|
|
62
|
+
return await serializeThread(host, thread, requestActor(requireRequestSixb(context)))
|
|
63
63
|
} catch (error) {
|
|
64
64
|
return handleAgentRouteError(error, context.set)
|
|
65
65
|
}
|
package/src/routes/telemetry.ts
CHANGED
|
@@ -4,9 +4,8 @@ import type { Elysia } from "elysia"
|
|
|
4
4
|
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
5
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
6
6
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
7
|
-
import { ErrorResponseSchema
|
|
7
|
+
import { ErrorResponseSchema } from "../schemas/common"
|
|
8
8
|
import {
|
|
9
|
-
AppendTelemetryBodySchema,
|
|
10
9
|
BulkTelemetryHistoryBodySchema,
|
|
11
10
|
BulkTelemetryHistoryResponseSchema,
|
|
12
11
|
TelemetryHistoryQuerySchema,
|
|
@@ -29,46 +28,6 @@ function serializeTelemetryPoint(point: TimeseriesPoint) {
|
|
|
29
28
|
|
|
30
29
|
export function registerTelemetryRoutes(app: Elysia, _host: SixbHostView) {
|
|
31
30
|
return app
|
|
32
|
-
.post(
|
|
33
|
-
"/api/objects/:objectTypeId/:objectId/telemetry/:propertyId",
|
|
34
|
-
async (context) => {
|
|
35
|
-
const { params, body, set } = context
|
|
36
|
-
try {
|
|
37
|
-
const parsedBody = AppendTelemetryBodySchema.parse(body)
|
|
38
|
-
await requireRequestSixb(context).objects.appendTelemetry(params.objectTypeId, [
|
|
39
|
-
{
|
|
40
|
-
id: params.objectId,
|
|
41
|
-
properties: {
|
|
42
|
-
[params.propertyId]: parsedBody.unit
|
|
43
|
-
? { value: parsedBody.value, unit: parsedBody.unit }
|
|
44
|
-
: parsedBody.value,
|
|
45
|
-
},
|
|
46
|
-
at: parseDate(parsedBody.at),
|
|
47
|
-
},
|
|
48
|
-
])
|
|
49
|
-
|
|
50
|
-
return { success: true }
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return handleRouteError(error, set)
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
params: TelemetryParamsSchema,
|
|
57
|
-
body: AppendTelemetryBodySchema,
|
|
58
|
-
response: {
|
|
59
|
-
200: SuccessResponseSchema,
|
|
60
|
-
400: ErrorResponseSchema,
|
|
61
|
-
403: ErrorResponseSchema,
|
|
62
|
-
404: ErrorResponseSchema,
|
|
63
|
-
},
|
|
64
|
-
detail: {
|
|
65
|
-
summary: "Append telemetry point",
|
|
66
|
-
tags: [OPENAPI_TAGS.telemetry.name],
|
|
67
|
-
operationId: "appendTelemetry",
|
|
68
|
-
security: accessTokenSecurityRequirement("appendTelemetry"),
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
31
|
.post(
|
|
73
32
|
"/api/telemetry/history",
|
|
74
33
|
async (context) => {
|
package/src/routes/ws/agents.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { principalsEqual } from "@sixb/core"
|
|
1
2
|
import {
|
|
2
3
|
AGENT_ACTIVITY_STREAM_ID,
|
|
3
4
|
type AgentActivityEvent,
|
|
@@ -10,8 +11,10 @@ import {
|
|
|
10
11
|
agentRunStreamId,
|
|
11
12
|
} from "@sixb/core/internal/agents/streams"
|
|
12
13
|
import type { Sixb } from "@sixb/core/internal/request-execution"
|
|
14
|
+
import type { Principal } from "@sixb/core/storage"
|
|
13
15
|
import type { Elysia } from "elysia"
|
|
14
16
|
import { z } from "zod"
|
|
17
|
+
import { requestActor } from "../../auth/scope"
|
|
15
18
|
import type { SixbServer } from "../../server"
|
|
16
19
|
import { decodeWsMessage, safeSend, wsRequestSixb, wsStateKey } from "../../utils/ws"
|
|
17
20
|
import { serializeAgentRun } from "../agents"
|
|
@@ -94,11 +97,17 @@ export async function canAccessAgentRunStream(
|
|
|
94
97
|
return { ok: true }
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* A run's or an approval's activity reaches whoever reads the turn it belongs to; a computer
|
|
102
|
+
* session's, or a thread's move, its owner alone.
|
|
103
|
+
*/
|
|
98
104
|
export async function canAccessAgentThreadActivity(
|
|
99
105
|
sixb: Sixb,
|
|
100
106
|
event: AgentActivityEvent
|
|
101
107
|
): Promise<boolean> {
|
|
108
|
+
if (event.type === "agent.computer.activity" || event.type === "agent.thread.moved") {
|
|
109
|
+
return principalsEqual(event.ownerPrincipal as Principal, requestActor(sixb))
|
|
110
|
+
}
|
|
102
111
|
const run = await sixb.agent.runs.getById(event.runId)
|
|
103
112
|
return run?.projectId === event.projectId && run.threadId === event.threadId
|
|
104
113
|
}
|