@sixb/server 0.1.8 → 0.1.10
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 +56 -38
- package/dist/index.js.map +11 -11
- package/dist/routes/connector-connection-runs.d.ts.map +1 -1
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +2 -2
- package/dist/routes/projections.d.ts +24 -0
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +6 -6
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/schemas/ai-accounting.d.ts +332 -24
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/common.d.ts +6 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/logs.d.ts +18 -18
- package/dist/schemas/projections.d.ts +243 -0
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +16 -16
- package/package.json +7 -7
- package/src/routes/agents.ts +1 -1
- package/src/routes/connector-connection-runs.ts +12 -3
- package/src/routes/files.ts +2 -6
- package/src/routes/webhooks.ts +15 -3
- package/src/routes/ws/agents.ts +5 -3
- package/src/routes/ws/events.ts +1 -1
- package/src/schemas/ai-accounting.ts +3 -0
- package/src/schemas/common.ts +2 -0
- package/src/schemas/projections.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1417,6 +1417,8 @@ function sixbFailureSchema(codes) {
|
|
|
1417
1417
|
retryable: z.boolean(),
|
|
1418
1418
|
at: z.string().datetime(),
|
|
1419
1419
|
details: JsonValueSchema.optional(),
|
|
1420
|
+
httpStatus: z.number().int().min(100).max(599).optional(),
|
|
1421
|
+
redacted: z.literal(true).optional(),
|
|
1420
1422
|
truncated: z.literal(true).optional()
|
|
1421
1423
|
});
|
|
1422
1424
|
}
|
|
@@ -2148,11 +2150,8 @@ import {
|
|
|
2148
2150
|
SYSTEM_PRINCIPAL
|
|
2149
2151
|
} from "@sixb/core";
|
|
2150
2152
|
import { computeBlobDigest, supportsDirectUpload } from "@sixb/core/blob-storage/server";
|
|
2151
|
-
import {
|
|
2152
|
-
|
|
2153
|
-
createUploadExpiresAt,
|
|
2154
|
-
FileUploadSessionError as FileUploadSessionError2
|
|
2155
|
-
} from "@sixb/core/storage";
|
|
2153
|
+
import { createFileUploadId, createUploadExpiresAt } from "@sixb/core/internal/storage";
|
|
2154
|
+
import { FileUploadSessionError as FileUploadSessionError2 } from "@sixb/core/storage";
|
|
2156
2155
|
var DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES = DEFAULT_SIMPLE_FILE_UPLOAD_BYTES + 1024 * 1024;
|
|
2157
2156
|
function registerFileRoutes(app, host) {
|
|
2158
2157
|
const uploadSessions = host.storage.fileUploadSessions ?? new InMemoryFileUploadSessions;
|
|
@@ -2753,13 +2752,13 @@ function toGatewayRunState(storedRun, workflowRun) {
|
|
|
2753
2752
|
};
|
|
2754
2753
|
}
|
|
2755
2754
|
if (storedRun?.kind === "conversation") {
|
|
2756
|
-
const
|
|
2755
|
+
const common = {
|
|
2757
2756
|
run: storedRun,
|
|
2758
2757
|
runId: storedRun.id,
|
|
2759
2758
|
agentExecution: { kind: "conversation", runId: storedRun.id },
|
|
2760
2759
|
agentRun: storedRun
|
|
2761
2760
|
};
|
|
2762
|
-
return { ...
|
|
2761
|
+
return { ...common, authority: "inherited" };
|
|
2763
2762
|
}
|
|
2764
2763
|
if (!workflowRun)
|
|
2765
2764
|
return null;
|
|
@@ -2772,19 +2771,19 @@ function toGatewayRunState(storedRun, workflowRun) {
|
|
|
2772
2771
|
}
|
|
2773
2772
|
async function resolveGatewayRunAuthorization(input) {
|
|
2774
2773
|
if (input.runState.authority === "inherited") {
|
|
2775
|
-
const
|
|
2774
|
+
const resolved = await resolveInheritedAgentExecutionAuthorization({
|
|
2776
2775
|
auth: input.auth,
|
|
2777
2776
|
projectId: input.host.id,
|
|
2778
2777
|
authorizationRef: input.execution.authorizationRef,
|
|
2779
2778
|
security: input.host.definitions.security
|
|
2780
2779
|
});
|
|
2781
|
-
const
|
|
2780
|
+
const authorization = inheritedRequestAuthorization(resolved, input.execution.authorizationRef);
|
|
2782
2781
|
assertAgentExecutionRecord({
|
|
2783
2782
|
execution: input.execution,
|
|
2784
2783
|
runId: input.runState.runId,
|
|
2785
|
-
authorization
|
|
2784
|
+
authorization
|
|
2786
2785
|
});
|
|
2787
|
-
return
|
|
2786
|
+
return authorization;
|
|
2788
2787
|
}
|
|
2789
2788
|
const resolved = await resolveAgentExecutionAuthorization({
|
|
2790
2789
|
auth: input.auth,
|
|
@@ -2886,8 +2885,8 @@ class PayloadTooLargeError extends Error {
|
|
|
2886
2885
|
|
|
2887
2886
|
// src/routes/agents.ts
|
|
2888
2887
|
import { AgentRequestError } from "@sixb/core";
|
|
2889
|
-
import { agentRunStreamId } from "@sixb/core/agents/streams";
|
|
2890
2888
|
import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/internal/agents";
|
|
2889
|
+
import { agentRunStreamId } from "@sixb/core/internal/agents/streams";
|
|
2891
2890
|
import {
|
|
2892
2891
|
AgentStorageError
|
|
2893
2892
|
} from "@sixb/core/storage";
|
|
@@ -3121,6 +3120,9 @@ var AiModelCallUsageRecordSchema = z8.object({
|
|
|
3121
3120
|
var AiModelCallAccountingItemSchema = z8.object({
|
|
3122
3121
|
usage: AiModelCallUsageRecordSchema,
|
|
3123
3122
|
attribution: z8.discriminatedUnion("kind", [
|
|
3123
|
+
z8.object({ kind: z8.literal("request"), requestId: z8.string() }),
|
|
3124
|
+
z8.object({ kind: z8.literal("action"), actionId: z8.string(), actionRunId: z8.string() }),
|
|
3125
|
+
z8.object({ kind: z8.literal("workflow"), workflowId: z8.string(), workflowRunId: z8.string() }),
|
|
3124
3126
|
z8.object({
|
|
3125
3127
|
kind: z8.literal("agent"),
|
|
3126
3128
|
agentRunId: z8.string(),
|
|
@@ -5035,16 +5037,21 @@ function registerConnectorConnectionRunRoutes(app, host, options) {
|
|
|
5035
5037
|
operationId: "reauthorizeConnectorConnection",
|
|
5036
5038
|
security: SIXB_CSRF_SECURITY_REQUIREMENT
|
|
5037
5039
|
}
|
|
5038
|
-
}).get("/auth/connectors/callback", async ({
|
|
5040
|
+
}).get("/auth/connectors/callback", async ({ request, set }) => {
|
|
5039
5041
|
let callbackCookie;
|
|
5040
5042
|
try {
|
|
5041
|
-
const
|
|
5043
|
+
const parameters = new URL(request.url).searchParams;
|
|
5044
|
+
const callbackParameters = Object.fromEntries([...new Set(parameters.keys())].map((name) => {
|
|
5045
|
+
const values = parameters.getAll(name);
|
|
5046
|
+
return [name, values.length === 1 ? values[0] : values];
|
|
5047
|
+
}));
|
|
5048
|
+
const parsed = ConnectorOAuthCallbackQuerySchema.parse(callbackParameters);
|
|
5042
5049
|
callbackCookie = readConnectorCallbackCookie(request, parsed.state);
|
|
5043
5050
|
const result = await getConnectorConnectionCallbackProcess(host).completeConnectionRun({
|
|
5044
5051
|
state: parsed.state,
|
|
5045
5052
|
redirectUri: options.resolveCallbackUrl(request),
|
|
5046
5053
|
callbackBinding: callbackCookie.value ?? "",
|
|
5047
|
-
...parsed.code === undefined ? { error: parsed.error } : { code: parsed.code }
|
|
5054
|
+
...parsed.code === undefined ? { error: parsed.error } : { code: parsed.code, callbackParameters }
|
|
5048
5055
|
});
|
|
5049
5056
|
return connectorCallbackRedirect(result.returnTo, result.connectorId, result.runId, clearConnectorCallbackCookie(request, callbackCookie.name));
|
|
5050
5057
|
} catch (error) {
|
|
@@ -7950,7 +7957,8 @@ var ProjectionRunBaseSchema = z22.object({
|
|
|
7950
7957
|
attempt: z22.number(),
|
|
7951
7958
|
progress: z22.object({
|
|
7952
7959
|
sourceRowsRead: z22.number(),
|
|
7953
|
-
sourceRowsSkipped: z22.number()
|
|
7960
|
+
sourceRowsSkipped: z22.number(),
|
|
7961
|
+
sourceChangesRead: z22.number().optional()
|
|
7954
7962
|
}),
|
|
7955
7963
|
queuedAt: z22.string(),
|
|
7956
7964
|
startedAt: z22.string().optional(),
|
|
@@ -10233,13 +10241,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10233
10241
|
if (!tx.workflowInterventions || !tx.workflowRuns) {
|
|
10234
10242
|
throw new Error("[SixbServer] Workflow storage disappeared during cancellation.");
|
|
10235
10243
|
}
|
|
10236
|
-
const
|
|
10244
|
+
const cancelled = await tx.workflowInterventions.cancel({
|
|
10237
10245
|
projectId: host.id,
|
|
10238
10246
|
id: intervention.id,
|
|
10239
10247
|
cancelledAt,
|
|
10240
10248
|
cancelledBy: serializePrincipal(principalForExecution(sixb))
|
|
10241
10249
|
});
|
|
10242
|
-
const
|
|
10250
|
+
const cancelledNode = await tx.workflowRuns.nodes.finish({
|
|
10243
10251
|
projectId: host.id,
|
|
10244
10252
|
id: intervention.nodeRunId,
|
|
10245
10253
|
status: "cancelled",
|
|
@@ -10252,7 +10260,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10252
10260
|
nodeRunId: intervention.nodeRunId
|
|
10253
10261
|
})
|
|
10254
10262
|
});
|
|
10255
|
-
const
|
|
10263
|
+
const cancelledRun = await tx.workflowRuns.finish({
|
|
10256
10264
|
projectId: host.id,
|
|
10257
10265
|
id: intervention.workflowRunId,
|
|
10258
10266
|
status: "cancelled",
|
|
@@ -10264,7 +10272,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10264
10272
|
runId: intervention.workflowRunId
|
|
10265
10273
|
})
|
|
10266
10274
|
});
|
|
10267
|
-
return { cancelled
|
|
10275
|
+
return { cancelled, cancelledNode, cancelledRun };
|
|
10268
10276
|
});
|
|
10269
10277
|
await emitWorkflowInterventionCancelled({
|
|
10270
10278
|
host,
|
|
@@ -10440,13 +10448,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10440
10448
|
return { error: "Workflow not found" };
|
|
10441
10449
|
}
|
|
10442
10450
|
if (existing.status === "cancelled") {
|
|
10443
|
-
const
|
|
10444
|
-
if (!
|
|
10451
|
+
const nodes = await sixb.workflows.runs.listNodes(existing.id, { order: "asc" });
|
|
10452
|
+
if (!nodes) {
|
|
10445
10453
|
throw new Error(`[SixbServer] Authorized workflow run '${existing.id}' lost its execution view.`);
|
|
10446
10454
|
}
|
|
10447
10455
|
return CancelWorkflowRunResponseSchema.parse({
|
|
10448
10456
|
run: serializeWorkflowRunDetail(existing),
|
|
10449
|
-
nodes:
|
|
10457
|
+
nodes: nodes.nodes.map(serializeWorkflowNodeRun)
|
|
10450
10458
|
});
|
|
10451
10459
|
}
|
|
10452
10460
|
if (existing.status === "succeeded" || existing.status === "failed") {
|
|
@@ -12973,7 +12981,11 @@ import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
|
12973
12981
|
import { reportRunFailure } from "@sixb/core/internal/error-reporting";
|
|
12974
12982
|
import { captureSixbFailure, createSixbError as createSixbError5, toSixbFailure as toSixbFailure2 } from "@sixb/core/internal/errors";
|
|
12975
12983
|
import { bindDurablePrimitiveExecution } from "@sixb/core/internal/primitive-execution";
|
|
12976
|
-
import {
|
|
12984
|
+
import {
|
|
12985
|
+
admitWebhookRun,
|
|
12986
|
+
createWebhookConnections,
|
|
12987
|
+
isStaticConnectorDefinition
|
|
12988
|
+
} from "@sixb/core/internal/webhooks";
|
|
12977
12989
|
import { WEBHOOK_RUN_FAILURE_CODES as WEBHOOK_RUN_FAILURE_CODES2, WebhookRunError } from "@sixb/core/storage";
|
|
12978
12990
|
var DEFAULT_WEBHOOK_BODY_LIMIT_BYTES = 1024 * 1024;
|
|
12979
12991
|
function registerWebhookRoutes(app, host) {
|
|
@@ -13109,10 +13121,11 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
13109
13121
|
rawBody: prepared.rawBody,
|
|
13110
13122
|
body: prepared.body,
|
|
13111
13123
|
logger,
|
|
13112
|
-
client: createClientResolver(execution.sixb, connector)
|
|
13124
|
+
client: createClientResolver(execution.sixb, connector),
|
|
13125
|
+
connections: createWebhookConnections(execution.sixb.connector, connector)
|
|
13113
13126
|
});
|
|
13114
13127
|
} catch (error) {
|
|
13115
|
-
const
|
|
13128
|
+
const failed = createWebhookRunFailure({
|
|
13116
13129
|
registered,
|
|
13117
13130
|
runId,
|
|
13118
13131
|
idempotencyKey: prepared.idempotencyKey,
|
|
@@ -13120,13 +13133,13 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
13120
13133
|
message: "Webhook handler failed",
|
|
13121
13134
|
cause: error
|
|
13122
13135
|
});
|
|
13123
|
-
reportFailure(
|
|
13136
|
+
reportFailure(failed.error, failed.failure);
|
|
13124
13137
|
try {
|
|
13125
13138
|
await finishWebhookRun(host, {
|
|
13126
13139
|
runId,
|
|
13127
13140
|
status: "failed",
|
|
13128
13141
|
responseStatus: 500,
|
|
13129
|
-
failure:
|
|
13142
|
+
failure: failed.failure
|
|
13130
13143
|
});
|
|
13131
13144
|
} catch (_finalizationError) {}
|
|
13132
13145
|
set.status = 500;
|
|
@@ -13222,6 +13235,9 @@ function parseWebhookBody(webhook, rawBody) {
|
|
|
13222
13235
|
function createClientResolver(sixb, connector) {
|
|
13223
13236
|
let clientPromise = null;
|
|
13224
13237
|
return () => {
|
|
13238
|
+
if (!isStaticConnectorDefinition(connector)) {
|
|
13239
|
+
throw createSixbError5("connector.configuration_invalid", "[SixbServer] OAuth webhook clients require connections.forAccount(accountId), then target.client().");
|
|
13240
|
+
}
|
|
13225
13241
|
clientPromise ??= sixb.connector(connector);
|
|
13226
13242
|
return clientPromise;
|
|
13227
13243
|
};
|
|
@@ -13258,12 +13274,14 @@ function isWebhookResponse(value) {
|
|
|
13258
13274
|
// src/routes/ws/agents.ts
|
|
13259
13275
|
import {
|
|
13260
13276
|
AGENT_ACTIVITY_STREAM_ID,
|
|
13261
|
-
agentActivityStreamDefinition,
|
|
13262
|
-
agentRunStreamDefinition,
|
|
13263
|
-
agentRunStreamId as agentRunStreamId2,
|
|
13264
13277
|
isAgentRunActivityEvent
|
|
13265
13278
|
} from "@sixb/core/agents/streams";
|
|
13266
13279
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
13280
|
+
import {
|
|
13281
|
+
agentActivityStreamDefinition,
|
|
13282
|
+
agentRunStreamDefinition,
|
|
13283
|
+
agentRunStreamId as agentRunStreamId2
|
|
13284
|
+
} from "@sixb/core/internal/agents/streams";
|
|
13267
13285
|
import { z as z33 } from "zod";
|
|
13268
13286
|
|
|
13269
13287
|
// src/utils/ws.ts
|
|
@@ -13626,7 +13644,7 @@ function errorMessage(error) {
|
|
|
13626
13644
|
}
|
|
13627
13645
|
|
|
13628
13646
|
// src/routes/ws/events.ts
|
|
13629
|
-
import { scopeKeysForEvent } from "@sixb/core/
|
|
13647
|
+
import { scopeKeysForEvent } from "@sixb/core/internal/event-scope";
|
|
13630
13648
|
import { z as z34 } from "zod";
|
|
13631
13649
|
var SubscribeSchema2 = z34.object({
|
|
13632
13650
|
type: z34.literal("subscribe"),
|
|
@@ -14082,13 +14100,13 @@ class LogSubscriptionHub {
|
|
|
14082
14100
|
this.scheduleFlush(state);
|
|
14083
14101
|
}
|
|
14084
14102
|
waitForQueueProgress(state) {
|
|
14085
|
-
return new Promise((
|
|
14103
|
+
return new Promise((resolve) => state.queueProgressWaiters.add(resolve));
|
|
14086
14104
|
}
|
|
14087
14105
|
notifyQueueProgress(state) {
|
|
14088
14106
|
const waiters = [...state.queueProgressWaiters];
|
|
14089
14107
|
state.queueProgressWaiters.clear();
|
|
14090
|
-
for (const
|
|
14091
|
-
|
|
14108
|
+
for (const resolve of waiters)
|
|
14109
|
+
resolve();
|
|
14092
14110
|
}
|
|
14093
14111
|
send(state, payload) {
|
|
14094
14112
|
if (state.closed)
|
|
@@ -14608,8 +14626,8 @@ function attachBunServer(app, bunServer) {
|
|
|
14608
14626
|
app.server = bunServer;
|
|
14609
14627
|
}
|
|
14610
14628
|
export {
|
|
14611
|
-
|
|
14612
|
-
|
|
14629
|
+
SixbServer,
|
|
14630
|
+
createSixbServer
|
|
14613
14631
|
};
|
|
14614
14632
|
|
|
14615
|
-
//# debugId=
|
|
14633
|
+
//# debugId=168374855DD168B264756E2164756E21
|