@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.
Files changed (135) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/public-routes.d.ts.map +1 -1
  3. package/dist/auth/run-token.d.ts +28 -0
  4. package/dist/auth/run-token.d.ts.map +1 -0
  5. package/dist/auth/scope.d.ts +11 -13
  6. package/dist/auth/scope.d.ts.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +4999 -4151
  10. package/dist/index.js.map +47 -43
  11. package/dist/registerRoutes.d.ts.map +1 -1
  12. package/dist/routes/actions.d.ts +1 -1
  13. package/dist/routes/agent-approval-gate.d.ts +7 -4
  14. package/dist/routes/agent-approval-gate.d.ts.map +1 -1
  15. package/dist/routes/agent-approvals.d.ts +14 -5
  16. package/dist/routes/agent-approvals.d.ts.map +1 -1
  17. package/dist/routes/agent-children.d.ts +2 -2
  18. package/dist/routes/agent-computers.d.ts +338 -0
  19. package/dist/routes/agent-computers.d.ts.map +1 -0
  20. package/dist/routes/agent-runners.d.ts +74 -0
  21. package/dist/routes/agent-runners.d.ts.map +1 -0
  22. package/dist/routes/agents.d.ts +250 -16
  23. package/dist/routes/agents.d.ts.map +1 -1
  24. package/dist/routes/ai-accounting.d.ts.map +1 -1
  25. package/dist/routes/artifacts.d.ts +5 -28
  26. package/dist/routes/artifacts.d.ts.map +1 -1
  27. package/dist/routes/auth.d.ts +10 -1
  28. package/dist/routes/auth.d.ts.map +1 -1
  29. package/dist/routes/datasets.d.ts +93 -17
  30. package/dist/routes/datasets.d.ts.map +1 -1
  31. package/dist/routes/events.d.ts +1 -1
  32. package/dist/routes/links.d.ts +121 -81
  33. package/dist/routes/links.d.ts.map +1 -1
  34. package/dist/routes/logs.d.ts +3 -3
  35. package/dist/routes/objects.d.ts +149 -58
  36. package/dist/routes/objects.d.ts.map +1 -1
  37. package/dist/routes/observed-agent-threads.d.ts +25 -4
  38. package/dist/routes/observed-agent-threads.d.ts.map +1 -1
  39. package/dist/routes/pipelines.d.ts +2 -2
  40. package/dist/routes/pipelines.d.ts.map +1 -1
  41. package/dist/routes/projections.d.ts +124 -122
  42. package/dist/routes/projections.d.ts.map +1 -1
  43. package/dist/routes/rules.d.ts +2 -2
  44. package/dist/routes/shared-access.d.ts +2 -2
  45. package/dist/routes/syncs.d.ts +34 -34
  46. package/dist/routes/syncs.d.ts.map +1 -1
  47. package/dist/routes/telemetry.d.ts +0 -50
  48. package/dist/routes/telemetry.d.ts.map +1 -1
  49. package/dist/routes/users.d.ts +1 -0
  50. package/dist/routes/users.d.ts.map +1 -1
  51. package/dist/routes/webhook-runs.d.ts +1 -1
  52. package/dist/routes/workflows.d.ts +25 -14
  53. package/dist/routes/workflows.d.ts.map +1 -1
  54. package/dist/routes/ws/agents.d.ts +4 -1
  55. package/dist/routes/ws/agents.d.ts.map +1 -1
  56. package/dist/routes/ws/logs.d.ts +10 -10
  57. package/dist/schemas/actions.d.ts +3 -3
  58. package/dist/schemas/activity.d.ts +4 -4
  59. package/dist/schemas/agent-approvals.d.ts +21 -21
  60. package/dist/schemas/agents.d.ts +819 -88
  61. package/dist/schemas/agents.d.ts.map +1 -1
  62. package/dist/schemas/ai-accounting.d.ts +1114 -6
  63. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  64. package/dist/schemas/auth.d.ts +49 -2
  65. package/dist/schemas/auth.d.ts.map +1 -1
  66. package/dist/schemas/datasets.d.ts +303 -60
  67. package/dist/schemas/datasets.d.ts.map +1 -1
  68. package/dist/schemas/event-payloads.d.ts +6 -6
  69. package/dist/schemas/events.d.ts +8 -8
  70. package/dist/schemas/lineage.d.ts +1272 -0
  71. package/dist/schemas/lineage.d.ts.map +1 -0
  72. package/dist/schemas/links.d.ts +4 -27
  73. package/dist/schemas/links.d.ts.map +1 -1
  74. package/dist/schemas/logs.d.ts +22 -22
  75. package/dist/schemas/objects.d.ts +7 -26
  76. package/dist/schemas/objects.d.ts.map +1 -1
  77. package/dist/schemas/pipelines.d.ts +12 -12
  78. package/dist/schemas/projections.d.ts +747 -733
  79. package/dist/schemas/projections.d.ts.map +1 -1
  80. package/dist/schemas/rules.d.ts +4 -4
  81. package/dist/schemas/shared-access.d.ts +2 -2
  82. package/dist/schemas/syncs.d.ts +24 -24
  83. package/dist/schemas/telemetry.d.ts +0 -13
  84. package/dist/schemas/telemetry.d.ts.map +1 -1
  85. package/dist/schemas/users.d.ts +8 -0
  86. package/dist/schemas/users.d.ts.map +1 -1
  87. package/dist/schemas/webhook-runs.d.ts +2 -2
  88. package/dist/schemas/workflows.d.ts +133 -44
  89. package/dist/schemas/workflows.d.ts.map +1 -1
  90. package/dist/server.d.ts +5 -0
  91. package/dist/server.d.ts.map +1 -1
  92. package/dist/utils/request-body.d.ts +5 -0
  93. package/dist/utils/request-body.d.ts.map +1 -1
  94. package/dist/utils/request-timing.d.ts +18 -0
  95. package/dist/utils/request-timing.d.ts.map +1 -0
  96. package/package.json +7 -7
  97. package/src/auth/public-routes.ts +0 -6
  98. package/src/auth/run-token.ts +327 -0
  99. package/src/auth/scope.ts +16 -37
  100. package/src/index.ts +1 -0
  101. package/src/registerRoutes.ts +4 -2
  102. package/src/routes/agent-approval-gate.ts +40 -14
  103. package/src/routes/agent-approvals.ts +3 -3
  104. package/src/routes/agent-computers.ts +348 -0
  105. package/src/routes/agent-runners.ts +205 -0
  106. package/src/routes/agents.ts +193 -26
  107. package/src/routes/ai-accounting.ts +149 -12
  108. package/src/routes/artifacts.ts +55 -11
  109. package/src/routes/auth.ts +24 -2
  110. package/src/routes/datasets.ts +60 -5
  111. package/src/routes/links.ts +43 -76
  112. package/src/routes/objects.ts +49 -42
  113. package/src/routes/observed-agent-threads.ts +2 -2
  114. package/src/routes/pipelines.ts +5 -0
  115. package/src/routes/syncs.ts +4 -0
  116. package/src/routes/telemetry.ts +1 -42
  117. package/src/routes/users.ts +15 -2
  118. package/src/routes/ws/agents.ts +10 -1
  119. package/src/schemas/agents.ts +131 -1
  120. package/src/schemas/ai-accounting.ts +78 -15
  121. package/src/schemas/artifacts.ts +1 -1
  122. package/src/schemas/auth.ts +19 -0
  123. package/src/schemas/datasets.ts +36 -0
  124. package/src/schemas/lineage.ts +115 -0
  125. package/src/schemas/links.ts +3 -11
  126. package/src/schemas/objects.ts +6 -10
  127. package/src/schemas/projections.ts +2 -0
  128. package/src/schemas/telemetry.ts +0 -6
  129. package/src/schemas/users.ts +6 -0
  130. package/src/server.ts +53 -15
  131. package/src/utils/request-body.ts +10 -4
  132. package/src/utils/request-timing.ts +136 -0
  133. package/dist/routes/agent-api-gateway.d.ts +0 -4
  134. package/dist/routes/agent-api-gateway.d.ts.map +0 -1
  135. package/src/routes/agent-api-gateway.ts +0 -404
@@ -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, SuccessResponseSchema } from "../schemas/common"
7
- import { LinkParamsSchema, RemoveLinkQuerySchema, UpsertLinkBodySchema } from "../schemas/links"
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
- .put(
13
- "/api/objects/:objectTypeId/:objectId/links/:linkId",
14
- async (context) => {
15
- const { params, body, set } = context
16
- try {
17
- const parsedBody = UpsertLinkBodySchema.parse(body)
18
- await requireRequestSixb(context).objects.upsertLink(
19
- params.objectTypeId,
20
- params.objectId,
21
- params.linkId,
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
- return { success: true }
68
- } catch (error) {
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
- params: LinkParamsSchema,
74
- query: RemoveLinkQuerySchema,
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
  }
@@ -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
  }
@@ -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
  )
@@ -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
  )
@@ -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, SuccessResponseSchema } from "../schemas/common"
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) => {
@@ -17,8 +17,21 @@ export function registerUserRoutes(app: Elysia, _host: SixbHostView) {
17
17
  const sixb = requireRequestSixb(context)
18
18
 
19
19
  try {
20
- const page = await sixb.users.list(ListUsersQuerySchema.parse(query))
21
- return { users: [...page.users], hasMore: page.hasMore, total: page.total }
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
  }
@@ -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
- /** A run's or an approval's activity reaches whoever reads the turn it belongs to. */
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
  }