@sixb/server 0.1.25 → 0.2.0
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/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/run-token.d.ts +28 -0
- package/dist/auth/run-token.d.ts.map +1 -0
- package/dist/auth/scope.d.ts +11 -13
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4999 -4151
- package/dist/index.js.map +47 -43
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +1 -1
- package/dist/routes/agent-approval-gate.d.ts +7 -4
- package/dist/routes/agent-approval-gate.d.ts.map +1 -1
- package/dist/routes/agent-approvals.d.ts +14 -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 +338 -0
- package/dist/routes/agent-computers.d.ts.map +1 -0
- package/dist/routes/agent-runners.d.ts +74 -0
- package/dist/routes/agent-runners.d.ts.map +1 -0
- package/dist/routes/agents.d.ts +250 -16
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/ai-accounting.d.ts.map +1 -1
- package/dist/routes/artifacts.d.ts +5 -28
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +10 -1
- 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 +25 -4
- package/dist/routes/observed-agent-threads.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +2 -2
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +124 -122
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/rules.d.ts +2 -2
- package/dist/routes/shared-access.d.ts +2 -2
- package/dist/routes/syncs.d.ts +34 -34
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/telemetry.d.ts +0 -50
- package/dist/routes/telemetry.d.ts.map +1 -1
- package/dist/routes/users.d.ts +1 -0
- package/dist/routes/users.d.ts.map +1 -1
- package/dist/routes/webhook-runs.d.ts +1 -1
- package/dist/routes/workflows.d.ts +25 -14
- 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 +819 -88
- 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 +49 -2
- 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 +747 -733
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/rules.d.ts +4 -4
- package/dist/schemas/shared-access.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +24 -24
- package/dist/schemas/telemetry.d.ts +0 -13
- package/dist/schemas/telemetry.d.ts.map +1 -1
- package/dist/schemas/users.d.ts +8 -0
- package/dist/schemas/users.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 +5 -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/auth/public-routes.ts +0 -6
- package/src/auth/run-token.ts +327 -0
- package/src/auth/scope.ts +16 -37
- package/src/index.ts +1 -0
- package/src/registerRoutes.ts +4 -2
- package/src/routes/agent-approval-gate.ts +40 -14
- package/src/routes/agent-approvals.ts +3 -3
- package/src/routes/agent-computers.ts +348 -0
- package/src/routes/agent-runners.ts +205 -0
- package/src/routes/agents.ts +193 -26
- package/src/routes/ai-accounting.ts +149 -12
- package/src/routes/artifacts.ts +55 -11
- package/src/routes/auth.ts +24 -2
- package/src/routes/datasets.ts +60 -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/pipelines.ts +5 -0
- package/src/routes/syncs.ts +4 -0
- package/src/routes/telemetry.ts +1 -42
- package/src/routes/users.ts +15 -2
- package/src/routes/ws/agents.ts +10 -1
- package/src/schemas/agents.ts +131 -1
- package/src/schemas/ai-accounting.ts +78 -15
- package/src/schemas/artifacts.ts +1 -1
- 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/projections.ts +2 -0
- package/src/schemas/telemetry.ts +0 -6
- package/src/schemas/users.ts +6 -0
- package/src/server.ts +53 -15
- package/src/utils/request-body.ts +10 -4
- package/src/utils/request-timing.ts +136 -0
- package/dist/routes/agent-api-gateway.d.ts +0 -4
- package/dist/routes/agent-api-gateway.d.ts.map +0 -1
- package/src/routes/agent-api-gateway.ts +0 -404
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/pipelines.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PipelineDefinition, PipelineStepExecutor, SixbHostView } from "@sixb/core"
|
|
2
2
|
import type { PipelineRunRecord, PipelineStepRunRecord } from "@sixb/core/storage"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
4
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
5
6
|
import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
6
7
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -143,6 +144,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
143
144
|
summary: "List registered pipelines",
|
|
144
145
|
tags: [OPENAPI_TAGS.pipelines.name],
|
|
145
146
|
operationId: "listPipelines",
|
|
147
|
+
security: accessTokenSecurityRequirement("listPipelines"),
|
|
146
148
|
},
|
|
147
149
|
}
|
|
148
150
|
)
|
|
@@ -166,6 +168,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
166
168
|
summary: "Get pipeline metadata",
|
|
167
169
|
tags: [OPENAPI_TAGS.pipelines.name],
|
|
168
170
|
operationId: "getPipeline",
|
|
171
|
+
security: accessTokenSecurityRequirement("getPipeline"),
|
|
169
172
|
},
|
|
170
173
|
}
|
|
171
174
|
)
|
|
@@ -211,6 +214,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
211
214
|
summary: "List pipeline run history",
|
|
212
215
|
tags: [OPENAPI_TAGS.pipelineRuns.name],
|
|
213
216
|
operationId: "listPipelineRuns",
|
|
217
|
+
security: accessTokenSecurityRequirement("listPipelineRuns"),
|
|
214
218
|
},
|
|
215
219
|
}
|
|
216
220
|
)
|
|
@@ -257,6 +261,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
257
261
|
summary: "Get pipeline run detail",
|
|
258
262
|
tags: [OPENAPI_TAGS.pipelineRuns.name],
|
|
259
263
|
operationId: "getPipelineRun",
|
|
264
|
+
security: accessTokenSecurityRequirement("getPipelineRun"),
|
|
260
265
|
},
|
|
261
266
|
}
|
|
262
267
|
)
|
package/src/routes/syncs.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SixbHostView, SyncDefinition } from "@sixb/core"
|
|
2
2
|
import type { SyncRunRecord } from "@sixb/core/storage"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
4
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
5
6
|
import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
6
7
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -105,6 +106,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
105
106
|
summary: "List registered syncs",
|
|
106
107
|
tags: [OPENAPI_TAGS.syncs.name],
|
|
107
108
|
operationId: "listSyncs",
|
|
109
|
+
security: accessTokenSecurityRequirement("listSyncs"),
|
|
108
110
|
},
|
|
109
111
|
}
|
|
110
112
|
)
|
|
@@ -128,6 +130,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
128
130
|
summary: "Get sync metadata",
|
|
129
131
|
tags: [OPENAPI_TAGS.syncs.name],
|
|
130
132
|
operationId: "getSync",
|
|
133
|
+
security: accessTokenSecurityRequirement("getSync"),
|
|
131
134
|
},
|
|
132
135
|
}
|
|
133
136
|
)
|
|
@@ -174,6 +177,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
174
177
|
summary: "List sync run history",
|
|
175
178
|
tags: [OPENAPI_TAGS.syncRuns.name],
|
|
176
179
|
operationId: "listSyncRuns",
|
|
180
|
+
security: accessTokenSecurityRequirement("listSyncRuns"),
|
|
177
181
|
},
|
|
178
182
|
}
|
|
179
183
|
)
|
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/users.ts
CHANGED
|
@@ -17,8 +17,21 @@ export function registerUserRoutes(app: Elysia, _host: SixbHostView) {
|
|
|
17
17
|
const sixb = requireRequestSixb(context)
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const { email, ...input } = ListUsersQuerySchema.parse(query)
|
|
21
|
+
if (email === undefined) {
|
|
22
|
+
const page = await sixb.users.list(input)
|
|
23
|
+
return { users: [...page.users], hasMore: page.hasMore, total: page.total }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// `users.get({ email })` over HTTP: a query parameter, so an email never goes in a path.
|
|
27
|
+
if (Object.values(input).some((value) => value !== undefined)) {
|
|
28
|
+
set.status = 400
|
|
29
|
+
return {
|
|
30
|
+
error: "[SixbServer] email finds one member and takes no other option.",
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const profile = await sixb.users.get({ email })
|
|
34
|
+
return { users: profile ? [profile] : [], hasMore: false, total: profile ? 1 : 0 }
|
|
22
35
|
} catch (error) {
|
|
23
36
|
return handleRouteError(error, set)
|
|
24
37
|
}
|
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
|
}
|