@sixb/server 0.2.2 → 0.2.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.
- package/README.md +3 -3
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/auth/scope.d.ts +3 -0
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/auth/shared-access.d.ts +23 -0
- package/dist/auth/shared-access.d.ts.map +1 -1
- package/dist/connectors/http.d.ts +6 -1
- package/dist/connectors/http.d.ts.map +1 -1
- package/dist/index.js +2777 -683
- package/dist/index.js.map +41 -34
- package/dist/live/awareness.d.ts +48 -0
- package/dist/live/awareness.d.ts.map +1 -0
- package/dist/live/room.d.ts +198 -0
- package/dist/live/room.d.ts.map +1 -0
- package/dist/live/rooms.d.ts +67 -0
- package/dist/live/rooms.d.ts.map +1 -0
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +3 -3
- package/dist/routes/agent-approvals.d.ts +10 -10
- package/dist/routes/agent-children.d.ts +2 -2
- package/dist/routes/agent-computers.d.ts +32 -0
- package/dist/routes/agent-computers.d.ts.map +1 -1
- package/dist/routes/agent-runners.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +48 -48
- package/dist/routes/artifact-frames.d.ts +2 -1
- package/dist/routes/artifact-frames.d.ts.map +1 -1
- package/dist/routes/artifacts.d.ts +1713 -178
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +21 -21
- package/dist/routes/connector-connection-runs.d.ts +124 -5
- package/dist/routes/connector-connection-runs.d.ts.map +1 -1
- package/dist/routes/connector-connections.d.ts +9 -1
- package/dist/routes/connector-connections.d.ts.map +1 -1
- package/dist/routes/datasets.d.ts +5 -5
- package/dist/routes/events.d.ts +4 -4
- package/dist/routes/lake.d.ts +91 -0
- package/dist/routes/lake.d.ts.map +1 -0
- package/dist/routes/links.d.ts +6 -6
- package/dist/routes/logs.d.ts +2 -2
- package/dist/routes/model-generations.d.ts +2 -2
- package/dist/routes/objects.d.ts +6 -6
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +7 -7
- package/dist/routes/ontology.d.ts +6 -6
- package/dist/routes/pipelines.d.ts +8 -4
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +2 -2
- package/dist/routes/share-grants.d.ts +9 -9
- package/dist/routes/shared-access.d.ts +57 -2
- package/dist/routes/shared-access.d.ts.map +1 -1
- package/dist/routes/status.d.ts +11 -15
- package/dist/routes/status.d.ts.map +1 -1
- package/dist/routes/syncs.d.ts +5 -2
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/telemetry.d.ts +7 -7
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +3 -3
- package/dist/routes/ws/artifacts.d.ts +57 -0
- package/dist/routes/ws/artifacts.d.ts.map +1 -0
- package/dist/routes/ws/events.d.ts +8 -7
- package/dist/routes/ws/events.d.ts.map +1 -1
- package/dist/routes/ws/index.d.ts +2 -1
- package/dist/routes/ws/index.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/routes/ws/shared-sockets.d.ts +52 -0
- package/dist/routes/ws/shared-sockets.d.ts.map +1 -0
- package/dist/schemas/actions.d.ts +7 -7
- package/dist/schemas/activity.d.ts +8 -8
- package/dist/schemas/agent-approvals.d.ts +27 -27
- package/dist/schemas/agents.d.ts +195 -154
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +12 -12
- package/dist/schemas/artifacts.d.ts +2106 -127
- package/dist/schemas/artifacts.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +63 -63
- package/dist/schemas/connectors.d.ts +180 -20
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/datasets.d.ts +44 -44
- package/dist/schemas/event-payloads.d.ts +2 -2
- package/dist/schemas/events.d.ts +26 -26
- package/dist/schemas/events.d.ts.map +1 -1
- package/dist/schemas/files.d.ts +12 -0
- package/dist/schemas/files.d.ts.map +1 -1
- package/dist/schemas/lake.d.ts +251 -0
- package/dist/schemas/lake.d.ts.map +1 -0
- package/dist/schemas/lineage.d.ts +56 -56
- package/dist/schemas/logs.d.ts +18 -18
- package/dist/schemas/models.d.ts +4 -4
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/ontology.d.ts +14 -14
- package/dist/schemas/pipelines.d.ts +70 -48
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +14 -14
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/share-grants.d.ts +30 -30
- package/dist/schemas/shared-access.d.ts +17 -4
- package/dist/schemas/shared-access.d.ts.map +1 -1
- package/dist/schemas/status.d.ts +59 -79
- package/dist/schemas/status.d.ts.map +1 -1
- package/dist/schemas/syncs.d.ts +26 -10
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/telemetry.d.ts +26 -26
- package/dist/schemas/workflows.d.ts +19 -19
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/ws.d.ts +3 -0
- package/dist/utils/ws.d.ts.map +1 -1
- package/package.json +11 -7
- package/src/artifacts/frame.ts +4 -13
- package/src/auth/scope.ts +10 -1
- package/src/auth/shared-access.ts +108 -12
- package/src/connectors/http.ts +35 -1
- package/src/live/README.md +136 -0
- package/src/live/awareness.ts +141 -0
- package/src/live/room.ts +933 -0
- package/src/live/rooms.ts +288 -0
- package/src/registerRoutes.ts +2 -0
- package/src/routes/agent-computers.ts +59 -1
- package/src/routes/agent-runners.ts +1 -0
- package/src/routes/artifact-frames.ts +40 -12
- package/src/routes/artifacts.ts +713 -28
- package/src/routes/connector-connection-runs.ts +7 -12
- package/src/routes/connector-connections.ts +10 -7
- package/src/routes/lake.ts +73 -0
- package/src/routes/objects.ts +3 -9
- package/src/routes/pipelines.ts +1 -0
- package/src/routes/shared-access.ts +53 -1
- package/src/routes/status.ts +9 -4
- package/src/routes/syncs.ts +1 -0
- package/src/routes/webhooks.ts +44 -3
- package/src/routes/ws/artifacts.ts +138 -0
- package/src/routes/ws/events.ts +7 -2
- package/src/routes/ws/index.ts +13 -2
- package/src/routes/ws/shared-sockets.ts +152 -0
- package/src/schemas/agents.ts +11 -0
- package/src/schemas/artifacts.ts +255 -18
- package/src/schemas/connectors.ts +17 -2
- package/src/schemas/files.ts +12 -0
- package/src/schemas/lake.ts +53 -0
- package/src/schemas/objects.ts +1 -0
- package/src/schemas/pipelines.ts +2 -0
- package/src/schemas/projections.ts +2 -2
- package/src/schemas/shared-access.ts +16 -0
- package/src/schemas/status.ts +16 -22
- package/src/schemas/syncs.ts +2 -0
- package/src/server.ts +35 -4
- package/src/utils/ws.ts +7 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { SharedSessionContext } from "@sixb/core/internal/shares"
|
|
2
|
+
import type { SharedAccessBoundary } from "../../auth/shared-access"
|
|
3
|
+
import { wsSharedSession, wsStateKey } from "../../utils/ws"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* How long a shared link's socket trusts its session before reading it again: on a timer, so a
|
|
7
|
+
* socket that only listens closes too, and on its next message past that.
|
|
8
|
+
*/
|
|
9
|
+
export const SHARED_SOCKET_RECHECK_MS = 10_000
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The close code of a socket whose shared link ended: revoked, expired, or left idle. The client
|
|
13
|
+
* stops reconnecting on it (`SHARED_ACCESS_ENDED_CLOSE_CODE` in `@sixb/client`).
|
|
14
|
+
*/
|
|
15
|
+
export const SHARED_ACCESS_ENDED_CLOSE_CODE = 4401
|
|
16
|
+
|
|
17
|
+
/** A socket closed because its session could not be read: the client reconnects. */
|
|
18
|
+
const UNREADABLE_SESSION_CLOSE_CODE = 1011
|
|
19
|
+
|
|
20
|
+
/** A socket, as far as watching it goes: closing it. */
|
|
21
|
+
export interface ClosableSocket {
|
|
22
|
+
close(code?: number, reason?: string): void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Watch {
|
|
26
|
+
/** The session as last read; null once it ended. */
|
|
27
|
+
current: Promise<SharedSessionContext | null>
|
|
28
|
+
checkedAt: number
|
|
29
|
+
/** The name the visitor gave, as last read: a change is passed on to `onRenamed`. */
|
|
30
|
+
name: string | undefined
|
|
31
|
+
readonly timer: ReturnType<typeof setInterval>
|
|
32
|
+
readonly onRenamed: (() => void) | undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The sockets shared links' sessions opened, each kept open only while its session holds.
|
|
37
|
+
*
|
|
38
|
+
* The upgrade proved the session once, as any request does, and the socket's SDK keeps that
|
|
39
|
+
* authority. A link revoked or a session expired since would go unnoticed, so each socket reads its
|
|
40
|
+
* session again, by its id, at most every {@link SHARED_SOCKET_RECHECK_MS}, and is closed with
|
|
41
|
+
* {@link SHARED_ACCESS_ENDED_CLOSE_CODE} once it ended. Reading it renews nothing: only a visitor's
|
|
42
|
+
* own requests keep their session from idling out.
|
|
43
|
+
*/
|
|
44
|
+
export class SharedSockets {
|
|
45
|
+
private readonly watches = new WeakMap<object, Watch>()
|
|
46
|
+
/**
|
|
47
|
+
* The open sockets of each session, read again at once when its visitor gives a name. Keyed by
|
|
48
|
+
* `wsStateKey`: Elysia hands each handler a wrapper of its own around the one raw socket.
|
|
49
|
+
*/
|
|
50
|
+
private readonly sockets = new Map<string, Map<object, ClosableSocket>>()
|
|
51
|
+
|
|
52
|
+
constructor(private readonly boundary: SharedAccessBoundary) {
|
|
53
|
+
// A name given through this server reaches its sockets at once; through another, at the next
|
|
54
|
+
// read, within SHARED_SOCKET_RECHECK_MS.
|
|
55
|
+
boundary.onGuestNamed((sessionId) => {
|
|
56
|
+
for (const ws of this.sockets.get(sessionId)?.values() ?? []) {
|
|
57
|
+
const watch = this.watches.get(wsStateKey(ws))
|
|
58
|
+
const session = wsSharedSession(ws)
|
|
59
|
+
if (watch && session) this.read(ws, watch, session)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Starts watching a socket that a shared link's session opened; any other is left alone.
|
|
66
|
+
* `onRenamed` hears when its visitor gives a name, or another, read from their session.
|
|
67
|
+
*/
|
|
68
|
+
open(ws: ClosableSocket, onRenamed?: () => void): void {
|
|
69
|
+
const session = wsSharedSession(ws)
|
|
70
|
+
if (!session) return
|
|
71
|
+
|
|
72
|
+
const watch: Watch = {
|
|
73
|
+
current: Promise.resolve(session),
|
|
74
|
+
checkedAt: Date.now(),
|
|
75
|
+
name: session.guestName,
|
|
76
|
+
timer: setInterval(() => void this.read(ws, watch, session), SHARED_SOCKET_RECHECK_MS),
|
|
77
|
+
onRenamed,
|
|
78
|
+
}
|
|
79
|
+
this.watches.set(wsStateKey(ws), watch)
|
|
80
|
+
|
|
81
|
+
const open = this.sockets.get(session.sessionId) ?? new Map<object, ClosableSocket>()
|
|
82
|
+
this.sockets.set(session.sessionId, open.set(wsStateKey(ws), ws))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Whether the socket may go on: false once the session that opened it ended, and the socket is
|
|
87
|
+
* closing. Always true for a socket no shared link opened.
|
|
88
|
+
*/
|
|
89
|
+
async holds(ws: ClosableSocket): Promise<boolean> {
|
|
90
|
+
const watch = this.watches.get(wsStateKey(ws))
|
|
91
|
+
const session = wsSharedSession(ws)
|
|
92
|
+
if (!watch || !session) return true
|
|
93
|
+
|
|
94
|
+
if (Date.now() - watch.checkedAt >= SHARED_SOCKET_RECHECK_MS) this.read(ws, watch, session)
|
|
95
|
+
return (await watch.current) !== null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The session that opened the socket, as it is now: its visitor's name, once they gave one. */
|
|
99
|
+
async session(ws: ClosableSocket): Promise<SharedSessionContext | null> {
|
|
100
|
+
const watch = this.watches.get(wsStateKey(ws))
|
|
101
|
+
const session = wsSharedSession(ws)
|
|
102
|
+
if (!watch || !session) return null
|
|
103
|
+
|
|
104
|
+
this.read(ws, watch, session)
|
|
105
|
+
return watch.current
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Stops watching a socket that closed. */
|
|
109
|
+
close(ws: ClosableSocket): void {
|
|
110
|
+
const key = wsStateKey(ws)
|
|
111
|
+
const watch = this.watches.get(key)
|
|
112
|
+
if (watch) clearInterval(watch.timer)
|
|
113
|
+
this.watches.delete(key)
|
|
114
|
+
|
|
115
|
+
const session = wsSharedSession(ws)
|
|
116
|
+
const open = session ? this.sockets.get(session.sessionId) : undefined
|
|
117
|
+
open?.delete(key)
|
|
118
|
+
if (session && open?.size === 0) this.sockets.delete(session.sessionId)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private read(ws: ClosableSocket, watch: Watch, session: SharedSessionContext): void {
|
|
122
|
+
watch.checkedAt = Date.now()
|
|
123
|
+
watch.current = this.boundary.current(session).then(
|
|
124
|
+
(current) => {
|
|
125
|
+
if (!current) {
|
|
126
|
+
this.end(ws, SHARED_ACCESS_ENDED_CLOSE_CODE, "Shared access ended")
|
|
127
|
+
return current
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (current.guestName !== watch.name) {
|
|
131
|
+
watch.name = current.guestName
|
|
132
|
+
watch.onRenamed?.()
|
|
133
|
+
}
|
|
134
|
+
return current
|
|
135
|
+
},
|
|
136
|
+
(error: unknown) => {
|
|
137
|
+
console.error("[SixbServer] A shared link's socket could not read its session:", error)
|
|
138
|
+
this.end(ws, UNREADABLE_SESSION_CLOSE_CODE, "Shared access could not be checked")
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private end(ws: ClosableSocket, code: number, reason: string): void {
|
|
145
|
+
this.close(ws)
|
|
146
|
+
try {
|
|
147
|
+
ws.close(code, reason)
|
|
148
|
+
} catch {
|
|
149
|
+
// Already closed.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
package/src/schemas/agents.ts
CHANGED
|
@@ -291,6 +291,17 @@ export const StopAgentBackgroundCommandResponseSchema = z.object({
|
|
|
291
291
|
command: AgentBackgroundCommandSchema.extend({ stopping: z.boolean().optional() }),
|
|
292
292
|
})
|
|
293
293
|
|
|
294
|
+
/** One of your computers with `sixb` open on it now, and the folders it's open in. */
|
|
295
|
+
export const AgentComputerSchema = z.object({
|
|
296
|
+
id: z.string(),
|
|
297
|
+
name: z.string(),
|
|
298
|
+
folders: z.array(z.string()),
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
export const AgentComputerListResponseSchema = z.object({
|
|
302
|
+
computers: z.array(AgentComputerSchema),
|
|
303
|
+
})
|
|
304
|
+
|
|
294
305
|
export const AddAgentThreadParticipantsBodySchema = z
|
|
295
306
|
.object({
|
|
296
307
|
/**
|
package/src/schemas/artifacts.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ARTIFACT_KINDS, ARTIFACT_STATE_LIMITS } from "@sixb/core/artifacts"
|
|
1
|
+
import { ARTIFACT_HOLDERS_LIMIT, ARTIFACT_KINDS, ARTIFACT_STATE_LIMITS } from "@sixb/core/artifacts"
|
|
2
|
+
import { ARTIFACT_RESTORE_POINTS } from "@sixb/core/internal/storage"
|
|
2
3
|
import { z } from "zod"
|
|
3
4
|
import { ErrorResponseSchema, PrincipalSchema } from "./common"
|
|
4
|
-
import { FileRefSchema } from "./files"
|
|
5
|
+
import { FileRefSchema, ShareGrantQuerySchema } from "./files"
|
|
5
6
|
|
|
6
7
|
const ArtifactKindSchema = z.enum(ARTIFACT_KINDS)
|
|
7
8
|
|
|
@@ -41,6 +42,8 @@ const SlidesOutlineSchema = z.object({
|
|
|
41
42
|
|
|
42
43
|
const PageOutlineSchema = z.object({ kind: z.literal("page"), title: z.string().optional() })
|
|
43
44
|
|
|
45
|
+
const ArtifactThemeModeSchema = z.enum(["light", "dark"])
|
|
46
|
+
|
|
44
47
|
const CanvasOutlineSchema = z.object({
|
|
45
48
|
kind: z.literal("canvas"),
|
|
46
49
|
items: z.array(
|
|
@@ -52,10 +55,18 @@ const CanvasOutlineSchema = z.object({
|
|
|
52
55
|
file: z.string(),
|
|
53
56
|
w: z.number(),
|
|
54
57
|
h: z.number(),
|
|
58
|
+
renderKey: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("What the board's preview is a picture of: a board kept as it was keeps it"),
|
|
55
62
|
}),
|
|
56
63
|
z.object({ id: z.string(), type: z.literal("section"), title: z.string().optional() }),
|
|
57
64
|
])
|
|
58
65
|
),
|
|
66
|
+
themes: z
|
|
67
|
+
.array(ArtifactThemeModeSchema)
|
|
68
|
+
.optional()
|
|
69
|
+
.describe("The modes each board has a preview in: both, or the one its theme.json pins"),
|
|
59
70
|
})
|
|
60
71
|
|
|
61
72
|
const FileOutlineSchema = z.object({ kind: z.literal("file"), mediaType: z.string() })
|
|
@@ -82,6 +93,14 @@ const ArtifactWarningSchema = z.object({
|
|
|
82
93
|
part: z.string().optional(),
|
|
83
94
|
})
|
|
84
95
|
|
|
96
|
+
const RevisionSchema = z
|
|
97
|
+
.number()
|
|
98
|
+
.int()
|
|
99
|
+
.positive()
|
|
100
|
+
.describe(
|
|
101
|
+
"Counts the artifact's changes: a write, a version created, a restore. It only grows, so content read at one revision is that revision's for good"
|
|
102
|
+
)
|
|
103
|
+
|
|
85
104
|
const ArtifactSchema = z.object({
|
|
86
105
|
id: z.string(),
|
|
87
106
|
projectId: z.string(),
|
|
@@ -89,8 +108,9 @@ const ArtifactSchema = z.object({
|
|
|
89
108
|
title: z.string(),
|
|
90
109
|
owner: PrincipalSchema,
|
|
91
110
|
latestVersion: z.number().int().positive(),
|
|
111
|
+
revision: RevisionSchema,
|
|
92
112
|
createdAt: z.string(),
|
|
93
|
-
updatedAt: z.string(),
|
|
113
|
+
updatedAt: z.string().describe("When the artifact last changed"),
|
|
94
114
|
})
|
|
95
115
|
|
|
96
116
|
const ArtifactOriginSchema = z.object({ threadId: z.string(), runId: z.string() })
|
|
@@ -98,22 +118,46 @@ const ArtifactOriginSchema = z.object({ threadId: z.string(), runId: z.string()
|
|
|
98
118
|
export const ArtifactVersionSchema = z.object({
|
|
99
119
|
artifactId: z.string(),
|
|
100
120
|
version: z.number().int().positive(),
|
|
121
|
+
revision: RevisionSchema.describe(
|
|
122
|
+
"The artifact's revision when this version last changed: the latest version's is the artifact's"
|
|
123
|
+
),
|
|
124
|
+
frozen: z
|
|
125
|
+
.boolean()
|
|
126
|
+
.describe(
|
|
127
|
+
"Someone created this version: it never changes again. The latest version is open until then, and each write replaces its content"
|
|
128
|
+
),
|
|
101
129
|
title: z.string(),
|
|
102
130
|
entry: z.string(),
|
|
103
131
|
files: z.array(ArtifactFileSchema),
|
|
104
132
|
outline: ArtifactOutlineSchema,
|
|
105
133
|
references: z.array(ArtifactReferenceSchema),
|
|
106
|
-
author: PrincipalSchema,
|
|
107
|
-
origin: ArtifactOriginSchema.optional()
|
|
108
|
-
|
|
134
|
+
author: PrincipalSchema.describe("Who last wrote its content"),
|
|
135
|
+
origin: ArtifactOriginSchema.optional().describe(
|
|
136
|
+
"The Agent turn and thread its content was last written from"
|
|
137
|
+
),
|
|
138
|
+
createdAt: z.string().describe("When the version was opened"),
|
|
139
|
+
updatedAt: z.string().describe("When its content was last written"),
|
|
140
|
+
frozenAt: z.string().optional().describe("When it was created, which froze it"),
|
|
141
|
+
frozenBy: PrincipalSchema.optional().describe("Who created it"),
|
|
142
|
+
boardPreviews: z
|
|
143
|
+
.record(z.string(), z.enum(["ready", "pending", "none"]))
|
|
144
|
+
.optional()
|
|
145
|
+
.describe(
|
|
146
|
+
"A canvas's boards by id, as reading or publishing the version returns them: ready when its preview is, pending while it is rendered, none when none will come and the board shows its outline"
|
|
147
|
+
),
|
|
109
148
|
})
|
|
110
149
|
|
|
111
150
|
const ArtifactVersionSummarySchema = ArtifactVersionSchema.pick({
|
|
112
151
|
version: true,
|
|
152
|
+
revision: true,
|
|
153
|
+
frozen: true,
|
|
113
154
|
title: true,
|
|
114
155
|
author: true,
|
|
115
156
|
origin: true,
|
|
116
157
|
createdAt: true,
|
|
158
|
+
updatedAt: true,
|
|
159
|
+
frozenAt: true,
|
|
160
|
+
frozenBy: true,
|
|
117
161
|
})
|
|
118
162
|
|
|
119
163
|
export const ArtifactParamsSchema = z.object({ artifactId: z.string().min(1) })
|
|
@@ -125,6 +169,41 @@ export const ArtifactVersionParamsSchema = ArtifactParamsSchema.extend({
|
|
|
125
169
|
.describe('A version number, or "latest"'),
|
|
126
170
|
})
|
|
127
171
|
|
|
172
|
+
export const ArtifactBoardPreviewParamsSchema = ArtifactVersionParamsSchema.extend({
|
|
173
|
+
board: z.string().min(1).describe("The board's id in the canvas"),
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
export const ArtifactBoardPreviewQuerySchema = z
|
|
177
|
+
.object({
|
|
178
|
+
theme: ArtifactThemeModeSchema.optional().describe(
|
|
179
|
+
"The reader's mode; a canvas whose theme.json pins one is pictured only in it"
|
|
180
|
+
),
|
|
181
|
+
size: z
|
|
182
|
+
.enum(["full", "small"])
|
|
183
|
+
.optional()
|
|
184
|
+
.describe(
|
|
185
|
+
"full, the default: a PNG of the board at its own size. small: a WebP at most 480 pixels wide, for a canvas that shows many boards at once"
|
|
186
|
+
),
|
|
187
|
+
revision: z.coerce
|
|
188
|
+
.number()
|
|
189
|
+
.int()
|
|
190
|
+
.min(1)
|
|
191
|
+
.optional()
|
|
192
|
+
.describe(
|
|
193
|
+
"The version's revision the picture is of. Another than the version's current one is 404 preview_not_found: the version changed, and says which pictures it has now. One that matches is cached for good"
|
|
194
|
+
),
|
|
195
|
+
key: z
|
|
196
|
+
.string()
|
|
197
|
+
.min(1)
|
|
198
|
+
.max(200)
|
|
199
|
+
.optional()
|
|
200
|
+
.describe(
|
|
201
|
+
"The board's render key the picture is of, as the version's outline names it, in place of revision: the picture stays the same while the board shows the same, however often the canvas around it changes. Another than the board's current one is 404 preview_not_found. One that matches is cached for good"
|
|
202
|
+
),
|
|
203
|
+
})
|
|
204
|
+
.extend(ShareGrantQuerySchema.shape)
|
|
205
|
+
.strict()
|
|
206
|
+
|
|
128
207
|
export const ArtifactQueryParamsSchema = ArtifactVersionParamsSchema.extend({
|
|
129
208
|
name: z.string().min(1).describe("The query's name: queries/<name>.json in the version"),
|
|
130
209
|
})
|
|
@@ -135,7 +214,7 @@ export const ArtifactListQuerySchema = z
|
|
|
135
214
|
.string()
|
|
136
215
|
.min(1)
|
|
137
216
|
.optional()
|
|
138
|
-
.describe("Only artifacts
|
|
217
|
+
.describe("Only artifacts this conversation shares: the Agent wrote them in it"),
|
|
139
218
|
kind: ArtifactKindSchema.optional().describe("Only artifacts of this kind"),
|
|
140
219
|
limit: z.string().optional(),
|
|
141
220
|
offset: z.string().optional(),
|
|
@@ -154,7 +233,7 @@ export const ArtifactResponseSchema = z.object({
|
|
|
154
233
|
access: z
|
|
155
234
|
.enum(["owner", "update", "read"])
|
|
156
235
|
.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
|
|
236
|
+
"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 an editor of an object that holds it, or only read as an observer of such a conversation or a reader of such an object"
|
|
158
237
|
),
|
|
159
238
|
})
|
|
160
239
|
|
|
@@ -169,15 +248,90 @@ export const PublishArtifactBodySchema = z
|
|
|
169
248
|
})
|
|
170
249
|
.strict()
|
|
171
250
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
251
|
+
const BaseRevisionSchema = z
|
|
252
|
+
.number()
|
|
253
|
+
.int()
|
|
254
|
+
.positive()
|
|
255
|
+
.optional()
|
|
256
|
+
.describe(
|
|
257
|
+
"The revision this was made from. When the artifact changed since, it is refused with 409 artifact_moved, naming the revision and who last wrote the latest version."
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
export const UpdateArtifactBodySchema = PublishArtifactBodySchema.extend({
|
|
261
|
+
baseRevision: BaseRevisionSchema,
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
export const FreezeArtifactBodySchema = z
|
|
265
|
+
.object({ baseRevision: BaseRevisionSchema })
|
|
266
|
+
.strict()
|
|
267
|
+
.default({})
|
|
268
|
+
|
|
269
|
+
export const RestoreArtifactBodySchema = z
|
|
270
|
+
.object({ baseRevision: BaseRevisionSchema })
|
|
271
|
+
.strict()
|
|
272
|
+
.default({})
|
|
273
|
+
|
|
274
|
+
export const ArtifactRestorePointParamsSchema = ArtifactParamsSchema.extend({
|
|
275
|
+
revision: z
|
|
276
|
+
.string()
|
|
277
|
+
.regex(/^[1-9]\d*$/)
|
|
278
|
+
.describe("The revision whose content the restore point holds"),
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
/** A restore point without its files: the list a Restore menu shows. */
|
|
282
|
+
const ArtifactRestorePointSummarySchema = z.object({
|
|
283
|
+
artifactId: z.string(),
|
|
284
|
+
revision: RevisionSchema.describe("The revision whose content it holds, which restores it"),
|
|
285
|
+
version: z.number().int().positive().describe("The version it was taken of"),
|
|
286
|
+
frozen: z
|
|
287
|
+
.boolean()
|
|
178
288
|
.describe(
|
|
179
|
-
"
|
|
289
|
+
"Whether that version was already created, and so frozen, when the point was taken: its content is then that version's"
|
|
180
290
|
),
|
|
291
|
+
title: z.string(),
|
|
292
|
+
author: PrincipalSchema.describe("Who had last written that content"),
|
|
293
|
+
origin: ArtifactOriginSchema.optional(),
|
|
294
|
+
updatedAt: z.string().describe("When that content was written"),
|
|
295
|
+
reason: z
|
|
296
|
+
.enum(["turn", "restore"])
|
|
297
|
+
.describe("Taken before an Agent turn's first write to the artifact, or before a restore"),
|
|
298
|
+
turnRunId: z.string().optional().describe("With turn: the turn's run"),
|
|
299
|
+
createdAt: z.string().describe("When it was taken"),
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
export const ArtifactRestorePointSchema = ArtifactRestorePointSummarySchema.extend({
|
|
303
|
+
entry: z.string(),
|
|
304
|
+
files: z.array(ArtifactFileSchema),
|
|
305
|
+
outline: ArtifactOutlineSchema,
|
|
306
|
+
references: z.array(ArtifactReferenceSchema),
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
export const ArtifactRestorePointListResponseSchema = z.object({
|
|
310
|
+
restorePoints: z
|
|
311
|
+
.array(ArtifactRestorePointSummarySchema)
|
|
312
|
+
.describe(`Newest first: an artifact keeps its last ${ARTIFACT_RESTORE_POINTS}`),
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
export const ArtifactHolderSchema = z.object({
|
|
316
|
+
objectTypeId: z.string(),
|
|
317
|
+
primaryId: z.string(),
|
|
318
|
+
propertyId: z.string().describe("The property whose value holds the artifact"),
|
|
319
|
+
title: z
|
|
320
|
+
.string()
|
|
321
|
+
.optional()
|
|
322
|
+
.describe("The object's value of its type's search title, when it has one you read"),
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
export const ArtifactHolderListResponseSchema = z.object({
|
|
326
|
+
holders: z
|
|
327
|
+
.array(ArtifactHolderSchema)
|
|
328
|
+
.describe(`The first ${ARTIFACT_HOLDERS_LIMIT} objects you read that hold the artifact`),
|
|
329
|
+
hasMore: z.boolean().describe("More objects you read hold it"),
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
export const ArtifactChangeResponseSchema = z.object({
|
|
333
|
+
artifact: ArtifactSchema,
|
|
334
|
+
version: ArtifactVersionSchema,
|
|
181
335
|
})
|
|
182
336
|
|
|
183
337
|
export const PublishedArtifactResponseSchema = z.object({
|
|
@@ -237,10 +391,93 @@ export const ArtifactErrorResponseSchema = ErrorResponseSchema.extend({
|
|
|
237
391
|
.string()
|
|
238
392
|
.optional()
|
|
239
393
|
.describe(
|
|
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
|
|
394
|
+
"Stable machine-readable failure code: artifact_not_found, artifact_kind_mismatch, artifact_moved, restore_point_not_found, comment_not_found, invalid_artifact, invalid_comment, invalid_state, name_required (a shared link's guest gives their name before commenting), state_full, comments_full, not_allowed, not_shared (it exists but neither a conversation nor an object you read shares it), read_only (you only read it), query_not_found, query_invalid (the ontology no longer admits the query), preview_not_found (the board has no preview yet, or will have none), execution_lost (a run token's run ended or moved to another runner), or storage_unavailable."
|
|
241
395
|
),
|
|
242
396
|
latest: z
|
|
243
|
-
.object({
|
|
397
|
+
.object({
|
|
398
|
+
version: z.number().int(),
|
|
399
|
+
revision: z.number().int(),
|
|
400
|
+
author: PrincipalSchema,
|
|
401
|
+
frozenBy: PrincipalSchema.optional(),
|
|
402
|
+
})
|
|
403
|
+
.optional()
|
|
404
|
+
.describe(
|
|
405
|
+
"With artifact_moved: the artifact's latest version, its revision, who last wrote it, and who created it once it is frozen"
|
|
406
|
+
),
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
const ArtifactCommentAnchorSchema = z.object({
|
|
410
|
+
board: z.string().max(200).optional().describe("The id of the canvas's board it is about"),
|
|
411
|
+
element: z
|
|
412
|
+
.string()
|
|
413
|
+
.max(1024)
|
|
414
|
+
.optional()
|
|
415
|
+
.describe("The address of the board's element it is about, such as body>main:0>h1:0"),
|
|
416
|
+
label: z
|
|
417
|
+
.string()
|
|
418
|
+
.max(1000)
|
|
419
|
+
.optional()
|
|
420
|
+
.describe("The element's first words, which name it once it is gone; kept to 120 characters"),
|
|
421
|
+
point: z
|
|
422
|
+
.object({ x: z.number().min(0).max(1), y: z.number().min(0).max(1) })
|
|
423
|
+
.optional()
|
|
424
|
+
.describe(
|
|
425
|
+
"Where on the board its pin is, as fractions of the board's width and height from its top left"
|
|
426
|
+
),
|
|
427
|
+
revision: RevisionSchema.describe("The artifact's revision its author saw"),
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
const ArtifactCommentAuthorSchema = z
|
|
431
|
+
.object({
|
|
432
|
+
type: z.enum(["user", "serviceAccount", "system", "guest"]),
|
|
433
|
+
id: z.string().min(1),
|
|
434
|
+
})
|
|
435
|
+
.describe(
|
|
436
|
+
"Who wrote it: a principal, or a guest, someone without an account who opened a shared link, whose id is their link's session"
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
export const ArtifactCommentSchema = z.object({
|
|
440
|
+
artifactId: z.string(),
|
|
441
|
+
id: z.string(),
|
|
442
|
+
parentId: z.string().optional().describe("The comment it replies to, for a reply"),
|
|
443
|
+
anchor: ArtifactCommentAnchorSchema,
|
|
444
|
+
body: z.string().describe("Plain text"),
|
|
445
|
+
author: ArtifactCommentAuthorSchema,
|
|
446
|
+
authorName: z
|
|
447
|
+
.string()
|
|
448
|
+
.nullable()
|
|
449
|
+
.describe(
|
|
450
|
+
"Its author's name: a member's profile name or email, the project's for its own code, or the name a guest gave; null for anyone the project cannot name. A guest reading it never gets a member's email"
|
|
451
|
+
),
|
|
452
|
+
origin: z
|
|
453
|
+
.object({ threadId: z.string(), runId: z.string() })
|
|
244
454
|
.optional()
|
|
245
|
-
.describe("
|
|
455
|
+
.describe("The Agent's run that wrote it for its author, and that run's conversation"),
|
|
456
|
+
createdAt: z.string(),
|
|
457
|
+
resolvedAt: z.string().optional().describe("When someone marked it resolved"),
|
|
458
|
+
resolvedBy: PrincipalSchema.optional().describe("Who marked it resolved"),
|
|
246
459
|
})
|
|
460
|
+
|
|
461
|
+
export const ArtifactCommentListResponseSchema = z.object({
|
|
462
|
+
comments: z.array(ArtifactCommentSchema).describe("Comments and replies, oldest first"),
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
export const ArtifactCommentParamsSchema = ArtifactParamsSchema.extend({
|
|
466
|
+
commentId: z.string().min(1).max(64),
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
export const AddArtifactCommentBodySchema = z.object({
|
|
470
|
+
body: z.string().min(1).max(4_000).describe("Plain text"),
|
|
471
|
+
anchor: ArtifactCommentAnchorSchema.partial()
|
|
472
|
+
.optional()
|
|
473
|
+
.describe(
|
|
474
|
+
"What it is about: a board, an element of the board, or, without, the artifact; at the artifact's revision by default. A reply is about what it replies to."
|
|
475
|
+
),
|
|
476
|
+
parentId: z.string().min(1).max(64).optional().describe("The comment it replies to"),
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
export const ResolveArtifactCommentBodySchema = z.object({
|
|
480
|
+
resolved: z.boolean().default(true).describe("False opens it again"),
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
export const DeleteArtifactCommentResponseSchema = z.object({ deleted: z.literal(true) })
|
|
@@ -84,10 +84,16 @@ export const ConnectorAccountSchema = z.object({
|
|
|
84
84
|
avatarUrl: z.string().url().optional(),
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
/** The project, or the one person whose own account the connection is. */
|
|
88
|
+
const ConnectorConnectionOwnerSchema = z.discriminatedUnion("type", [
|
|
89
|
+
z.object({ type: z.literal("project") }),
|
|
90
|
+
z.object({ type: z.literal("user"), id: z.string() }),
|
|
91
|
+
])
|
|
92
|
+
|
|
87
93
|
export const ConnectorConnectionSchema = z.object({
|
|
88
94
|
id: z.string(),
|
|
89
95
|
connectorId: z.string(),
|
|
90
|
-
owner:
|
|
96
|
+
owner: ConnectorConnectionOwnerSchema,
|
|
91
97
|
slot: z.string(),
|
|
92
98
|
account: ConnectorAccountSchema,
|
|
93
99
|
status: z.enum(["connected", "needs_reauthorization", "disconnected"]),
|
|
@@ -100,7 +106,7 @@ const ConnectorConnectionRunBaseSchema = z.object({
|
|
|
100
106
|
id: z.string(),
|
|
101
107
|
connectorId: z.string(),
|
|
102
108
|
kind: z.enum(["connect", "reauthorize"]),
|
|
103
|
-
owner:
|
|
109
|
+
owner: ConnectorConnectionOwnerSchema,
|
|
104
110
|
slot: z.string(),
|
|
105
111
|
createdAt: z.string().datetime(),
|
|
106
112
|
updatedAt: z.string().datetime(),
|
|
@@ -136,12 +142,21 @@ export const ConnectorConnectionRunSchema = z.union([
|
|
|
136
142
|
}),
|
|
137
143
|
])
|
|
138
144
|
|
|
145
|
+
/** `"me"` fills the caller's own connection, on a connector whose owners include `"user"`. */
|
|
146
|
+
const ConnectorConnectionOwnerChoiceSchema = z.enum(["project", "me"])
|
|
147
|
+
|
|
148
|
+
export const ListConnectorConnectionsQuerySchema = z.object({
|
|
149
|
+
owner: ConnectorConnectionOwnerChoiceSchema.optional(),
|
|
150
|
+
})
|
|
151
|
+
|
|
139
152
|
export const StartConnectorConnectionRunBodySchema = z.object({
|
|
153
|
+
owner: ConnectorConnectionOwnerChoiceSchema.default("project"),
|
|
140
154
|
slot: z.string().trim().min(1),
|
|
141
155
|
returnTo: z.string().url(),
|
|
142
156
|
})
|
|
143
157
|
|
|
144
158
|
export const AddConnectorConnectionBodySchema = z.object({
|
|
159
|
+
owner: ConnectorConnectionOwnerChoiceSchema.default("project"),
|
|
145
160
|
slot: z.string().trim().min(1),
|
|
146
161
|
})
|
|
147
162
|
|
package/src/schemas/files.ts
CHANGED
|
@@ -83,6 +83,18 @@ export const CompleteFileUploadBodySchema = z.object({
|
|
|
83
83
|
parts: z.array(FileUploadPartSchema).optional(),
|
|
84
84
|
})
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The grant a shared link's session names in the query of what a browser loads by itself, such as
|
|
88
|
+
* an `<img>`, which cannot send the header. The boundary reads it before routing; a route declares
|
|
89
|
+
* it to keep it in the OpenAPI contract and through query validation.
|
|
90
|
+
*/
|
|
91
|
+
export const ShareGrantQuerySchema = z.object({
|
|
92
|
+
shareGrant: z
|
|
93
|
+
.string()
|
|
94
|
+
.optional()
|
|
95
|
+
.describe("Share grant selector for elements that cannot send the x-sixb-share-grant header"),
|
|
96
|
+
})
|
|
97
|
+
|
|
86
98
|
export const FileContentQuerySchema = z.object({
|
|
87
99
|
path: z.string().min(1),
|
|
88
100
|
disposition: z.enum(["inline", "attachment"]).optional(),
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
const DatasetStorageWarningSchema = z.object({
|
|
4
|
+
code: z.enum(["partitioned-small-dataset"]),
|
|
5
|
+
message: z.string(),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const DatasetStorageHealthSchema = z.object({
|
|
9
|
+
datasetId: z.string(),
|
|
10
|
+
materialized: z.boolean().describe("Whether the dataset has a table in the lake"),
|
|
11
|
+
rowCount: z.number().int(),
|
|
12
|
+
dataFiles: z.number().int().describe("Data files its current rows are read from"),
|
|
13
|
+
smallDataFiles: z.number().int().describe("Data files small enough that compaction merges them"),
|
|
14
|
+
dataBytes: z.number().int(),
|
|
15
|
+
deleteFiles: z.number().int().describe("Files listing deleted rows, until compaction"),
|
|
16
|
+
inlinedRows: z.number().int().describe("Rows kept in the catalog rather than in files"),
|
|
17
|
+
retainedSnapshots: z.number().int().describe("Commits still in the dataset's history"),
|
|
18
|
+
partitionBy: z.array(z.string()),
|
|
19
|
+
warnings: z.array(DatasetStorageWarningSchema),
|
|
20
|
+
ingest: z
|
|
21
|
+
.object({
|
|
22
|
+
pendingDeliveries: z.number().int(),
|
|
23
|
+
pendingChanges: z.number().int(),
|
|
24
|
+
oldestReceivedAt: z
|
|
25
|
+
.string()
|
|
26
|
+
.datetime()
|
|
27
|
+
.nullable()
|
|
28
|
+
.describe("When the oldest waiting delivery arrived"),
|
|
29
|
+
rejectedDeliveries: z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.describe("Deliveries refused when written, kept for a week to read and send again"),
|
|
33
|
+
})
|
|
34
|
+
.nullable()
|
|
35
|
+
.describe("Ingested changes waiting or refused; null when there are none"),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const LakeHealthResponseSchema = z.object({
|
|
39
|
+
available: z.boolean().describe("Whether the lake storage provider supports maintenance"),
|
|
40
|
+
cleanup: z.object({
|
|
41
|
+
state: z
|
|
42
|
+
.enum(["off", "idle", "not-requested", "no-worker", "failing", "cleaning", "ok"])
|
|
43
|
+
.describe(
|
|
44
|
+
"What actually happens: `not-requested` when no orchestrator asks, `no-worker` when no lake worker runs what it asks"
|
|
45
|
+
),
|
|
46
|
+
lastRequestedAt: z.string().nullable().describe("When the orchestrator last asked for cleanup"),
|
|
47
|
+
lastRunAt: z.string().nullable().describe("When a lake worker last started a cleanup"),
|
|
48
|
+
keepVersionsFor: z.string(),
|
|
49
|
+
deleteFilesAfter: z.string(),
|
|
50
|
+
cleanupEvery: z.string(),
|
|
51
|
+
}),
|
|
52
|
+
datasets: z.array(DatasetStorageHealthSchema),
|
|
53
|
+
})
|
package/src/schemas/objects.ts
CHANGED
package/src/schemas/pipelines.ts
CHANGED
|
@@ -63,6 +63,8 @@ export const PipelineRunSchema = z.object({
|
|
|
63
63
|
projectId: z.string(),
|
|
64
64
|
pipelineId: z.string(),
|
|
65
65
|
status: PipelineRunStatusSchema,
|
|
66
|
+
/** How many executions took the run: above one, it resumed after losing its worker. */
|
|
67
|
+
attempt: z.number(),
|
|
66
68
|
queuedAt: z.string(),
|
|
67
69
|
startedAt: z.string().optional(),
|
|
68
70
|
finishedAt: z.string().optional(),
|