@axiom-lattice/gateway 8.1.1 → 8.2.0
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/embed/{embed-page-AgentDetailSideApp-RY4FAEAM.js → embed-page-AgentDetailSideApp-WDDE7BEH.js} +1 -1
- package/dist/embed/{embed-page-AgentGovernanceWorkbench-UFDULZ5A.js → embed-page-AgentGovernanceWorkbench-7YPU3QB2.js} +1 -1
- package/dist/embed/{embed-page-LangfuseDashboard-GNNJGAA2.js → embed-page-LangfuseDashboard-BEOJDMWF.js} +1 -1
- package/dist/embed/{embed-page-MessageGraph-S7GCLNLR.js → embed-page-MessageGraph-LNNMCH6I.js} +1 -1
- package/dist/embed/{embed-page-ReactChart-LWZPH244.js → embed-page-ReactChart-D7RZQB2H.js} +1 -1
- package/dist/embed/{embed-page-SkillFlow-OVIGJFUH.js → embed-page-SkillFlow-3X24ILKU.js} +1 -1
- package/dist/embed/{embed-page-TasksSideApp-AOS4MZAI.js → embed-page-TasksSideApp-KD4S22SL.js} +1 -1
- package/dist/embed/{embed-page-ThreadMaintenancePanel-PXL2TJBO.js → embed-page-ThreadMaintenancePanel-V327PV5R.js} +1 -1
- package/dist/embed/{embed-page-TopologyRuntimeView-GRM34Z2Z.js → embed-page-TopologyRuntimeView-Z7MY6U5T.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-JV26AHRB.js → embed-page-WorkflowAutomationView-4MY4HG7R.js} +1 -1
- package/dist/embed/embed-page-chunk-4XKCMM5C.js +211 -0
- package/dist/embed/{embed-page-chunk-YCTDKWKW.js → embed-page-chunk-ASEIOK7X.js} +1 -1
- package/dist/embed/{embed-page-chunk-6ZHR5GWS.js → embed-page-chunk-BSRASK7V.js} +6 -6
- package/dist/embed/{embed-page-chunk-ABGWNVMG.js → embed-page-chunk-BZKAPY7M.js} +1 -1
- package/dist/embed/embed-page-chunk-CFFDP526.js +6835 -0
- package/dist/embed/{embed-page-chunk-5XP4FJW7.js → embed-page-chunk-EM6VGUZ2.js} +1 -1
- package/dist/embed/{embed-page-chunk-3UK7XM33.js → embed-page-chunk-G5MXFDNZ.js} +1 -1
- package/dist/embed/{embed-page-chunk-OQUMCCF5.js → embed-page-chunk-G5PDHDBZ.js} +1 -1
- package/dist/embed/{embed-page-chunk-YM76GTXK.js → embed-page-chunk-HZZ5HNTF.js} +1 -1
- package/dist/embed/{embed-page-chunk-ONXC5S22.js → embed-page-chunk-PMOGSY6W.js} +1 -1
- package/dist/embed/{embed-page-en-G5J7KW6V.js → embed-page-en-JOTELYAL.js} +1 -1
- package/dist/embed/{embed-page-zh-72QSTYRF.js → embed-page-zh-BPO6ZSJM.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/index.js +148 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/embed/embed-page-chunk-NNQHJZ5Q.js +0 -211
- package/dist/embed/embed-page-chunk-SQSVDSG6.js +0 -6746
package/dist/index.mjs
CHANGED
|
@@ -3112,6 +3112,29 @@ async function listAllRuns(ledger, tenantId, threadId) {
|
|
|
3112
3112
|
if (page.length < ACTIVE_RUN_PAGE_SIZE) return runs;
|
|
3113
3113
|
}
|
|
3114
3114
|
}
|
|
3115
|
+
var INPUT_PREVIEW_MAX = 200;
|
|
3116
|
+
function contentToPreview(content) {
|
|
3117
|
+
if (typeof content === "string") return content;
|
|
3118
|
+
if (!Array.isArray(content)) return "";
|
|
3119
|
+
return content.map((part) => {
|
|
3120
|
+
if (typeof part === "string") return part;
|
|
3121
|
+
return isRecord(part) && typeof part.text === "string" ? part.text : "";
|
|
3122
|
+
}).join("");
|
|
3123
|
+
}
|
|
3124
|
+
function inputPreview(input) {
|
|
3125
|
+
if (!isRecord(input)) return null;
|
|
3126
|
+
if (typeof input.message === "string") {
|
|
3127
|
+
return input.message.trim().slice(0, INPUT_PREVIEW_MAX) || null;
|
|
3128
|
+
}
|
|
3129
|
+
const messages = Array.isArray(input.messages) ? input.messages : [];
|
|
3130
|
+
for (const message of messages) {
|
|
3131
|
+
if (!isRecord(message)) continue;
|
|
3132
|
+
if (message.role !== void 0 && message.role !== "human") continue;
|
|
3133
|
+
const text = contentToPreview(message.content).trim();
|
|
3134
|
+
if (text) return text.slice(0, INPUT_PREVIEW_MAX);
|
|
3135
|
+
}
|
|
3136
|
+
return null;
|
|
3137
|
+
}
|
|
3115
3138
|
function toSafeRun(run2) {
|
|
3116
3139
|
return {
|
|
3117
3140
|
runId: run2.runId,
|
|
@@ -3123,7 +3146,9 @@ function toSafeRun(run2) {
|
|
|
3123
3146
|
createdAt: run2.createdAt,
|
|
3124
3147
|
updatedAt: run2.updatedAt,
|
|
3125
3148
|
startedAt: run2.startedAt,
|
|
3126
|
-
finishedAt: run2.finishedAt
|
|
3149
|
+
finishedAt: run2.finishedAt,
|
|
3150
|
+
messageId: run2.inputMessageIds[0] ?? null,
|
|
3151
|
+
inputPreview: inputPreview(run2.input)
|
|
3127
3152
|
};
|
|
3128
3153
|
}
|
|
3129
3154
|
function isTerminal(run2) {
|
|
@@ -3253,6 +3278,35 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3253
3278
|
const pollIntervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
3254
3279
|
const now = deps.now ?? Date.now;
|
|
3255
3280
|
const sleep = deps.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
3281
|
+
const withRunCreateLock = async (request, reply, tenantId, assistantId, threadId, operation) => {
|
|
3282
|
+
const key = runCreateScopeKey(tenantId, assistantId, threadId);
|
|
3283
|
+
return serializeRunCreate(key, async () => {
|
|
3284
|
+
const leaseStore = resolveLeaseStore();
|
|
3285
|
+
if (!leaseStore) return operation();
|
|
3286
|
+
try {
|
|
3287
|
+
return await withLease(
|
|
3288
|
+
leaseStore,
|
|
3289
|
+
key,
|
|
3290
|
+
getReplicaId2(),
|
|
3291
|
+
operation,
|
|
3292
|
+
RUN_CREATE_LEASE
|
|
3293
|
+
);
|
|
3294
|
+
} catch (error) {
|
|
3295
|
+
if (error instanceof LeaseAcquisitionTimeoutError) {
|
|
3296
|
+
request.log.warn(
|
|
3297
|
+
{ err: error, leaseKey: key },
|
|
3298
|
+
"Run create lease acquisition timed out"
|
|
3299
|
+
);
|
|
3300
|
+
return unavailable(
|
|
3301
|
+
reply,
|
|
3302
|
+
RUN_CREATE_LOCK_TIMEOUT,
|
|
3303
|
+
"Could not serialize run creation for this thread; retry shortly"
|
|
3304
|
+
);
|
|
3305
|
+
}
|
|
3306
|
+
throw error;
|
|
3307
|
+
}
|
|
3308
|
+
});
|
|
3309
|
+
};
|
|
3256
3310
|
const waitForTerminal = async (tenantId, params, initial) => {
|
|
3257
3311
|
let current3 = initial;
|
|
3258
3312
|
const deadline = now() + waitTimeoutMs;
|
|
@@ -3482,35 +3536,6 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3482
3536
|
const outcome = await createPending();
|
|
3483
3537
|
return outcome.ok ? respondCreated(outcome.run) : outcome.response;
|
|
3484
3538
|
};
|
|
3485
|
-
const withRunCreateLock = async (operation) => {
|
|
3486
|
-
const key = runCreateScopeKey(tenantId, assistantId, threadId);
|
|
3487
|
-
return serializeRunCreate(key, async () => {
|
|
3488
|
-
const leaseStore = resolveLeaseStore();
|
|
3489
|
-
if (!leaseStore) return operation();
|
|
3490
|
-
try {
|
|
3491
|
-
return await withLease(
|
|
3492
|
-
leaseStore,
|
|
3493
|
-
key,
|
|
3494
|
-
getReplicaId2(),
|
|
3495
|
-
operation,
|
|
3496
|
-
RUN_CREATE_LEASE
|
|
3497
|
-
);
|
|
3498
|
-
} catch (error) {
|
|
3499
|
-
if (error instanceof LeaseAcquisitionTimeoutError) {
|
|
3500
|
-
request.log.warn(
|
|
3501
|
-
{ err: error, leaseKey: key },
|
|
3502
|
-
"Run create lease acquisition timed out"
|
|
3503
|
-
);
|
|
3504
|
-
return unavailable(
|
|
3505
|
-
reply,
|
|
3506
|
-
RUN_CREATE_LOCK_TIMEOUT,
|
|
3507
|
-
"Could not serialize run creation for this thread; retry shortly"
|
|
3508
|
-
);
|
|
3509
|
-
}
|
|
3510
|
-
throw error;
|
|
3511
|
-
}
|
|
3512
|
-
});
|
|
3513
|
-
};
|
|
3514
3539
|
const scopedRunApiRuns = (runs) => runs.filter(
|
|
3515
3540
|
(run2) => run2.tenantId === tenantId && run2.threadId === threadId && run2.assistantId === assistantId && run2.source === "run_api"
|
|
3516
3541
|
);
|
|
@@ -3530,7 +3555,7 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3530
3555
|
}
|
|
3531
3556
|
};
|
|
3532
3557
|
if (strategy === "reject") {
|
|
3533
|
-
return withRunCreateLock(async () => {
|
|
3558
|
+
return withRunCreateLock(request, reply, tenantId, assistantId, threadId, async () => {
|
|
3534
3559
|
const read = await readThreadRuns();
|
|
3535
3560
|
if (!read.ok) return read.response;
|
|
3536
3561
|
const active2 = scopedRunApiRuns(read.runs).filter(isActiveRun);
|
|
@@ -3546,7 +3571,7 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3546
3571
|
});
|
|
3547
3572
|
}
|
|
3548
3573
|
if (strategy === "interrupt") {
|
|
3549
|
-
return withRunCreateLock(async () => {
|
|
3574
|
+
return withRunCreateLock(request, reply, tenantId, assistantId, threadId, async () => {
|
|
3550
3575
|
const read = await readThreadRuns();
|
|
3551
3576
|
if (!read.ok) return read.response;
|
|
3552
3577
|
const scoped = scopedRunApiRuns(read.runs);
|
|
@@ -3609,8 +3634,8 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3609
3634
|
return createAndRespond();
|
|
3610
3635
|
});
|
|
3611
3636
|
}
|
|
3612
|
-
if (strategy !== "rollback") return withRunCreateLock(createAndRespond);
|
|
3613
|
-
return withRunCreateLock(async () => {
|
|
3637
|
+
if (strategy !== "rollback") return withRunCreateLock(request, reply, tenantId, assistantId, threadId, createAndRespond);
|
|
3638
|
+
return withRunCreateLock(request, reply, tenantId, assistantId, threadId, async () => {
|
|
3614
3639
|
const active2 = (await listAllRuns(ledger, tenantId, threadId)).filter(
|
|
3615
3640
|
(run2) => run2.tenantId === tenantId && run2.threadId === threadId && run2.assistantId === assistantId && run2.source !== "legacy" && (run2.status === "pending" || run2.status === "running")
|
|
3616
3641
|
);
|
|
@@ -3745,6 +3770,76 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3745
3770
|
return createAndRespond();
|
|
3746
3771
|
});
|
|
3747
3772
|
};
|
|
3773
|
+
const cancelActive = async (request, reply) => {
|
|
3774
|
+
if (!ledger) {
|
|
3775
|
+
return unavailable(reply, RUN_LEDGER_UNAVAILABLE, "Run ledger is not available");
|
|
3776
|
+
}
|
|
3777
|
+
const tenantId = getTenantId4(request);
|
|
3778
|
+
const { assistantId, threadId } = request.params;
|
|
3779
|
+
if (!await ownsThread(tenantId, assistantId, threadId)) {
|
|
3780
|
+
return notFound2(reply, THREAD_NOT_FOUND2, "Thread not found");
|
|
3781
|
+
}
|
|
3782
|
+
const router = resolveRouter();
|
|
3783
|
+
return withRunCreateLock(request, reply, tenantId, assistantId, threadId, async () => {
|
|
3784
|
+
let runs;
|
|
3785
|
+
try {
|
|
3786
|
+
runs = await listAllRuns(ledger, tenantId, threadId);
|
|
3787
|
+
} catch (error) {
|
|
3788
|
+
request.log.error({ err: error }, "Active run read failed");
|
|
3789
|
+
return unavailable(reply, RUN_CREATE_UNAVAILABLE2, "Run queue is not available");
|
|
3790
|
+
}
|
|
3791
|
+
const active2 = runs.filter(
|
|
3792
|
+
(run2) => run2.tenantId === tenantId && run2.assistantId === assistantId && run2.threadId === threadId && run2.source === "run_api" && isActiveRun(run2)
|
|
3793
|
+
);
|
|
3794
|
+
const cancelled = [];
|
|
3795
|
+
const requested = [];
|
|
3796
|
+
const failed = [];
|
|
3797
|
+
for (const run2 of active2) {
|
|
3798
|
+
try {
|
|
3799
|
+
if (run2.status === "pending") {
|
|
3800
|
+
const status2 = await ledger.requestCancel(tenantId, run2.runId);
|
|
3801
|
+
if (status2 === "cancelled") {
|
|
3802
|
+
const latest = await ledger.getRun(tenantId, run2.runId);
|
|
3803
|
+
if (latest) cancelled.push(toSafeRun(latest));
|
|
3804
|
+
} else if (status2 === "requested") {
|
|
3805
|
+
requested.push(toSafeRun(run2));
|
|
3806
|
+
}
|
|
3807
|
+
continue;
|
|
3808
|
+
}
|
|
3809
|
+
if (router) {
|
|
3810
|
+
const status2 = await router.requestCancelById({
|
|
3811
|
+
tenantId,
|
|
3812
|
+
assistantId,
|
|
3813
|
+
threadId,
|
|
3814
|
+
runId: run2.runId,
|
|
3815
|
+
reason: "abort"
|
|
3816
|
+
});
|
|
3817
|
+
if (status2 === "requested" || status2 === "cancelled") {
|
|
3818
|
+
requested.push(toSafeRun(run2));
|
|
3819
|
+
}
|
|
3820
|
+
continue;
|
|
3821
|
+
}
|
|
3822
|
+
const status = await ledger.requestCancel(tenantId, run2.runId);
|
|
3823
|
+
if (status === "requested" || status === "cancelled") {
|
|
3824
|
+
requested.push(toSafeRun(run2));
|
|
3825
|
+
}
|
|
3826
|
+
} catch (error) {
|
|
3827
|
+
failed.push({
|
|
3828
|
+
runId: run2.runId,
|
|
3829
|
+
code: "RUN_CANCEL_FAILED",
|
|
3830
|
+
message: error instanceof Error ? error.message : String(error)
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
return reply.status(200).send({
|
|
3835
|
+
success: true,
|
|
3836
|
+
accepted: failed.length === 0,
|
|
3837
|
+
cancelled,
|
|
3838
|
+
requested,
|
|
3839
|
+
failed
|
|
3840
|
+
});
|
|
3841
|
+
});
|
|
3842
|
+
};
|
|
3748
3843
|
const list = async (request, reply) => {
|
|
3749
3844
|
if (!ledger) {
|
|
3750
3845
|
return unavailable(reply, RUN_LEDGER_UNAVAILABLE, "Run ledger is not available");
|
|
@@ -3754,12 +3849,14 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
3754
3849
|
if (!await ownsThread(tenantId, assistantId, threadId)) {
|
|
3755
3850
|
return notFound2(reply, THREAD_NOT_FOUND2, "Thread not found");
|
|
3756
3851
|
}
|
|
3757
|
-
const
|
|
3758
|
-
|
|
3852
|
+
const activeOnly = request.query.active === "true" || request.query.active === "1";
|
|
3853
|
+
const source = request.query.source;
|
|
3854
|
+
const scoped = (activeOnly ? await listAllRuns(ledger, tenantId, threadId) : await ledger.listRuns(tenantId, threadId)).filter(
|
|
3855
|
+
(run2) => run2.tenantId === tenantId && run2.threadId === threadId && run2.assistantId === assistantId && (!activeOnly || isActiveRun(run2)) && (source === void 0 || run2.source === source)
|
|
3759
3856
|
);
|
|
3760
3857
|
return reply.status(200).send({
|
|
3761
3858
|
success: true,
|
|
3762
|
-
data: { runs:
|
|
3859
|
+
data: { runs: scoped.map(toSafeRun) }
|
|
3763
3860
|
});
|
|
3764
3861
|
};
|
|
3765
3862
|
const get = async (request, reply) => {
|
|
@@ -4115,7 +4212,7 @@ function createRunLifecycleHandlers(deps = {}) {
|
|
|
4115
4212
|
run: toSafeRun(outcome.run)
|
|
4116
4213
|
});
|
|
4117
4214
|
};
|
|
4118
|
-
return { create, list, get, join: join4, cancel };
|
|
4215
|
+
return { create, list, get, join: join4, cancel, cancelActive };
|
|
4119
4216
|
}
|
|
4120
4217
|
function registerRunLifecycleRoutes(app2, deps = {}) {
|
|
4121
4218
|
const handlers = createRunLifecycleHandlers(deps);
|
|
@@ -4127,6 +4224,10 @@ function registerRunLifecycleRoutes(app2, deps = {}) {
|
|
|
4127
4224
|
"/api/assistants/:assistantId/threads/:threadId/runs",
|
|
4128
4225
|
handlers.list
|
|
4129
4226
|
);
|
|
4227
|
+
app2.post(
|
|
4228
|
+
"/api/assistants/:assistantId/threads/:threadId/runs/cancel-active",
|
|
4229
|
+
handlers.cancelActive
|
|
4230
|
+
);
|
|
4130
4231
|
app2.get(
|
|
4131
4232
|
"/api/assistants/:assistantId/threads/:threadId/runs/:runId",
|
|
4132
4233
|
handlers.get
|
|
@@ -21023,6 +21124,15 @@ function registerAgentWebAppRuntimeRoutes(app2, deps) {
|
|
|
21023
21124
|
return normalizeError2(reply, error);
|
|
21024
21125
|
}
|
|
21025
21126
|
});
|
|
21127
|
+
routes.post(`${prefix}/assistants/:assistantId/threads/:threadId/runs/cancel-active`, async (request, reply) => {
|
|
21128
|
+
try {
|
|
21129
|
+
const params = mirrorThreadParams.parse(request.params);
|
|
21130
|
+
const { proxy } = await authorizeRunMirror(request, params);
|
|
21131
|
+
return await runLifecycle.cancelActive(proxy, reply);
|
|
21132
|
+
} catch (error) {
|
|
21133
|
+
return normalizeError2(reply, error);
|
|
21134
|
+
}
|
|
21135
|
+
});
|
|
21026
21136
|
routes.post(`${prefix}/assistants/:assistantId/threads/:threadId/runs/:runId/cancel`, async (request, reply) => {
|
|
21027
21137
|
try {
|
|
21028
21138
|
const params = mirrorRunParams.parse(request.params);
|