@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.
Files changed (98) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2495 -1845
  5. package/dist/index.js.map +29 -27
  6. package/dist/routes/actions.d.ts +1 -1
  7. package/dist/routes/agent-approvals.d.ts +11 -5
  8. package/dist/routes/agent-approvals.d.ts.map +1 -1
  9. package/dist/routes/agent-children.d.ts +2 -2
  10. package/dist/routes/agent-computers.d.ts +214 -10
  11. package/dist/routes/agent-computers.d.ts.map +1 -1
  12. package/dist/routes/agent-runners.d.ts +1 -1
  13. package/dist/routes/agent-runners.d.ts.map +1 -1
  14. package/dist/routes/agents.d.ts +230 -24
  15. package/dist/routes/agents.d.ts.map +1 -1
  16. package/dist/routes/ai-accounting.d.ts.map +1 -1
  17. package/dist/routes/auth.d.ts +9 -0
  18. package/dist/routes/auth.d.ts.map +1 -1
  19. package/dist/routes/datasets.d.ts +93 -17
  20. package/dist/routes/datasets.d.ts.map +1 -1
  21. package/dist/routes/events.d.ts +1 -1
  22. package/dist/routes/links.d.ts +121 -81
  23. package/dist/routes/links.d.ts.map +1 -1
  24. package/dist/routes/logs.d.ts +3 -3
  25. package/dist/routes/objects.d.ts +149 -58
  26. package/dist/routes/objects.d.ts.map +1 -1
  27. package/dist/routes/observed-agent-threads.d.ts +23 -5
  28. package/dist/routes/observed-agent-threads.d.ts.map +1 -1
  29. package/dist/routes/pipelines.d.ts +2 -2
  30. package/dist/routes/projections.d.ts +122 -122
  31. package/dist/routes/rules.d.ts +2 -2
  32. package/dist/routes/telemetry.d.ts +0 -50
  33. package/dist/routes/telemetry.d.ts.map +1 -1
  34. package/dist/routes/webhook-runs.d.ts +1 -1
  35. package/dist/routes/workflows.d.ts +21 -10
  36. package/dist/routes/workflows.d.ts.map +1 -1
  37. package/dist/routes/ws/agents.d.ts +4 -1
  38. package/dist/routes/ws/agents.d.ts.map +1 -1
  39. package/dist/routes/ws/logs.d.ts +10 -10
  40. package/dist/schemas/actions.d.ts +3 -3
  41. package/dist/schemas/activity.d.ts +4 -4
  42. package/dist/schemas/agent-approvals.d.ts +21 -21
  43. package/dist/schemas/agents.d.ts +760 -107
  44. package/dist/schemas/agents.d.ts.map +1 -1
  45. package/dist/schemas/ai-accounting.d.ts +1114 -6
  46. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  47. package/dist/schemas/auth.d.ts +47 -0
  48. package/dist/schemas/auth.d.ts.map +1 -1
  49. package/dist/schemas/datasets.d.ts +303 -60
  50. package/dist/schemas/datasets.d.ts.map +1 -1
  51. package/dist/schemas/event-payloads.d.ts +6 -6
  52. package/dist/schemas/events.d.ts +8 -8
  53. package/dist/schemas/lineage.d.ts +1272 -0
  54. package/dist/schemas/lineage.d.ts.map +1 -0
  55. package/dist/schemas/links.d.ts +4 -27
  56. package/dist/schemas/links.d.ts.map +1 -1
  57. package/dist/schemas/logs.d.ts +22 -22
  58. package/dist/schemas/objects.d.ts +7 -26
  59. package/dist/schemas/objects.d.ts.map +1 -1
  60. package/dist/schemas/pipelines.d.ts +12 -12
  61. package/dist/schemas/projections.d.ts +733 -733
  62. package/dist/schemas/rules.d.ts +4 -4
  63. package/dist/schemas/telemetry.d.ts +0 -13
  64. package/dist/schemas/telemetry.d.ts.map +1 -1
  65. package/dist/schemas/webhook-runs.d.ts +2 -2
  66. package/dist/schemas/workflows.d.ts +133 -44
  67. package/dist/schemas/workflows.d.ts.map +1 -1
  68. package/dist/server.d.ts +4 -0
  69. package/dist/server.d.ts.map +1 -1
  70. package/dist/utils/request-body.d.ts +5 -0
  71. package/dist/utils/request-body.d.ts.map +1 -1
  72. package/dist/utils/request-timing.d.ts +18 -0
  73. package/dist/utils/request-timing.d.ts.map +1 -0
  74. package/package.json +7 -7
  75. package/src/index.ts +1 -0
  76. package/src/routes/agent-approvals.ts +2 -2
  77. package/src/routes/agent-computers.ts +309 -87
  78. package/src/routes/agent-runners.ts +30 -6
  79. package/src/routes/agents.ts +187 -25
  80. package/src/routes/ai-accounting.ts +149 -12
  81. package/src/routes/auth.ts +24 -2
  82. package/src/routes/datasets.ts +55 -5
  83. package/src/routes/links.ts +43 -76
  84. package/src/routes/objects.ts +49 -42
  85. package/src/routes/observed-agent-threads.ts +2 -2
  86. package/src/routes/telemetry.ts +1 -42
  87. package/src/routes/ws/agents.ts +10 -1
  88. package/src/schemas/agents.ts +121 -6
  89. package/src/schemas/ai-accounting.ts +78 -15
  90. package/src/schemas/auth.ts +19 -0
  91. package/src/schemas/datasets.ts +36 -0
  92. package/src/schemas/lineage.ts +115 -0
  93. package/src/schemas/links.ts +3 -11
  94. package/src/schemas/objects.ts +6 -10
  95. package/src/schemas/telemetry.ts +0 -6
  96. package/src/server.ts +18 -2
  97. package/src/utils/request-body.ts +10 -4
  98. package/src/utils/request-timing.ts +136 -0
@@ -1,5 +1,6 @@
1
1
  import { MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core"
2
2
  import { MAX_AGENT_CONTEXT_LABEL_LENGTH } from "@sixb/core/agents/context"
3
+ import { CONTROL_CHARACTER } from "@sixb/core/internal/agent-run-storage-provider"
3
4
  import { LANGUAGE_MODEL_TIERS } from "@sixb/core/models"
4
5
  import {
5
6
  AGENT_RUN_DIAGNOSTIC_CODES,
@@ -104,6 +105,22 @@ export const AgentThreadListQuerySchema = z
104
105
  })
105
106
  .strict()
106
107
 
108
+ /** Shown back to its owner as written, so it holds no control character. */
109
+ const plainText = (schema: z.ZodString) =>
110
+ schema.refine((text) => !CONTROL_CHARACTER.test(text), "has a control character")
111
+
112
+ /** Where on your computer a thread runs: the computer `sixb` is open on, and its folder there. */
113
+ export const AgentThreadComputerInputSchema = z
114
+ .object({
115
+ /** The id `sixb` keeps for the computer, beside its sign-in. */
116
+ id: plainText(z.string().trim().min(1).max(200)),
117
+ /** What you call the computer, such as "Anthony's MacBook Pro". */
118
+ name: plainText(z.string().trim().min(1).max(120)),
119
+ /** The absolute path its turns work in. */
120
+ folder: plainText(z.string().min(1).max(4096)),
121
+ })
122
+ .strict()
123
+
107
124
  export const CreateAgentThreadBodySchema = z
108
125
  .object({
109
126
  title: z.string().trim().min(1).optional(),
@@ -111,6 +128,8 @@ export const CreateAgentThreadBodySchema = z
111
128
  sandbox: z.record(z.string(), JsonValueSchema).optional(),
112
129
  /** Run its turns on your computer, which claims them, instead of in the cloud. */
113
130
  runsOn: z.literal("computer").optional(),
131
+ /** The computer and folder its turns run in: required with `runsOn: "computer"`. */
132
+ computer: AgentThreadComputerInputSchema.optional(),
114
133
  })
115
134
  .strict()
116
135
 
@@ -155,8 +174,20 @@ export const AgentThreadSchema = z.object({
155
174
  sandboxParams: z.record(z.string(), JsonValueSchema).optional(),
156
175
  /** Its turns run on its owner's computer; absent, in the cloud. */
157
176
  runsOn: z.literal("computer").optional(),
158
- /** Which of its owner's computers runs it; absent until one claims its first turn. */
159
- computerId: z.string().optional(),
177
+ /**
178
+ * Where on its owner's computer it runs, and whether `sixb` is open there now: shown to its owner
179
+ * alone. Absent for a computer's thread from before folders were kept, until its owner moves it.
180
+ */
181
+ computer: z
182
+ .object({
183
+ id: z.string(),
184
+ name: z.string(),
185
+ folder: z.string(),
186
+ online: z.boolean(),
187
+ })
188
+ .optional(),
189
+ /** When its turns last moved to where they run now: the files earlier turns used are not here. */
190
+ movedAt: z.string().optional(),
160
191
  status: AgentThreadStatusSchema,
161
192
  activeRunId: z.string().nullable(),
162
193
  lastMessageAt: z.string().optional(),
@@ -183,12 +214,24 @@ export const CreateAgentThreadResponseSchema = z.object({
183
214
  })
184
215
 
185
216
  export const MoveAgentThreadToComputerBodySchema = z
186
- .object({
187
- /** The id `sixb` keeps for the computer, beside its sign-in. */
188
- computerId: z.string().trim().min(1).max(200),
189
- })
217
+ .object({ computer: AgentThreadComputerInputSchema })
218
+ .strict()
219
+
220
+ export const AgentComputerSessionParamsSchema = z.object({
221
+ sessionId: z.string().trim().min(1).max(200),
222
+ })
223
+
224
+ export const HoldAgentComputerSessionBodySchema = z
225
+ .object({ computer: AgentThreadComputerInputSchema })
190
226
  .strict()
191
227
 
228
+ export const HoldAgentComputerSessionResponseSchema = z.object({
229
+ /** Renew before then, or the session lapses and its threads read as offline. */
230
+ expiresAt: z.string(),
231
+ /** Queued turns of your threads on this computer, in this folder, for it to claim. */
232
+ waiting: z.array(z.string()),
233
+ })
234
+
192
235
  export const AddAgentThreadParticipantsBodySchema = z
193
236
  .object({
194
237
  /**
@@ -254,6 +297,11 @@ const AgentToolCallBaseSchema = z.object({
254
297
  const AgentToolCallOutputSchema = AgentToolCallBaseSchema.extend({
255
298
  state: z.literal("output-available"),
256
299
  output: JsonValueSchema,
300
+ /**
301
+ * The whole output, when it was too large for the model's context: `output` is then a bounded
302
+ * copy. Its content is served at `/parts/<index>/outputFile/fileRef` of the message.
303
+ */
304
+ outputFile: z.object({ fileRef: FileRefSchema, path: z.string() }).optional(),
257
305
  })
258
306
 
259
307
  const AgentToolCallErrorSchema = AgentToolCallBaseSchema.extend({
@@ -320,8 +368,15 @@ export const AgentRunDiagnosticSchema = z.object({
320
368
  message: z.string(),
321
369
  })
322
370
 
371
+ const AgentContextCheckpointReasonSchema = z
372
+ .enum(["threshold", "overflow"])
373
+ .describe(
374
+ "`threshold`: the conversation reached its model's limit, or came back large after its cache expired. `overflow`: the provider refused a request as too long, and the turn went on condensed."
375
+ )
376
+
323
377
  export const AgentMessageCompactionSchema = z.object({
324
378
  checkpointId: z.string(),
379
+ reason: AgentContextCheckpointReasonSchema,
325
380
  summary: z.string(),
326
381
  createdAt: z.string(),
327
382
  })
@@ -466,6 +521,66 @@ export const RetryAgentRunResponseSchema = z.object({
466
521
  run: AgentRunSchema,
467
522
  })
468
523
 
524
+ export const AgentThreadContextQuerySchema = z.object({
525
+ /** The model to measure the conversation against, with `modelId`. Omitted: its latest turn's. */
526
+ provider: z.string().min(1).optional(),
527
+ modelId: z.string().min(1).optional(),
528
+ })
529
+
530
+ export const AgentThreadContextSchema = z.object({
531
+ /** The model the limits are this one's: the one asked for, else the latest turn's or the default. */
532
+ model: LanguageModelRefSchema,
533
+ windowTokens: z.number().int().positive(),
534
+ /** The window less the output reserve: past it, the conversation is condensed before a call. */
535
+ limitTokens: z.number().int().positive(),
536
+ /** What the next request weighs, as the worker estimates it. Absent before the first answer. */
537
+ usedTokens: z.number().int().nonnegative().optional(),
538
+ /**
539
+ * `usedTokens` by part, in a fixed order: the prompt's parts, the tools, then the history's.
540
+ * They add up to `usedTokens`, which is counted; the split is an estimate by each part's size.
541
+ */
542
+ parts: z
543
+ .array(
544
+ z.object({
545
+ part: z
546
+ .enum([
547
+ "system",
548
+ "instructions",
549
+ "memory",
550
+ "skills",
551
+ "ontology",
552
+ "tools",
553
+ "summary",
554
+ "messages",
555
+ "toolResults",
556
+ "files",
557
+ ])
558
+ .describe(
559
+ "`system`: Sixb's own prompt. `instructions`: the project's SIXB.md. `memory`, `skills`, `ontology`: their index in the prompt and the files the agent read. `tools`: the tool definitions. `summary`: what a condensed conversation keeps of its earlier part. `messages`: the conversation's text. `toolResults`: every other tool result. `files`: attachments and images."
560
+ ),
561
+ tokens: z.number().int().positive(),
562
+ })
563
+ )
564
+ .optional(),
565
+ /** The call the conversation's history ends with, as the provider counted it. */
566
+ lastCall: z
567
+ .object({
568
+ inputTokens: z.number().int().nonnegative(),
569
+ outputTokens: z.number().int().nonnegative().optional(),
570
+ cacheReadInputTokens: z.number().int().nonnegative().optional(),
571
+ occurredAt: z.string(),
572
+ })
573
+ .optional(),
574
+ lastCompaction: z
575
+ .object({
576
+ reason: AgentContextCheckpointReasonSchema,
577
+ createdAt: z.string(),
578
+ estimatedInputTokensBefore: z.number().int().nonnegative(),
579
+ estimatedInputTokensAfter: z.number().int().nonnegative(),
580
+ })
581
+ .optional(),
582
+ })
583
+
469
584
  export const AgentRunListQuerySchema = z.object({
470
585
  status: AgentRunStatusSchema.optional(),
471
586
  limit: z.string().optional(),
@@ -14,11 +14,37 @@ export const AiMoneySchema = z.object({
14
14
  export const AiAccountingBucketSchema = z.enum(["hour", "day", "week"])
15
15
  export const AiValuationStatusSchema = z.enum(["rated", "unpriceable", "unvalued"])
16
16
 
17
+ const ModelKindSchema = z.enum([
18
+ "language",
19
+ "image",
20
+ "video",
21
+ "embedding",
22
+ "decision",
23
+ "transcription",
24
+ "speech",
25
+ "reranking",
26
+ ])
27
+
17
28
  export const AiAccountingRangeQuerySchema = z.object({
18
29
  from: IsoDateSchema,
19
30
  to: IsoDateSchema,
20
31
  providerId: z.string().trim().min(1).optional(),
21
32
  modelId: z.string().trim().min(1).optional(),
33
+ person: z
34
+ .string()
35
+ .regex(/^(none|user:.+|serviceAccount:.+)$/)
36
+ .optional()
37
+ .describe(
38
+ "Calls one person or service account asked for, as user:<id> or serviceAccount:<id>, or none for those nobody did, such as a schedule's"
39
+ ),
40
+ source: z
41
+ .string()
42
+ .regex(/^(agent|action|other|workflow|workflow:.+)$/)
43
+ .optional()
44
+ .describe(
45
+ "Calls from agent conversations and their sub-agents, actions, workflows or one as workflow:<id>, or other"
46
+ ),
47
+ kind: ModelKindSchema.optional().describe("Calls to one kind of model"),
22
48
  })
23
49
 
24
50
  export const AiAccountingOverviewQuerySchema = AiAccountingRangeQuerySchema.extend({
@@ -39,16 +65,12 @@ export const AiCostSummarySchema = z.object({
39
65
  unvaluedCallCount: z.number().int().nonnegative(),
40
66
  })
41
67
 
42
- const ModelKindSchema = z.enum([
43
- "language",
44
- "image",
45
- "video",
46
- "embedding",
47
- "decision",
48
- "transcription",
49
- "speech",
50
- "reranking",
51
- ])
68
+ const AiAccountingRequesterSchema = z.object({
69
+ type: z.enum(["user", "serviceAccount"]),
70
+ id: z.string(),
71
+ name: z.string().optional().describe("Their name, or a service account's"),
72
+ email: z.string().optional(),
73
+ })
52
74
 
53
75
  const AiAccountingAggregateSchema = z.object({
54
76
  modelCallCount: z.number().int().nonnegative(),
@@ -89,12 +111,32 @@ export const AiAccountingOverviewResponseSchema = z.object({
89
111
  end: IsoDateSchema,
90
112
  })
91
113
  ),
114
+ modelSeries: z
115
+ .array(
116
+ z.object({
117
+ providerId: z.string(),
118
+ modelId: z.string(),
119
+ series: z.array(
120
+ AiAccountingAggregateSchema.extend({ start: IsoDateSchema, end: IsoDateSchema })
121
+ ),
122
+ })
123
+ )
124
+ .describe("Each model's own series, every period included"),
92
125
  models: z.array(
93
126
  AiAccountingAggregateSchema.extend({
94
127
  providerId: z.string(),
95
128
  modelId: z.string(),
96
129
  })
97
130
  ),
131
+ people: z
132
+ .array(
133
+ AiAccountingAggregateSchema.extend({
134
+ requester: AiAccountingRequesterSchema.optional().describe(
135
+ "Absent for the calls nobody asked for, such as a schedule's"
136
+ ),
137
+ })
138
+ )
139
+ .describe("Who asked for the calls"),
98
140
  kinds: z.array(
99
141
  AiAccountingAggregateSchema.extend({
100
142
  modelKind: ModelKindSchema.optional().describe(
@@ -278,6 +320,11 @@ export const AiModelCallAccountingListResponseSchema = z.object({
278
320
 
279
321
  export const AiModelCallGroupsQuerySchema = AiModelCallAccountingListQuerySchema.omit({
280
322
  executionId: true,
323
+ }).extend({
324
+ sort: z
325
+ .enum(["recent", "cost"])
326
+ .optional()
327
+ .describe("Most recent first, the default, or costliest first"),
281
328
  })
282
329
 
283
330
  const AiModelCallExecutionSummarySchema = z.object({
@@ -290,23 +337,39 @@ const AiModelCallExecutionSummarySchema = z.object({
290
337
  .nonnegative()
291
338
  .optional()
292
339
  .describe("Present when every call that reports tokens did; images and speech don't."),
340
+ inputTokens: z.number().int().nonnegative().optional(),
341
+ cacheReadInputTokens: z.number().int().nonnegative().optional(),
293
342
  outputImages: z.number().int().nonnegative().optional(),
294
343
  inputCharacters: z.number().int().nonnegative().optional(),
295
344
  audioDurationMs: z.number().int().nonnegative().optional(),
296
345
  costs: AiCostSummarySchema,
297
346
  firstCallAt: IsoDateSchema,
298
347
  lastCallAt: IsoDateSchema,
299
- models: z.array(AiBillingIdentitySchema),
348
+ models: z.array(
349
+ AiBillingIdentitySchema.extend({
350
+ modelCallCount: z.number().int().nonnegative(),
351
+ costs: AiCostSummarySchema,
352
+ })
353
+ ),
300
354
  /** Present only when the caller can read the initiating conversation. */
301
355
  label: z.string().optional(),
356
+ prompt: z
357
+ .string()
358
+ .optional()
359
+ .describe("What a turn was asked, when the caller can read its conversation"),
302
360
  })
303
361
 
304
362
  export const AiModelCallGroupsResponseSchema = z.object({
305
363
  items: z.array(
306
- AiModelCallExecutionSummarySchema.omit({ models: true }).extend({
307
- executions: z.array(AiModelCallExecutionSummarySchema),
308
- canOpenThread: z.boolean(),
309
- })
364
+ AiModelCallExecutionSummarySchema.omit({ models: true, prompt: true })
365
+ .extend({
366
+ executions: z
367
+ .array(AiModelCallExecutionSummarySchema)
368
+ .describe("A conversation's turns and sub-agents, or a workflow run's agent steps"),
369
+ canOpenThread: z.boolean(),
370
+ requester: AiAccountingRequesterSchema.optional().describe("Who started it"),
371
+ })
372
+ .describe("One conversation, workflow run, or other execution that called models")
310
373
  ),
311
374
  total: z.number().int().nonnegative(),
312
375
  hasMore: z.boolean(),
@@ -102,6 +102,12 @@ export const AuthMemberCapabilitiesSchema = z.object({
102
102
 
103
103
  export const AuthMemberSchema = AuthManagedMemberSchema.extend({
104
104
  capabilities: AuthMemberCapabilitiesSchema,
105
+ lastActiveAt: z
106
+ .string()
107
+ .optional()
108
+ .describe(
109
+ "Their latest session's last request, or its sign-in; absent if they never signed in"
110
+ ),
105
111
  })
106
112
 
107
113
  export const GetAuthAccessManagementOptionsResponseSchema = z.object({
@@ -294,6 +300,19 @@ export const AuthSessionResponseSchema = z.union([
294
300
  avatarUrl: z.string().optional(),
295
301
  groupIds: z.array(z.string()),
296
302
  }),
303
+ /** The Console, and the Settings pages about the project, this person may open. */
304
+ access: z.object({
305
+ members: z
306
+ .boolean()
307
+ .describe("Members: a membership policy lets them invite, assign groups or suspend"),
308
+ serviceAccounts: z
309
+ .boolean()
310
+ .describe("Service accounts: a membership policy lets them manage them"),
311
+ usage: z.boolean().describe("Usage: they hold can.observe(agent.usage)"),
312
+ activity: z.boolean().describe("Activity: they hold can.observe(project.activity)"),
313
+ console: z.boolean().describe("The Console: they hold can.observe(project.console)"),
314
+ logs: z.boolean().describe("Console › Logs: they hold can.observe(project.logs)"),
315
+ }),
297
316
  session: z.object({
298
317
  id: z.string(),
299
318
  expiresAt: z.string(),
@@ -13,6 +13,10 @@ export const DatasetVersionsQuerySchema = z.object({
13
13
  limit: z.string().optional(),
14
14
  })
15
15
 
16
+ export const DatasetLineageQuerySchema = z.object({
17
+ depth: z.string().optional(),
18
+ })
19
+
16
20
  /**
17
21
  * Elysia's query parser splits any comma-separated value into an array before validation, and
18
22
  * pushes a repeated key's value into the existing array as-is. `?columns=id`, `?columns=id,title`,
@@ -72,10 +76,16 @@ export const DatasetVersionRefSchema = z.object({
72
76
  versionId: z.string(),
73
77
  })
74
78
 
79
+ export const DatasetColumnRefSchema = z.object({
80
+ datasetId: z.string(),
81
+ column: z.string(),
82
+ })
83
+
75
84
  export const DatasetProducerSchema = z.object({
76
85
  kind: z.enum(["sync", "pipeline", "ingest"]),
77
86
  id: z.string().optional(),
78
87
  runId: z.string().optional(),
88
+ stepId: z.string().optional(),
79
89
  })
80
90
 
81
91
  export const DatasetVersionSchema = z.object({
@@ -109,6 +119,32 @@ export const DatasetCatalogItemSchema = DatasetDefinitionSchema.extend({
109
119
  projectionIds: z.array(z.string()),
110
120
  })
111
121
 
122
+ const DatasetLineageVersionSchema = DatasetVersionSchema.pick({
123
+ datasetId: true,
124
+ versionId: true,
125
+ parentVersionId: true,
126
+ mode: true,
127
+ createdAt: true,
128
+ producer: true,
129
+ })
130
+
131
+ /** An input version the lake no longer holds, for example one that expired. */
132
+ const DatasetLineageExpiredVersionSchema = DatasetVersionRefSchema.extend({
133
+ expired: z.literal(true),
134
+ })
135
+
136
+ /** Mirrors the core `DatasetLineage`: the starting version first, then upstream, nearest first. */
137
+ export const DatasetLineageResponseSchema = z.object({
138
+ nodes: z.array(z.union([DatasetLineageVersionSchema, DatasetLineageExpiredVersionSchema])),
139
+ edges: z.array(z.object({ from: DatasetVersionRefSchema, to: DatasetVersionRefSchema })),
140
+ restricted: z
141
+ .number()
142
+ .int()
143
+ .nonnegative()
144
+ .describe("Versions left out because the caller cannot view their dataset."),
145
+ truncated: z.boolean().describe("Whether the walk stopped at `depth` or at the node cap."),
146
+ })
147
+
112
148
  export const DatasetVersionListResponseSchema = z.object({
113
149
  versions: z.array(DatasetVersionSchema),
114
150
  count: z.number(),
@@ -0,0 +1,115 @@
1
+ import { z } from "zod"
2
+ import { JsonValueSchema } from "./common"
3
+ import { DatasetColumnRefSchema, DatasetVersionRefSchema } from "./datasets"
4
+ import { EventExecutorSchema } from "./events"
5
+
6
+ // Mirrors the core `ObjectLineage` and `LinkLineage`: sources are described once, keyed, and the
7
+ // existence and each property point at one by its key.
8
+
9
+ const RequestedBySchema = z
10
+ .object({ type: z.enum(["user", "serviceAccount"]), id: z.string() })
11
+ .describe("Principal on whose behalf the commit ran; absent for automatic or anonymous work.")
12
+
13
+ const LineageSourceSchema = z.discriminatedUnion("kind", [
14
+ z.object({
15
+ kind: z.literal("projection"),
16
+ projectionId: z.string(),
17
+ projectionRunId: z
18
+ .string()
19
+ .optional()
20
+ .describe("Absent for a caller who cannot view the projection's runs."),
21
+ datasetVersion: DatasetVersionRefSchema.optional().describe(
22
+ "The dataset version applied. Absent for a caller who cannot view the dataset."
23
+ ),
24
+ rowOrigins: z
25
+ .array(DatasetColumnRefSchema)
26
+ .optional()
27
+ .describe(
28
+ "Upstream columns that decide which rows the version holds, which every value depends on. Absent when the version records no lineage or the caller cannot view it."
29
+ ),
30
+ }),
31
+ z.object({
32
+ kind: z.literal("edit"),
33
+ commitId: z
34
+ .string()
35
+ .nullable()
36
+ .describe("Null when the commits made at that instant cannot be told apart."),
37
+ committedAt: z.string(),
38
+ requestedBy: RequestedBySchema.optional(),
39
+ executor: EventExecutorSchema.optional(),
40
+ action: z
41
+ .object({ actionId: z.string(), runId: z.string() })
42
+ .optional()
43
+ .describe("Absent for a direct write, and for an Action run the caller cannot view."),
44
+ }),
45
+ z.object({
46
+ kind: z.literal("telemetry"),
47
+ commitId: z.string(),
48
+ committedAt: z.string(),
49
+ projectionId: z.string().optional(),
50
+ requestedBy: RequestedBySchema.optional(),
51
+ executor: EventExecutorSchema.optional(),
52
+ }),
53
+ z.object({ kind: z.literal("identity") }),
54
+ ])
55
+
56
+ const LineageSourcesSchema = z
57
+ .record(LineageSourceSchema)
58
+ .describe(
59
+ "Keyed `projection:<id>`, `commit:<id>`, `commit@<instant>` when the commit is unknown, `telemetry:<commitId>` and `identity`."
60
+ )
61
+
62
+ const RestrictedSchema = z
63
+ .number()
64
+ .int()
65
+ .nonnegative()
66
+ .describe("Steps left out because the caller cannot view them.")
67
+
68
+ const PropertyLineageSchema = z.object({
69
+ source: z.string().describe("The source that decided the value: a key of `sources`."),
70
+ column: z.string().optional(),
71
+ origins: z.array(DatasetColumnRefSchema).optional(),
72
+ removed: z.literal(true).optional(),
73
+ at: z.string().optional(),
74
+ replaced: z
75
+ .object({
76
+ source: z.string(),
77
+ column: z.string().optional(),
78
+ value: JsonValueSchema.optional(),
79
+ })
80
+ .optional(),
81
+ resolution: z
82
+ .discriminatedUnion("strategy", [
83
+ z.object({ strategy: z.literal("editsWin") }),
84
+ z.object({
85
+ strategy: z.literal("mostRecent"),
86
+ sourceUpdatedAt: z.string(),
87
+ editedAt: z.string().optional(),
88
+ }),
89
+ ])
90
+ .optional(),
91
+ })
92
+
93
+ export const ObjectLineageSchema = z.object({
94
+ objectTypeId: z.string(),
95
+ primaryId: z.string(),
96
+ existence: z.object({ source: z.string() }),
97
+ sources: LineageSourcesSchema,
98
+ properties: z.record(PropertyLineageSchema),
99
+ restricted: RestrictedSchema,
100
+ })
101
+
102
+ export const LinkLineageSchema = z.object({
103
+ sourceTypeId: z.string(),
104
+ sourceId: z.string(),
105
+ linkId: z.string(),
106
+ targetTypeId: z.string(),
107
+ targetId: z.string(),
108
+ existence: z.object({
109
+ source: z.string(),
110
+ columns: z.array(z.string()).optional(),
111
+ origins: z.array(DatasetColumnRefSchema).optional(),
112
+ }),
113
+ sources: LineageSourcesSchema,
114
+ restricted: RestrictedSchema,
115
+ })
@@ -1,21 +1,13 @@
1
1
  import { z } from "zod"
2
2
 
3
- export const LinkSourceParamsSchema = z.object({
3
+ export const LinkParamsSchema = z.object({
4
4
  objectTypeId: z.string().min(1),
5
5
  objectId: z.string().min(1),
6
- })
7
-
8
- export const LinkParamsSchema = LinkSourceParamsSchema.extend({
9
6
  linkId: z.string().min(1),
10
7
  })
11
8
 
12
- export const RemoveLinkQuerySchema = z.object({
13
- targetTypeId: z.string().min(1),
14
- targetId: z.string().min(1),
15
- })
16
-
17
- export const UpsertLinkBodySchema = z.object({
9
+ /** A link is named by its target. */
10
+ export const LinkLineageQuerySchema = z.object({
18
11
  targetTypeId: z.string().min(1),
19
12
  targetId: z.string().min(1),
20
- properties: z.record(z.unknown()).optional(),
21
13
  })
@@ -6,7 +6,6 @@ import { ArtifactErrorResponseSchema } from "./artifacts"
6
6
  import { UserProfileSchema } from "./auth"
7
7
  import {
8
8
  AiUsageLimitErrorResponseSchema,
9
- codedErrorResponseSchema,
10
9
  ErrorResponseSchema,
11
10
  JsonValueSchema,
12
11
  jsonValueOpenApiOverride,
@@ -121,10 +120,6 @@ export const ObjectsQuerySchema = z
121
120
  }
122
121
  })
123
122
 
124
- export const UpsertObjectBodySchema = z.object({
125
- properties: z.record(z.unknown()),
126
- })
127
-
128
123
  export const UniquePropertyParamsSchema = z.object({
129
124
  objectTypeId: z.string().min(1),
130
125
  propertyId: z.string().min(1),
@@ -501,6 +496,12 @@ export const ObjectQueryOpenApiSchemas: OpenApiSchemas = {
501
496
  required: ["mode", "providerIssues", "fallbackIssues", "issues"],
502
497
  additionalProperties: false,
503
498
  properties: {
499
+ readObjectTypeIds: {
500
+ type: "array",
501
+ items: { type: "string" },
502
+ description:
503
+ "Every object type the query reads: where it starts, and what it traverses or expands",
504
+ },
504
505
  mode: { type: "string", enum: ["pushdown", "fallback", "pipeline", "rejected"] },
505
506
  providerIssues: {
506
507
  type: "array",
@@ -1094,8 +1095,3 @@ export const ObjectLookupNotFoundResponseSchema = ErrorResponseSchema.extend({
1094
1095
  "`object.not_found` when no object visible to the caller holds the value. Other 404s, such as an unknown type, have no code."
1095
1096
  ),
1096
1097
  })
1097
-
1098
- /** A write would give a unique property's value to a second object of the type. */
1099
- export const UniqueViolationErrorResponseSchema = codedErrorResponseSchema([
1100
- "object.unique_violation",
1101
- ])
@@ -31,12 +31,6 @@ export const BulkTelemetryHistoryBodySchema = z
31
31
  })
32
32
  .strict()
33
33
 
34
- export const AppendTelemetryBodySchema = z.object({
35
- value: z.unknown(),
36
- unit: z.string().optional(),
37
- at: z.string().optional(),
38
- })
39
-
40
34
  export const TelemetryPointSchema = z.object({
41
35
  projectId: z.string(),
42
36
  objectTypeId: z.string(),