@sixb/server 0.2.1 → 0.2.3
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 +2876 -667
- package/dist/index.js.map +43 -36
- 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 +21 -11
- package/dist/routes/agent-approvals.d.ts.map +1 -1
- package/dist/routes/agent-children.d.ts +4 -4
- package/dist/routes/agent-computers.d.ts +146 -1
- 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 +152 -60
- package/dist/routes/agents.d.ts.map +1 -1
- 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 +21 -11
- package/dist/routes/observed-agent-threads.d.ts.map +1 -1
- package/dist/routes/ontology.d.ts +6 -6
- package/dist/routes/pipelines.d.ts +13 -9
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +27 -27
- 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 +9 -6
- 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 +14 -14
- 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 +16 -16
- package/dist/schemas/agent-approvals.d.ts +27 -27
- package/dist/schemas/agents.d.ts +642 -196
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +41 -41
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- 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 +86 -64
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +160 -160
- 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 +38 -22
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/telemetry.d.ts +26 -26
- package/dist/schemas/workflows.d.ts +71 -71
- 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 +208 -14
- package/src/routes/agent-runners.ts +1 -0
- package/src/routes/agents.ts +52 -7
- 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 +71 -1
- package/src/schemas/ai-accounting.ts +1 -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
package/src/routes/agents.ts
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
import { agentRunStreamId } from "@sixb/core/internal/agents/streams"
|
|
18
18
|
import { resolveFileRefAtPath } from "@sixb/core/internal/blob-storage"
|
|
19
19
|
import {
|
|
20
|
+
type AgentBackgroundCommandRef,
|
|
21
|
+
type AgentComputerBackgroundCommand,
|
|
20
22
|
type AgentContextCheckpointRecord,
|
|
21
23
|
type AgentMessageRecord,
|
|
22
24
|
type AgentRunDiagnostic,
|
|
@@ -126,7 +128,7 @@ export async function serializeThreads(
|
|
|
126
128
|
title: thread.title,
|
|
127
129
|
sandboxParams: thread.sandboxParams,
|
|
128
130
|
runsOn: thread.runsOn,
|
|
129
|
-
|
|
131
|
+
...placeOf(thread),
|
|
130
132
|
movedAt: thread.movedAt ? toIsoString(thread.movedAt) : undefined,
|
|
131
133
|
sandboxState: thread.sandboxState && {
|
|
132
134
|
name: thread.sandboxState.name,
|
|
@@ -153,14 +155,19 @@ export async function serializeThread(
|
|
|
153
155
|
return serialized
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Where each of the viewer's own computer threads runs, whether its folder is open now, and the
|
|
160
|
+
* background commands their `sixb` runs for it.
|
|
161
|
+
*/
|
|
157
162
|
async function computerPlaces(
|
|
158
163
|
host: SixbHostView,
|
|
159
164
|
threads: readonly AgentThreadView[],
|
|
160
165
|
viewer: Principal
|
|
161
|
-
): Promise<(thread: AgentThreadView) =>
|
|
166
|
+
): Promise<(thread: AgentThreadView) => ThreadComputerView> {
|
|
167
|
+
// A thread that moved may still have commands running where it was.
|
|
162
168
|
const owned = (thread: AgentThreadView) =>
|
|
163
|
-
thread.computer !== undefined
|
|
169
|
+
(thread.computer !== undefined || thread.movedAt !== undefined) &&
|
|
170
|
+
principalsEqual(thread.ownerPrincipal, viewer)
|
|
164
171
|
const live =
|
|
165
172
|
host.storage.agents && threads.some(owned)
|
|
166
173
|
? await host.storage.agents.computers.listLive({
|
|
@@ -170,13 +177,51 @@ async function computerPlaces(
|
|
|
170
177
|
})
|
|
171
178
|
: []
|
|
172
179
|
return (thread) => {
|
|
180
|
+
if (!owned(thread)) return {}
|
|
181
|
+
|
|
182
|
+
// Its background commands, from any of its owner's sixb: a command started in one folder runs
|
|
183
|
+
// on there once the thread moved to another, or to the cloud. And which of them a stop is on.
|
|
184
|
+
const backgroundCommands = live.flatMap((session) =>
|
|
185
|
+
(session.backgroundCommands ?? [])
|
|
186
|
+
.filter((command) => command.threadId === thread.id)
|
|
187
|
+
.map((command) => {
|
|
188
|
+
const stopping =
|
|
189
|
+
command.status === "running" &&
|
|
190
|
+
(session.stopRequests ?? []).some((ref) => sameBackgroundCommand(command, ref))
|
|
191
|
+
return stopping ? { ...command, stopping } : command
|
|
192
|
+
})
|
|
193
|
+
)
|
|
194
|
+
|
|
173
195
|
const computer = thread.computer
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
196
|
+
const online =
|
|
197
|
+
computer !== undefined &&
|
|
198
|
+
live.some((session) => sameComputerPlace(session.computer, computer))
|
|
199
|
+
return {
|
|
200
|
+
...(computer ? { computer: { ...computer, online } } : {}),
|
|
201
|
+
...(backgroundCommands.length > 0 ? { backgroundCommands } : {}),
|
|
202
|
+
}
|
|
177
203
|
}
|
|
178
204
|
}
|
|
179
205
|
|
|
206
|
+
interface ThreadComputerView {
|
|
207
|
+
readonly computer?: AgentThreadComputer & { readonly online: boolean }
|
|
208
|
+
readonly backgroundCommands?: readonly (AgentComputerBackgroundCommand & {
|
|
209
|
+
readonly stopping?: boolean
|
|
210
|
+
})[]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Whether a reported background command is the one `ref` names: by its start, as ids repeat. */
|
|
214
|
+
export function sameBackgroundCommand(
|
|
215
|
+
command: AgentBackgroundCommandRef,
|
|
216
|
+
ref: AgentBackgroundCommandRef
|
|
217
|
+
): boolean {
|
|
218
|
+
return (
|
|
219
|
+
command.threadId === ref.threadId &&
|
|
220
|
+
command.id === ref.id &&
|
|
221
|
+
command.startedAt === ref.startedAt
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
180
225
|
function serializeMessage(
|
|
181
226
|
message: AgentMessageRecord,
|
|
182
227
|
annotations: readonly AgentRunDiagnostic[] = [],
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SixbHostView } from "@sixb/core"
|
|
2
2
|
import { parseArtifactAddress } from "@sixb/core/artifacts"
|
|
3
|
+
import { annotateBoard } from "@sixb/core/artifacts/live"
|
|
3
4
|
import {
|
|
4
5
|
ARTIFACT_FRAME_ROUTE_PREFIX,
|
|
5
6
|
FRAME_ASSETS,
|
|
7
|
+
FRAME_REFERENCE_PATH,
|
|
6
8
|
FRAME_REFERENCE_PREFIX,
|
|
7
9
|
frameEntries,
|
|
8
10
|
frameLayout,
|
|
@@ -11,6 +13,11 @@ import {
|
|
|
11
13
|
rewriteFrameReferences,
|
|
12
14
|
} from "@sixb/core/internal/artifacts/frames"
|
|
13
15
|
import { openFileRef } from "@sixb/core/internal/blob-storage"
|
|
16
|
+
import type {
|
|
17
|
+
ArtifactFrameTarget,
|
|
18
|
+
ArtifactStorage,
|
|
19
|
+
ArtifactVersionRecord,
|
|
20
|
+
} from "@sixb/core/storage"
|
|
14
21
|
import type { Elysia } from "elysia"
|
|
15
22
|
import { frameContentSecurityPolicy } from "../artifacts/frame"
|
|
16
23
|
import type { ResolvedSixbApiBrowserPolicy } from "../auth/browser-origin"
|
|
@@ -24,7 +31,8 @@ interface FrameContext {
|
|
|
24
31
|
/**
|
|
25
32
|
* Serves a version's files to its sandboxed frame, under the token a frame link carries: the token
|
|
26
33
|
* is the credential, so the route is public. Each entry gets its layout's kit and the runtime,
|
|
27
|
-
* which are served beside the files.
|
|
34
|
+
* which are served beside the files. A canvas's board asked for with `?sixb-edit` is served for
|
|
35
|
+
* editing: its static elements marked with their addresses. Hidden from OpenAPI: clients receive frame links, they
|
|
28
36
|
* never build them.
|
|
29
37
|
*/
|
|
30
38
|
export function registerArtifactFrameRoutes(
|
|
@@ -84,21 +92,16 @@ async function frameResponse(
|
|
|
84
92
|
}
|
|
85
93
|
let lent = false
|
|
86
94
|
if (path?.startsWith(FRAME_REFERENCE_PREFIX)) {
|
|
87
|
-
// A file another artifact lends this one: only one its frame was issued with
|
|
88
|
-
|
|
95
|
+
// A file another artifact lends this one: only one its frame was issued with. A pinned
|
|
96
|
+
// address shows its created version; an unpinned one the lender's latest, as it is now.
|
|
97
|
+
const match = FRAME_REFERENCE_PATH.exec(path.slice(FRAME_REFERENCE_PREFIX.length))
|
|
89
98
|
const target = frame.targets.find(
|
|
90
99
|
(candidate) =>
|
|
91
100
|
candidate.artifactId === match?.[1] &&
|
|
92
|
-
candidate.version ===
|
|
101
|
+
String(candidate.version) === match?.[2] &&
|
|
93
102
|
parseArtifactAddress(candidate.address)?.path === match?.[3]
|
|
94
103
|
)
|
|
95
|
-
const lender = target
|
|
96
|
-
? await storage.getVersion({
|
|
97
|
-
projectId: host.id,
|
|
98
|
-
artifactId: target.artifactId,
|
|
99
|
-
version: target.version,
|
|
100
|
-
})
|
|
101
|
-
: null
|
|
104
|
+
const lender = target ? await lenderVersion(storage, host.id, target) : null
|
|
102
105
|
if (!lender || !match) return notFound()
|
|
103
106
|
version = lender
|
|
104
107
|
path = match[3] ?? null
|
|
@@ -115,8 +118,18 @@ async function frameResponse(
|
|
|
115
118
|
headers.set("cache-control", "private, no-cache")
|
|
116
119
|
if (options.head) return new Response(null, { headers })
|
|
117
120
|
const text = await new Response(opened.body).text()
|
|
121
|
+
|
|
122
|
+
// A canvas's board served for editing has its static elements marked with their addresses,
|
|
123
|
+
// for the runtime to report and edit them by.
|
|
124
|
+
const editing =
|
|
125
|
+
version.outline.kind === "canvas" && new URL(request.url).searchParams.has("sixb-edit")
|
|
126
|
+
const source = editing ? annotateBoard(text) : text
|
|
118
127
|
return new Response(
|
|
119
|
-
injectFrameAssets(
|
|
128
|
+
injectFrameAssets(
|
|
129
|
+
rewriteFrameReferences(source, frame.targets, file.path),
|
|
130
|
+
layout,
|
|
131
|
+
file.path
|
|
132
|
+
),
|
|
120
133
|
{ headers }
|
|
121
134
|
)
|
|
122
135
|
}
|
|
@@ -135,6 +148,21 @@ async function frameResponse(
|
|
|
135
148
|
return response
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
async function lenderVersion(
|
|
152
|
+
storage: ArtifactStorage,
|
|
153
|
+
projectId: string,
|
|
154
|
+
target: ArtifactFrameTarget
|
|
155
|
+
): Promise<ArtifactVersionRecord | null> {
|
|
156
|
+
const { artifactId } = target
|
|
157
|
+
const version =
|
|
158
|
+
target.version === "latest"
|
|
159
|
+
? (await storage.get({ projectId, id: artifactId }))?.latestVersion
|
|
160
|
+
: target.version
|
|
161
|
+
if (version === undefined) return null
|
|
162
|
+
|
|
163
|
+
return storage.getVersion({ projectId, artifactId, version })
|
|
164
|
+
}
|
|
165
|
+
|
|
138
166
|
function decodePath(raw: string | undefined): string | null {
|
|
139
167
|
try {
|
|
140
168
|
return decodeURIComponent(raw ?? "")
|