@sixb/server 0.1.2 → 0.1.4

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 (90) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/experience.d.ts +33 -0
  3. package/dist/auth/experience.d.ts.map +1 -0
  4. package/dist/auth/public-routes.d.ts.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2122 -1391
  8. package/dist/index.js.map +24 -19
  9. package/dist/openapi/tags.d.ts +10 -2
  10. package/dist/openapi/tags.d.ts.map +1 -1
  11. package/dist/registerRoutes.d.ts.map +1 -1
  12. package/dist/routes/action-runs.d.ts +6 -6
  13. package/dist/routes/actions.d.ts +3 -3
  14. package/dist/routes/agents.d.ts +164 -77
  15. package/dist/routes/agents.d.ts.map +1 -1
  16. package/dist/routes/ai-accounting.d.ts +31 -0
  17. package/dist/routes/ai-accounting.d.ts.map +1 -0
  18. package/dist/routes/auth.d.ts +110 -53
  19. package/dist/routes/auth.d.ts.map +1 -1
  20. package/dist/routes/connector-connection-runs.d.ts +56 -56
  21. package/dist/routes/connector-connections.d.ts +14 -14
  22. package/dist/routes/datasets.d.ts +12 -12
  23. package/dist/routes/events.d.ts +1 -1
  24. package/dist/routes/files.d.ts +8 -8
  25. package/dist/routes/links.d.ts +6 -57
  26. package/dist/routes/links.d.ts.map +1 -1
  27. package/dist/routes/logs.d.ts +3 -3
  28. package/dist/routes/models.d.ts +60 -0
  29. package/dist/routes/models.d.ts.map +1 -0
  30. package/dist/routes/objects.d.ts +51 -3
  31. package/dist/routes/objects.d.ts.map +1 -1
  32. package/dist/routes/pipelines.d.ts +10 -10
  33. package/dist/routes/projections.d.ts +150 -136
  34. package/dist/routes/projections.d.ts.map +1 -1
  35. package/dist/routes/syncs.d.ts +38 -38
  36. package/dist/routes/telemetry.d.ts +7 -7
  37. package/dist/routes/webhook-runs.d.ts +2 -2
  38. package/dist/routes/workflows.d.ts +142 -57
  39. package/dist/routes/workflows.d.ts.map +1 -1
  40. package/dist/routes/ws/logs.d.ts +10 -10
  41. package/dist/schemas/actions.d.ts +16 -16
  42. package/dist/schemas/agents.d.ts +586 -142
  43. package/dist/schemas/agents.d.ts.map +1 -1
  44. package/dist/schemas/ai-accounting.d.ts +2393 -0
  45. package/dist/schemas/ai-accounting.d.ts.map +1 -0
  46. package/dist/schemas/auth.d.ts +96 -96
  47. package/dist/schemas/connectors.d.ts +35 -25
  48. package/dist/schemas/connectors.d.ts.map +1 -1
  49. package/dist/schemas/event-payloads.d.ts +6 -6
  50. package/dist/schemas/events.d.ts +6 -6
  51. package/dist/schemas/links.d.ts +0 -41
  52. package/dist/schemas/links.d.ts.map +1 -1
  53. package/dist/schemas/logs.d.ts +22 -22
  54. package/dist/schemas/models.d.ts +50 -0
  55. package/dist/schemas/models.d.ts.map +1 -0
  56. package/dist/schemas/objects.d.ts +22 -0
  57. package/dist/schemas/objects.d.ts.map +1 -1
  58. package/dist/schemas/pipelines.d.ts +20 -20
  59. package/dist/schemas/projections.d.ts +947 -806
  60. package/dist/schemas/projections.d.ts.map +1 -1
  61. package/dist/schemas/status.d.ts +2 -2
  62. package/dist/schemas/syncs.d.ts +33 -33
  63. package/dist/schemas/webhook-runs.d.ts +12 -12
  64. package/dist/schemas/workflows.d.ts +833 -162
  65. package/dist/schemas/workflows.d.ts.map +1 -1
  66. package/dist/server.d.ts +5 -0
  67. package/dist/server.d.ts.map +1 -1
  68. package/package.json +5 -5
  69. package/src/auth/experience.ts +190 -0
  70. package/src/auth/public-routes.ts +7 -0
  71. package/src/index.ts +1 -0
  72. package/src/openapi/tags.ts +8 -0
  73. package/src/registerRoutes.ts +4 -0
  74. package/src/routes/agents.ts +22 -3
  75. package/src/routes/ai-accounting.ts +166 -0
  76. package/src/routes/auth.ts +188 -32
  77. package/src/routes/links.ts +2 -53
  78. package/src/routes/models.ts +31 -0
  79. package/src/routes/objects.ts +103 -0
  80. package/src/routes/projections.ts +18 -4
  81. package/src/routes/workflows.ts +16 -0
  82. package/src/schemas/agents.ts +19 -9
  83. package/src/schemas/ai-accounting.ts +182 -0
  84. package/src/schemas/connectors.ts +13 -3
  85. package/src/schemas/links.ts +0 -17
  86. package/src/schemas/models.ts +15 -0
  87. package/src/schemas/objects.ts +104 -0
  88. package/src/schemas/projections.ts +12 -3
  89. package/src/schemas/workflows.ts +8 -3
  90. package/src/server.ts +10 -0
@@ -2,10 +2,12 @@ import { AGENT_REASONING_LEVELS, MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core"
2
2
  import {
3
3
  AGENT_RUN_DIAGNOSTIC_CODES,
4
4
  AGENT_RUN_FAILURE_CODES,
5
+ AGENT_RUN_FINISH_REASONS,
5
6
  type AgentRunFailureCode,
6
7
  type SixbFailure,
7
8
  } from "@sixb/core/storage"
8
9
  import { z } from "zod"
10
+ import { AiCostSummarySchema } from "./ai-accounting"
9
11
  import { AiUsageSummarySchema } from "./ai-usage"
10
12
  import { JsonValueSchema, sixbFailureSchema } from "./common"
11
13
  import { FileRefSchema } from "./files"
@@ -77,6 +79,13 @@ export const AgentLoopConfigSchema = z.object({
77
79
  maxSteps: z.number().int().positive().optional(),
78
80
  })
79
81
  .optional(),
82
+ context: z
83
+ .object({
84
+ windowTokens: z.number().int().positive().optional(),
85
+ reserveTokens: z.number().int().positive().optional(),
86
+ keepRecentTokens: z.number().int().positive().optional(),
87
+ })
88
+ .optional(),
80
89
  })
81
90
 
82
91
  export const AgentReasoningLevelSchema = z.enum(AGENT_REASONING_LEVELS)
@@ -193,6 +202,12 @@ export const AgentRunDiagnosticSchema = z.object({
193
202
  message: z.string(),
194
203
  })
195
204
 
205
+ export const AgentMessageCompactionSchema = z.object({
206
+ checkpointId: z.string(),
207
+ summary: z.string(),
208
+ createdAt: z.string(),
209
+ })
210
+
196
211
  export const AgentMessageSchema = z.object({
197
212
  id: z.string(),
198
213
  projectId: z.string(),
@@ -204,6 +219,8 @@ export const AgentMessageSchema = z.object({
204
219
  parts: z.array(AgentMessagePartSchema),
205
220
  /** Platform-authored annotations associated with this message's run. */
206
221
  annotations: z.array(AgentRunDiagnosticSchema),
222
+ /** A durable context summary created before this response's model call. */
223
+ compaction: AgentMessageCompactionSchema.optional(),
207
224
  metadata: JsonValueSchema.optional(),
208
225
  contentVersion: z.number(),
209
226
  createdAt: z.string(),
@@ -242,15 +259,7 @@ export const AgentRunStatusSchema = z.enum([
242
259
  "cancelled",
243
260
  ])
244
261
 
245
- export const AgentRunFinishReasonSchema = z.enum([
246
- "stop",
247
- "length",
248
- "content-filter",
249
- "tool-calls",
250
- "error",
251
- "other",
252
- "unknown",
253
- ])
262
+ export const AgentRunFinishReasonSchema = z.enum(AGENT_RUN_FINISH_REASONS)
254
263
 
255
264
  export const AgentRunSchema = z.object({
256
265
  id: z.string(),
@@ -263,6 +272,7 @@ export const AgentRunSchema = z.object({
263
272
  modelId: z.string().optional(),
264
273
  finishReason: AgentRunFinishReasonSchema.optional(),
265
274
  usage: AiUsageSummarySchema.optional(),
275
+ cost: AiCostSummarySchema.optional(),
266
276
  diagnostics: z.array(AgentRunDiagnosticSchema).optional(),
267
277
  error: AgentRunFailureSchema.optional(),
268
278
  attempt: z.number(),
@@ -0,0 +1,182 @@
1
+ import { z } from "zod"
2
+ import { AiUsageSummarySchema } from "./ai-usage"
3
+
4
+ const IntegerStringSchema = z.string().regex(/^\d+$/)
5
+ const IsoDateSchema = z.string().datetime({ offset: true })
6
+
7
+ export const AiAccountingBucketSchema = z.enum(["hour", "day", "week"])
8
+ export const AiValuationStatusSchema = z.enum(["rated", "unpriceable", "unvalued"])
9
+
10
+ export const AiAccountingRangeQuerySchema = z.object({
11
+ from: IsoDateSchema,
12
+ to: IsoDateSchema,
13
+ providerId: z.string().trim().min(1).optional(),
14
+ modelId: z.string().trim().min(1).optional(),
15
+ })
16
+
17
+ export const AiAccountingOverviewQuerySchema = AiAccountingRangeQuerySchema.extend({
18
+ bucket: AiAccountingBucketSchema,
19
+ })
20
+
21
+ export const AiModelCallAccountingListQuerySchema = AiAccountingRangeQuerySchema.extend({
22
+ executionId: z.string().trim().min(1).optional(),
23
+ valuationStatus: AiValuationStatusSchema.optional(),
24
+ limit: IntegerStringSchema.optional(),
25
+ offset: IntegerStringSchema.optional(),
26
+ })
27
+
28
+ export const AiMoneySchema = z.object({
29
+ currency: z.string().regex(/^[A-Z]{3}$/),
30
+ amountNanos: IntegerStringSchema,
31
+ })
32
+
33
+ export const AiCostSummarySchema = z.object({
34
+ amounts: z.array(AiMoneySchema),
35
+ ratedCallCount: z.number().int().nonnegative(),
36
+ unpriceableCallCount: z.number().int().nonnegative(),
37
+ unvaluedCallCount: z.number().int().nonnegative(),
38
+ })
39
+
40
+ const AiAccountingAggregateSchema = z.object({
41
+ modelCallCount: z.number().int().nonnegative(),
42
+ usage: AiUsageSummarySchema,
43
+ costs: AiCostSummarySchema,
44
+ })
45
+
46
+ export const AiAccountingOverviewResponseSchema = z.object({
47
+ range: z.object({ from: IsoDateSchema, to: IsoDateSchema }),
48
+ bucket: AiAccountingBucketSchema,
49
+ totals: AiAccountingAggregateSchema,
50
+ series: z.array(
51
+ AiAccountingAggregateSchema.extend({
52
+ start: IsoDateSchema,
53
+ end: IsoDateSchema,
54
+ })
55
+ ),
56
+ models: z.array(
57
+ AiAccountingAggregateSchema.extend({
58
+ providerId: z.string(),
59
+ modelId: z.string(),
60
+ })
61
+ ),
62
+ agents: z.array(
63
+ AiAccountingAggregateSchema.extend({
64
+ agentId: z.string(),
65
+ })
66
+ ),
67
+ workflows: z.array(
68
+ AiAccountingAggregateSchema.extend({
69
+ workflowId: z.string(),
70
+ })
71
+ ),
72
+ })
73
+
74
+ export const AiPricingContextSchema = z.object({
75
+ serviceTier: z.string().optional(),
76
+ batch: z.boolean().optional(),
77
+ region: z.string().optional(),
78
+ inferenceGeo: z.string().optional(),
79
+ routedProviderId: z.string().optional(),
80
+ deploymentId: z.string().optional(),
81
+ inferenceProfileId: z.string().optional(),
82
+ cacheWriteTtlSeconds: z.number().int().positive().optional(),
83
+ mode: z.string().optional(),
84
+ })
85
+
86
+ const AiCostComponentSchema = z.object({
87
+ meter: z.enum([
88
+ "tokens.input.total",
89
+ "tokens.input.uncached",
90
+ "tokens.input.cacheRead",
91
+ "tokens.input.cacheWrite",
92
+ "tokens.output.total",
93
+ "tokens.output.text",
94
+ "tokens.output.reasoning",
95
+ ]),
96
+ quantity: IntegerStringSchema,
97
+ rateAmountNanosPerMillion: IntegerStringSchema,
98
+ chargeAmountNanos: IntegerStringSchema,
99
+ })
100
+
101
+ const AiBillingIdentitySchema = z.object({
102
+ providerId: z.string(),
103
+ modelId: z.string(),
104
+ })
105
+
106
+ const AiPriceSourceSchema = z.object({
107
+ sourceId: z.string(),
108
+ sourceEntryId: z.string(),
109
+ sourceVersion: z.string(),
110
+ sourceUrl: z.string().url(),
111
+ observedAt: IsoDateSchema,
112
+ })
113
+
114
+ const AiModelCallCostSchema = z.discriminatedUnion("status", [
115
+ z.object({
116
+ status: z.literal("rated"),
117
+ billingIdentity: AiBillingIdentitySchema,
118
+ pricingContext: AiPricingContextSchema,
119
+ priceSource: AiPriceSourceSchema,
120
+ money: AiMoneySchema,
121
+ components: z.array(AiCostComponentSchema),
122
+ ratedAt: IsoDateSchema,
123
+ }),
124
+ z.object({
125
+ status: z.literal("unpriceable"),
126
+ billingIdentity: AiBillingIdentitySchema.optional(),
127
+ pricingContext: AiPricingContextSchema,
128
+ priceSource: AiPriceSourceSchema,
129
+ reason: z.enum([
130
+ "missingBillingIdentity",
131
+ "missingCatalogEntry",
132
+ "missingUsageMeter",
133
+ "unsupportedPricingDimension",
134
+ "invalidUsageForFormula",
135
+ ]),
136
+ missingMeters: z.array(AiCostComponentSchema.shape.meter).optional(),
137
+ ratedAt: IsoDateSchema,
138
+ }),
139
+ ])
140
+
141
+ const AiModelCallUsageRecordSchema = z.object({
142
+ id: z.string(),
143
+ executionId: z.string(),
144
+ attempt: z.number().int().positive(),
145
+ callId: z.string(),
146
+ providerId: z.string(),
147
+ requestedModelId: z.string(),
148
+ responseModelId: z.string().optional(),
149
+ responseId: z.string(),
150
+ usage: AiUsageSummarySchema,
151
+ occurredAt: IsoDateSchema,
152
+ recordedAt: IsoDateSchema,
153
+ })
154
+
155
+ export const AiModelCallAccountingItemSchema = z.object({
156
+ usage: AiModelCallUsageRecordSchema,
157
+ attribution: z
158
+ .discriminatedUnion("kind", [
159
+ z.object({
160
+ kind: z.literal("agent"),
161
+ agentId: z.string(),
162
+ agentRunId: z.string(),
163
+ threadId: z.string(),
164
+ }),
165
+ z.object({
166
+ kind: z.literal("workflowAgent"),
167
+ agentId: z.string(),
168
+ nodeRunId: z.string(),
169
+ workflowId: z.string(),
170
+ workflowRunId: z.string(),
171
+ }),
172
+ ])
173
+ .optional(),
174
+ cost: AiModelCallCostSchema.optional(),
175
+ valuationStatus: AiValuationStatusSchema,
176
+ })
177
+
178
+ export const AiModelCallAccountingListResponseSchema = z.object({
179
+ items: z.array(AiModelCallAccountingItemSchema),
180
+ hasMore: z.boolean(),
181
+ total: z.number().int().nonnegative(),
182
+ })
@@ -168,9 +168,19 @@ export const ConnectorOAuthCallbackQuerySchema = z
168
168
  auth_code: z.string().min(1).optional(),
169
169
  error: z.string().min(1).optional(),
170
170
  })
171
- .refine((query) => [query.code, query.auth_code, query.error].filter(Boolean).length === 1, {
172
- message: "OAuth callback must contain exactly one of code, auth_code, or error.",
173
- })
171
+ .refine(
172
+ (query) => {
173
+ const hasAuthorizationCode = query.code !== undefined || query.auth_code !== undefined
174
+ const hasProviderError = query.error !== undefined
175
+ return hasAuthorizationCode !== hasProviderError
176
+ },
177
+ { message: "OAuth callback must contain exactly one of an authorization code or error." }
178
+ )
179
+ .refine(
180
+ (query) =>
181
+ query.code === undefined || query.auth_code === undefined || query.code === query.auth_code,
182
+ { message: "OAuth callback code and auth_code must match when both are present." }
183
+ )
174
184
  .transform(({ auth_code, ...query }) => ({ ...query, code: query.code ?? auth_code }))
175
185
 
176
186
  function connectorRouteErrorResponseSchema<
@@ -9,11 +9,6 @@ export const LinkParamsSchema = LinkSourceParamsSchema.extend({
9
9
  linkId: z.string().min(1),
10
10
  })
11
11
 
12
- export const LinkQuerySchema = z.object({
13
- linkId: z.string().optional(),
14
- direction: z.enum(["outgoing", "incoming", "both"]).default("outgoing"),
15
- })
16
-
17
12
  export const RemoveLinkQuerySchema = z.object({
18
13
  targetTypeId: z.string().min(1),
19
14
  targetId: z.string().min(1),
@@ -24,15 +19,3 @@ export const UpsertLinkBodySchema = z.object({
24
19
  targetId: z.string().min(1),
25
20
  properties: z.record(z.unknown()).optional(),
26
21
  })
27
-
28
- export const ObjectLinkSchema = z.object({
29
- projectId: z.string(),
30
- sourceTypeId: z.string(),
31
- sourceId: z.string(),
32
- linkId: z.string(),
33
- targetTypeId: z.string(),
34
- targetId: z.string(),
35
- properties: z.record(z.unknown()).optional(),
36
- createdAt: z.string(),
37
- updatedAt: z.string(),
38
- })
@@ -0,0 +1,15 @@
1
+ import { z } from "zod"
2
+
3
+ export const LanguageModelSchema = z.object({
4
+ /**
5
+ * The AI SDK binding and model id the project configured. Together they identify the entry;
6
+ * the runtime's internal reference is not part of this contract.
7
+ */
8
+ provider: z.string(),
9
+ modelId: z.string(),
10
+ isDefault: z.boolean(),
11
+ })
12
+
13
+ export const ModelCatalogSchema = z.object({
14
+ language: z.array(LanguageModelSchema),
15
+ })
@@ -194,6 +194,19 @@ export const ObjectQuerySchema: z.ZodType<unknown> = z.lazy(() =>
194
194
  includeSubtypes: z.boolean().optional(),
195
195
  })
196
196
  .strict(),
197
+ z
198
+ .object({
199
+ kind: z.literal("refs"),
200
+ refs: z.array(
201
+ z
202
+ .object({
203
+ objectTypeId: z.string().min(1),
204
+ primaryId: z.string().min(1),
205
+ })
206
+ .strict()
207
+ ),
208
+ })
209
+ .strict(),
197
210
  z
198
211
  .object({
199
212
  kind: z.literal("filter"),
@@ -306,6 +319,17 @@ export const ObjectQueryFacetsRequestSchema = z
306
319
  })
307
320
  .strict()
308
321
 
322
+ export const ObjectQueryLinksRequestSchema = z
323
+ .object({
324
+ query: ObjectQuerySchema,
325
+ direction: z.enum(["outgoing", "incoming", "both"]).default("both"),
326
+ linkId: z.string().min(1).optional(),
327
+ includeObjects: z.boolean().default(false),
328
+ pageSize: z.number().int().positive().max(1_000).default(100),
329
+ pageToken: z.string().min(1).optional(),
330
+ })
331
+ .strict()
332
+
309
333
  export const TwinObjectSchema = z.object({
310
334
  primaryId: z.string(),
311
335
  objectTypeId: z.string(),
@@ -326,6 +350,7 @@ const objectQueryRef = { $ref: "#/components/schemas/ObjectQuery" }
326
350
  const objectQueryPredicateRef = { $ref: "#/components/schemas/ObjectQueryPredicate" }
327
351
  const objectQuerySortFieldRef = { $ref: "#/components/schemas/ObjectQuerySortField" }
328
352
  const objectExpansionRef = { $ref: "#/components/schemas/ObjectExpansion" }
353
+ const objectRefSchemaRef = { $ref: "#/components/schemas/ObjectRef" }
329
354
 
330
355
  /**
331
356
  * zod-to-json-schema currently drops recursive z.lazy schemas when the server's
@@ -476,6 +501,39 @@ export const ObjectQueryOpenApiSchemas = {
476
501
  plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
477
502
  },
478
503
  },
504
+ ObjectQueryLink: {
505
+ type: "object",
506
+ required: ["source", "linkId", "target", "createdAt", "updatedAt"],
507
+ additionalProperties: false,
508
+ properties: {
509
+ source: objectRefSchemaRef,
510
+ linkId: { type: "string" },
511
+ target: objectRefSchemaRef,
512
+ properties: { type: "object", additionalProperties: true },
513
+ createdAt: { type: "string" },
514
+ updatedAt: { type: "string" },
515
+ },
516
+ },
517
+ ObjectQueryLinksResponse: {
518
+ type: "object",
519
+ required: ["objects", "links", "hasMore"],
520
+ additionalProperties: false,
521
+ properties: {
522
+ objects: {
523
+ type: "array",
524
+ description:
525
+ "Selected objects followed by visible endpoint objects from this link page, de-duplicated. Empty unless includeObjects is true.",
526
+ items: { $ref: "#/components/schemas/ObjectQueryObject" },
527
+ },
528
+ links: {
529
+ type: "array",
530
+ description: "Visible physical links in deterministic identity order.",
531
+ items: { $ref: "#/components/schemas/ObjectQueryLink" },
532
+ },
533
+ hasMore: { type: "boolean" },
534
+ nextPageToken: { type: "string" },
535
+ },
536
+ },
479
537
  ObjectQueryErrorResponse: {
480
538
  type: "object",
481
539
  required: ["error"],
@@ -535,6 +593,37 @@ export const ObjectQueryOpenApiSchemas = {
535
593
  },
536
594
  },
537
595
  },
596
+ ObjectQueryLinksRequest: {
597
+ type: "object",
598
+ required: ["query"],
599
+ additionalProperties: false,
600
+ properties: {
601
+ query: objectQueryRef,
602
+ direction: { type: "string", enum: ["outgoing", "incoming", "both"], default: "both" },
603
+ linkId: { type: "string", minLength: 1 },
604
+ includeObjects: {
605
+ type: "boolean",
606
+ default: false,
607
+ description: "Include selected objects and visible endpoints from the current link page.",
608
+ },
609
+ pageSize: { type: "integer", minimum: 1, maximum: 1_000, default: 100 },
610
+ pageToken: {
611
+ type: "string",
612
+ minLength: 1,
613
+ description:
614
+ "Opaque token from the previous page. The project, normalized query, direction, and linkId must remain unchanged.",
615
+ },
616
+ },
617
+ },
618
+ ObjectRef: {
619
+ type: "object",
620
+ required: ["objectTypeId", "primaryId"],
621
+ additionalProperties: false,
622
+ properties: {
623
+ objectTypeId: { type: "string", minLength: 1 },
624
+ primaryId: { type: "string", minLength: 1 },
625
+ },
626
+ },
538
627
  ObjectQuery: {
539
628
  oneOf: [
540
629
  {
@@ -547,6 +636,21 @@ export const ObjectQueryOpenApiSchemas = {
547
636
  includeSubtypes: { type: "boolean" },
548
637
  },
549
638
  },
639
+ {
640
+ type: "object",
641
+ required: ["kind", "refs"],
642
+ additionalProperties: false,
643
+ properties: {
644
+ kind: { type: "string", enum: ["refs"] },
645
+ refs: {
646
+ type: "array",
647
+ minItems: 1,
648
+ description:
649
+ "One to 1,000 unique identities after normalization; duplicate entries are accepted and removed.",
650
+ items: objectRefSchemaRef,
651
+ },
652
+ },
653
+ },
550
654
  {
551
655
  type: "object",
552
656
  required: ["kind", "input", "predicate"],
@@ -83,6 +83,11 @@ export const ForeignKeyDescriptorSchema = z.object({
83
83
  targetObjectTypeId: z.string(),
84
84
  })
85
85
 
86
+ export const SourceEditConflictResolutionSchema = z.union([
87
+ z.object({ strategy: z.literal("editsWin") }),
88
+ z.object({ strategy: z.literal("mostRecent"), sourceTimestamp: z.string() }),
89
+ ])
90
+
86
91
  export const ObjectProjectionSchema = z.object({
87
92
  _tag: z.literal("ObjectProjectionDefinition"),
88
93
  id: z.string(),
@@ -90,6 +95,7 @@ export const ObjectProjectionSchema = z.object({
90
95
  datasetId: z.string(),
91
96
  properties: z.record(z.string()),
92
97
  links: z.record(ForeignKeyDescriptorSchema),
98
+ conflictResolution: SourceEditConflictResolutionSchema,
93
99
  latestRun: ProjectionRunSchema.nullable(),
94
100
  })
95
101
 
@@ -109,12 +115,15 @@ export const TelemetryProjectionSchema = z.object({
109
115
  _tag: z.literal("TelemetryProjectionDefinition"),
110
116
  id: z.string(),
111
117
  objectTypeId: z.string(),
112
- propertyId: z.string(),
113
118
  datasetId: z.string(),
114
119
  objectIdField: z.string(),
115
120
  atField: z.string(),
116
- valueField: z.string(),
117
- unitField: z.string().optional(),
121
+ properties: z.record(
122
+ z.object({
123
+ valueField: z.string(),
124
+ unitField: z.string().optional(),
125
+ })
126
+ ),
118
127
  latestRun: ProjectionRunSchema.nullable(),
119
128
  })
120
129
 
@@ -4,7 +4,8 @@ import {
4
4
  type WorkflowRunFailureCode,
5
5
  } from "@sixb/core/storage"
6
6
  import { z } from "zod"
7
- import { AgentRunFailureSchema } from "./agents"
7
+ import { AgentMessagePartSchema, AgentRunFailureSchema } from "./agents"
8
+ import { AiCostSummarySchema } from "./ai-accounting"
8
9
  import { AiUsageSummarySchema } from "./ai-usage"
9
10
  import { JsonValueSchema, sixbFailureSchema } from "./common"
10
11
 
@@ -148,15 +149,19 @@ export const WorkflowAgentNodeExecutionSummarySchema = z.object({
148
149
  modelId: z.string().optional(),
149
150
  finishReason: z.string().optional(),
150
151
  usage: AiUsageSummarySchema.optional(),
152
+ cost: AiCostSummarySchema.optional(),
151
153
  startedAt: z.string().optional(),
152
154
  completedAt: z.string().optional(),
153
155
  })
154
156
 
157
+ export const WorkflowAgentFailurePhaseSchema = z.enum(["agent-loop", "structured-finalizer"])
158
+
155
159
  export const WorkflowAgentNodeExecutionSchema = WorkflowAgentNodeExecutionSummarySchema.extend({
156
160
  nodeRunId: z.string(),
157
161
  prompt: z.string(),
158
- trace: z.array(z.unknown()).optional(),
159
- diagnostics: z.array(z.unknown()).optional(),
162
+ trace: z.array(AgentMessagePartSchema).optional(),
163
+ diagnostics: z.array(JsonValueSchema).optional(),
164
+ failurePhase: WorkflowAgentFailurePhaseSchema.optional(),
160
165
  error: AgentRunFailureSchema.optional(),
161
166
  createdAt: z.string(),
162
167
  })
package/src/server.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  type SixbApiBrowserPolicy,
26
26
  } from "./auth/browser-origin"
27
27
  import { CSRF_TOKEN_RESPONSE_HEADER_NAME } from "./auth/csrf"
28
+ import type { SixbAuthExperienceOptions } from "./auth/experience"
28
29
  import { ServerAuthGuard } from "./auth/guard"
29
30
  import { consumeInternalRequestAuthState } from "./auth/scope"
30
31
  import { SESSION_ACTIVITY_HEADER_NAME } from "./auth/session-activity"
@@ -49,6 +50,8 @@ export interface SixbServerOptions {
49
50
  hostname?: string
50
51
  quiet?: boolean
51
52
  browser: SixbApiBrowserPolicy
53
+ /** Optional custom-app auth bundle mounted under the API's `/auth` routes. */
54
+ authExperience?: SixbAuthExperienceOptions
52
55
  }
53
56
 
54
57
  export function createSixbServer(options: SixbServerOptions): SixbServer {
@@ -63,6 +66,7 @@ export class SixbServer {
63
66
  private readonly apiBrowserPolicy: ResolvedSixbApiBrowserPolicy
64
67
  private readonly authContextResolver: ResolveRequestAuthContext
65
68
  private readonly authRedirectContextResolver: ResolveAuthRedirectContext
69
+ private readonly authExperience?: SixbAuthExperienceOptions
66
70
  private app: SixbApp | null = null
67
71
  private bunServer: ReturnType<typeof Bun.serve> | null = null
68
72
  private maintenance: OntologyMaintenanceHandle | null = null
@@ -77,6 +81,7 @@ export class SixbServer {
77
81
  this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(
78
82
  this.apiBrowserPolicy
79
83
  )
84
+ this.authExperience = options.authExperience
80
85
  }
81
86
 
82
87
  getHost(): SixbHostView {
@@ -117,6 +122,10 @@ export class SixbServer {
117
122
  return this.apiBrowserPolicy
118
123
  }
119
124
 
125
+ getAuthExperience(): SixbAuthExperienceOptions | undefined {
126
+ return this.authExperience
127
+ }
128
+
120
129
  async start(): Promise<void> {
121
130
  if (this.app !== null || this.bunServer !== null || this.maintenance !== null) {
122
131
  throw new Error("[SixbServer] Server is already running.")
@@ -304,6 +313,7 @@ export function createSixbApi(server: SixbServer) {
304
313
  server.resolveAuthRedirectContext(request, input),
305
314
  getInvitationDestinationOptions: (request) => server.getInvitationDestinationOptions(request),
306
315
  resolveAuthRequestOrigin: (request) => server.resolveAuthRequestOrigin(request),
316
+ authExperience: server.getAuthExperience(),
307
317
  resolveInvitationRedirectContext: (request, input) =>
308
318
  server.resolveInvitationRedirectContext(request, input),
309
319
  })