@sixb/server 0.1.8 → 0.1.9
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 +36 -32
- package/dist/index.js.map +8 -8
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +2 -2
- 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/workflows.d.ts +16 -16
- package/package.json +7 -7
- package/src/routes/agents.ts +1 -1
- package/src/routes/files.ts +2 -6
- 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/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(),
|
|
@@ -10233,13 +10235,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10233
10235
|
if (!tx.workflowInterventions || !tx.workflowRuns) {
|
|
10234
10236
|
throw new Error("[SixbServer] Workflow storage disappeared during cancellation.");
|
|
10235
10237
|
}
|
|
10236
|
-
const
|
|
10238
|
+
const cancelled = await tx.workflowInterventions.cancel({
|
|
10237
10239
|
projectId: host.id,
|
|
10238
10240
|
id: intervention.id,
|
|
10239
10241
|
cancelledAt,
|
|
10240
10242
|
cancelledBy: serializePrincipal(principalForExecution(sixb))
|
|
10241
10243
|
});
|
|
10242
|
-
const
|
|
10244
|
+
const cancelledNode = await tx.workflowRuns.nodes.finish({
|
|
10243
10245
|
projectId: host.id,
|
|
10244
10246
|
id: intervention.nodeRunId,
|
|
10245
10247
|
status: "cancelled",
|
|
@@ -10252,7 +10254,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10252
10254
|
nodeRunId: intervention.nodeRunId
|
|
10253
10255
|
})
|
|
10254
10256
|
});
|
|
10255
|
-
const
|
|
10257
|
+
const cancelledRun = await tx.workflowRuns.finish({
|
|
10256
10258
|
projectId: host.id,
|
|
10257
10259
|
id: intervention.workflowRunId,
|
|
10258
10260
|
status: "cancelled",
|
|
@@ -10264,7 +10266,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10264
10266
|
runId: intervention.workflowRunId
|
|
10265
10267
|
})
|
|
10266
10268
|
});
|
|
10267
|
-
return { cancelled
|
|
10269
|
+
return { cancelled, cancelledNode, cancelledRun };
|
|
10268
10270
|
});
|
|
10269
10271
|
await emitWorkflowInterventionCancelled({
|
|
10270
10272
|
host,
|
|
@@ -10440,13 +10442,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
10440
10442
|
return { error: "Workflow not found" };
|
|
10441
10443
|
}
|
|
10442
10444
|
if (existing.status === "cancelled") {
|
|
10443
|
-
const
|
|
10444
|
-
if (!
|
|
10445
|
+
const nodes = await sixb.workflows.runs.listNodes(existing.id, { order: "asc" });
|
|
10446
|
+
if (!nodes) {
|
|
10445
10447
|
throw new Error(`[SixbServer] Authorized workflow run '${existing.id}' lost its execution view.`);
|
|
10446
10448
|
}
|
|
10447
10449
|
return CancelWorkflowRunResponseSchema.parse({
|
|
10448
10450
|
run: serializeWorkflowRunDetail(existing),
|
|
10449
|
-
nodes:
|
|
10451
|
+
nodes: nodes.nodes.map(serializeWorkflowNodeRun)
|
|
10450
10452
|
});
|
|
10451
10453
|
}
|
|
10452
10454
|
if (existing.status === "succeeded" || existing.status === "failed") {
|
|
@@ -13112,7 +13114,7 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
13112
13114
|
client: createClientResolver(execution.sixb, connector)
|
|
13113
13115
|
});
|
|
13114
13116
|
} catch (error) {
|
|
13115
|
-
const
|
|
13117
|
+
const failed = createWebhookRunFailure({
|
|
13116
13118
|
registered,
|
|
13117
13119
|
runId,
|
|
13118
13120
|
idempotencyKey: prepared.idempotencyKey,
|
|
@@ -13120,13 +13122,13 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
13120
13122
|
message: "Webhook handler failed",
|
|
13121
13123
|
cause: error
|
|
13122
13124
|
});
|
|
13123
|
-
reportFailure(
|
|
13125
|
+
reportFailure(failed.error, failed.failure);
|
|
13124
13126
|
try {
|
|
13125
13127
|
await finishWebhookRun(host, {
|
|
13126
13128
|
runId,
|
|
13127
13129
|
status: "failed",
|
|
13128
13130
|
responseStatus: 500,
|
|
13129
|
-
failure:
|
|
13131
|
+
failure: failed.failure
|
|
13130
13132
|
});
|
|
13131
13133
|
} catch (_finalizationError) {}
|
|
13132
13134
|
set.status = 500;
|
|
@@ -13258,12 +13260,14 @@ function isWebhookResponse(value) {
|
|
|
13258
13260
|
// src/routes/ws/agents.ts
|
|
13259
13261
|
import {
|
|
13260
13262
|
AGENT_ACTIVITY_STREAM_ID,
|
|
13261
|
-
agentActivityStreamDefinition,
|
|
13262
|
-
agentRunStreamDefinition,
|
|
13263
|
-
agentRunStreamId as agentRunStreamId2,
|
|
13264
13263
|
isAgentRunActivityEvent
|
|
13265
13264
|
} from "@sixb/core/agents/streams";
|
|
13266
13265
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
13266
|
+
import {
|
|
13267
|
+
agentActivityStreamDefinition,
|
|
13268
|
+
agentRunStreamDefinition,
|
|
13269
|
+
agentRunStreamId as agentRunStreamId2
|
|
13270
|
+
} from "@sixb/core/internal/agents/streams";
|
|
13267
13271
|
import { z as z33 } from "zod";
|
|
13268
13272
|
|
|
13269
13273
|
// src/utils/ws.ts
|
|
@@ -13626,7 +13630,7 @@ function errorMessage(error) {
|
|
|
13626
13630
|
}
|
|
13627
13631
|
|
|
13628
13632
|
// src/routes/ws/events.ts
|
|
13629
|
-
import { scopeKeysForEvent } from "@sixb/core/
|
|
13633
|
+
import { scopeKeysForEvent } from "@sixb/core/internal/event-scope";
|
|
13630
13634
|
import { z as z34 } from "zod";
|
|
13631
13635
|
var SubscribeSchema2 = z34.object({
|
|
13632
13636
|
type: z34.literal("subscribe"),
|
|
@@ -14082,13 +14086,13 @@ class LogSubscriptionHub {
|
|
|
14082
14086
|
this.scheduleFlush(state);
|
|
14083
14087
|
}
|
|
14084
14088
|
waitForQueueProgress(state) {
|
|
14085
|
-
return new Promise((
|
|
14089
|
+
return new Promise((resolve) => state.queueProgressWaiters.add(resolve));
|
|
14086
14090
|
}
|
|
14087
14091
|
notifyQueueProgress(state) {
|
|
14088
14092
|
const waiters = [...state.queueProgressWaiters];
|
|
14089
14093
|
state.queueProgressWaiters.clear();
|
|
14090
|
-
for (const
|
|
14091
|
-
|
|
14094
|
+
for (const resolve of waiters)
|
|
14095
|
+
resolve();
|
|
14092
14096
|
}
|
|
14093
14097
|
send(state, payload) {
|
|
14094
14098
|
if (state.closed)
|
|
@@ -14608,8 +14612,8 @@ function attachBunServer(app, bunServer) {
|
|
|
14608
14612
|
app.server = bunServer;
|
|
14609
14613
|
}
|
|
14610
14614
|
export {
|
|
14611
|
-
|
|
14612
|
-
|
|
14615
|
+
SixbServer,
|
|
14616
|
+
createSixbServer
|
|
14613
14617
|
};
|
|
14614
14618
|
|
|
14615
|
-
//# debugId=
|
|
14619
|
+
//# debugId=9579A35BED5BF80264756E2164756E21
|