@probelabs/visor 0.1.183-ee → 0.1.184-ee
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/agent-protocol/task-live-update-slack.d.ts +24 -0
- package/dist/agent-protocol/task-live-update-slack.d.ts.map +1 -0
- package/dist/agent-protocol/task-live-update-teams.d.ts +25 -0
- package/dist/agent-protocol/task-live-update-teams.d.ts.map +1 -0
- package/dist/agent-protocol/task-live-update-telegram.d.ts +25 -0
- package/dist/agent-protocol/task-live-update-telegram.d.ts.map +1 -0
- package/dist/agent-protocol/task-live-updates.d.ts +102 -0
- package/dist/agent-protocol/task-live-updates.d.ts.map +1 -0
- package/dist/agent-protocol/task-progress-tool.d.ts.map +1 -1
- package/dist/agent-protocol/task-trace-resolution.d.ts +11 -0
- package/dist/agent-protocol/task-trace-resolution.d.ts.map +1 -0
- package/dist/agent-protocol/trace-serializer.d.ts.map +1 -1
- package/dist/agent-protocol/track-execution.d.ts +8 -0
- package/dist/agent-protocol/track-execution.d.ts.map +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/frontends/slack-frontend.d.ts +2 -0
- package/dist/frontends/slack-frontend.d.ts.map +1 -1
- package/dist/frontends/teams-frontend.d.ts.map +1 -1
- package/dist/frontends/telegram-frontend.d.ts.map +1 -1
- package/dist/generated/config-schema.d.ts +110 -6
- package/dist/generated/config-schema.d.ts.map +1 -1
- package/dist/index.js +2239 -261
- package/dist/logger.d.ts +4 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/mcp-job-manager.d.ts +70 -0
- package/dist/mcp-job-manager.d.ts.map +1 -0
- package/dist/mcp-server.d.ts +6 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/runners/mcp-server-runner.d.ts +4 -0
- package/dist/runners/mcp-server-runner.d.ts.map +1 -1
- package/dist/runners/runner-factory.d.ts.map +1 -1
- package/dist/sdk/{a2a-frontend-5YDHFQXD.mjs → a2a-frontend-OI4OVSKC.mjs} +4 -4
- package/dist/sdk/check-provider-registry-RITJW67U.mjs +32 -0
- package/dist/sdk/check-provider-registry-ZZ6N4GDP.mjs +32 -0
- package/dist/sdk/{chunk-4BN2XI4X.mjs → chunk-4HIWZA6M.mjs} +2 -2
- package/dist/sdk/{chunk-RI4ONH5X.mjs → chunk-4MHHELVZ.mjs} +2 -2
- package/dist/sdk/{chunk-J27D43HS.mjs → chunk-4ZLYHSN4.mjs} +2 -2
- package/dist/sdk/{chunk-ZPYODGYA.mjs → chunk-6E625R3C.mjs} +19 -4
- package/dist/sdk/chunk-6E625R3C.mjs.map +1 -0
- package/dist/sdk/{chunk-GA2TYKSR.mjs → chunk-7XKHFRPN.mjs} +4 -4
- package/dist/sdk/{chunk-6C3R6E42.mjs → chunk-IY5PQ5EN.mjs} +30 -6
- package/dist/sdk/chunk-IY5PQ5EN.mjs.map +1 -0
- package/dist/sdk/{chunk-MFXPJUUE.mjs → chunk-PUHU6UY6.mjs} +4 -3
- package/dist/sdk/chunk-PUHU6UY6.mjs.map +1 -0
- package/dist/sdk/{chunk-XOAEKFKB.mjs → chunk-QLT42TX7.mjs} +2 -2
- package/dist/sdk/chunk-SRU5TFNY.mjs +620 -0
- package/dist/sdk/chunk-SRU5TFNY.mjs.map +1 -0
- package/dist/sdk/{chunk-P2K4VOMU.mjs → chunk-TSX3YS3F.mjs} +3 -3
- package/dist/sdk/{chunk-WKLJ57WF.mjs → chunk-UM7LGO2P.mjs} +6 -6
- package/dist/sdk/{chunk-7VTZDC2X.mjs → chunk-VPPBOKBQ.mjs} +2 -2
- package/dist/sdk/chunk-WZQMTD7W.mjs +33 -0
- package/dist/sdk/chunk-WZQMTD7W.mjs.map +1 -0
- package/dist/sdk/{chunk-ZOF5QT6U.mjs → chunk-YBXNG75V.mjs} +118 -10
- package/dist/sdk/chunk-YBXNG75V.mjs.map +1 -0
- package/dist/sdk/{chunk-UXB4XWEE.mjs → chunk-YYFSAAD6.mjs} +53 -51
- package/dist/sdk/chunk-YYFSAAD6.mjs.map +1 -0
- package/dist/sdk/{chunk-RHKPFJLG.mjs → chunk-ZNKL6ESZ.mjs} +2 -2
- package/dist/sdk/{chunk-IDL3AA3G.mjs → chunk-ZYDRR6PZ.mjs} +1150 -403
- package/dist/sdk/chunk-ZYDRR6PZ.mjs.map +1 -0
- package/dist/sdk/{command-executor-YNJOS77A.mjs → command-executor-LHUW77GR.mjs} +3 -3
- package/dist/sdk/{config-PCP6O6Y6.mjs → config-TVU5RWR5.mjs} +3 -3
- package/dist/sdk/{dist-3UGGEZB3.mjs → dist-PN5UHL6A.mjs} +429 -429
- package/dist/sdk/dist-PN5UHL6A.mjs.map +1 -0
- package/dist/sdk/{email-frontend-WSNADJPI.mjs → email-frontend-ECHQCFTR.mjs} +2 -2
- package/dist/sdk/{failure-condition-evaluator-IRFKTYZD.mjs → failure-condition-evaluator-USY3ISVA.mjs} +6 -6
- package/dist/sdk/{github-auth-BJQBLK2V.mjs → github-auth-UO4DMNCC.mjs} +2 -2
- package/dist/sdk/{github-frontend-DECYOBRN.mjs → github-frontend-2T5PWYD5.mjs} +6 -6
- package/dist/sdk/{host-CFM2ASDI.mjs → host-OJSMCLKK.mjs} +6 -6
- package/dist/sdk/{host-T4LNVU2H.mjs → host-RM6UJEPP.mjs} +7 -7
- package/dist/sdk/{knex-store-OEWSZEBY.mjs → knex-store-KCMFAMH5.mjs} +2 -2
- package/dist/sdk/{liquid-extensions-E3AKRX7P.mjs → liquid-extensions-KZIRR4OY.mjs} +4 -4
- package/dist/sdk/{loader-WRGI244P.mjs → loader-35YWX5UQ.mjs} +4 -4
- package/dist/sdk/{memory-store-OHUIXCWJ.mjs → memory-store-3JONK7AF.mjs} +3 -3
- package/dist/sdk/{opa-policy-engine-IVMCGVNA.mjs → opa-policy-engine-FY5D45YS.mjs} +2 -2
- package/dist/sdk/{prompt-state-LN57DQF3.mjs → prompt-state-VVJMONT3.mjs} +3 -3
- package/dist/sdk/{renderer-schema-BT2IXMLW.mjs → renderer-schema-JZRRU5CW.mjs} +2 -2
- package/dist/sdk/{routing-H2PQ57OA.mjs → routing-NNQQSLWA.mjs} +8 -8
- package/dist/sdk/{schedule-tool-2DPNSU63.mjs → schedule-tool-ADZ2ON4I.mjs} +15 -14
- package/dist/sdk/schedule-tool-EMNF3FPQ.mjs +38 -0
- package/dist/sdk/{schedule-tool-handler-NBEO46RV.mjs → schedule-tool-handler-3R3IC6VA.mjs} +15 -14
- package/dist/sdk/{schedule-tool-handler-KLHE2SOW.mjs → schedule-tool-handler-F76ZD2WU.mjs} +17 -16
- package/dist/sdk/sdk.d.mts +40 -0
- package/dist/sdk/sdk.d.ts +40 -0
- package/dist/sdk/sdk.js +1154 -176
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +14 -13
- package/dist/sdk/sdk.mjs.map +1 -1
- package/dist/sdk/{slack-frontend-DF5VL4OF.mjs → slack-frontend-K3TPGERM.mjs} +65 -9
- package/dist/sdk/slack-frontend-K3TPGERM.mjs.map +1 -0
- package/dist/sdk/{task-evaluator-OVMG7S56.mjs → task-evaluator-H3BXC7SE.mjs} +3 -3
- package/dist/sdk/{teams-frontend-DNW5GZP3.mjs → teams-frontend-6RRW533K.mjs} +54 -1
- package/dist/sdk/teams-frontend-6RRW533K.mjs.map +1 -0
- package/dist/sdk/{telegram-frontend-GA7OLADB.mjs → telegram-frontend-5UA77YAT.mjs} +48 -1
- package/dist/sdk/telegram-frontend-5UA77YAT.mjs.map +1 -0
- package/dist/sdk/{trace-helpers-26ZCAE2V.mjs → trace-helpers-OMF4C24T.mjs} +3 -3
- package/dist/sdk/{trace-serializer-KKBJHM7J.mjs → trace-serializer-EBHTHZYT.mjs} +3 -3
- package/dist/sdk/track-execution-3CHMGEPH.mjs +249 -0
- package/dist/sdk/track-execution-3CHMGEPH.mjs.map +1 -0
- package/dist/sdk/{utcp-check-provider-WI3QZ3W6.mjs → utcp-check-provider-Q4PD5EP2.mjs} +5 -5
- package/dist/sdk/workflow-check-provider-TC2G33WF.mjs +32 -0
- package/dist/sdk/workflow-check-provider-U4UXZ5YS.mjs +32 -0
- package/dist/sdk/{workflow-registry-YCZ3FCJC.mjs → workflow-registry-K56UTX36.mjs} +3 -3
- package/dist/slack/client.d.ts +14 -0
- package/dist/slack/client.d.ts.map +1 -1
- package/dist/slack/socket-runner.d.ts.map +1 -1
- package/dist/teams/client.d.ts +16 -0
- package/dist/teams/client.d.ts.map +1 -1
- package/dist/teams/webhook-runner.d.ts.map +1 -1
- package/dist/telegram/client.d.ts +17 -0
- package/dist/telegram/client.d.ts.map +1 -1
- package/dist/telegram/polling-runner.d.ts.map +1 -1
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +40 -0
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/generated/config-schema.json +0 -4027
- package/dist/sdk/a2a-frontend-6LWBIPMS.mjs +0 -1734
- package/dist/sdk/a2a-frontend-6LWBIPMS.mjs.map +0 -1
- package/dist/sdk/check-provider-registry-WSEVHJEV.mjs +0 -31
- package/dist/sdk/check-provider-registry-YRADEEQY.mjs +0 -31
- package/dist/sdk/chunk-34QX63WK.mjs +0 -244
- package/dist/sdk/chunk-34QX63WK.mjs.map +0 -1
- package/dist/sdk/chunk-54KOAC4W.mjs +0 -665
- package/dist/sdk/chunk-6C3R6E42.mjs.map +0 -1
- package/dist/sdk/chunk-7W5QCO4Y.mjs +0 -5943
- package/dist/sdk/chunk-7W5QCO4Y.mjs.map +0 -1
- package/dist/sdk/chunk-7XRSCOKE.mjs +0 -825
- package/dist/sdk/chunk-FT3I25QV.mjs +0 -251
- package/dist/sdk/chunk-FT3I25QV.mjs.map +0 -1
- package/dist/sdk/chunk-G7GSN3SK.mjs +0 -390
- package/dist/sdk/chunk-G7GSN3SK.mjs.map +0 -1
- package/dist/sdk/chunk-IDL3AA3G.mjs.map +0 -1
- package/dist/sdk/chunk-J27D43HS.mjs.map +0 -1
- package/dist/sdk/chunk-MEB2TTIE.mjs +0 -157
- package/dist/sdk/chunk-MEB2TTIE.mjs.map +0 -1
- package/dist/sdk/chunk-MFXPJUUE.mjs.map +0 -1
- package/dist/sdk/chunk-NPSLGKXB.mjs +0 -1502
- package/dist/sdk/chunk-P2K4VOMU.mjs.map +0 -1
- package/dist/sdk/chunk-PQWZ6NFL.mjs +0 -459
- package/dist/sdk/chunk-PQWZ6NFL.mjs.map +0 -1
- package/dist/sdk/chunk-S5FSRHMY.mjs +0 -139
- package/dist/sdk/chunk-S5FSRHMY.mjs.map +0 -1
- package/dist/sdk/chunk-TFUQ2D5L.mjs +0 -307
- package/dist/sdk/chunk-TFUQ2D5L.mjs.map +0 -1
- package/dist/sdk/chunk-UCMJJ3IM.mjs +0 -227
- package/dist/sdk/chunk-UCMJJ3IM.mjs.map +0 -1
- package/dist/sdk/chunk-UFHOIB3R.mjs +0 -482
- package/dist/sdk/chunk-UFHOIB3R.mjs.map +0 -1
- package/dist/sdk/chunk-UXB4XWEE.mjs.map +0 -1
- package/dist/sdk/chunk-V45TITKX.mjs +0 -739
- package/dist/sdk/chunk-V45TITKX.mjs.map +0 -1
- package/dist/sdk/chunk-WKLJ57WF.mjs.map +0 -1
- package/dist/sdk/chunk-ZOF5QT6U.mjs.map +0 -1
- package/dist/sdk/chunk-ZPYODGYA.mjs.map +0 -1
- package/dist/sdk/command-executor-3AHGIYQG.mjs +0 -14
- package/dist/sdk/config-JE4HKTWW.mjs +0 -16
- package/dist/sdk/dist-3UGGEZB3.mjs.map +0 -1
- package/dist/sdk/failure-condition-evaluator-H3PBFBYT.mjs +0 -18
- package/dist/sdk/github-auth-27SZGPEC.mjs +0 -196
- package/dist/sdk/github-auth-BJQBLK2V.mjs.map +0 -1
- package/dist/sdk/github-frontend-TZRBOQCN.mjs +0 -1394
- package/dist/sdk/github-frontend-TZRBOQCN.mjs.map +0 -1
- package/dist/sdk/lazy-otel-5NH4ZJJM.mjs +0 -24
- package/dist/sdk/liquid-extensions-P6KDYILF.mjs +0 -25
- package/dist/sdk/memory-store-K5N7MC7U.mjs +0 -12
- package/dist/sdk/metrics-JTOG2HNO.mjs +0 -41
- package/dist/sdk/prompt-state-YPICX7PI.mjs +0 -16
- package/dist/sdk/renderer-schema-KOIH75RZ.mjs +0 -51
- package/dist/sdk/renderer-schema-KOIH75RZ.mjs.map +0 -1
- package/dist/sdk/routing-JMZ7HDCC.mjs +0 -26
- package/dist/sdk/schedule-tool-4M45RK3E.mjs +0 -37
- package/dist/sdk/schedule-tool-4M45RK3E.mjs.map +0 -1
- package/dist/sdk/schedule-tool-handler-KLHE2SOW.mjs.map +0 -1
- package/dist/sdk/schedule-tool-handler-NBEO46RV.mjs.map +0 -1
- package/dist/sdk/slack-frontend-BPWXNIHE.mjs +0 -929
- package/dist/sdk/slack-frontend-BPWXNIHE.mjs.map +0 -1
- package/dist/sdk/slack-frontend-DF5VL4OF.mjs.map +0 -1
- package/dist/sdk/task-evaluator-GQYDOSGT.mjs +0 -1392
- package/dist/sdk/task-evaluator-GQYDOSGT.mjs.map +0 -1
- package/dist/sdk/teams-frontend-DNW5GZP3.mjs.map +0 -1
- package/dist/sdk/telegram-frontend-GA7OLADB.mjs.map +0 -1
- package/dist/sdk/trace-helpers-26ZCAE2V.mjs.map +0 -1
- package/dist/sdk/trace-helpers-XV5GAX5L.mjs +0 -29
- package/dist/sdk/trace-helpers-XV5GAX5L.mjs.map +0 -1
- package/dist/sdk/trace-serializer-KKBJHM7J.mjs.map +0 -1
- package/dist/sdk/track-execution-3EC24C2X.mjs +0 -163
- package/dist/sdk/track-execution-3EC24C2X.mjs.map +0 -1
- package/dist/sdk/track-execution-66RLL6QT.mjs +0 -143
- package/dist/sdk/track-execution-66RLL6QT.mjs.map +0 -1
- package/dist/sdk/utcp-check-provider-JLIYF5HH.mjs +0 -16
- package/dist/sdk/utcp-check-provider-JLIYF5HH.mjs.map +0 -1
- package/dist/sdk/utcp-check-provider-WI3QZ3W6.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-X2UREEH7.mjs +0 -31
- package/dist/sdk/workflow-check-provider-X2UREEH7.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-YXALZNAQ.mjs +0 -31
- package/dist/sdk/workflow-check-provider-YXALZNAQ.mjs.map +0 -1
- package/dist/sdk/workflow-registry-X2IPY35M.mjs +0 -12
- package/dist/sdk/workflow-registry-X2IPY35M.mjs.map +0 -1
- package/dist/sdk/workflow-registry-YCZ3FCJC.mjs.map +0 -1
- /package/dist/sdk/{a2a-frontend-5YDHFQXD.mjs.map → a2a-frontend-OI4OVSKC.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-WSEVHJEV.mjs.map → check-provider-registry-RITJW67U.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-YRADEEQY.mjs.map → check-provider-registry-ZZ6N4GDP.mjs.map} +0 -0
- /package/dist/sdk/{chunk-4BN2XI4X.mjs.map → chunk-4HIWZA6M.mjs.map} +0 -0
- /package/dist/sdk/{chunk-RI4ONH5X.mjs.map → chunk-4MHHELVZ.mjs.map} +0 -0
- /package/dist/sdk/{chunk-54KOAC4W.mjs.map → chunk-4ZLYHSN4.mjs.map} +0 -0
- /package/dist/sdk/{chunk-GA2TYKSR.mjs.map → chunk-7XKHFRPN.mjs.map} +0 -0
- /package/dist/sdk/{chunk-XOAEKFKB.mjs.map → chunk-QLT42TX7.mjs.map} +0 -0
- /package/dist/sdk/{chunk-7XRSCOKE.mjs.map → chunk-TSX3YS3F.mjs.map} +0 -0
- /package/dist/sdk/{chunk-NPSLGKXB.mjs.map → chunk-UM7LGO2P.mjs.map} +0 -0
- /package/dist/sdk/{chunk-7VTZDC2X.mjs.map → chunk-VPPBOKBQ.mjs.map} +0 -0
- /package/dist/sdk/{chunk-RHKPFJLG.mjs.map → chunk-ZNKL6ESZ.mjs.map} +0 -0
- /package/dist/sdk/{command-executor-3AHGIYQG.mjs.map → command-executor-LHUW77GR.mjs.map} +0 -0
- /package/dist/sdk/{command-executor-YNJOS77A.mjs.map → config-TVU5RWR5.mjs.map} +0 -0
- /package/dist/sdk/{email-frontend-WSNADJPI.mjs.map → email-frontend-ECHQCFTR.mjs.map} +0 -0
- /package/dist/sdk/{config-JE4HKTWW.mjs.map → failure-condition-evaluator-USY3ISVA.mjs.map} +0 -0
- /package/dist/sdk/{github-auth-27SZGPEC.mjs.map → github-auth-UO4DMNCC.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-DECYOBRN.mjs.map → github-frontend-2T5PWYD5.mjs.map} +0 -0
- /package/dist/sdk/{host-CFM2ASDI.mjs.map → host-OJSMCLKK.mjs.map} +0 -0
- /package/dist/sdk/{host-T4LNVU2H.mjs.map → host-RM6UJEPP.mjs.map} +0 -0
- /package/dist/sdk/{knex-store-OEWSZEBY.mjs.map → knex-store-KCMFAMH5.mjs.map} +0 -0
- /package/dist/sdk/{config-PCP6O6Y6.mjs.map → liquid-extensions-KZIRR4OY.mjs.map} +0 -0
- /package/dist/sdk/{loader-WRGI244P.mjs.map → loader-35YWX5UQ.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-H3PBFBYT.mjs.map → memory-store-3JONK7AF.mjs.map} +0 -0
- /package/dist/sdk/{opa-policy-engine-IVMCGVNA.mjs.map → opa-policy-engine-FY5D45YS.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-IRFKTYZD.mjs.map → prompt-state-VVJMONT3.mjs.map} +0 -0
- /package/dist/sdk/{renderer-schema-BT2IXMLW.mjs.map → renderer-schema-JZRRU5CW.mjs.map} +0 -0
- /package/dist/sdk/{lazy-otel-5NH4ZJJM.mjs.map → routing-NNQQSLWA.mjs.map} +0 -0
- /package/dist/sdk/{liquid-extensions-E3AKRX7P.mjs.map → schedule-tool-ADZ2ON4I.mjs.map} +0 -0
- /package/dist/sdk/{liquid-extensions-P6KDYILF.mjs.map → schedule-tool-EMNF3FPQ.mjs.map} +0 -0
- /package/dist/sdk/{memory-store-K5N7MC7U.mjs.map → schedule-tool-handler-3R3IC6VA.mjs.map} +0 -0
- /package/dist/sdk/{memory-store-OHUIXCWJ.mjs.map → schedule-tool-handler-F76ZD2WU.mjs.map} +0 -0
- /package/dist/sdk/{task-evaluator-OVMG7S56.mjs.map → task-evaluator-H3BXC7SE.mjs.map} +0 -0
- /package/dist/sdk/{metrics-JTOG2HNO.mjs.map → trace-helpers-OMF4C24T.mjs.map} +0 -0
- /package/dist/sdk/{prompt-state-LN57DQF3.mjs.map → trace-serializer-EBHTHZYT.mjs.map} +0 -0
- /package/dist/sdk/{prompt-state-YPICX7PI.mjs.map → utcp-check-provider-Q4PD5EP2.mjs.map} +0 -0
- /package/dist/sdk/{routing-H2PQ57OA.mjs.map → workflow-check-provider-TC2G33WF.mjs.map} +0 -0
- /package/dist/sdk/{routing-JMZ7HDCC.mjs.map → workflow-check-provider-U4UXZ5YS.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-2DPNSU63.mjs.map → workflow-registry-K56UTX36.mjs.map} +0 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchTraceSpans,
|
|
3
|
+
init_trace_serializer,
|
|
4
|
+
serializeTraceForPrompt
|
|
5
|
+
} from "./chunk-IY5PQ5EN.mjs";
|
|
6
|
+
import {
|
|
7
|
+
init_logger,
|
|
8
|
+
logger
|
|
9
|
+
} from "./chunk-6E625R3C.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__esm,
|
|
12
|
+
__require
|
|
13
|
+
} from "./chunk-J7LXIPZS.mjs";
|
|
14
|
+
|
|
15
|
+
// src/agent-protocol/task-live-updates.ts
|
|
16
|
+
import crypto from "crypto";
|
|
17
|
+
function resolveTaskLiveUpdatesConfig(config) {
|
|
18
|
+
if (!config) return null;
|
|
19
|
+
if (config === true) {
|
|
20
|
+
return {
|
|
21
|
+
enabled: true,
|
|
22
|
+
intervalSeconds: DEFAULT_TASK_LIVE_UPDATE_INTERVAL_SECONDS,
|
|
23
|
+
model: DEFAULT_TASK_LIVE_UPDATE_MODEL,
|
|
24
|
+
prompt: DEFAULT_TASK_LIVE_UPDATE_PROMPT,
|
|
25
|
+
initialMessage: "",
|
|
26
|
+
maxTraceChars: DEFAULT_TASK_LIVE_UPDATE_MAX_TRACE_CHARS
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (config.enabled === false) return null;
|
|
30
|
+
return {
|
|
31
|
+
enabled: true,
|
|
32
|
+
intervalSeconds: Math.max(
|
|
33
|
+
1,
|
|
34
|
+
Math.floor(config.interval_seconds || DEFAULT_TASK_LIVE_UPDATE_INTERVAL_SECONDS)
|
|
35
|
+
),
|
|
36
|
+
model: config.model || DEFAULT_TASK_LIVE_UPDATE_MODEL,
|
|
37
|
+
provider: config.provider,
|
|
38
|
+
prompt: config.prompt || DEFAULT_TASK_LIVE_UPDATE_PROMPT,
|
|
39
|
+
initialMessage: config.initial_message || "",
|
|
40
|
+
maxTraceChars: Math.max(
|
|
41
|
+
1e3,
|
|
42
|
+
Math.floor(config.max_trace_chars || DEFAULT_TASK_LIVE_UPDATE_MAX_TRACE_CHARS)
|
|
43
|
+
)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isFrontendLiveUpdatesEnabled(config, frontend) {
|
|
47
|
+
if (!config) return false;
|
|
48
|
+
if (config === true) return true;
|
|
49
|
+
if (config.enabled === false) return false;
|
|
50
|
+
const frontendCfg = config.frontends?.[frontend];
|
|
51
|
+
if (frontendCfg?.enabled === false) return false;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
async function defaultSerializeTrace(traceRef, maxChars, traceId) {
|
|
55
|
+
logger.debug(
|
|
56
|
+
`[TaskLiveUpdates] Serializing trace for progress update (traceRef=${traceRef}, traceId=${traceId || "-"}, sink=${process.env.VISOR_TELEMETRY_SINK || "auto"})`
|
|
57
|
+
);
|
|
58
|
+
return serializeTraceForPrompt(traceRef, maxChars, void 0, void 0, traceId);
|
|
59
|
+
}
|
|
60
|
+
async function summarizeTaskProgress(input) {
|
|
61
|
+
const { ProbeAgent } = __require("@probelabs/probe");
|
|
62
|
+
const agentOptions = {
|
|
63
|
+
sessionId: `visor-task-progress-${Date.now()}-${crypto.randomUUID().slice(0, 8)}`,
|
|
64
|
+
systemPrompt: input.config.prompt,
|
|
65
|
+
maxIterations: 1,
|
|
66
|
+
disableTools: true
|
|
67
|
+
};
|
|
68
|
+
if (input.config.model) agentOptions.model = input.config.model;
|
|
69
|
+
if (input.config.provider) agentOptions.provider = input.config.provider;
|
|
70
|
+
const agent = new ProbeAgent(agentOptions);
|
|
71
|
+
if (typeof agent.initialize === "function") {
|
|
72
|
+
await agent.initialize();
|
|
73
|
+
}
|
|
74
|
+
const userPrompt = [
|
|
75
|
+
`<user_request>
|
|
76
|
+
${input.requestText}
|
|
77
|
+
</user_request>`,
|
|
78
|
+
input.previousUpdate ? `<previous_update>
|
|
79
|
+
${input.previousUpdate}
|
|
80
|
+
</previous_update>` : "<previous_update>(none)</previous_update>",
|
|
81
|
+
`<timing>
|
|
82
|
+
started_at: ${input.startedAt.toISOString()}
|
|
83
|
+
now: ${input.now.toISOString()}
|
|
84
|
+
elapsed: ${formatDuration(input.elapsedSeconds)}
|
|
85
|
+
last_update_at: ${input.previousUpdateAt ? input.previousUpdateAt.toISOString() : "(none)"}
|
|
86
|
+
time_since_last_update: ${input.previousUpdateAt ? formatDuration(input.secondsSincePreviousUpdate || 0) : "(none)"}
|
|
87
|
+
</timing>`,
|
|
88
|
+
`<execution_trace>
|
|
89
|
+
${input.traceSnapshot}
|
|
90
|
+
</execution_trace>`
|
|
91
|
+
].join("\n\n");
|
|
92
|
+
const response = await agent.answer(userPrompt);
|
|
93
|
+
const cleaned = response.replace(/^```(?:markdown|md|text)?\s*\n?/i, "").replace(/\n?```\s*$/m, "").trim();
|
|
94
|
+
return cleaned || null;
|
|
95
|
+
}
|
|
96
|
+
function formatDuration(totalSeconds) {
|
|
97
|
+
const seconds = Math.max(0, Math.floor(totalSeconds));
|
|
98
|
+
const hours = Math.floor(seconds / 3600);
|
|
99
|
+
const minutes = Math.floor(seconds % 3600 / 60);
|
|
100
|
+
const remainingSeconds = seconds % 60;
|
|
101
|
+
const parts = [];
|
|
102
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
103
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
104
|
+
if (remainingSeconds > 0 || parts.length === 0) parts.push(`${remainingSeconds}s`);
|
|
105
|
+
return parts.join(" ");
|
|
106
|
+
}
|
|
107
|
+
function normalizeProgressSummary(text) {
|
|
108
|
+
const wantedLabels = ["Progress", "Last done", "Now", "Waiting on"];
|
|
109
|
+
const lines = text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
110
|
+
const matched = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const line of lines) {
|
|
112
|
+
const match = line.match(/^-?\s*(Progress|Last done|Now|Waiting on|Timing)\s*:\s*(.+)$/i);
|
|
113
|
+
if (!match) continue;
|
|
114
|
+
const label = match[1].toLowerCase();
|
|
115
|
+
if (label === "timing") continue;
|
|
116
|
+
const canonical = wantedLabels.find((item) => item.toLowerCase() === label);
|
|
117
|
+
if (canonical && !matched.has(canonical)) {
|
|
118
|
+
matched.set(canonical, match[2].trim());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (matched.size === wantedLabels.length) {
|
|
122
|
+
return wantedLabels.map((label) => `- ${label}: ${matched.get(label)}`).join("\n");
|
|
123
|
+
}
|
|
124
|
+
const withoutTiming = lines.filter((line) => !/^-?\s*(Timing|Metadata|Trace)\s*:/i.test(line));
|
|
125
|
+
return withoutTiming.join("\n");
|
|
126
|
+
}
|
|
127
|
+
function formatProgressMetadata(timing) {
|
|
128
|
+
const parts = [`elapsed ${formatDuration(timing.elapsedSeconds)}`];
|
|
129
|
+
if (timing.previousUpdateAt) {
|
|
130
|
+
parts.push(`previous update ${formatDuration(timing.secondsSincePreviousUpdate || 0)} ago`);
|
|
131
|
+
parts.push(`at ${timing.previousUpdateAt.toISOString()}`);
|
|
132
|
+
} else {
|
|
133
|
+
parts.push("first live update");
|
|
134
|
+
}
|
|
135
|
+
if (timing.activatedSkills && timing.activatedSkills.length > 0) {
|
|
136
|
+
parts.push(`activated skills ${formatSkillList(timing.activatedSkills)}`);
|
|
137
|
+
}
|
|
138
|
+
return `_Metadata: ${parts.join(" | ")}_`;
|
|
139
|
+
}
|
|
140
|
+
function formatSkillList(skills) {
|
|
141
|
+
const normalized = dedupeStrings(skills);
|
|
142
|
+
if (normalized.length <= 4) return normalized.join(", ");
|
|
143
|
+
return `${normalized.slice(0, 4).join(", ")} +${normalized.length - 4} more`;
|
|
144
|
+
}
|
|
145
|
+
function dedupeStrings(values) {
|
|
146
|
+
if (!Array.isArray(values)) return [];
|
|
147
|
+
return [...new Set(values.map((value) => String(value || "").trim()).filter(Boolean))];
|
|
148
|
+
}
|
|
149
|
+
async function extractTraceSkillMetadata(traceRef, traceId) {
|
|
150
|
+
if (!traceRef && !traceId) return void 0;
|
|
151
|
+
try {
|
|
152
|
+
const spans = await fetchTraceSpans(traceId || traceRef);
|
|
153
|
+
if (!spans.length) return void 0;
|
|
154
|
+
const routeIntentSpan = spans.find(
|
|
155
|
+
(span) => span.attributes["visor.check.id"] === "route-intent"
|
|
156
|
+
);
|
|
157
|
+
const buildConfigSpan = spans.find(
|
|
158
|
+
(span) => span.attributes["visor.check.id"] === "build-config"
|
|
159
|
+
);
|
|
160
|
+
const classifySpan = spans.find((span) => span.attributes["visor.check.id"] === "classify");
|
|
161
|
+
const routeIntentOutput = parseJsonAttribute(routeIntentSpan?.attributes["visor.check.output"]);
|
|
162
|
+
const classifyOutput = parseJsonAttribute(classifySpan?.attributes["visor.check.output"]);
|
|
163
|
+
const buildConfigOutput = parseJsonAttribute(buildConfigSpan?.attributes["visor.check.output"]);
|
|
164
|
+
const activatedSkills = dedupeStrings(
|
|
165
|
+
Array.isArray(buildConfigOutput?.activated_skills) ? buildConfigOutput.activated_skills : void 0
|
|
166
|
+
);
|
|
167
|
+
const fallbackActivatedSkills = dedupeStrings(
|
|
168
|
+
(Array.isArray(routeIntentOutput?.skills) ? routeIntentOutput.skills : void 0) || (Array.isArray(classifyOutput?.skills) ? classifyOutput.skills : void 0)
|
|
169
|
+
);
|
|
170
|
+
const finalActivatedSkills = activatedSkills.length > 0 ? activatedSkills : fallbackActivatedSkills;
|
|
171
|
+
if (!finalActivatedSkills.length) return void 0;
|
|
172
|
+
return { activatedSkills: finalActivatedSkills };
|
|
173
|
+
} catch (err) {
|
|
174
|
+
logger.debug(
|
|
175
|
+
`[TaskLiveUpdates] Failed to extract skill metadata from trace: ${err instanceof Error ? err.message : String(err)}`
|
|
176
|
+
);
|
|
177
|
+
return void 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function parseJsonAttribute(value) {
|
|
181
|
+
if (typeof value !== "string" || !value.trim()) return void 0;
|
|
182
|
+
try {
|
|
183
|
+
const parsed = JSON.parse(value);
|
|
184
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
185
|
+
} catch {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function buildStallFallbackSummary(traceSnapshot, previousUpdate) {
|
|
190
|
+
const lastDone = extractProgressField(previousUpdate, "Last done") || "continuing from the last completed analysis step";
|
|
191
|
+
const lower = traceSnapshot.toLowerCase();
|
|
192
|
+
let now = "waiting for the current analysis step to finish";
|
|
193
|
+
let waitingOn = "the current analysis step to complete";
|
|
194
|
+
if (lower.includes("search.delegate") || lower.includes("tool: search") || lower.includes("search(")) {
|
|
195
|
+
now = "running or waiting on the current code search step";
|
|
196
|
+
waitingOn = "search results and downstream analysis to finish";
|
|
197
|
+
} else if (lower.includes("extract(") || lower.includes("tool: extract")) {
|
|
198
|
+
now = "extracting the relevant code or documentation context";
|
|
199
|
+
waitingOn = "the extract step to finish and be interpreted";
|
|
200
|
+
} else if (lower.includes("engineer-task") || lower.includes("engineer")) {
|
|
201
|
+
now = "waiting on the current implementation or validation step";
|
|
202
|
+
waitingOn = "the engineer workflow to finish the current step";
|
|
203
|
+
} else if (lower.includes("ai.request") || lower.includes("gemini") || lower.includes("claude") || lower.includes("openai")) {
|
|
204
|
+
now = "waiting on the current model analysis step";
|
|
205
|
+
waitingOn = "the active model response to finish";
|
|
206
|
+
} else if (lower.includes("bash(") || lower.includes("go test") || lower.includes("npm test")) {
|
|
207
|
+
now = "running or waiting on command-based validation";
|
|
208
|
+
waitingOn = "the current command or test run to finish";
|
|
209
|
+
} else if (lower.includes("setup-projects") || lower.includes("build-config")) {
|
|
210
|
+
now = "preparing the workspace and loading the required context";
|
|
211
|
+
waitingOn = "workspace setup and context loading to finish";
|
|
212
|
+
}
|
|
213
|
+
return [
|
|
214
|
+
"- Progress: still working through the same step; no new completed action yet",
|
|
215
|
+
`- Last done: ${lastDone}`,
|
|
216
|
+
`- Now: ${now}`,
|
|
217
|
+
`- Waiting on: ${waitingOn}`
|
|
218
|
+
].join("\n");
|
|
219
|
+
}
|
|
220
|
+
function extractProgressField(text, label) {
|
|
221
|
+
if (!text) return void 0;
|
|
222
|
+
const match = text.match(new RegExp(`(?:^|\\n)-?\\s*${escapeRegExp(label)}\\s*:\\s*(.+)$`, "im"));
|
|
223
|
+
return match?.[1]?.trim() || void 0;
|
|
224
|
+
}
|
|
225
|
+
function escapeRegExp(value) {
|
|
226
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
227
|
+
}
|
|
228
|
+
var DEFAULT_TASK_LIVE_UPDATE_INTERVAL_SECONDS, DEFAULT_TASK_LIVE_UPDATE_MAX_TRACE_CHARS, DEFAULT_TASK_LIVE_UPDATE_FIRST_UPDATE_DELAY_SECONDS, DEFAULT_TASK_LIVE_UPDATE_METADATA_REFRESH_SECONDS, DEFAULT_TASK_LIVE_UPDATE_STALL_FALLBACK_SECONDS, DEFAULT_TASK_LIVE_UPDATE_MODEL, DEFAULT_TASK_LIVE_UPDATE_STALL_NOTICE, DEFAULT_TASK_LIVE_UPDATE_PROMPT, TaskLiveUpdateManager;
|
|
229
|
+
var init_task_live_updates = __esm({
|
|
230
|
+
"src/agent-protocol/task-live-updates.ts"() {
|
|
231
|
+
"use strict";
|
|
232
|
+
init_logger();
|
|
233
|
+
init_trace_serializer();
|
|
234
|
+
DEFAULT_TASK_LIVE_UPDATE_INTERVAL_SECONDS = 10;
|
|
235
|
+
DEFAULT_TASK_LIVE_UPDATE_MAX_TRACE_CHARS = 12e3;
|
|
236
|
+
DEFAULT_TASK_LIVE_UPDATE_FIRST_UPDATE_DELAY_SECONDS = 10;
|
|
237
|
+
DEFAULT_TASK_LIVE_UPDATE_METADATA_REFRESH_SECONDS = 5;
|
|
238
|
+
DEFAULT_TASK_LIVE_UPDATE_STALL_FALLBACK_SECONDS = 60;
|
|
239
|
+
DEFAULT_TASK_LIVE_UPDATE_MODEL = "gemini-3.1-flash-lite-preview";
|
|
240
|
+
DEFAULT_TASK_LIVE_UPDATE_STALL_NOTICE = "_No new meaningful progress is visible yet. Some steps can stay quiet for up to 5 minutes before there is new news._";
|
|
241
|
+
DEFAULT_TASK_LIVE_UPDATE_PROMPT = `You are generating a short live progress update for a user while an AI task is still running.
|
|
242
|
+
|
|
243
|
+
This is NOT the final answer.
|
|
244
|
+
Do NOT answer the user's original request.
|
|
245
|
+
Do NOT write the final solution.
|
|
246
|
+
Do NOT explain the topic in full.
|
|
247
|
+
Do NOT provide a root cause, recommendation, summary of findings, or conclusion.
|
|
248
|
+
Even if you think you already know the answer, do NOT give it here.
|
|
249
|
+
|
|
250
|
+
You will receive:
|
|
251
|
+
- the user's original request
|
|
252
|
+
- the previous progress update, if any
|
|
253
|
+
- timing metadata for this run
|
|
254
|
+
- the latest execution trace snapshot
|
|
255
|
+
|
|
256
|
+
Your job is to produce a concise status update that tells the user only:
|
|
257
|
+
- the overall progress so far
|
|
258
|
+
- the last meaningful action that finished
|
|
259
|
+
- what the agent is doing right now
|
|
260
|
+
- what it is likely waiting on, if anything
|
|
261
|
+
|
|
262
|
+
Rules:
|
|
263
|
+
- This is a STATUS UPDATE, not the final answer
|
|
264
|
+
- Never answer the user's request directly
|
|
265
|
+
- Never switch into explanation mode
|
|
266
|
+
- Never write a complete answer, even partially
|
|
267
|
+
- Keep it short: exactly 4 short bullet points
|
|
268
|
+
- Use the exact bullet labels below
|
|
269
|
+
- Do NOT generate timing metadata lines
|
|
270
|
+
- Do NOT generate task_id lines
|
|
271
|
+
- Timing metadata is provided only so you understand task pace and recency
|
|
272
|
+
- The system will append timing and task metadata separately
|
|
273
|
+
- Prefer concrete progress over generic wording
|
|
274
|
+
- Mention the most recent completed action before the current action
|
|
275
|
+
- Do not claim completion unless the task is actually done
|
|
276
|
+
- Do not mention internal implementation details unless they help explain the current work
|
|
277
|
+
- Avoid repeating the previous update verbatim
|
|
278
|
+
- Do not use code fences
|
|
279
|
+
- Plain markdown text only
|
|
280
|
+
|
|
281
|
+
Required output format:
|
|
282
|
+
- Progress: <very short overall progress statement, not a final answer>
|
|
283
|
+
- Last done: <most recent completed action>
|
|
284
|
+
- Now: <current action in progress>
|
|
285
|
+
- Waiting on: <tool, search, model, user input, or "nothing blocking right now">
|
|
286
|
+
|
|
287
|
+
Trace interpretation rules:
|
|
288
|
+
- Translate internal trace phases into user-meaningful progress, do not just repeat raw span names
|
|
289
|
+
- If the trace shows routing or classify work, describe that as understanding the request and choosing the right path
|
|
290
|
+
- If the trace shows setup-projects, build-config, or loading context, describe that as preparing the workspace or gathering context
|
|
291
|
+
- If the trace shows search, extract, code-explorer, or file inspection, describe that as investigating the codebase
|
|
292
|
+
- If the trace shows engineer work, edits, tests, PR creation, or command execution, describe that as implementing or verifying changes
|
|
293
|
+
- If the trace shows completion prompts, final answer generation, summarization, final validation, or output rendering, describe that as validating findings and preparing the final response
|
|
294
|
+
- If the trace shows waiting on a long AI request, delegate, tool call, or sandboxed child task, describe that as waiting for analysis or validation to finish
|
|
295
|
+
|
|
296
|
+
If you are tempted to answer the user's question, stop and convert that into:
|
|
297
|
+
- what was learned so far
|
|
298
|
+
- what was just completed
|
|
299
|
+
- what is still being checked
|
|
300
|
+
|
|
301
|
+
Bad update example:
|
|
302
|
+
- "API rate limiting works by..."
|
|
303
|
+
|
|
304
|
+
Good update example:
|
|
305
|
+
- "Progress: identified the gateway components involved in rate limiting"
|
|
306
|
+
- "Last done: found the middleware files and session manager entry points"
|
|
307
|
+
- "Now: tracing the enforcement path through the gateway"
|
|
308
|
+
- "Waiting on: search results for the limiter implementation details"`;
|
|
309
|
+
TaskLiveUpdateManager = class {
|
|
310
|
+
constructor(ctx, deps) {
|
|
311
|
+
this.ctx = ctx;
|
|
312
|
+
this.deps = {
|
|
313
|
+
summarizeProgress: deps?.summarizeProgress || summarizeTaskProgress,
|
|
314
|
+
serializeTrace: deps?.serializeTrace || defaultSerializeTrace,
|
|
315
|
+
extractSkillMetadata: deps?.extractSkillMetadata || extractTraceSkillMetadata
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
deps;
|
|
319
|
+
timer;
|
|
320
|
+
firstTickTimer;
|
|
321
|
+
metadataRefreshTimer;
|
|
322
|
+
running = false;
|
|
323
|
+
started = false;
|
|
324
|
+
completed = false;
|
|
325
|
+
startedAt = /* @__PURE__ */ new Date();
|
|
326
|
+
lastUpdateText;
|
|
327
|
+
lastUpdateAt;
|
|
328
|
+
lastTraceSnapshot;
|
|
329
|
+
lastPostedMessage;
|
|
330
|
+
lastStallFallbackAt;
|
|
331
|
+
lastUpdateKind = "semantic";
|
|
332
|
+
lastSkillMetadata;
|
|
333
|
+
async start() {
|
|
334
|
+
if (this.started) return;
|
|
335
|
+
this.started = true;
|
|
336
|
+
try {
|
|
337
|
+
const started = await this.ctx.sink.start();
|
|
338
|
+
this.recordSinkRef(started);
|
|
339
|
+
logger.info(
|
|
340
|
+
`[TaskLiveUpdates] Started for task ${this.ctx.taskId}; first update in ${DEFAULT_TASK_LIVE_UPDATE_FIRST_UPDATE_DELAY_SECONDS}s, interval=${this.ctx.config.intervalSeconds}s, provider=${this.ctx.config.provider || "default"}, model=${this.ctx.config.model}`
|
|
341
|
+
);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
logger.warn(
|
|
344
|
+
`[TaskLiveUpdates] Failed to initialize live updates for task ${this.ctx.taskId}: ${err instanceof Error ? err.message : String(err)}`
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
this.firstTickTimer = setTimeout(() => {
|
|
348
|
+
void this.runFirstTick();
|
|
349
|
+
}, DEFAULT_TASK_LIVE_UPDATE_FIRST_UPDATE_DELAY_SECONDS * 1e3);
|
|
350
|
+
if (typeof this.firstTickTimer?.unref === "function") {
|
|
351
|
+
this.firstTickTimer.unref();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
async complete(finalText) {
|
|
355
|
+
if (this.completed) return;
|
|
356
|
+
this.completed = true;
|
|
357
|
+
this.stop();
|
|
358
|
+
try {
|
|
359
|
+
logger.info(`[TaskLiveUpdates] Publishing final success update for task ${this.ctx.taskId}`);
|
|
360
|
+
const result = await this.ctx.sink.complete(this.decorateText(finalText));
|
|
361
|
+
this.recordSinkRef(result);
|
|
362
|
+
this.ctx.appendHistory?.(finalText, "completed");
|
|
363
|
+
} catch (err) {
|
|
364
|
+
logger.warn(
|
|
365
|
+
`[TaskLiveUpdates] Failed to publish final update for task ${this.ctx.taskId}: ${err instanceof Error ? err.message : String(err)}`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async fail(finalText) {
|
|
370
|
+
if (this.completed) return;
|
|
371
|
+
this.completed = true;
|
|
372
|
+
this.stop();
|
|
373
|
+
try {
|
|
374
|
+
logger.info(`[TaskLiveUpdates] Publishing final failure update for task ${this.ctx.taskId}`);
|
|
375
|
+
const result = await this.ctx.sink.fail(this.decorateText(finalText));
|
|
376
|
+
this.recordSinkRef(result);
|
|
377
|
+
this.ctx.appendHistory?.(finalText, "failed");
|
|
378
|
+
} catch (err) {
|
|
379
|
+
logger.warn(
|
|
380
|
+
`[TaskLiveUpdates] Failed to publish failure update for task ${this.ctx.taskId}: ${err instanceof Error ? err.message : String(err)}`
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
stop() {
|
|
385
|
+
if (this.firstTickTimer) {
|
|
386
|
+
clearTimeout(this.firstTickTimer);
|
|
387
|
+
this.firstTickTimer = void 0;
|
|
388
|
+
}
|
|
389
|
+
if (this.timer) {
|
|
390
|
+
clearInterval(this.timer);
|
|
391
|
+
this.timer = void 0;
|
|
392
|
+
}
|
|
393
|
+
if (this.metadataRefreshTimer) {
|
|
394
|
+
clearInterval(this.metadataRefreshTimer);
|
|
395
|
+
this.metadataRefreshTimer = void 0;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async tick() {
|
|
399
|
+
if (this.completed || this.running) return;
|
|
400
|
+
const traceState = this.getTraceState();
|
|
401
|
+
if (!traceState.traceRef && !traceState.traceId) {
|
|
402
|
+
logger.debug(
|
|
403
|
+
`[TaskLiveUpdates] Skipping tick for task ${this.ctx.taskId}: no trace reference available yet`
|
|
404
|
+
);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
this.running = true;
|
|
408
|
+
try {
|
|
409
|
+
const traceRef = traceState.traceRef || traceState.traceId;
|
|
410
|
+
const traceSnapshot = await this.deps.serializeTrace(
|
|
411
|
+
traceRef,
|
|
412
|
+
this.ctx.config.maxTraceChars,
|
|
413
|
+
traceState.traceId
|
|
414
|
+
);
|
|
415
|
+
if (this.completed) {
|
|
416
|
+
logger.debug(
|
|
417
|
+
`[TaskLiveUpdates] Aborting in-flight tick for task ${this.ctx.taskId}: task already completed`
|
|
418
|
+
);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (!traceSnapshot || traceSnapshot === "(no trace data available)") {
|
|
422
|
+
logger.debug(
|
|
423
|
+
`[TaskLiveUpdates] Skipping tick for task ${this.ctx.taskId}: no trace data available yet (traceRef=${traceRef})`
|
|
424
|
+
);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (traceSnapshot === this.lastTraceSnapshot) {
|
|
428
|
+
await this.maybePublishStallFallback(traceSnapshot, traceState.traceId);
|
|
429
|
+
logger.debug(
|
|
430
|
+
`[TaskLiveUpdates] Skipping tick for task ${this.ctx.taskId}: trace snapshot unchanged`
|
|
431
|
+
);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const summary = await this.deps.summarizeProgress({
|
|
435
|
+
requestText: this.ctx.requestText,
|
|
436
|
+
previousUpdate: this.lastUpdateText,
|
|
437
|
+
traceSnapshot,
|
|
438
|
+
config: this.ctx.config,
|
|
439
|
+
startedAt: this.startedAt,
|
|
440
|
+
now: /* @__PURE__ */ new Date(),
|
|
441
|
+
elapsedSeconds: Math.max(0, Math.floor((Date.now() - this.startedAt.getTime()) / 1e3)),
|
|
442
|
+
previousUpdateAt: this.lastUpdateAt,
|
|
443
|
+
secondsSincePreviousUpdate: this.lastUpdateAt ? Math.max(0, Math.floor((Date.now() - this.lastUpdateAt.getTime()) / 1e3)) : void 0
|
|
444
|
+
});
|
|
445
|
+
if (this.completed) {
|
|
446
|
+
logger.debug(
|
|
447
|
+
`[TaskLiveUpdates] Aborting in-flight tick for task ${this.ctx.taskId}: task already completed after summarization`
|
|
448
|
+
);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const cleaned = summary?.trim();
|
|
452
|
+
if (!cleaned || cleaned === this.lastUpdateText) {
|
|
453
|
+
await this.maybePublishStallFallback(traceSnapshot, traceState.traceId);
|
|
454
|
+
logger.debug(
|
|
455
|
+
`[TaskLiveUpdates] Skipping tick for task ${this.ctx.taskId}: summary empty or unchanged`
|
|
456
|
+
);
|
|
457
|
+
this.lastTraceSnapshot = traceSnapshot;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
logger.info(
|
|
461
|
+
`[TaskLiveUpdates] Publishing progress update for task ${this.ctx.taskId}: ${cleaned.slice(0, 160)}`
|
|
462
|
+
);
|
|
463
|
+
this.lastSkillMetadata = await this.deps.extractSkillMetadata(traceRef, traceState.traceId);
|
|
464
|
+
this.lastUpdateKind = "semantic";
|
|
465
|
+
const message = this.decorateProgressText(
|
|
466
|
+
cleaned,
|
|
467
|
+
{
|
|
468
|
+
elapsedSeconds: Math.max(0, Math.floor((Date.now() - this.startedAt.getTime()) / 1e3)),
|
|
469
|
+
previousUpdateAt: this.lastUpdateAt,
|
|
470
|
+
secondsSincePreviousUpdate: this.lastUpdateAt ? Math.max(0, Math.floor((Date.now() - this.lastUpdateAt.getTime()) / 1e3)) : void 0,
|
|
471
|
+
activatedSkills: this.lastSkillMetadata?.activatedSkills
|
|
472
|
+
},
|
|
473
|
+
traceState.traceId
|
|
474
|
+
);
|
|
475
|
+
const result = await this.ctx.sink.update(message);
|
|
476
|
+
this.recordSinkRef(result);
|
|
477
|
+
this.ctx.appendHistory?.(cleaned, "progress");
|
|
478
|
+
this.lastUpdateText = cleaned;
|
|
479
|
+
this.lastUpdateAt = /* @__PURE__ */ new Date();
|
|
480
|
+
this.lastTraceSnapshot = traceSnapshot;
|
|
481
|
+
this.lastPostedMessage = message;
|
|
482
|
+
this.lastStallFallbackAt = void 0;
|
|
483
|
+
} catch (err) {
|
|
484
|
+
logger.warn(
|
|
485
|
+
`[TaskLiveUpdates] Progress update failed for task ${this.ctx.taskId}: ${err instanceof Error ? err.message : String(err)}`
|
|
486
|
+
);
|
|
487
|
+
} finally {
|
|
488
|
+
this.running = false;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
async runFirstTick() {
|
|
492
|
+
if (this.completed) return;
|
|
493
|
+
logger.debug(`[TaskLiveUpdates] Running first scheduled tick for task ${this.ctx.taskId}`);
|
|
494
|
+
await this.tick();
|
|
495
|
+
if (this.completed) return;
|
|
496
|
+
this.timer = setInterval(() => {
|
|
497
|
+
void this.tick();
|
|
498
|
+
}, this.ctx.config.intervalSeconds * 1e3);
|
|
499
|
+
if (typeof this.timer?.unref === "function") {
|
|
500
|
+
this.timer.unref();
|
|
501
|
+
}
|
|
502
|
+
this.metadataRefreshTimer = setInterval(() => {
|
|
503
|
+
void this.refreshProgressMetadata();
|
|
504
|
+
}, DEFAULT_TASK_LIVE_UPDATE_METADATA_REFRESH_SECONDS * 1e3);
|
|
505
|
+
if (typeof this.metadataRefreshTimer?.unref === "function") {
|
|
506
|
+
this.metadataRefreshTimer.unref();
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
recordSinkRef(result) {
|
|
510
|
+
if (result?.ref) this.ctx.onPostedRef?.(result.ref);
|
|
511
|
+
}
|
|
512
|
+
getTraceState() {
|
|
513
|
+
const resolved = this.ctx.resolveTraceState?.();
|
|
514
|
+
return {
|
|
515
|
+
traceRef: resolved?.traceRef || this.ctx.traceRef,
|
|
516
|
+
traceId: resolved?.traceId || this.ctx.traceId
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
decorateText(text, _traceId) {
|
|
520
|
+
if (!this.ctx.includeTraceId) return text;
|
|
521
|
+
if (text.includes(`task_id: ${this.ctx.taskId}`)) return text;
|
|
522
|
+
return `${text}
|
|
523
|
+
|
|
524
|
+
\`task_id: ${this.ctx.taskId}\``;
|
|
525
|
+
}
|
|
526
|
+
decorateProgressText(text, timing, traceId) {
|
|
527
|
+
const normalized = normalizeProgressSummary(text);
|
|
528
|
+
const blocks = [
|
|
529
|
+
"*Live Update*",
|
|
530
|
+
"_Current task is still running. This message updates in place until the final answer is ready._",
|
|
531
|
+
this.lastUpdateKind === "stall" ? DEFAULT_TASK_LIVE_UPDATE_STALL_NOTICE : "",
|
|
532
|
+
normalized,
|
|
533
|
+
formatProgressMetadata(timing)
|
|
534
|
+
].filter(Boolean);
|
|
535
|
+
return this.decorateText(blocks.join("\n\n"), traceId);
|
|
536
|
+
}
|
|
537
|
+
async refreshProgressMetadata() {
|
|
538
|
+
if (this.completed || this.running || !this.lastUpdateText) return;
|
|
539
|
+
const traceState = this.getTraceState();
|
|
540
|
+
const message = this.decorateProgressText(
|
|
541
|
+
this.lastUpdateText,
|
|
542
|
+
{
|
|
543
|
+
elapsedSeconds: Math.max(0, Math.floor((Date.now() - this.startedAt.getTime()) / 1e3)),
|
|
544
|
+
previousUpdateAt: this.lastUpdateAt,
|
|
545
|
+
secondsSincePreviousUpdate: this.lastUpdateAt ? Math.max(0, Math.floor((Date.now() - this.lastUpdateAt.getTime()) / 1e3)) : void 0,
|
|
546
|
+
activatedSkills: this.lastSkillMetadata?.activatedSkills
|
|
547
|
+
},
|
|
548
|
+
traceState.traceId
|
|
549
|
+
);
|
|
550
|
+
if (!message || message === this.lastPostedMessage) return;
|
|
551
|
+
if (this.completed) return;
|
|
552
|
+
try {
|
|
553
|
+
logger.debug(
|
|
554
|
+
`[TaskLiveUpdates] Refreshing metadata-only live update for task ${this.ctx.taskId}`
|
|
555
|
+
);
|
|
556
|
+
const result = await this.ctx.sink.update(message);
|
|
557
|
+
this.recordSinkRef(result);
|
|
558
|
+
this.lastPostedMessage = message;
|
|
559
|
+
} catch (err) {
|
|
560
|
+
logger.warn(
|
|
561
|
+
`[TaskLiveUpdates] Metadata refresh failed for task ${this.ctx.taskId}: ${err instanceof Error ? err.message : String(err)}`
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
async maybePublishStallFallback(traceSnapshot, traceId) {
|
|
566
|
+
if (this.completed) return;
|
|
567
|
+
const now = /* @__PURE__ */ new Date();
|
|
568
|
+
if (this.lastStallFallbackAt && now.getTime() - this.lastStallFallbackAt.getTime() < DEFAULT_TASK_LIVE_UPDATE_STALL_FALLBACK_SECONDS * 1e3) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (this.lastUpdateAt && now.getTime() - this.lastUpdateAt.getTime() < DEFAULT_TASK_LIVE_UPDATE_STALL_FALLBACK_SECONDS * 1e3) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
this.lastSkillMetadata = await this.deps.extractSkillMetadata(
|
|
575
|
+
this.getTraceState().traceRef || traceId || "",
|
|
576
|
+
traceId
|
|
577
|
+
);
|
|
578
|
+
const fallback = buildStallFallbackSummary(traceSnapshot, this.lastUpdateText);
|
|
579
|
+
const baseText = this.lastUpdateText || fallback;
|
|
580
|
+
if (!baseText) return;
|
|
581
|
+
logger.info(
|
|
582
|
+
`[TaskLiveUpdates] Publishing stall notice for task ${this.ctx.taskId}: ${baseText.slice(0, 160)}`
|
|
583
|
+
);
|
|
584
|
+
this.lastUpdateKind = "stall";
|
|
585
|
+
if (this.completed) return;
|
|
586
|
+
const message = this.decorateProgressText(
|
|
587
|
+
baseText,
|
|
588
|
+
{
|
|
589
|
+
elapsedSeconds: Math.max(0, Math.floor((Date.now() - this.startedAt.getTime()) / 1e3)),
|
|
590
|
+
previousUpdateAt: this.lastUpdateAt,
|
|
591
|
+
secondsSincePreviousUpdate: this.lastUpdateAt ? Math.max(0, Math.floor((Date.now() - this.lastUpdateAt.getTime()) / 1e3)) : void 0,
|
|
592
|
+
activatedSkills: this.lastSkillMetadata?.activatedSkills
|
|
593
|
+
},
|
|
594
|
+
traceId
|
|
595
|
+
);
|
|
596
|
+
if (message === this.lastPostedMessage) {
|
|
597
|
+
this.lastStallFallbackAt = now;
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
const result = await this.ctx.sink.update(message);
|
|
601
|
+
this.recordSinkRef(result);
|
|
602
|
+
if (!this.lastUpdateText) {
|
|
603
|
+
this.ctx.appendHistory?.(baseText, "progress");
|
|
604
|
+
this.lastUpdateText = baseText;
|
|
605
|
+
this.lastUpdateAt = now;
|
|
606
|
+
}
|
|
607
|
+
this.lastPostedMessage = message;
|
|
608
|
+
this.lastStallFallbackAt = now;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
export {
|
|
615
|
+
resolveTaskLiveUpdatesConfig,
|
|
616
|
+
isFrontendLiveUpdatesEnabled,
|
|
617
|
+
TaskLiveUpdateManager,
|
|
618
|
+
init_task_live_updates
|
|
619
|
+
};
|
|
620
|
+
//# sourceMappingURL=chunk-SRU5TFNY.mjs.map
|