@sixb/server 0.2.3 → 0.2.5
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/index.js +354 -30
- package/dist/index.js.map +12 -12
- package/dist/live/room.d.ts +2 -0
- package/dist/live/room.d.ts.map +1 -1
- package/dist/routes/agent-runners.d.ts +5 -1
- package/dist/routes/agent-runners.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +898 -6
- package/dist/routes/agents.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 +287 -21
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +7 -7
- package/dist/routes/events.d.ts +4 -4
- package/dist/routes/links.d.ts +8 -0
- package/dist/routes/links.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +8 -0
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +2 -0
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/ws/events.d.ts +6 -6
- package/dist/schemas/agents.d.ts +5089 -250
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/artifacts.d.ts +676 -36
- package/dist/schemas/artifacts.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +8 -8
- package/dist/schemas/events.d.ts +36 -24
- package/dist/schemas/events.d.ts.map +1 -1
- package/dist/schemas/lineage.d.ts +112 -0
- package/dist/schemas/lineage.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +11 -0
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/live/README.md +9 -6
- package/src/live/room.ts +16 -8
- package/src/routes/agent-runners.ts +15 -4
- package/src/routes/agents.ts +203 -5
- package/src/routes/artifact-frames.ts +22 -9
- package/src/routes/artifacts.ts +124 -3
- package/src/schemas/agents.ts +68 -2
- package/src/schemas/artifacts.ts +66 -1
- package/src/schemas/events.ts +1 -0
- package/src/schemas/projections.ts +1 -0
- package/src/server.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -1148,7 +1148,7 @@ import {
|
|
|
1148
1148
|
import { z as z10 } from "zod";
|
|
1149
1149
|
|
|
1150
1150
|
// src/schemas/agents.ts
|
|
1151
|
-
import { MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core";
|
|
1151
|
+
import { AGENT_MESSAGE_DELIVERIES, MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core";
|
|
1152
1152
|
import { MAX_AGENT_CONTEXT_LABEL_LENGTH } from "@sixb/core/agents/context";
|
|
1153
1153
|
import { CONTROL_CHARACTER } from "@sixb/core/internal/agent-run-storage-provider";
|
|
1154
1154
|
import { LANGUAGE_MODEL_TIERS as LANGUAGE_MODEL_TIERS2 } from "@sixb/core/models";
|
|
@@ -1851,6 +1851,7 @@ var AgentAuthorizablePrincipalSchema = z9.object({
|
|
|
1851
1851
|
type: z9.enum(["user", "serviceAccount"]),
|
|
1852
1852
|
id: z9.string().min(1)
|
|
1853
1853
|
});
|
|
1854
|
+
var AgentMessageDeliverySchema = z9.enum(AGENT_MESSAGE_DELIVERIES);
|
|
1854
1855
|
var AgentObjectContextSchema = z9.object({
|
|
1855
1856
|
kind: z9.literal("object"),
|
|
1856
1857
|
ref: z9.object({
|
|
@@ -2140,7 +2141,8 @@ var PostAgentMessageBodySchema = z9.object({
|
|
|
2140
2141
|
approvalMode: AgentApprovalModeSchema.optional(),
|
|
2141
2142
|
attachments: z9.array(FileRefSchema).optional(),
|
|
2142
2143
|
context: z9.array(AgentContextEntryInputSchema).max(MAX_AGENT_CONTEXT_ENTRIES).optional(),
|
|
2143
|
-
messageId: z9.string().trim().min(1).optional()
|
|
2144
|
+
messageId: z9.string().trim().min(1).optional(),
|
|
2145
|
+
delivery: AgentMessageDeliverySchema.optional()
|
|
2144
2146
|
}).strict();
|
|
2145
2147
|
var AgentRequestErrorResponseSchema = ErrorResponseSchema.extend({
|
|
2146
2148
|
code: z9.string().optional()
|
|
@@ -2182,8 +2184,46 @@ var AgentRunSchema = z9.object({
|
|
|
2182
2184
|
startedAt: z9.string().optional(),
|
|
2183
2185
|
completedAt: z9.string().optional()
|
|
2184
2186
|
});
|
|
2187
|
+
var AgentInboxItemSchema = z9.object({
|
|
2188
|
+
id: z9.string(),
|
|
2189
|
+
projectId: z9.string(),
|
|
2190
|
+
threadId: z9.string(),
|
|
2191
|
+
messageId: z9.string(),
|
|
2192
|
+
seq: z9.number(),
|
|
2193
|
+
authorPrincipal: AgentPrincipalSchema,
|
|
2194
|
+
mode: z9.enum(["steer", "queue"]),
|
|
2195
|
+
parts: z9.array(AgentMessagePartSchema),
|
|
2196
|
+
spec: z9.object({
|
|
2197
|
+
model: LanguageModelRefSchema.optional(),
|
|
2198
|
+
reasoning: ModelReasoningSchema.optional(),
|
|
2199
|
+
approvalMode: AgentApprovalModeSchema.optional()
|
|
2200
|
+
}).optional(),
|
|
2201
|
+
timeZone: z9.string().optional(),
|
|
2202
|
+
locale: z9.string().optional(),
|
|
2203
|
+
immediate: z9.boolean().optional(),
|
|
2204
|
+
createdAt: z9.string(),
|
|
2205
|
+
updatedAt: z9.string()
|
|
2206
|
+
});
|
|
2207
|
+
var AgentInboxListResponseSchema = z9.object({
|
|
2208
|
+
items: z9.array(AgentInboxItemSchema)
|
|
2209
|
+
});
|
|
2210
|
+
var AgentThreadInboxParamsSchema = AgentThreadParamsSchema.extend({
|
|
2211
|
+
itemId: z9.string().min(1)
|
|
2212
|
+
});
|
|
2213
|
+
var UpdateAgentInboxItemBodySchema = z9.object({
|
|
2214
|
+
text: z9.string().trim().min(1).optional(),
|
|
2215
|
+
model: LanguageModelRefSchema.optional(),
|
|
2216
|
+
reasoning: ModelReasoningSchema.optional(),
|
|
2217
|
+
approvalMode: AgentApprovalModeSchema.optional(),
|
|
2218
|
+
delivery: z9.enum(["steer", "queue"]).optional(),
|
|
2219
|
+
immediate: z9.literal(true).optional()
|
|
2220
|
+
}).strict();
|
|
2221
|
+
var UpdateAgentInboxItemResponseSchema = z9.object({
|
|
2222
|
+
item: AgentInboxItemSchema
|
|
2223
|
+
});
|
|
2185
2224
|
var PostAgentMessageResponseSchema = z9.object({
|
|
2186
|
-
run: AgentRunSchema
|
|
2225
|
+
run: AgentRunSchema.optional(),
|
|
2226
|
+
item: AgentInboxItemSchema.optional()
|
|
2187
2227
|
});
|
|
2188
2228
|
var CancelAgentRunResponseSchema = z9.object({
|
|
2189
2229
|
run: AgentRunSchema
|
|
@@ -4526,6 +4566,24 @@ function serializeMessage(message, annotations = [], checkpoint) {
|
|
|
4526
4566
|
completedAt: message.completedAt ? toIsoString(message.completedAt) : undefined
|
|
4527
4567
|
});
|
|
4528
4568
|
}
|
|
4569
|
+
function serializeAgentInboxItem(item) {
|
|
4570
|
+
return AgentInboxItemSchema.parse({
|
|
4571
|
+
id: item.id,
|
|
4572
|
+
projectId: item.projectId,
|
|
4573
|
+
threadId: item.threadId,
|
|
4574
|
+
messageId: item.messageId,
|
|
4575
|
+
seq: item.seq,
|
|
4576
|
+
authorPrincipal: item.authorPrincipal,
|
|
4577
|
+
mode: item.mode,
|
|
4578
|
+
parts: item.parts,
|
|
4579
|
+
spec: item.spec,
|
|
4580
|
+
timeZone: item.timeZone,
|
|
4581
|
+
locale: item.locale,
|
|
4582
|
+
immediate: item.immediate === true ? true : undefined,
|
|
4583
|
+
createdAt: toIsoString(item.createdAt),
|
|
4584
|
+
updatedAt: toIsoString(item.updatedAt)
|
|
4585
|
+
});
|
|
4586
|
+
}
|
|
4529
4587
|
function serializeAgentRun(run) {
|
|
4530
4588
|
return AgentRunSchema.parse({
|
|
4531
4589
|
id: run.id,
|
|
@@ -4567,6 +4625,17 @@ async function getAgentMessageFileContentThread(params) {
|
|
|
4567
4625
|
}
|
|
4568
4626
|
return params.authState.sixb.agent.threads.getById(params.threadId);
|
|
4569
4627
|
}
|
|
4628
|
+
function handleAgentInboxRouteError(error, set) {
|
|
4629
|
+
if (error instanceof AgentStorageError2 && error.code === "invalid_state") {
|
|
4630
|
+
set.status = 409;
|
|
4631
|
+
return { error: "A turn already read this message", code: error.code };
|
|
4632
|
+
}
|
|
4633
|
+
if (error instanceof AgentStorageError2 && error.code === "inbox_limit") {
|
|
4634
|
+
set.status = 409;
|
|
4635
|
+
return { error: "Too many messages are waiting in this conversation", code: error.code };
|
|
4636
|
+
}
|
|
4637
|
+
return handleAgentRouteError(error, set);
|
|
4638
|
+
}
|
|
4570
4639
|
function handleAgentRouteError(error, set) {
|
|
4571
4640
|
if (error instanceof AgentStorageError2 && error.code === "duplicate_id") {
|
|
4572
4641
|
set.status = 409;
|
|
@@ -4965,6 +5034,34 @@ function registerAgentRoutes(app, host) {
|
|
|
4965
5034
|
tags: [OPENAPI_TAGS.agentThreads.name],
|
|
4966
5035
|
security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
|
|
4967
5036
|
}
|
|
5037
|
+
}).post("/api/agent-threads/:threadId/sandbox/restore", async (context) => {
|
|
5038
|
+
try {
|
|
5039
|
+
const sixb = requireRequestSixb(context);
|
|
5040
|
+
const thread = await sixb.agent.threads.restoreSandbox(context.params.threadId, context.body);
|
|
5041
|
+
return serializeThread(host, thread, requestActor(sixb));
|
|
5042
|
+
} catch (error) {
|
|
5043
|
+
if (error instanceof AgentStorageError2 && error.code === "invalid_state") {
|
|
5044
|
+
context.set.status = 409;
|
|
5045
|
+
return { error: "Sandbox state changed or a run is active. Reload and try again." };
|
|
5046
|
+
}
|
|
5047
|
+
return handleAgentRouteError(error, context.set);
|
|
5048
|
+
}
|
|
5049
|
+
}, {
|
|
5050
|
+
params: AgentThreadParamsSchema,
|
|
5051
|
+
body: z13.object({ expectedSandboxName: z13.string().min(1) }).strict(),
|
|
5052
|
+
response: {
|
|
5053
|
+
200: AgentThreadSchema,
|
|
5054
|
+
400: ErrorResponseSchema,
|
|
5055
|
+
403: AgentRequestErrorResponseSchema,
|
|
5056
|
+
404: ErrorResponseSchema,
|
|
5057
|
+
409: AgentRequestErrorResponseSchema
|
|
5058
|
+
},
|
|
5059
|
+
detail: {
|
|
5060
|
+
summary: "Explicitly go on in the workspace a failed save left, with its files as they were",
|
|
5061
|
+
operationId: "restoreAgentThreadSandbox",
|
|
5062
|
+
tags: [OPENAPI_TAGS.agentThreads.name],
|
|
5063
|
+
security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
|
|
5064
|
+
}
|
|
4968
5065
|
}).get("/api/agent-threads/:threadId/messages", async (context) => {
|
|
4969
5066
|
const { params, query, set } = context;
|
|
4970
5067
|
const authState = requestAuthState(context);
|
|
@@ -5050,13 +5147,14 @@ function registerAgentRoutes(app, host) {
|
|
|
5050
5147
|
context: parsed.context,
|
|
5051
5148
|
messageId: parsed.messageId
|
|
5052
5149
|
};
|
|
5053
|
-
const
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
run: serializeAgentRun(result.run)
|
|
5150
|
+
const sent = await sixb.agent.runs.send({
|
|
5151
|
+
...requestInput,
|
|
5152
|
+
delivery: parsed.delivery
|
|
5057
5153
|
});
|
|
5154
|
+
set.status = 202;
|
|
5155
|
+
return PostAgentMessageResponseSchema.parse(sent.kind === "turn" ? { run: serializeAgentRun(sent.run) } : { item: serializeAgentInboxItem(sent.item) });
|
|
5058
5156
|
} catch (error) {
|
|
5059
|
-
return
|
|
5157
|
+
return handleAgentInboxRouteError(error, set);
|
|
5060
5158
|
}
|
|
5061
5159
|
}, {
|
|
5062
5160
|
params: AgentThreadParamsSchema,
|
|
@@ -5076,6 +5174,95 @@ function registerAgentRoutes(app, host) {
|
|
|
5076
5174
|
operationId: "postAgentThreadMessage",
|
|
5077
5175
|
security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
|
|
5078
5176
|
}
|
|
5177
|
+
}).get("/api/agent-threads/:threadId/inbox", async (context) => {
|
|
5178
|
+
const { params, set } = context;
|
|
5179
|
+
const sixb = requireRequestSixb(context);
|
|
5180
|
+
try {
|
|
5181
|
+
if (!host.storage.agents) {
|
|
5182
|
+
return missingAgentStorageResponse(set);
|
|
5183
|
+
}
|
|
5184
|
+
const items = await sixb.agent.inbox.list(params.threadId);
|
|
5185
|
+
return AgentInboxListResponseSchema.parse({
|
|
5186
|
+
items: items.map(serializeAgentInboxItem)
|
|
5187
|
+
});
|
|
5188
|
+
} catch (error) {
|
|
5189
|
+
return handleAgentRouteError(error, set);
|
|
5190
|
+
}
|
|
5191
|
+
}, {
|
|
5192
|
+
params: AgentThreadParamsSchema,
|
|
5193
|
+
response: {
|
|
5194
|
+
200: AgentInboxListResponseSchema,
|
|
5195
|
+
400: AgentRequestErrorResponseSchema,
|
|
5196
|
+
404: ErrorResponseSchema,
|
|
5197
|
+
501: ErrorResponseSchema
|
|
5198
|
+
},
|
|
5199
|
+
detail: {
|
|
5200
|
+
summary: "List agent thread inbox messages",
|
|
5201
|
+
tags: [OPENAPI_TAGS.agentThreads.name],
|
|
5202
|
+
operationId: "listAgentThreadInbox",
|
|
5203
|
+
security: accessTokenSecurityRequirement("listAgentThreadInbox")
|
|
5204
|
+
}
|
|
5205
|
+
}).patch("/api/agent-threads/:threadId/inbox/:itemId", async (context) => {
|
|
5206
|
+
const { params, body, set } = context;
|
|
5207
|
+
const sixb = requireRequestSixb(context);
|
|
5208
|
+
try {
|
|
5209
|
+
if (!host.storage.agents) {
|
|
5210
|
+
return missingAgentStorageResponse(set);
|
|
5211
|
+
}
|
|
5212
|
+
const parsed = UpdateAgentInboxItemBodySchema.parse(body);
|
|
5213
|
+
const item = await sixb.agent.inbox.update(params.threadId, params.itemId, parsed);
|
|
5214
|
+
return UpdateAgentInboxItemResponseSchema.parse({
|
|
5215
|
+
item: serializeAgentInboxItem(item)
|
|
5216
|
+
});
|
|
5217
|
+
} catch (error) {
|
|
5218
|
+
return handleAgentInboxRouteError(error, set);
|
|
5219
|
+
}
|
|
5220
|
+
}, {
|
|
5221
|
+
params: AgentThreadInboxParamsSchema,
|
|
5222
|
+
body: UpdateAgentInboxItemBodySchema,
|
|
5223
|
+
response: {
|
|
5224
|
+
200: UpdateAgentInboxItemResponseSchema,
|
|
5225
|
+
400: AgentRequestErrorResponseSchema,
|
|
5226
|
+
403: AgentRequestErrorResponseSchema,
|
|
5227
|
+
404: ErrorResponseSchema,
|
|
5228
|
+
409: AgentRequestErrorResponseSchema,
|
|
5229
|
+
501: ErrorResponseSchema
|
|
5230
|
+
},
|
|
5231
|
+
detail: {
|
|
5232
|
+
summary: "Update a waiting agent thread message",
|
|
5233
|
+
tags: [OPENAPI_TAGS.agentThreads.name],
|
|
5234
|
+
operationId: "updateAgentThreadInboxItem",
|
|
5235
|
+
security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
|
|
5236
|
+
}
|
|
5237
|
+
}).delete("/api/agent-threads/:threadId/inbox/:itemId", async (context) => {
|
|
5238
|
+
const { params, set } = context;
|
|
5239
|
+
const sixb = requireRequestSixb(context);
|
|
5240
|
+
try {
|
|
5241
|
+
if (!host.storage.agents) {
|
|
5242
|
+
return missingAgentStorageResponse(set);
|
|
5243
|
+
}
|
|
5244
|
+
await sixb.agent.inbox.remove(params.threadId, params.itemId);
|
|
5245
|
+
set.status = 204;
|
|
5246
|
+
return;
|
|
5247
|
+
} catch (error) {
|
|
5248
|
+
return handleAgentInboxRouteError(error, set);
|
|
5249
|
+
}
|
|
5250
|
+
}, {
|
|
5251
|
+
params: AgentThreadInboxParamsSchema,
|
|
5252
|
+
response: {
|
|
5253
|
+
204: z13.void(),
|
|
5254
|
+
400: AgentRequestErrorResponseSchema,
|
|
5255
|
+
403: AgentRequestErrorResponseSchema,
|
|
5256
|
+
404: ErrorResponseSchema,
|
|
5257
|
+
409: AgentRequestErrorResponseSchema,
|
|
5258
|
+
501: ErrorResponseSchema
|
|
5259
|
+
},
|
|
5260
|
+
detail: {
|
|
5261
|
+
summary: "Withdraw a waiting agent thread message",
|
|
5262
|
+
tags: [OPENAPI_TAGS.agentThreads.name],
|
|
5263
|
+
operationId: "withdrawAgentThreadInboxItem",
|
|
5264
|
+
security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
|
|
5265
|
+
}
|
|
5079
5266
|
}).post("/api/agent-threads/:threadId/cancel", async (context) => {
|
|
5080
5267
|
const { params, body, set } = context;
|
|
5081
5268
|
const sixb = requireRequestSixb(context);
|
|
@@ -6325,10 +6512,13 @@ function startLapsedRunSweeper(host) {
|
|
|
6325
6512
|
}
|
|
6326
6513
|
function agentRunSessionHandler(host) {
|
|
6327
6514
|
let sessions;
|
|
6328
|
-
return async (request) => {
|
|
6515
|
+
return async (request, server) => {
|
|
6329
6516
|
sessions ??= agentRunSessionHost(host);
|
|
6330
6517
|
const served = sessions ? await serveAgentRunSession(sessions, request, {
|
|
6331
|
-
admitted: () =>
|
|
6518
|
+
admitted: () => {
|
|
6519
|
+
liftRequestBodyCap(request);
|
|
6520
|
+
server?.timeout(request, 0);
|
|
6521
|
+
}
|
|
6332
6522
|
}) : null;
|
|
6333
6523
|
if (served)
|
|
6334
6524
|
return served;
|
|
@@ -7025,7 +7215,9 @@ import {
|
|
|
7025
7215
|
FRAME_REFERENCE_PREFIX,
|
|
7026
7216
|
frameEntries,
|
|
7027
7217
|
frameLayout,
|
|
7218
|
+
frozenDocumentHtml,
|
|
7028
7219
|
injectFrameAssets,
|
|
7220
|
+
markDocumentSections,
|
|
7029
7221
|
resolveArtifactFrame,
|
|
7030
7222
|
rewriteFrameReferences
|
|
7031
7223
|
} from "@sixb/core/internal/artifacts/frames";
|
|
@@ -7108,7 +7300,7 @@ async function frameResponse(host, policy, { params, request }, options = {}) {
|
|
|
7108
7300
|
const file = version.files.find((candidate) => candidate.path === path);
|
|
7109
7301
|
if (!file)
|
|
7110
7302
|
return notFound();
|
|
7111
|
-
const layout = frameLayout(version
|
|
7303
|
+
const layout = frameLayout(version);
|
|
7112
7304
|
if (!lent && layout && frameEntries(version).includes(file.path)) {
|
|
7113
7305
|
const opened = await openFileRef(host.blobStorage, file.file);
|
|
7114
7306
|
if (!opened)
|
|
@@ -7118,9 +7310,12 @@ async function frameResponse(host, policy, { params, request }, options = {}) {
|
|
|
7118
7310
|
if (options.head)
|
|
7119
7311
|
return new Response(null, { headers });
|
|
7120
7312
|
const text = await new Response(opened.body).text();
|
|
7121
|
-
const
|
|
7122
|
-
const
|
|
7123
|
-
|
|
7313
|
+
const { outline } = version;
|
|
7314
|
+
const editing = (outline.kind === "canvas" || outline.kind === "document") && new URL(request.url).searchParams.has("sixb-edit");
|
|
7315
|
+
const marked = editing ? annotateBoard(text) : text;
|
|
7316
|
+
const shown = outline.kind === "document" && version.frozenAt ? frozenDocumentHtml(marked) : marked;
|
|
7317
|
+
const source = outline.kind === "document" ? markDocumentSections(shown, outline.headings) : shown;
|
|
7318
|
+
return new Response(injectFrameAssets(rewriteFrameReferences(source, frame.targets, file.path), layout, file.path, outline.kind === "document" ? outline.paper : undefined), { headers });
|
|
7124
7319
|
}
|
|
7125
7320
|
const response = await createFileContentResponse({
|
|
7126
7321
|
blobStorage: host.blobStorage,
|
|
@@ -7168,7 +7363,8 @@ import {
|
|
|
7168
7363
|
boardPreview,
|
|
7169
7364
|
boardPreviewStatuses,
|
|
7170
7365
|
boardPreviews,
|
|
7171
|
-
boardsReadLiveData
|
|
7366
|
+
boardsReadLiveData,
|
|
7367
|
+
documentPdfKey
|
|
7172
7368
|
} from "@sixb/core/internal/artifacts/publish";
|
|
7173
7369
|
import { ZodError as ZodError6 } from "zod";
|
|
7174
7370
|
|
|
@@ -7271,7 +7467,22 @@ var ArtifactFileSchema = z18.object({
|
|
|
7271
7467
|
});
|
|
7272
7468
|
var DocumentOutlineSchema = z18.object({
|
|
7273
7469
|
kind: z18.literal("document"),
|
|
7274
|
-
headings: z18.array(z18.object({ depth: z18.number().int(), text: z18.string(), slug: z18.string() }))
|
|
7470
|
+
headings: z18.array(z18.object({ depth: z18.number().int(), text: z18.string(), slug: z18.string() })),
|
|
7471
|
+
format: z18.literal("html").optional().describe("html for a designed document, document.html with its own stylesheets"),
|
|
7472
|
+
paper: z18.object({
|
|
7473
|
+
width: z18.number(),
|
|
7474
|
+
height: z18.number(),
|
|
7475
|
+
margin: z18.object({
|
|
7476
|
+
top: z18.number(),
|
|
7477
|
+
right: z18.number(),
|
|
7478
|
+
bottom: z18.number(),
|
|
7479
|
+
left: z18.number()
|
|
7480
|
+
})
|
|
7481
|
+
}).optional().describe("The sheet a designed document's @page rule sets, in CSS pixels: its size and margins"),
|
|
7482
|
+
holder: z18.object({
|
|
7483
|
+
objectTypeId: z18.string(),
|
|
7484
|
+
links: z18.array(z18.string()).describe("The holder's links its fields read through")
|
|
7485
|
+
}).optional().describe('The object a designed document shows live data of, as <meta name="sixb:object-type"> names its type: the one object of that type that holds the document')
|
|
7275
7486
|
});
|
|
7276
7487
|
var SheetOutlineSchema = z18.object({
|
|
7277
7488
|
kind: z18.literal("sheet"),
|
|
@@ -7354,8 +7565,28 @@ var ArtifactVersionSchema = z18.object({
|
|
|
7354
7565
|
updatedAt: z18.string().describe("When its content was last written"),
|
|
7355
7566
|
frozenAt: z18.string().optional().describe("When it was created, which froze it"),
|
|
7356
7567
|
frozenBy: PrincipalSchema.optional().describe("Who created it"),
|
|
7357
|
-
boardPreviews: z18.record(z18.string(), z18.enum(["ready", "pending", "none"])).optional().describe("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")
|
|
7568
|
+
boardPreviews: z18.record(z18.string(), z18.enum(["ready", "pending", "none"])).optional().describe("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"),
|
|
7569
|
+
printable: z18.boolean().optional().describe("true for a designed document in a project that prints to PDF: POST to its pdf route to print it, with the values whoever asks reads")
|
|
7570
|
+
});
|
|
7571
|
+
var ArtifactPdfKeySchema = z18.string().regex(/^sha256:[0-9a-f]{64}$/).describe("The values a document that shows live data prints: ask with it again, and get that PDF with it, whatever the values are by then");
|
|
7572
|
+
var ArtifactPdfResponseSchema = z18.discriminatedUnion("status", [
|
|
7573
|
+
z18.object({
|
|
7574
|
+
status: z18.literal("ready"),
|
|
7575
|
+
pages: z18.number().int().min(1).describe("How many pages it printed on"),
|
|
7576
|
+
key: ArtifactPdfKeySchema.optional()
|
|
7577
|
+
}),
|
|
7578
|
+
z18.object({ status: z18.literal("printing"), key: ArtifactPdfKeySchema.optional() }),
|
|
7579
|
+
z18.object({
|
|
7580
|
+
status: z18.literal("failed"),
|
|
7581
|
+
reason: z18.string().describe("Why it could not be printed"),
|
|
7582
|
+
key: ArtifactPdfKeySchema.optional()
|
|
7583
|
+
})
|
|
7584
|
+
]);
|
|
7585
|
+
var ArtifactPdfQuerySchema = z18.object({
|
|
7586
|
+
retry: z18.enum(["true", "false"]).optional().describe("true asks again for a PDF that could not be printed, instead of hearing why"),
|
|
7587
|
+
key: ArtifactPdfKeySchema.optional()
|
|
7358
7588
|
});
|
|
7589
|
+
var ArtifactPdfDownloadQuerySchema = z18.object({ key: ArtifactPdfKeySchema.optional() });
|
|
7359
7590
|
var ArtifactVersionSummarySchema = ArtifactVersionSchema.pick({
|
|
7360
7591
|
version: true,
|
|
7361
7592
|
revision: true,
|
|
@@ -7480,7 +7711,7 @@ var ArtifactFrameResponseSchema = z18.object({
|
|
|
7480
7711
|
expiresAt: z18.string().describe("When the frame stops serving; ask for a new one before then")
|
|
7481
7712
|
});
|
|
7482
7713
|
var ArtifactErrorResponseSchema = ErrorResponseSchema.extend({
|
|
7483
|
-
code: z18.string().optional().describe("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."),
|
|
7714
|
+
code: z18.string().optional().describe("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, holder_not_found (no one object of the type a designed document names that you read holds it), query_invalid (the ontology no longer admits the query), preview_not_found (the board has no preview yet, or will have none), pdf_not_found (the document is not printed yet: ask for it first), pdf_unavailable (the project has no sandboxes to print in), execution_lost (a run token's run ended or moved to another runner), or storage_unavailable."),
|
|
7484
7715
|
latest: z18.object({
|
|
7485
7716
|
version: z18.number().int(),
|
|
7486
7717
|
revision: z18.number().int(),
|
|
@@ -7809,7 +8040,8 @@ var EventExecutorSchema = z21.discriminatedUnion("type", [
|
|
|
7809
8040
|
z21.object({ type: z21.literal("ontology.recover"), recoveryId: z21.string() }),
|
|
7810
8041
|
z21.object({ type: z21.literal("ontology.indexVectors"), indexingId: z21.string() })
|
|
7811
8042
|
])
|
|
7812
|
-
})
|
|
8043
|
+
}),
|
|
8044
|
+
z21.object({ type: z21.literal("script"), runId: z21.string(), path: z21.string() })
|
|
7813
8045
|
]);
|
|
7814
8046
|
var StoredAuthorableEventBaseSchema = StoredEventBaseSchema.extend({
|
|
7815
8047
|
correlationId: z21.string().optional(),
|
|
@@ -10059,7 +10291,8 @@ async function versionResponse(host, version, options = {}) {
|
|
|
10059
10291
|
const statuses = stored && options.previews === false ? new Map([...stored.keys()].map((board) => [board, "none"])) : stored;
|
|
10060
10292
|
return {
|
|
10061
10293
|
...versionBody(version),
|
|
10062
|
-
...statuses ? { boardPreviews: Object.fromEntries(statuses) } : {}
|
|
10294
|
+
...statuses ? { boardPreviews: Object.fromEntries(statuses) } : {},
|
|
10295
|
+
...host.sandboxes && documentPdfKey(version) ? { printable: true } : {}
|
|
10063
10296
|
};
|
|
10064
10297
|
}
|
|
10065
10298
|
async function serializeChange(host, change) {
|
|
@@ -10141,6 +10374,7 @@ function handleArtifactRouteError(error, set) {
|
|
|
10141
10374
|
switch (error.code) {
|
|
10142
10375
|
case "artifact_not_found":
|
|
10143
10376
|
case "comment_not_found":
|
|
10377
|
+
case "holder_not_found":
|
|
10144
10378
|
case "query_not_found":
|
|
10145
10379
|
case "restore_point_not_found":
|
|
10146
10380
|
set.status = 404;
|
|
@@ -10165,6 +10399,7 @@ function handleArtifactRouteError(error, set) {
|
|
|
10165
10399
|
case "read_only":
|
|
10166
10400
|
set.status = 403;
|
|
10167
10401
|
break;
|
|
10402
|
+
case "pdf_unavailable":
|
|
10168
10403
|
case "storage_unavailable":
|
|
10169
10404
|
set.status = 501;
|
|
10170
10405
|
break;
|
|
@@ -10293,6 +10528,36 @@ async function artifactBoardPreviewResponse(host, context) {
|
|
|
10293
10528
|
return handleArtifactRouteError(error, context.set);
|
|
10294
10529
|
}
|
|
10295
10530
|
}
|
|
10531
|
+
async function artifactPdfResponse(host, context) {
|
|
10532
|
+
try {
|
|
10533
|
+
const { artifactId } = context.params;
|
|
10534
|
+
const number = versionParam(context.params.version);
|
|
10535
|
+
const sixb = requireRequestSixb(context);
|
|
10536
|
+
const version = await sixb.artifacts.getVersion(artifactId, number);
|
|
10537
|
+
if (!version)
|
|
10538
|
+
return await refusal2(context, artifactId, context.set);
|
|
10539
|
+
const pdf = await sixb.artifacts.pdf(artifactId, {
|
|
10540
|
+
version: number,
|
|
10541
|
+
print: false,
|
|
10542
|
+
...context.query.key ? { key: context.query.key } : {}
|
|
10543
|
+
});
|
|
10544
|
+
const response = pdf?.status === "ready" && await createFileContentResponse({
|
|
10545
|
+
blobStorage: host.blobStorage,
|
|
10546
|
+
fileRef: pdf.file,
|
|
10547
|
+
request: context.request,
|
|
10548
|
+
disposition: "attachment"
|
|
10549
|
+
});
|
|
10550
|
+
if (!response) {
|
|
10551
|
+
context.set.status = 404;
|
|
10552
|
+
context.set.headers["cache-control"] = "no-store";
|
|
10553
|
+
return { error: "PDF not found", code: "pdf_not_found" };
|
|
10554
|
+
}
|
|
10555
|
+
response.headers.set("cache-control", number !== "latest" && version.frozenAt ? "private, max-age=31536000, immutable" : "private, no-cache");
|
|
10556
|
+
return response;
|
|
10557
|
+
} catch (error) {
|
|
10558
|
+
return handleArtifactRouteError(error, context.set);
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10296
10561
|
function seesBoardPreviews(context, version) {
|
|
10297
10562
|
return !requestAuthState(context).sharedSession || !boardsReadLiveData(version);
|
|
10298
10563
|
}
|
|
@@ -10626,7 +10891,7 @@ function registerArtifactRoutes(app, host) {
|
|
|
10626
10891
|
},
|
|
10627
10892
|
detail: {
|
|
10628
10893
|
summary: "List an artifact's comments",
|
|
10629
|
-
description: "Every comment and reply, oldest first, resolved ones included. Whoever reads the artifact reads them.",
|
|
10894
|
+
description: "Every comment and reply, oldest first, resolved ones included. Whoever reads the artifact reads them; a shared link's guest reads only the threads started by a guest of the same link, with every reply in them.",
|
|
10630
10895
|
tags: [OPENAPI_TAGS.artifacts.name],
|
|
10631
10896
|
operationId: "listArtifactComments",
|
|
10632
10897
|
security: accessTokenSecurityRequirement("listArtifactComments")
|
|
@@ -10659,7 +10924,7 @@ function registerArtifactRoutes(app, host) {
|
|
|
10659
10924
|
},
|
|
10660
10925
|
detail: {
|
|
10661
10926
|
summary: "Comment on an artifact",
|
|
10662
|
-
description: "Adds a comment, or a reply with parentId, as the caller. Whoever reads the artifact may, a shared link's guest included, under the name they gave its session (400 name_required until they give one). A canvas's comment can be about one of its boards, or an element of a board by its address. Readers receive artifact.commented.",
|
|
10927
|
+
description: "Adds a comment, or a reply with parentId, as the caller. Whoever reads the artifact may, a shared link's guest included, under the name they gave its session (400 name_required until they give one), and replies only in a thread they read (404 comment_not_found otherwise). A canvas's comment can be about one of its boards, or an element of a board by its address. Readers of the thread receive artifact.commented.",
|
|
10663
10928
|
tags: [OPENAPI_TAGS.artifacts.name],
|
|
10664
10929
|
operationId: "addArtifactComment",
|
|
10665
10930
|
security: accessTokenSecurityRequirement("addArtifactComment")
|
|
@@ -10870,6 +11135,59 @@ function registerArtifactRoutes(app, host) {
|
|
|
10870
11135
|
operationId: "getArtifactVersion",
|
|
10871
11136
|
security: accessTokenSecurityRequirement("getArtifactVersion")
|
|
10872
11137
|
}
|
|
11138
|
+
}).post("/api/artifacts/:artifactId/versions/:version/pdf", async (context) => {
|
|
11139
|
+
try {
|
|
11140
|
+
const { artifactId } = context.params;
|
|
11141
|
+
const pdf = await requireRequestSixb(context).artifacts.pdf(artifactId, {
|
|
11142
|
+
version: versionParam(context.params.version),
|
|
11143
|
+
retry: context.query.retry === "true",
|
|
11144
|
+
...context.query.key ? { key: context.query.key } : {}
|
|
11145
|
+
});
|
|
11146
|
+
if (!pdf)
|
|
11147
|
+
return await refusal2(context, artifactId, context.set);
|
|
11148
|
+
if (pdf.status !== "ready")
|
|
11149
|
+
return pdf;
|
|
11150
|
+
const { file: _file, ...ready } = pdf;
|
|
11151
|
+
return ready;
|
|
11152
|
+
} catch (error) {
|
|
11153
|
+
return handleArtifactRouteError(error, context.set);
|
|
11154
|
+
}
|
|
11155
|
+
}, {
|
|
11156
|
+
params: ArtifactVersionParamsSchema,
|
|
11157
|
+
query: ArtifactPdfQuerySchema,
|
|
11158
|
+
response: {
|
|
11159
|
+
200: ArtifactPdfResponseSchema,
|
|
11160
|
+
400: ArtifactErrorResponseSchema,
|
|
11161
|
+
403: ArtifactErrorResponseSchema,
|
|
11162
|
+
404: ArtifactErrorResponseSchema,
|
|
11163
|
+
501: ArtifactErrorResponseSchema
|
|
11164
|
+
},
|
|
11165
|
+
detail: {
|
|
11166
|
+
summary: "Print a designed document to PDF",
|
|
11167
|
+
description: "Answers ready once the version is printed, and printing until then, having asked for it: ask again after a few seconds, then get it. Failed with why when it could not be printed; retry=true asks again. A document that shows live data answers with a key: ask again and get it with that key, which names the values the first ask printed. It prints as its stylesheets' @page rule lays it out, in a sandbox of the project. Whoever reads the artifact may ask. 400 invalid_artifact when the version is not a designed document; 501 pdf_unavailable in a project without sandboxes.",
|
|
11168
|
+
tags: [OPENAPI_TAGS.artifacts.name],
|
|
11169
|
+
operationId: "printArtifactPdf",
|
|
11170
|
+
security: accessTokenSecurityRequirement("printArtifactPdf")
|
|
11171
|
+
}
|
|
11172
|
+
}).get("/api/artifacts/:artifactId/versions/:version/pdf", async (context) => artifactPdfResponse(host, context), {
|
|
11173
|
+
params: ArtifactVersionParamsSchema,
|
|
11174
|
+
query: ArtifactPdfDownloadQuerySchema,
|
|
11175
|
+
detail: {
|
|
11176
|
+
summary: "Get a designed document's PDF",
|
|
11177
|
+
description: "The version printed to PDF, with the values its fields read as the caller reads them, as a download named after the title it printed with: for a document that shows live data, those its POST's key names. 404 pdf_not_found until it is printed: ask for it with POST first. A frozen version's PDF never changes, and is cached as such.",
|
|
11178
|
+
tags: [OPENAPI_TAGS.artifacts.name],
|
|
11179
|
+
operationId: "getArtifactPdf",
|
|
11180
|
+
security: accessTokenSecurityRequirement("getArtifactPdf"),
|
|
11181
|
+
responses: {
|
|
11182
|
+
200: {
|
|
11183
|
+
description: "The PDF",
|
|
11184
|
+
content: { "application/pdf": { schema: { type: "string", format: "binary" } } }
|
|
11185
|
+
},
|
|
11186
|
+
304: { description: "The PDF is unchanged; reuse the privately cached one" },
|
|
11187
|
+
403: artifactErrorResponse(403),
|
|
11188
|
+
404: artifactErrorResponse(404)
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
10873
11191
|
}).get("/api/artifacts/:artifactId/versions/:version/boards/:board/preview", async (context) => artifactBoardPreviewResponse(host, context), {
|
|
10874
11192
|
params: ArtifactBoardPreviewParamsSchema,
|
|
10875
11193
|
query: ArtifactBoardPreviewQuerySchema,
|
|
@@ -10910,7 +11228,7 @@ function registerArtifactRoutes(app, host) {
|
|
|
10910
11228
|
params: ArtifactQueryParamsSchema,
|
|
10911
11229
|
detail: {
|
|
10912
11230
|
summary: "Run an artifact's query",
|
|
10913
|
-
description: `Runs the version's queries/<name>.json as the caller, with their rights: a type they cannot view is refused with 403, and a marked property they are not cleared for is left out of each row. Rows are serialized as POST /api/objects/query returns them, beside the schema of what they hold as the caller may view it. Use "latest" for the newest version. A query the ontology no longer admits is refused with 409 query_invalid.`,
|
|
11231
|
+
description: `Runs the version's queries/<name>.json as the caller, with their rights: a type they cannot view is refused with 403, and a marked property they are not cleared for is left out of each row. Rows are serialized as POST /api/objects/query returns them, beside the schema of what they hold as the caller may view it. Use "latest" for the newest version. A query the ontology no longer admits is refused with 409 query_invalid. A designed document's "holder" is the object that holds it, of the type it names, with the links its fields read through: 404 holder_not_found when no one such object the caller reads holds it.`,
|
|
10914
11232
|
tags: [OPENAPI_TAGS.artifacts.name],
|
|
10915
11233
|
operationId: "getArtifactQuery",
|
|
10916
11234
|
security: accessTokenSecurityRequirement("getArtifactQuery"),
|
|
@@ -13865,6 +14183,7 @@ var ObjectProjectionSchema = z33.object({
|
|
|
13865
14183
|
users: z33.record(z33.enum(["email", "id"])).optional(),
|
|
13866
14184
|
links: z33.record(ForeignKeyDescriptorSchema),
|
|
13867
14185
|
conflictResolution: SourceEditConflictResolutionSchema,
|
|
14186
|
+
missing: z33.literal("remove").optional(),
|
|
13868
14187
|
latestRun: ProjectionRunSchema.nullable()
|
|
13869
14188
|
});
|
|
13870
14189
|
var LinkProjectionSchema = z33.object({
|
|
@@ -19677,9 +19996,11 @@ import {
|
|
|
19677
19996
|
AGENT_PRESENCE_MS,
|
|
19678
19997
|
artifactLiveStream,
|
|
19679
19998
|
artifactPresenceStream,
|
|
19999
|
+
keepsDocument,
|
|
19680
20000
|
loadArtifactDocument,
|
|
19681
20001
|
mergeIntoDocument,
|
|
19682
20002
|
parseArtifactLiveRecord,
|
|
20003
|
+
readChange,
|
|
19683
20004
|
readDocumentState,
|
|
19684
20005
|
readLiveFiles,
|
|
19685
20006
|
sameArtifactFiles,
|
|
@@ -19721,6 +20042,7 @@ class LiveRoom {
|
|
|
19721
20042
|
shadow;
|
|
19722
20043
|
state = "saved";
|
|
19723
20044
|
error;
|
|
20045
|
+
refused = false;
|
|
19724
20046
|
failure;
|
|
19725
20047
|
attempts = 0;
|
|
19726
20048
|
idle;
|
|
@@ -19753,7 +20075,7 @@ class LiveRoom {
|
|
|
19753
20075
|
const artifact = await storage.get({ projectId: host.projectId, id: artifactId });
|
|
19754
20076
|
if (!artifact)
|
|
19755
20077
|
return "not_found";
|
|
19756
|
-
if (artifact.kind
|
|
20078
|
+
if (!keepsDocument(artifact.kind))
|
|
19757
20079
|
return "not_live";
|
|
19758
20080
|
const version = await storage.getVersion({
|
|
19759
20081
|
projectId: host.projectId,
|
|
@@ -20002,6 +20324,7 @@ class LiveRoom {
|
|
|
20002
20324
|
this.savedSnapshot = written;
|
|
20003
20325
|
this.attempts = 0;
|
|
20004
20326
|
this.error = undefined;
|
|
20327
|
+
this.refused = false;
|
|
20005
20328
|
this.failure = undefined;
|
|
20006
20329
|
this.setState(this.dirty ? "unsaved" : "saved", true);
|
|
20007
20330
|
if (this.dirty && !this.idle)
|
|
@@ -20012,8 +20335,9 @@ class LiveRoom {
|
|
|
20012
20335
|
this.attempts += 1;
|
|
20013
20336
|
this.error = error instanceof Error ? error.message : String(error);
|
|
20014
20337
|
this.failure = error;
|
|
20015
|
-
this.setState("failed", true);
|
|
20016
20338
|
const code = error instanceof ArtifactRequestError2 ? error.code : undefined;
|
|
20339
|
+
this.refused = code === "invalid_artifact";
|
|
20340
|
+
this.setState("failed", true);
|
|
20017
20341
|
if (code === "artifact_not_found") {
|
|
20018
20342
|
for (const member of [...this.members.values()]) {
|
|
20019
20343
|
member.connection.send({ type: "left", artifactId: this.artifactId, reason: "not_found" });
|
|
@@ -20120,8 +20444,7 @@ class LiveRoom {
|
|
|
20120
20444
|
}
|
|
20121
20445
|
readable(bytes) {
|
|
20122
20446
|
try {
|
|
20123
|
-
syncProtocol.readSyncMessage(decoding2.createDecoder(bytes), encoding2.createEncoder(), this.shadow, null);
|
|
20124
|
-
documentFiles(this.shadow);
|
|
20447
|
+
readChange(this.shadow, () => syncProtocol.readSyncMessage(decoding2.createDecoder(bytes), encoding2.createEncoder(), this.shadow, null));
|
|
20125
20448
|
return true;
|
|
20126
20449
|
} catch {
|
|
20127
20450
|
this.shadow.destroy();
|
|
@@ -20316,7 +20639,8 @@ class LiveRoom {
|
|
|
20316
20639
|
state: this.state,
|
|
20317
20640
|
revision: this.synced.revision,
|
|
20318
20641
|
snapshot: encodeLiveData(this.savedSnapshot),
|
|
20319
|
-
...this.state === "failed" && this.error ? { error: this.error } : {}
|
|
20642
|
+
...this.state === "failed" && this.error ? { error: this.error } : {},
|
|
20643
|
+
...this.state === "failed" && this.refused ? { refused: true } : {}
|
|
20320
20644
|
};
|
|
20321
20645
|
}
|
|
20322
20646
|
setState(state, announce = false) {
|
|
@@ -21566,7 +21890,7 @@ function createSixbApi(server) {
|
|
|
21566
21890
|
maxAge: 600
|
|
21567
21891
|
}));
|
|
21568
21892
|
const serveRunnerSession = agentRunSessionHandler(host);
|
|
21569
|
-
app.onRequest(async ({ request }) => await serveRunnerSession(request) ?? undefined);
|
|
21893
|
+
app.onRequest(async ({ request, server }) => await serveRunnerSession(request, server) ?? undefined);
|
|
21570
21894
|
app.onRequest(async ({ request }) => {
|
|
21571
21895
|
const runToken = requestRunToken(request);
|
|
21572
21896
|
if (runToken === undefined)
|
|
@@ -21821,4 +22145,4 @@ export {
|
|
|
21821
22145
|
requestTimingOptionsFromEnv
|
|
21822
22146
|
};
|
|
21823
22147
|
|
|
21824
|
-
//# debugId=
|
|
22148
|
+
//# debugId=39E8C6B2A92C4BF064756E2164756E21
|