@sixb/server 0.1.21 → 0.1.22
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/dist/artifacts/frame.d.ts +5 -0
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/auth/browser-origin.d.ts +5 -1
- package/dist/auth/browser-origin.d.ts.map +1 -1
- package/dist/auth/experience.d.ts +1 -0
- package/dist/auth/experience.d.ts.map +1 -1
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/responses.d.ts +1 -1
- package/dist/auth/responses.d.ts.map +1 -1
- package/dist/auth/scope.d.ts +19 -3
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/index.js +10093 -7553
- package/dist/index.js.map +51 -39
- package/dist/models/display.d.ts +27 -0
- package/dist/models/display.d.ts.map +1 -1
- package/dist/openapi/components.d.ts +14 -0
- package/dist/openapi/components.d.ts.map +1 -0
- package/dist/openapi/tags.d.ts +14 -2
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +5 -5
- package/dist/routes/agent-api-gateway.d.ts.map +1 -1
- package/dist/routes/agent-approval-gate.d.ts +27 -0
- package/dist/routes/agent-approval-gate.d.ts.map +1 -0
- package/dist/routes/agent-approvals.d.ts +599 -0
- package/dist/routes/agent-approvals.d.ts.map +1 -0
- package/dist/routes/agent-children.d.ts +318 -0
- package/dist/routes/agent-children.d.ts.map +1 -0
- package/dist/routes/agent-memory.d.ts +267 -0
- package/dist/routes/agent-memory.d.ts.map +1 -0
- package/dist/routes/agents.d.ts +999 -80
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/ai-accounting.d.ts.map +1 -1
- package/dist/routes/artifact-frames.d.ts +3 -3
- package/dist/routes/artifact-frames.d.ts.map +1 -1
- package/dist/routes/artifacts.d.ts +790 -134
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +116 -10
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connector-connection-runs.d.ts +50 -50
- package/dist/routes/connectors.d.ts +2 -2
- package/dist/routes/datasets.d.ts +20 -20
- package/dist/routes/events.d.ts +4 -4
- package/dist/routes/files.d.ts +14 -14
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/links.d.ts +2 -2
- package/dist/routes/logs.d.ts +5 -5
- package/dist/routes/model-calls.d.ts +155 -0
- package/dist/routes/model-calls.d.ts.map +1 -0
- package/dist/routes/model-generations.d.ts +400 -0
- package/dist/routes/model-generations.d.ts.map +1 -0
- package/dist/routes/models.d.ts +434 -1
- package/dist/routes/models.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +71 -40
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +682 -0
- package/dist/routes/observed-agent-threads.d.ts.map +1 -0
- package/dist/routes/ontology.d.ts +66 -62
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +24 -24
- package/dist/routes/projections.d.ts +55 -55
- package/dist/routes/rules.d.ts +2 -2
- package/dist/routes/share-grants.d.ts +9 -9
- package/dist/routes/syncs.d.ts +46 -46
- package/dist/routes/users.d.ts +117 -0
- package/dist/routes/users.d.ts.map +1 -0
- package/dist/routes/webhook-runs.d.ts +1 -1
- package/dist/routes/workflows.d.ts +118 -52
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/agents.d.ts +7 -2
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/events.d.ts +6 -6
- package/dist/routes/ws/logs.d.ts +14 -14
- package/dist/schemas/actions.d.ts +15 -15
- package/dist/schemas/activity.d.ts +48 -28
- package/dist/schemas/activity.d.ts.map +1 -1
- package/dist/schemas/agent-approvals.d.ts +1091 -0
- package/dist/schemas/agent-approvals.d.ts.map +1 -0
- package/dist/schemas/agent-memory.d.ts +250 -0
- package/dist/schemas/agent-memory.d.ts.map +1 -0
- package/dist/schemas/agents.d.ts +5442 -369
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +1290 -411
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/ai-limits.d.ts +10 -10
- package/dist/schemas/ai-usage.d.ts +12 -0
- package/dist/schemas/ai-usage.d.ts.map +1 -1
- package/dist/schemas/artifacts.d.ts +650 -98
- package/dist/schemas/artifacts.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +119 -46
- package/dist/schemas/auth.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +22 -22
- package/dist/schemas/datasets.d.ts +98 -98
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +26 -26
- package/dist/schemas/events.d.ts.map +1 -1
- package/dist/schemas/files.d.ts +24 -24
- package/dist/schemas/links.d.ts +2 -2
- package/dist/schemas/logs.d.ts +32 -32
- package/dist/schemas/models.d.ts +8889 -10
- package/dist/schemas/models.d.ts.map +1 -1
- package/dist/schemas/objects.d.ts +48 -12
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/ontology.d.ts +127 -104
- package/dist/schemas/ontology.d.ts.map +1 -1
- package/dist/schemas/pipelines.d.ts +132 -132
- package/dist/schemas/projections.d.ts +314 -314
- package/dist/schemas/rules.d.ts +4 -4
- package/dist/schemas/share-grants.d.ts +30 -30
- package/dist/schemas/syncs.d.ts +49 -49
- package/dist/schemas/users.d.ts +72 -0
- package/dist/schemas/users.d.ts.map +1 -0
- package/dist/schemas/webhook-runs.d.ts +6 -6
- package/dist/schemas/workflows.d.ts +701 -186
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/http.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/artifacts/frame.ts +6 -1
- package/src/auth/browser-origin.ts +8 -3
- package/src/auth/experience.ts +1 -1
- package/src/auth/guard.ts +2 -2
- package/src/auth/public-routes.ts +6 -0
- package/src/auth/responses.ts +7 -6
- package/src/auth/scope.ts +32 -3
- package/src/models/display.ts +61 -16
- package/src/openapi/components.ts +54 -0
- package/src/openapi/tags.ts +12 -0
- package/src/registerRoutes.ts +14 -0
- package/src/routes/agent-api-gateway.ts +115 -91
- package/src/routes/agent-approval-gate.ts +213 -0
- package/src/routes/agent-approvals.ts +299 -0
- package/src/routes/agent-children.ts +209 -0
- package/src/routes/agent-memory.ts +210 -0
- package/src/routes/agents.ts +363 -142
- package/src/routes/ai-accounting.ts +4 -0
- package/src/routes/artifact-frames.ts +14 -8
- package/src/routes/artifacts.ts +297 -22
- package/src/routes/auth.ts +306 -13
- package/src/routes/files.ts +6 -7
- package/src/routes/model-calls.ts +120 -0
- package/src/routes/model-generations.ts +245 -0
- package/src/routes/models.ts +116 -9
- package/src/routes/objects.ts +55 -61
- package/src/routes/observed-agent-threads.ts +253 -0
- package/src/routes/ontology.ts +1 -0
- package/src/routes/users.ts +73 -0
- package/src/routes/workflows.ts +6 -9
- package/src/routes/ws/agents.ts +10 -5
- package/src/schemas/activity.ts +2 -0
- package/src/schemas/agent-approvals.ts +129 -0
- package/src/schemas/agent-memory.ts +96 -0
- package/src/schemas/agents.ts +239 -0
- package/src/schemas/ai-accounting.ts +40 -4
- package/src/schemas/ai-usage.ts +10 -0
- package/src/schemas/artifacts.ts +91 -3
- package/src/schemas/auth.ts +25 -0
- package/src/schemas/models.ts +197 -1
- package/src/schemas/objects.ts +181 -0
- package/src/schemas/ontology.ts +1 -0
- package/src/schemas/users.ts +24 -0
- package/src/schemas/workflows.ts +2 -0
- package/src/server.ts +9 -10
- package/src/utils/http.ts +2 -0
package/src/schemas/agents.ts
CHANGED
|
@@ -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 { LANGUAGE_MODEL_TIERS } from "@sixb/core/models"
|
|
3
4
|
import {
|
|
4
5
|
AGENT_RUN_DIAGNOSTIC_CODES,
|
|
5
6
|
AGENT_RUN_FAILURE_CODES,
|
|
@@ -8,6 +9,14 @@ import {
|
|
|
8
9
|
type SixbFailure,
|
|
9
10
|
} from "@sixb/core/storage"
|
|
10
11
|
import { z } from "zod"
|
|
12
|
+
import {
|
|
13
|
+
AgentApprovalCallSummarySchema,
|
|
14
|
+
AgentApprovalModeSchema,
|
|
15
|
+
AgentApprovalModeSourceSchema,
|
|
16
|
+
AgentApprovalOutcomeSchema,
|
|
17
|
+
AgentApprovalSchema,
|
|
18
|
+
AgentApprovalStatusSchema,
|
|
19
|
+
} from "./agent-approvals"
|
|
11
20
|
import { AiCostSummarySchema } from "./ai-accounting"
|
|
12
21
|
import { AiUsageSummarySchema } from "./ai-usage"
|
|
13
22
|
import { ErrorResponseSchema, JsonValueSchema, sixbFailureSchema } from "./common"
|
|
@@ -87,6 +96,8 @@ export const AgentThreadStatusSchema = z.enum(["active", "archived"])
|
|
|
87
96
|
export const AgentThreadListQuerySchema = z
|
|
88
97
|
.object({
|
|
89
98
|
status: AgentThreadStatusSchema.optional(),
|
|
99
|
+
/** `true` lists the threads other users added the caller to, instead of the caller's own. */
|
|
100
|
+
sharedWithMe: z.enum(["true", "false"]).optional(),
|
|
90
101
|
limit: z.string().optional(),
|
|
91
102
|
offset: z.string().optional(),
|
|
92
103
|
order: z.enum(["asc", "desc"]).optional(),
|
|
@@ -101,6 +112,18 @@ export const CreateAgentThreadBodySchema = z
|
|
|
101
112
|
})
|
|
102
113
|
.strict()
|
|
103
114
|
|
|
115
|
+
/** A user the thread's owner added: they read the whole conversation and talk in it. */
|
|
116
|
+
/** A principal with its account's display name, as message authors and thread people are named. */
|
|
117
|
+
export const AgentMessageAuthorSchema = AgentPrincipalSchema.extend({
|
|
118
|
+
displayName: z.string().optional(),
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
export const AgentThreadParticipantSchema = z.object({
|
|
122
|
+
principal: AgentMessageAuthorSchema.extend({ type: z.literal("user") }),
|
|
123
|
+
addedAt: z.string(),
|
|
124
|
+
addedBy: AgentPrincipalSchema,
|
|
125
|
+
})
|
|
126
|
+
|
|
104
127
|
export const AgentThreadSchema = z.object({
|
|
105
128
|
sandboxState: z
|
|
106
129
|
.object({
|
|
@@ -111,7 +134,21 @@ export const AgentThreadSchema = z.object({
|
|
|
111
134
|
.optional(),
|
|
112
135
|
id: z.string(),
|
|
113
136
|
projectId: z.string(),
|
|
137
|
+
/** A conversation, or the thread a sub-agent works in: read through its conversation. */
|
|
138
|
+
kind: z.enum(["conversation", "subagent"]),
|
|
139
|
+
/** A sub-agent's thread: its conversation, the turn that spawned it, and its key there. */
|
|
140
|
+
parent: z
|
|
141
|
+
.object({
|
|
142
|
+
threadId: z.string(),
|
|
143
|
+
/** The turn that spawned it; its later runs work under the turns that go on with it. */
|
|
144
|
+
spawnedBy: z.string(),
|
|
145
|
+
key: z.string(),
|
|
146
|
+
})
|
|
147
|
+
.optional(),
|
|
114
148
|
ownerPrincipal: AgentPrincipalSchema,
|
|
149
|
+
/** The owner, named by their account. */
|
|
150
|
+
owner: AgentMessageAuthorSchema,
|
|
151
|
+
participants: z.array(AgentThreadParticipantSchema),
|
|
115
152
|
title: z.string().optional(),
|
|
116
153
|
sandboxParams: z.record(z.string(), JsonValueSchema).optional(),
|
|
117
154
|
status: AgentThreadStatusSchema,
|
|
@@ -120,6 +157,13 @@ export const AgentThreadSchema = z.object({
|
|
|
120
157
|
messageCount: z.number(),
|
|
121
158
|
createdAt: z.string(),
|
|
122
159
|
updatedAt: z.string(),
|
|
160
|
+
/** Your mode in this thread, when the thread is read alone. */
|
|
161
|
+
approvalMode: AgentApprovalModeSchema.optional(),
|
|
162
|
+
/**
|
|
163
|
+
* Where your mode in this thread comes from, with `approvalMode`. `run`: a sub-agent's thread,
|
|
164
|
+
* whose mode is its latest run's, copied from the turn it works under, for every reader.
|
|
165
|
+
*/
|
|
166
|
+
approvalModeSource: AgentApprovalModeSourceSchema.optional(),
|
|
123
167
|
})
|
|
124
168
|
|
|
125
169
|
export const AgentThreadListResponseSchema = z.object({
|
|
@@ -132,6 +176,28 @@ export const CreateAgentThreadResponseSchema = z.object({
|
|
|
132
176
|
thread: AgentThreadSchema,
|
|
133
177
|
})
|
|
134
178
|
|
|
179
|
+
export const AddAgentThreadParticipantsBodySchema = z
|
|
180
|
+
.object({
|
|
181
|
+
/**
|
|
182
|
+
* Active users of the project, by id or by their account's email; someone already taking part
|
|
183
|
+
* is left as they are.
|
|
184
|
+
*/
|
|
185
|
+
users: z
|
|
186
|
+
.array(
|
|
187
|
+
z.union([
|
|
188
|
+
z.object({ type: z.literal("user"), id: z.string().trim().min(1) }).strict(),
|
|
189
|
+
z.object({ email: z.string().trim().min(1) }).strict(),
|
|
190
|
+
])
|
|
191
|
+
)
|
|
192
|
+
.min(1)
|
|
193
|
+
.max(50),
|
|
194
|
+
})
|
|
195
|
+
.strict()
|
|
196
|
+
|
|
197
|
+
export const AgentThreadParticipantParamsSchema = AgentThreadParamsSchema.extend({
|
|
198
|
+
userId: z.string().min(1),
|
|
199
|
+
})
|
|
200
|
+
|
|
135
201
|
export const AgentMessageRoleSchema = z.enum(["system", "user", "assistant"])
|
|
136
202
|
|
|
137
203
|
const AgentTextPartSchema = z.object({
|
|
@@ -187,9 +253,43 @@ const AgentContinuationPartSchema = z.object({
|
|
|
187
253
|
type: z.literal("continuation"),
|
|
188
254
|
})
|
|
189
255
|
|
|
256
|
+
/** How a call the Agent held ended; Sixb writes it at the start of the next message. */
|
|
257
|
+
const AgentApprovalOutcomePartSchema = z.object({
|
|
258
|
+
type: z.literal("approval-outcome"),
|
|
259
|
+
approvalId: z.string(),
|
|
260
|
+
status: AgentApprovalStatusSchema.exclude(["pending"]),
|
|
261
|
+
call: AgentApprovalCallSummarySchema,
|
|
262
|
+
outcome: AgentApprovalOutcomeSchema.optional(),
|
|
263
|
+
/** The turn's sub-agent that made the call, when the turn did not make it itself. */
|
|
264
|
+
caller: z
|
|
265
|
+
.object({
|
|
266
|
+
runId: z.string(),
|
|
267
|
+
key: z.string(),
|
|
268
|
+
/** The message resumed the turn and the sub-agent, paused on its calls, went on. */
|
|
269
|
+
continues: z.literal(true).optional(),
|
|
270
|
+
})
|
|
271
|
+
.optional(),
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* A message a sub-agent's parent sent it, as it read it before a step: a steer, or the answer to
|
|
276
|
+
* the question it asked (`inReplyTo`). Only a sub-agent's thread holds one.
|
|
277
|
+
*/
|
|
278
|
+
export const AgentMailPartSchema = z.object({
|
|
279
|
+
type: z.literal("mail"),
|
|
280
|
+
id: z.string(),
|
|
281
|
+
from: z.literal("parent"),
|
|
282
|
+
kind: z.enum(["message", "answer"]),
|
|
283
|
+
inReplyTo: z.string().optional(),
|
|
284
|
+
text: z.string(),
|
|
285
|
+
/** It came as the sub-agent answered, so it wrote its result again. */
|
|
286
|
+
afterAnswer: z.literal(true).optional(),
|
|
287
|
+
})
|
|
288
|
+
|
|
190
289
|
export const AgentMessagePartSchema = z.union([
|
|
191
290
|
AgentTextPartSchema,
|
|
192
291
|
AgentContinuationPartSchema,
|
|
292
|
+
AgentApprovalOutcomePartSchema,
|
|
193
293
|
AgentReasoningPartSchema,
|
|
194
294
|
AgentStepStartPartSchema,
|
|
195
295
|
AgentFilePartSchema,
|
|
@@ -197,6 +297,7 @@ export const AgentMessagePartSchema = z.union([
|
|
|
197
297
|
AgentContextPartSchema,
|
|
198
298
|
AgentToolCallOutputSchema,
|
|
199
299
|
AgentToolCallErrorSchema,
|
|
300
|
+
AgentMailPartSchema,
|
|
200
301
|
])
|
|
201
302
|
|
|
202
303
|
export const AgentRunDiagnosticSchema = z.object({
|
|
@@ -240,6 +341,8 @@ export const AgentMessagesQuerySchema = z.object({
|
|
|
240
341
|
|
|
241
342
|
export const AgentMessageListResponseSchema = z.object({
|
|
242
343
|
messages: z.array(AgentMessageSchema),
|
|
344
|
+
/** The page's distinct authors, to name each message's `authorPrincipal`. */
|
|
345
|
+
authors: z.array(AgentMessageAuthorSchema),
|
|
243
346
|
hasMore: z.boolean(),
|
|
244
347
|
total: z.number(),
|
|
245
348
|
})
|
|
@@ -256,6 +359,8 @@ export const PostAgentMessageBodySchema = z
|
|
|
256
359
|
timeZone: z.string().trim().min(1).max(100).optional(),
|
|
257
360
|
/** BCP 47 language of the person asking. */
|
|
258
361
|
locale: z.string().trim().min(1).max(100).optional(),
|
|
362
|
+
/** What this turn may change without asking you. Omitted: your choice in the thread. */
|
|
363
|
+
approvalMode: AgentApprovalModeSchema.optional(),
|
|
259
364
|
attachments: z.array(FileRefSchema).optional(),
|
|
260
365
|
context: z.array(AgentContextEntryInputSchema).max(MAX_AGENT_CONTEXT_ENTRIES).optional(),
|
|
261
366
|
messageId: z.string().trim().min(1).optional(),
|
|
@@ -284,13 +389,26 @@ export const AgentRunFinishReasonSchema = z.enum(AGENT_RUN_FINISH_REASONS)
|
|
|
284
389
|
export const AgentRunSchema = z.object({
|
|
285
390
|
id: z.string(),
|
|
286
391
|
projectId: z.string(),
|
|
392
|
+
/** A conversation's turn, or a sub-agent's run in its own thread. */
|
|
393
|
+
kind: z.enum(["conversation", "subagent"]),
|
|
287
394
|
threadId: z.string(),
|
|
288
395
|
triggerMessageId: z.string(),
|
|
396
|
+
/** A sub-agent's: the turn it works under, whose deadline, mode and stop it shares. */
|
|
397
|
+
parentRunId: z.string().optional(),
|
|
289
398
|
requestedBy: AgentAuthorizablePrincipalSchema.optional(),
|
|
290
399
|
status: AgentRunStatusSchema,
|
|
291
400
|
model: LanguageModelRefSchema.optional(),
|
|
401
|
+
/** With tiers, the tier of the model the turn runs on. */
|
|
402
|
+
tier: z.enum(LANGUAGE_MODEL_TIERS).optional(),
|
|
292
403
|
reasoning: ModelReasoningSchema.optional(),
|
|
404
|
+
/** What the turn could change without asking. Absent on turns from before approval modes. */
|
|
405
|
+
approvalMode: AgentApprovalModeSchema.optional(),
|
|
293
406
|
modelId: z.string().optional(),
|
|
407
|
+
/**
|
|
408
|
+
* `awaiting_approval`: the turn succeeded and paused on calls waiting for its requester. It stays
|
|
409
|
+
* so: a later turn continues it once they decided on every call, unless a call was set aside or
|
|
410
|
+
* the turn stopped. The thread's approvals say where they stand.
|
|
411
|
+
*/
|
|
294
412
|
finishReason: AgentRunFinishReasonSchema.optional(),
|
|
295
413
|
usage: AiUsageSummarySchema.optional(),
|
|
296
414
|
cost: AiCostSummarySchema.optional(),
|
|
@@ -311,6 +429,24 @@ export const CancelAgentRunResponseSchema = z.object({
|
|
|
311
429
|
run: AgentRunSchema,
|
|
312
430
|
})
|
|
313
431
|
|
|
432
|
+
export const DecideAgentApprovalResponseSchema = z.object({
|
|
433
|
+
approval: AgentApprovalSchema,
|
|
434
|
+
/** The turn that resumed the paused one, when this decision was its last. */
|
|
435
|
+
run: AgentRunSchema.optional(),
|
|
436
|
+
/**
|
|
437
|
+
* The paused turn could not resume; the decision and the call's outcome stand. `retrying`: Sixb
|
|
438
|
+
* resumes it once it can. Otherwise the thread's next message tells the Agent how its calls ended.
|
|
439
|
+
*/
|
|
440
|
+
resume: z
|
|
441
|
+
.object({
|
|
442
|
+
status: z.literal("refused"),
|
|
443
|
+
code: z.string(),
|
|
444
|
+
message: z.string(),
|
|
445
|
+
retrying: z.boolean(),
|
|
446
|
+
})
|
|
447
|
+
.optional(),
|
|
448
|
+
})
|
|
449
|
+
|
|
314
450
|
export const RetryAgentRunResponseSchema = z.object({
|
|
315
451
|
run: AgentRunSchema,
|
|
316
452
|
})
|
|
@@ -327,3 +463,106 @@ export const AgentRunListResponseSchema = z.object({
|
|
|
327
463
|
hasMore: z.boolean(),
|
|
328
464
|
total: z.number(),
|
|
329
465
|
})
|
|
466
|
+
|
|
467
|
+
/** A file a turn and its sub-agent hand each other, by its path in the sub-agent's sandbox. */
|
|
468
|
+
export const AgentChildFileSchema = z.object({
|
|
469
|
+
path: z.string(),
|
|
470
|
+
fileRef: FileRefSchema,
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
export const AgentChildRunSchema = z.object({
|
|
474
|
+
id: z.string(),
|
|
475
|
+
/** The turn the run worked under: the one that spawned the sub-agent, or one that went on. */
|
|
476
|
+
parentRunId: z.string(),
|
|
477
|
+
status: AgentRunStatusSchema,
|
|
478
|
+
finishReason: AgentRunFinishReasonSchema.optional(),
|
|
479
|
+
error: AgentRunFailureSchema.optional(),
|
|
480
|
+
modelId: z.string().optional(),
|
|
481
|
+
attempt: z.number(),
|
|
482
|
+
/** Subscribe to it on `/ws/agents` with the run's id while it is at work. */
|
|
483
|
+
streamId: z.string(),
|
|
484
|
+
createdAt: z.string(),
|
|
485
|
+
startedAt: z.string().optional(),
|
|
486
|
+
completedAt: z.string().optional(),
|
|
487
|
+
/** What it answered, and the files it wrote under `out/`, by path relative to it. */
|
|
488
|
+
result: z
|
|
489
|
+
.object({
|
|
490
|
+
text: z.string(),
|
|
491
|
+
files: z.array(AgentChildFileSchema).optional(),
|
|
492
|
+
/** Why none of what it wrote under `out/` came back. */
|
|
493
|
+
filesError: z.string().optional(),
|
|
494
|
+
})
|
|
495
|
+
.optional(),
|
|
496
|
+
usage: AiUsageSummarySchema.optional(),
|
|
497
|
+
cost: AiCostSummarySchema.optional(),
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
/** What a paused sub-agent waits for before it goes on. */
|
|
501
|
+
export const AgentChildAwaitingSchema = z.discriminatedUnion("type", [
|
|
502
|
+
z.object({
|
|
503
|
+
type: z.literal("approval"),
|
|
504
|
+
/** Its calls still waiting for the turn's requester. */
|
|
505
|
+
approvalIds: z.array(z.string()),
|
|
506
|
+
}),
|
|
507
|
+
/** Its calls were decided: it continues once its turn resumes. */
|
|
508
|
+
z.object({ type: z.literal("resume") }),
|
|
509
|
+
/** It paused on the question it asked: a later turn of the conversation answers it. */
|
|
510
|
+
z.object({
|
|
511
|
+
type: z.literal("answer"),
|
|
512
|
+
question: z.object({ id: z.string(), text: z.string() }),
|
|
513
|
+
}),
|
|
514
|
+
])
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Why a paused sub-agent never continues. On its calls: a new message set them aside, one expired,
|
|
518
|
+
* or its turn was stopped, its requester leaving the conversation among the reasons. On its
|
|
519
|
+
* question: `replaced`, the Agent spawned another sub-agent under its key.
|
|
520
|
+
*/
|
|
521
|
+
export const AgentChildEndedSchema = z.object({
|
|
522
|
+
reason: z.enum(["superseded", "expired", "stopped", "replaced"]),
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
export const AgentChildSchema = z.object({
|
|
526
|
+
/** Its first run's id: the one `spawn_agent` answered with. */
|
|
527
|
+
id: z.string(),
|
|
528
|
+
/** Its own thread: `GET /api/agent-threads/:threadId/messages` reads what it did. */
|
|
529
|
+
threadId: z.string(),
|
|
530
|
+
projectId: z.string(),
|
|
531
|
+
/** The turn that spawned it. */
|
|
532
|
+
spawnedBy: z.string(),
|
|
533
|
+
key: z.string(),
|
|
534
|
+
task: z.string(),
|
|
535
|
+
model: LanguageModelRefSchema,
|
|
536
|
+
tier: z.enum(LANGUAGE_MODEL_TIERS).optional(),
|
|
537
|
+
reasoning: ModelReasoningSchema.optional(),
|
|
538
|
+
/** What its parent handed it, by path in its sandbox. */
|
|
539
|
+
handedFiles: z.array(AgentChildFileSchema),
|
|
540
|
+
/** Its latest run's. */
|
|
541
|
+
status: AgentRunStatusSchema,
|
|
542
|
+
/**
|
|
543
|
+
* `awaiting_approval` or `awaiting_answer`: it paused on held calls or on its question.
|
|
544
|
+
* `awaiting` says what it waits for, or `ended` why it will not continue.
|
|
545
|
+
*/
|
|
546
|
+
finishReason: AgentRunFinishReasonSchema.optional(),
|
|
547
|
+
error: AgentRunFailureSchema.optional(),
|
|
548
|
+
awaiting: AgentChildAwaitingSchema.optional(),
|
|
549
|
+
ended: AgentChildEndedSchema.optional(),
|
|
550
|
+
/** Its run at work, which streams on `/ws/agents`; `null` when none is. */
|
|
551
|
+
activeRunId: z.string().nullable(),
|
|
552
|
+
createdAt: z.string(),
|
|
553
|
+
completedAt: z.string().optional(),
|
|
554
|
+
/** Every run of it, and what those ran. */
|
|
555
|
+
usage: AiUsageSummarySchema.optional(),
|
|
556
|
+
cost: AiCostSummarySchema.optional(),
|
|
557
|
+
/** Oldest first: the run spawned, then each that continued it. */
|
|
558
|
+
runs: z.array(AgentChildRunSchema),
|
|
559
|
+
})
|
|
560
|
+
|
|
561
|
+
export const AgentChildListQuerySchema = z.object({
|
|
562
|
+
/** Only those this turn of the conversation spawned. */
|
|
563
|
+
runId: z.string().min(1).optional(),
|
|
564
|
+
})
|
|
565
|
+
|
|
566
|
+
export const AgentChildListResponseSchema = z.object({
|
|
567
|
+
children: z.array(AgentChildSchema),
|
|
568
|
+
})
|
|
@@ -39,6 +39,17 @@ export const AiCostSummarySchema = z.object({
|
|
|
39
39
|
unvaluedCallCount: z.number().int().nonnegative(),
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
const ModelKindSchema = z.enum([
|
|
43
|
+
"language",
|
|
44
|
+
"image",
|
|
45
|
+
"video",
|
|
46
|
+
"embedding",
|
|
47
|
+
"decision",
|
|
48
|
+
"transcription",
|
|
49
|
+
"speech",
|
|
50
|
+
"reranking",
|
|
51
|
+
])
|
|
52
|
+
|
|
42
53
|
const AiAccountingAggregateSchema = z.object({
|
|
43
54
|
modelCallCount: z.number().int().nonnegative(),
|
|
44
55
|
usage: AiUsageSummarySchema.describe(
|
|
@@ -59,6 +70,10 @@ const AiAccountingAggregateSchema = z.object({
|
|
|
59
70
|
textOutputTokens: z.number().int().nonnegative(),
|
|
60
71
|
reasoningOutputTokens: z.number().int().nonnegative(),
|
|
61
72
|
audioDurationMs: z.number().int().nonnegative(),
|
|
73
|
+
imageOutputTokens: z.number().int().nonnegative(),
|
|
74
|
+
audioOutputTokens: z.number().int().nonnegative(),
|
|
75
|
+
outputImages: z.number().int().nonnegative(),
|
|
76
|
+
inputCharacters: z.number().int().nonnegative(),
|
|
62
77
|
}),
|
|
63
78
|
}),
|
|
64
79
|
costs: AiCostSummarySchema,
|
|
@@ -80,6 +95,13 @@ export const AiAccountingOverviewResponseSchema = z.object({
|
|
|
80
95
|
modelId: z.string(),
|
|
81
96
|
})
|
|
82
97
|
),
|
|
98
|
+
kinds: z.array(
|
|
99
|
+
AiAccountingAggregateSchema.extend({
|
|
100
|
+
modelKind: ModelKindSchema.optional().describe(
|
|
101
|
+
"Absent for calls recorded before their kind was captured."
|
|
102
|
+
),
|
|
103
|
+
})
|
|
104
|
+
),
|
|
83
105
|
agents: z.array(
|
|
84
106
|
z.discriminatedUnion("kind", [
|
|
85
107
|
AiAccountingAggregateSchema.extend({ kind: z.literal("agent") }),
|
|
@@ -121,11 +143,19 @@ const AiCostComponentSchema = z.object({
|
|
|
121
143
|
"tokens.output.total",
|
|
122
144
|
"tokens.output.text",
|
|
123
145
|
"tokens.output.reasoning",
|
|
146
|
+
"tokens.output.image",
|
|
147
|
+
"tokens.output.audio",
|
|
124
148
|
"audio.input.milliseconds",
|
|
149
|
+
"images.output",
|
|
150
|
+
"characters.input",
|
|
125
151
|
]),
|
|
126
152
|
quantity: IntegerStringSchema,
|
|
127
153
|
rateAmountNanosPerMillion: IntegerStringSchema,
|
|
128
154
|
chargeAmountNanos: IntegerStringSchema,
|
|
155
|
+
variant: z
|
|
156
|
+
.string()
|
|
157
|
+
.optional()
|
|
158
|
+
.describe("The price variant that applied, such as an image size. Display only."),
|
|
129
159
|
})
|
|
130
160
|
|
|
131
161
|
const AiBillingIdentitySchema = z.object({
|
|
@@ -194,9 +224,7 @@ const AiModelCallUsageRecordSchema = z.object({
|
|
|
194
224
|
callId: z.string(),
|
|
195
225
|
providerId: z.string(),
|
|
196
226
|
requestedModelId: z.string(),
|
|
197
|
-
modelKind:
|
|
198
|
-
.enum(["language", "image", "video", "embedding", "decision", "transcription", "reranking"])
|
|
199
|
-
.optional(),
|
|
227
|
+
modelKind: ModelKindSchema.optional(),
|
|
200
228
|
requestedReasoning: ModelReasoningSchema.optional(),
|
|
201
229
|
responseModelId: z.string().optional(),
|
|
202
230
|
responseId: z.string(),
|
|
@@ -256,7 +284,15 @@ const AiModelCallExecutionSummarySchema = z.object({
|
|
|
256
284
|
executionId: z.string(),
|
|
257
285
|
attribution: AiModelCallAccountingItemSchema.shape.attribution,
|
|
258
286
|
modelCallCount: z.number().int().nonnegative(),
|
|
259
|
-
totalTokens: z
|
|
287
|
+
totalTokens: z
|
|
288
|
+
.number()
|
|
289
|
+
.int()
|
|
290
|
+
.nonnegative()
|
|
291
|
+
.optional()
|
|
292
|
+
.describe("Present when every call that reports tokens did; images and speech don't."),
|
|
293
|
+
outputImages: z.number().int().nonnegative().optional(),
|
|
294
|
+
inputCharacters: z.number().int().nonnegative().optional(),
|
|
295
|
+
audioDurationMs: z.number().int().nonnegative().optional(),
|
|
260
296
|
costs: AiCostSummarySchema,
|
|
261
297
|
firstCallAt: IsoDateSchema,
|
|
262
298
|
lastCallAt: IsoDateSchema,
|
package/src/schemas/ai-usage.ts
CHANGED
|
@@ -15,5 +15,15 @@ export const AiUsageSummarySchema = z.object({
|
|
|
15
15
|
audioDurationMs: TokenCountSchema.optional().describe(
|
|
16
16
|
"Audio content duration in milliseconds; not billed duration."
|
|
17
17
|
),
|
|
18
|
+
imageOutputTokens: TokenCountSchema.optional().describe(
|
|
19
|
+
"Output tokens that encode generated images, within outputTokens."
|
|
20
|
+
),
|
|
21
|
+
audioOutputTokens: TokenCountSchema.optional().describe(
|
|
22
|
+
"Output tokens that encode generated audio, within outputTokens."
|
|
23
|
+
),
|
|
24
|
+
outputImages: TokenCountSchema.optional().describe("Images the call returned."),
|
|
25
|
+
inputCharacters: TokenCountSchema.optional().describe(
|
|
26
|
+
"Input characters, counted by the provider's own billing rule."
|
|
27
|
+
),
|
|
18
28
|
reportingStatus: z.enum(["complete", "partial", "unavailable"]),
|
|
19
29
|
})
|
package/src/schemas/artifacts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ARTIFACT_KINDS } from "@sixb/core/artifacts"
|
|
1
|
+
import { ARTIFACT_KINDS, ARTIFACT_STATE_LIMITS } from "@sixb/core/artifacts"
|
|
2
2
|
import { z } from "zod"
|
|
3
3
|
import { ErrorResponseSchema, PrincipalSchema } from "./common"
|
|
4
4
|
import { FileRefSchema } from "./files"
|
|
@@ -21,7 +21,15 @@ const DocumentOutlineSchema = z.object({
|
|
|
21
21
|
const SheetOutlineSchema = z.object({
|
|
22
22
|
kind: z.literal("sheet"),
|
|
23
23
|
sheets: z.array(
|
|
24
|
-
z.object({
|
|
24
|
+
z.object({
|
|
25
|
+
name: z.string(),
|
|
26
|
+
rows: z.number().int().describe("The rows of its CSV; none for a live sheet"),
|
|
27
|
+
columns: z.array(z.string()),
|
|
28
|
+
query: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("A live sheet's query, queries/<name>.json, whose rows each reader reads"),
|
|
32
|
+
})
|
|
25
33
|
),
|
|
26
34
|
charts: z.array(z.string()),
|
|
27
35
|
})
|
|
@@ -31,12 +39,33 @@ const SlidesOutlineSchema = z.object({
|
|
|
31
39
|
slides: z.array(z.object({ title: z.string().optional() })),
|
|
32
40
|
})
|
|
33
41
|
|
|
42
|
+
const PageOutlineSchema = z.object({ kind: z.literal("page"), title: z.string().optional() })
|
|
43
|
+
|
|
44
|
+
const CanvasOutlineSchema = z.object({
|
|
45
|
+
kind: z.literal("canvas"),
|
|
46
|
+
items: z.array(
|
|
47
|
+
z.discriminatedUnion("type", [
|
|
48
|
+
z.object({
|
|
49
|
+
id: z.string(),
|
|
50
|
+
type: z.literal("board"),
|
|
51
|
+
title: z.string().optional(),
|
|
52
|
+
file: z.string(),
|
|
53
|
+
w: z.number(),
|
|
54
|
+
h: z.number(),
|
|
55
|
+
}),
|
|
56
|
+
z.object({ id: z.string(), type: z.literal("section"), title: z.string().optional() }),
|
|
57
|
+
])
|
|
58
|
+
),
|
|
59
|
+
})
|
|
60
|
+
|
|
34
61
|
const FileOutlineSchema = z.object({ kind: z.literal("file"), mediaType: z.string() })
|
|
35
62
|
|
|
36
63
|
const ArtifactOutlineSchema = z.discriminatedUnion("kind", [
|
|
37
64
|
DocumentOutlineSchema,
|
|
38
65
|
SheetOutlineSchema,
|
|
39
66
|
SlidesOutlineSchema,
|
|
67
|
+
PageOutlineSchema,
|
|
68
|
+
CanvasOutlineSchema,
|
|
40
69
|
FileOutlineSchema,
|
|
41
70
|
])
|
|
42
71
|
|
|
@@ -96,6 +125,10 @@ export const ArtifactVersionParamsSchema = ArtifactParamsSchema.extend({
|
|
|
96
125
|
.describe('A version number, or "latest"'),
|
|
97
126
|
})
|
|
98
127
|
|
|
128
|
+
export const ArtifactQueryParamsSchema = ArtifactVersionParamsSchema.extend({
|
|
129
|
+
name: z.string().min(1).describe("The query's name: queries/<name>.json in the version"),
|
|
130
|
+
})
|
|
131
|
+
|
|
99
132
|
export const ArtifactListQuerySchema = z
|
|
100
133
|
.object({
|
|
101
134
|
thread: z
|
|
@@ -118,6 +151,11 @@ export const ArtifactListResponseSchema = z.object({
|
|
|
118
151
|
export const ArtifactResponseSchema = z.object({
|
|
119
152
|
artifact: ArtifactSchema,
|
|
120
153
|
versions: z.array(ArtifactVersionSummarySchema).describe("Newest first"),
|
|
154
|
+
access: z
|
|
155
|
+
.enum(["owner", "update", "read"])
|
|
156
|
+
.describe(
|
|
157
|
+
"What the caller may do with it: everything as its owner, publish and keep page data as a participant of a conversation that shares it, or only read as an observer of one"
|
|
158
|
+
),
|
|
121
159
|
})
|
|
122
160
|
|
|
123
161
|
export const PublishArtifactBodySchema = z
|
|
@@ -131,6 +169,17 @@ export const PublishArtifactBodySchema = z
|
|
|
131
169
|
})
|
|
132
170
|
.strict()
|
|
133
171
|
|
|
172
|
+
export const PublishArtifactVersionBodySchema = PublishArtifactBodySchema.extend({
|
|
173
|
+
baseVersion: z
|
|
174
|
+
.number()
|
|
175
|
+
.int()
|
|
176
|
+
.positive()
|
|
177
|
+
.optional()
|
|
178
|
+
.describe(
|
|
179
|
+
"The version this one was made from. When another was published since, the publish is refused with 409 artifact_moved, naming the latest version."
|
|
180
|
+
),
|
|
181
|
+
})
|
|
182
|
+
|
|
134
183
|
export const PublishedArtifactResponseSchema = z.object({
|
|
135
184
|
artifact: ArtifactSchema,
|
|
136
185
|
version: ArtifactVersionSchema,
|
|
@@ -139,6 +188,41 @@ export const PublishedArtifactResponseSchema = z.object({
|
|
|
139
188
|
|
|
140
189
|
export const DeleteArtifactResponseSchema = z.object({ deleted: z.literal(true) })
|
|
141
190
|
|
|
191
|
+
export const ArtifactStateParamsSchema = ArtifactParamsSchema.extend({
|
|
192
|
+
key: z
|
|
193
|
+
.string()
|
|
194
|
+
.min(1)
|
|
195
|
+
.max(ARTIFACT_STATE_LIMITS.maxKeyLength)
|
|
196
|
+
.describe("The key a page keeps the value under, such as filters"),
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
const ArtifactStateEntrySchema = z.object({
|
|
200
|
+
key: z.string(),
|
|
201
|
+
value: z.unknown().describe("The JSON value"),
|
|
202
|
+
updatedAt: z.string(),
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
export const ArtifactStateResponseSchema = z.object({
|
|
206
|
+
entries: z.array(ArtifactStateEntrySchema).describe("By key, in order"),
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
export const SetArtifactStateBodySchema = z.object({
|
|
210
|
+
value: z
|
|
211
|
+
.unknown()
|
|
212
|
+
.refine((value) => value !== undefined, "A value is required.")
|
|
213
|
+
.describe(
|
|
214
|
+
`Any JSON value: at most ${ARTIFACT_STATE_LIMITS.maxValueBytes / 1024} KB written out, within ${ARTIFACT_STATE_LIMITS.maxKeys} keys and ${ARTIFACT_STATE_LIMITS.maxBytes / 1024 / 1024} MB for each reader`
|
|
215
|
+
),
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
export const SetArtifactStateResponseSchema = ArtifactStateEntrySchema
|
|
219
|
+
|
|
220
|
+
export const DeleteArtifactStateResponseSchema = z.object({ deleted: z.boolean() })
|
|
221
|
+
|
|
222
|
+
export const ClearArtifactStateResponseSchema = z.object({
|
|
223
|
+
cleared: z.number().int().describe("How many values were deleted"),
|
|
224
|
+
})
|
|
225
|
+
|
|
142
226
|
export const ArtifactFrameResponseSchema = z.object({
|
|
143
227
|
path: z
|
|
144
228
|
.string()
|
|
@@ -153,6 +237,10 @@ export const ArtifactErrorResponseSchema = ErrorResponseSchema.extend({
|
|
|
153
237
|
.string()
|
|
154
238
|
.optional()
|
|
155
239
|
.describe(
|
|
156
|
-
"Stable machine-readable failure code: artifact_not_found, artifact_kind_mismatch, invalid_artifact, not_allowed, or storage_unavailable."
|
|
240
|
+
"Stable machine-readable failure code: artifact_not_found, artifact_kind_mismatch, artifact_moved, invalid_artifact, invalid_state, state_full, not_allowed, not_shared (it exists but no conversation you read shares it), read_only (you observe the conversation that shares it), query_not_found, query_invalid (the ontology no longer admits the query), or storage_unavailable."
|
|
157
241
|
),
|
|
242
|
+
latest: z
|
|
243
|
+
.object({ version: z.number().int(), author: PrincipalSchema })
|
|
244
|
+
.optional()
|
|
245
|
+
.describe("With artifact_moved: the latest version and who published it"),
|
|
158
246
|
})
|
package/src/schemas/auth.ts
CHANGED
|
@@ -37,6 +37,15 @@ export const AuthAccessTokenStatusSchema = z.enum(["active", "expired", "revoked
|
|
|
37
37
|
export const AuthServiceAccountStatusSchema = z.enum(["active", "suspended"])
|
|
38
38
|
export const AuthUserStatusSchema = z.enum(["active", "suspended"])
|
|
39
39
|
|
|
40
|
+
/** A member as the directory shows them. */
|
|
41
|
+
export const UserProfileSchema = z.object({
|
|
42
|
+
id: z.string(),
|
|
43
|
+
email: z.string(),
|
|
44
|
+
displayName: z.string().optional(),
|
|
45
|
+
avatarUrl: z.string().optional(),
|
|
46
|
+
status: AuthUserStatusSchema,
|
|
47
|
+
})
|
|
48
|
+
|
|
40
49
|
export const AuthAccessTokenSubjectSchema = z.object({
|
|
41
50
|
type: z.enum(["user", "serviceAccount"]),
|
|
42
51
|
id: z.string(),
|
|
@@ -292,6 +301,22 @@ export const AuthSessionResponseSchema = z.union([
|
|
|
292
301
|
}),
|
|
293
302
|
])
|
|
294
303
|
|
|
304
|
+
export const AuthProfileFieldSchema = z.enum(["displayName", "avatarUrl"])
|
|
305
|
+
|
|
306
|
+
export const AuthProfileResponseSchema = z.object({
|
|
307
|
+
profile: UserProfileSchema,
|
|
308
|
+
/** Set by the identity provider at every sign-in, so they cannot be changed here. */
|
|
309
|
+
managedFields: z.array(AuthProfileFieldSchema),
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
/** Omitted fields stay unchanged, and `null` or an empty string clears one. */
|
|
313
|
+
export const UpdateAuthProfileBodySchema = z
|
|
314
|
+
.object({
|
|
315
|
+
displayName: z.string().nullable().optional(),
|
|
316
|
+
avatarUrl: z.string().nullable().optional(),
|
|
317
|
+
})
|
|
318
|
+
.strict()
|
|
319
|
+
|
|
295
320
|
export const AuthSignOutResponseSchema = z.object({
|
|
296
321
|
success: z.boolean(),
|
|
297
322
|
})
|