@xopcai/xopc 0.0.187 → 0.0.188
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/demo-memory/src/index.js +1 -0
- package/dist/extensions/feishu/src/streaming/streaming-adapter.js +1 -3
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +0 -2
- package/dist/extensions/telegram/src/draft-stream.d.ts +0 -4
- package/dist/extensions/telegram/src/draft-stream.js +1 -53
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-WlR2zEvA.js → activity-store--QoUGhiS.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-RedDszrG.js → agent-avatar-dicebear-B0yweLNQ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Df9mTa-K.js → agents-C6OV-gMm.js} +1 -1
- package/dist/gateway/static/root/assets/{api-tVOllncq.js → api-5laWqfiE.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C9hKBzaF.js → app-management-settings-panel-BXJ8Jiv_.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-5cQvq7hd.js → appearance-settings-DG9n9D1M.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Bd3tN-k2.js → apps-page-Ci14lDeO.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Ct-shK4n.js → archive-plugin-Ceh5qrZf.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CpPj3m-q.js → attachment-load-jFW7uYf7.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Q1xmb4Rh.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BpSXZBle.js → binary-plugins-XDlkI1r4.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B8hR2tXc.js → block-editor-kyKc2IhE.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-jb5Hf-hm.js → browser-settings-page-DbowrHXD.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_LAXUrh.js → browser-workflow-inputs-BJa5Iz_v.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CPAs7-6s.js → browser-workflows-page-CTQQOsn5.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BjUe4raq.js → capabilities-settings-panel-DoZPFdKF.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-CKklVY2p.js → capability-presets-api-Dn-7MMEo.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DiWIMYRr.js → capability-presets-settings-panel-Bt8Hnx0h.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-WWN-nbFL.js → channel-recipient-api-BgIkWq01.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D8IkjMuX.js → channels-settings-Bpsebsru.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DFmdYRE5.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-CdNkVFdB.js → connector-logo-TRr9ybf6.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BT2ahw52.js → connectors-page-Tg5kl22i.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bm_IEAf3.js → desktop-pet-CSwd00CV.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C0Ve04-G.js → desktop-pet-settings-CuNQvHGu.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B2cvhvAI.js → directory-picker-path-field-ct0n5Rje.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DNashgGu.js → extension-debug-page-BeRBuMUU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Bvo-5htX.js → extension-page-DbK-Cwao.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BBESdISV.js → extension-settings-page-C9ag5tb5.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-ClQvokMo.js → gateway-config-api-CC7EvEFp.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CIRs2QVy.js → gateway-settings-9g8uIry9.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CntXJF6W.js → gateway-startup-retry-B2DmdlwO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CWKcZuvc.js → heartbeat-settings-fl1oC_-5.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-C59f8UJw.js → home-page-Bao9jq_z.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-DjSAQwGy.js → image-generation-api-GMTaS6eI.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cl5n1f_U.css +1 -0
- package/dist/gateway/static/root/assets/index-OJgiMh07.js +223 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ahKHpjoW.js → keyboard-shortcuts-settings-DhGYddbI.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DRB4UQBE.js → local-app-workbench-page-B69NvtvH.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-B6GKdgza.js → local-apps-page-CmnrBmWi.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Bff30u5V.js → locale-store-D6hs74o5.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CNp4XiBN.js → logs-page-Cq3cABqg.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BeNMJm_i.js → markdown-split-CZaBPOVn.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bdzrj_-6.js → media-plugins-CiKvSgCv.js} +1 -1
- package/dist/gateway/static/root/assets/messages-D02NNLCZ.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-MYIi-9S9.js → notes-page-Bisbzqlz.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-DqSkeDXX.js → notes-workbench-BOZfJFhE.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-3t88bbGx.js → page-tabs-BxlwhAbH.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Cf_BWbeE.js → preview-open-alternatives-RM8wXxfT.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CKq73c98.js → product-open-page-DdBlibek.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BrbHs4Wp.js → project-detail-page-TSKFb2tN.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-B80rtkj6.js → projects-page-BokeBrTT.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-_Q3GEznb.js → remote-access-hub-C56anxCX.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-NqOm-OG1.js → schema-form-BDKbpmXv.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-55dJOUVg.js → sessions-page-C7TQADrD.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BDOPKeAX.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DYAS8p8z.js → settings-form-section-zxo5ZGOu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DZFhxihA.js → settings-loading-skeleton-DgIp8_S6.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BSIiMLi-.js → settings-page-BUPSIa9P.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DfFfkdED.js → settings-page-layout-97LmwrzC.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-q_yE6-H1.js → setup-status-panel-BRg766eW.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CYtrQaZN.js → share-preview-page-BH7i3g1S.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-gYkRX9Ik.js → shares-settings-DhEAviQ_.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Ct7AV8ls.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-GZHKDFSb.js → skills-page-DoVuprZm.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-BBXirAjc.js → skills-page.utils-s-a5WV9j.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DLf5YvFl.js → system-settings-panel-BxjeMT5k.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DFGkuYfl.js → task-detail-page-BahycnfW.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-y7e_tvYi.js → theme-store-BRxdsmic.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-5sHEZ5w5.js → time-picker-BGk_Tbsj.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DR12j_dr.js → typed-models-lib-39MjwPSq.js} +1 -1
- package/dist/gateway/static/root/assets/{use-save-bar-registration-BsvcJgZl.js → use-save-bar-registration-5aVSjTjO.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-q5dr8JFG.js → user-context-page-B9K41qmy.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DKADXFWD.js → voice-api-key-field-XU-7sBSg.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BC1nExf8.js → work-discovery-overlay-CJqu8UHq.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-fNvSg40M.js → work-discovery-page-BBVnRHju.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C8X5W-8k.js → workflow-run-setup-panel-DXtg8Qxl.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-YJBKmPYK.js → workflows-page-Bs_tYfst.js} +1 -1
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tool-activity.js +223 -0
- package/dist/src/agent/agent-manager.js +2 -8
- package/dist/src/agent/code-intelligence/binary.js +1 -1
- package/dist/src/agent/embedded/run-for-session.d.ts +0 -2
- package/dist/src/agent/embedded/run-for-session.js +99 -112
- package/dist/src/agent/external-tools/composio-provider.d.ts +29 -0
- package/dist/src/agent/external-tools/composio-provider.js +307 -0
- package/dist/src/agent/external-tools/extension-provider.d.ts +20 -0
- package/dist/src/agent/external-tools/extension-provider.js +68 -0
- package/dist/src/agent/external-tools/gateway-tools.d.ts +8 -0
- package/dist/src/agent/external-tools/gateway-tools.js +89 -0
- package/dist/src/agent/external-tools/index.d.ts +24 -0
- package/dist/src/agent/external-tools/index.js +40 -0
- package/dist/src/agent/external-tools/mcp-provider.d.ts +29 -0
- package/dist/src/agent/external-tools/mcp-provider.js +118 -0
- package/dist/src/agent/external-tools/memory-provider.d.ts +21 -0
- package/dist/src/agent/external-tools/memory-provider.js +56 -0
- package/dist/src/agent/external-tools/refs.d.ts +5 -0
- package/dist/src/agent/external-tools/refs.js +18 -0
- package/dist/src/agent/external-tools/service.d.ts +26 -0
- package/dist/src/agent/external-tools/service.js +117 -0
- package/dist/src/agent/external-tools/types.d.ts +28 -0
- package/dist/src/agent/external-tools/types.js +9 -0
- package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
- package/dist/src/agent/inbound/inbound-loop.js +0 -3
- package/dist/src/agent/mcp/{bundle-mcp-materialize.d.ts → bundle-mcp-gateway.d.ts} +1 -19
- package/dist/src/agent/mcp/bundle-mcp-gateway.js +60 -0
- package/dist/src/agent/mcp/bundle-mcp-names.d.ts +0 -8
- package/dist/src/agent/mcp/bundle-mcp-names.js +2 -29
- package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +4 -7
- package/dist/src/agent/mcp/bundle-mcp-policy.js +6 -20
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
- package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +1 -2
- package/dist/src/agent/mcp/bundle-mcp-tools.js +1 -2
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +0 -5
- package/dist/src/agent/mcp/index.d.ts +0 -2
- package/dist/src/agent/mcp/index.js +2 -5
- package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/context/planner.d.ts +1 -0
- package/dist/src/agent/memory/context/planner.js +22 -7
- package/dist/src/agent/memory/manager.d.ts +4 -1
- package/dist/src/agent/memory/manager.js +5 -2
- package/dist/src/agent/memory/types.d.ts +2 -0
- package/dist/src/agent/messaging/stream-manager.d.ts +2 -14
- package/dist/src/agent/messaging/stream-manager.js +0 -12
- package/dist/src/agent/orchestration/agent-event-handler.d.ts +1 -3
- package/dist/src/agent/orchestration/agent-event-handler.js +0 -36
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -5
- package/dist/src/agent/orchestration/agent-orchestrator.js +0 -5
- package/dist/src/agent/prompt/sections/behavior.js +6 -4
- package/dist/src/agent/service.d.ts +0 -3
- package/dist/src/agent/service.js +0 -28
- package/dist/src/agent/service.types.d.ts +0 -3
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/starter-agents.js +2 -2
- package/dist/src/agent/tools/delegate-tool.js +5 -1
- package/dist/src/agent/tools/executor.js +1 -1
- package/dist/src/agent/tools/factory.d.ts +2 -1
- package/dist/src/agent/tools/factory.js +16 -22
- package/dist/src/agent/tools/index.d.ts +0 -1
- package/dist/src/agent/tools/index.js +1 -2
- package/dist/src/agent/workflow/workflow-child-tools.js +7 -1
- package/dist/src/browser/providers/cloakbrowser.js +1 -1
- package/dist/src/channels/channel-domain.d.ts +0 -4
- package/dist/src/channels/plugin-types.d.ts +0 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +3 -1
- package/dist/src/extensions/extension-registry-impl.js +7 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/types/core.d.ts +2 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +5 -2
- package/dist/src/gateway/chat-stream/mapper.js +16 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +4 -0
- package/dist/src/gateway/file-reference-errors.d.ts +6 -0
- package/dist/src/gateway/file-reference-errors.js +21 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +34 -13
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +34 -13
- package/dist/src/gateway/hono/routes/you.js +3 -3
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +4 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.js +3 -1
- package/dist/src/storage/sqlite/migrations/108_repair_user_memory_provider.sql +18 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tui/tool-summary.d.ts +1 -2
- package/dist/src/tui/tool-summary.js +2 -18
- package/dist/src/tunnel/frpc-binary.js +1 -1
- package/dist/src/user-context/projection.d.ts +1 -0
- package/dist/src/user-context/projection.js +2 -1
- package/dist/src/voice/local/model-files.js +1 -1
- package/dist/src/work-discovery/service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/automations-page-w6K9GZQ7.js +0 -6
- package/dist/gateway/static/root/assets/channels-status-swr-CySs1GQX.js +0 -1
- package/dist/gateway/static/root/assets/index-D-YfWVyS.css +0 -1
- package/dist/gateway/static/root/assets/index-vi5KlR5_.js +0 -222
- package/dist/gateway/static/root/assets/messages-CPxz48hr.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-CSFCZj14.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BoNBMKW6.js +0 -1
- package/dist/src/agent/feedback/feedback-coordinator.d.ts +0 -73
- package/dist/src/agent/feedback/feedback-coordinator.js +0 -156
- package/dist/src/agent/feedback/index.d.ts +0 -4
- package/dist/src/agent/feedback/index.js +0 -2
- package/dist/src/agent/lifecycle/progress.d.ts +0 -90
- package/dist/src/agent/lifecycle/progress.js +0 -339
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +0 -183
- package/dist/src/agent/mcp/mcp-tool-meta.d.ts +0 -8
- package/dist/src/agent/mcp/mcp-tool-meta.js +0 -13
- package/dist/src/agent/mcp/resolve-embedded-mcp-tools.d.ts +0 -14
- package/dist/src/agent/mcp/resolve-embedded-mcp-tools.js +0 -48
- package/dist/src/agent/tools/composio-tool.d.ts +0 -21
- package/dist/src/agent/tools/composio-tool.js +0 -261
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ni as e}from"./index-vi5KlR5_.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-Bff30u5V.js";import{ei as r}from"./index-vi5KlR5_.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Feedback Coordinator - Coordinates all feedback mechanisms
|
|
3
|
-
*
|
|
4
|
-
* Unifies progress feedback, stream updates, and direct messages
|
|
5
|
-
* into a single coherent feedback system.
|
|
6
|
-
*/
|
|
7
|
-
import type { MessageBus } from '../../infra/bus/index.js';
|
|
8
|
-
import type { SessionContext } from '../session/session-context.js';
|
|
9
|
-
import type { ProgressFeedbackManager, ProgressStage } from '../lifecycle/progress.js';
|
|
10
|
-
import type { StreamHandle } from '../messaging/stream-manager.js';
|
|
11
|
-
export interface FeedbackCoordinatorConfig {
|
|
12
|
-
progressManager: ProgressFeedbackManager;
|
|
13
|
-
bus: MessageBus;
|
|
14
|
-
}
|
|
15
|
-
export declare class FeedbackCoordinator {
|
|
16
|
-
private progressManager;
|
|
17
|
-
private bus;
|
|
18
|
-
private currentStreamHandle;
|
|
19
|
-
private currentContext;
|
|
20
|
-
constructor(config: FeedbackCoordinatorConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Set the current context for feedback
|
|
23
|
-
*/
|
|
24
|
-
setContext(context: SessionContext): void;
|
|
25
|
-
/**
|
|
26
|
-
* Clear the current context
|
|
27
|
-
*/
|
|
28
|
-
clearContext(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Start a task and initialize feedback
|
|
31
|
-
*/
|
|
32
|
-
startTask(): void;
|
|
33
|
-
/**
|
|
34
|
-
* End a task and cleanup feedback
|
|
35
|
-
*/
|
|
36
|
-
endTask(): void;
|
|
37
|
-
/**
|
|
38
|
-
* Set the stream handle for progress updates
|
|
39
|
-
*/
|
|
40
|
-
setStreamHandle(handle: StreamHandle): void;
|
|
41
|
-
/**
|
|
42
|
-
* Clear the stream handle
|
|
43
|
-
*/
|
|
44
|
-
clearStreamHandle(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Send progress message via stream or direct message
|
|
47
|
-
*/
|
|
48
|
-
private sendProgressMessage;
|
|
49
|
-
/**
|
|
50
|
-
* Send heartbeat for long-running tasks
|
|
51
|
-
*/
|
|
52
|
-
private sendHeartbeat;
|
|
53
|
-
/**
|
|
54
|
-
* Map tool name to progress stage
|
|
55
|
-
*/
|
|
56
|
-
private getToolStage;
|
|
57
|
-
/**
|
|
58
|
-
* Update progress via stream
|
|
59
|
-
*/
|
|
60
|
-
updateProgress(text: string, stage: ProgressStage, detail?: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Set progress stage
|
|
63
|
-
*/
|
|
64
|
-
setProgress(stage: ProgressStage, detail?: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* Send a direct message to the current context
|
|
67
|
-
*/
|
|
68
|
-
sendMessage(content: string): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Get the progress manager instance
|
|
71
|
-
*/
|
|
72
|
-
getProgressManager(): ProgressFeedbackManager;
|
|
73
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { formatHeartbeatMessage, formatProgressMessage } from "../lifecycle/progress.js";
|
|
4
|
-
//#region src/agent/feedback/feedback-coordinator.ts
|
|
5
|
-
init_logger();
|
|
6
|
-
const log = createLogger("FeedbackCoordinator");
|
|
7
|
-
var FeedbackCoordinator = class {
|
|
8
|
-
progressManager;
|
|
9
|
-
bus;
|
|
10
|
-
currentStreamHandle = null;
|
|
11
|
-
currentContext = null;
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.progressManager = config.progressManager;
|
|
14
|
-
this.bus = config.bus;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Set the current context for feedback
|
|
18
|
-
*/
|
|
19
|
-
setContext(context) {
|
|
20
|
-
this.currentContext = context;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Clear the current context
|
|
24
|
-
*/
|
|
25
|
-
clearContext() {
|
|
26
|
-
this.currentContext = null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Start a task and initialize feedback
|
|
30
|
-
*/
|
|
31
|
-
startTask() {
|
|
32
|
-
this.progressManager.startTask();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* End a task and cleanup feedback
|
|
36
|
-
*/
|
|
37
|
-
endTask() {
|
|
38
|
-
this.progressManager.endTask();
|
|
39
|
-
this.clearStreamHandle();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Set the stream handle for progress updates
|
|
43
|
-
*/
|
|
44
|
-
setStreamHandle(handle) {
|
|
45
|
-
this.currentStreamHandle = handle;
|
|
46
|
-
if (handle) this.progressManager.setCallbacks({
|
|
47
|
-
onProgress: (msg) => this.sendProgressMessage(msg),
|
|
48
|
-
onStreamStart: (toolName, toolArgs) => {
|
|
49
|
-
const stage = this.getToolStage(toolName);
|
|
50
|
-
if (this.currentStreamHandle?.setProgress) {
|
|
51
|
-
let detail;
|
|
52
|
-
if (toolArgs.path) detail = String(toolArgs.path);
|
|
53
|
-
else if (toolArgs.command) {
|
|
54
|
-
const cmd = String(toolArgs.command);
|
|
55
|
-
detail = cmd.length > 30 ? cmd.slice(0, 30) + "..." : cmd;
|
|
56
|
-
}
|
|
57
|
-
this.currentStreamHandle.setProgress(stage, detail);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
onStreamEnd: () => {
|
|
61
|
-
if (this.currentStreamHandle?.setProgress) this.currentStreamHandle.setProgress("idle");
|
|
62
|
-
},
|
|
63
|
-
onHeartbeat: (elapsedMs, stage) => {
|
|
64
|
-
this.sendHeartbeat(elapsedMs, stage);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Clear the stream handle
|
|
70
|
-
*/
|
|
71
|
-
clearStreamHandle() {
|
|
72
|
-
this.currentStreamHandle = null;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Send progress message via stream or direct message
|
|
76
|
-
*/
|
|
77
|
-
async sendProgressMessage(msg) {
|
|
78
|
-
if (!this.currentContext) return;
|
|
79
|
-
if (this.currentStreamHandle?.updateProgress && msg.stage !== "idle") this.currentStreamHandle.updateProgress("", msg.stage, msg.message);
|
|
80
|
-
else if (msg.type === "error") {
|
|
81
|
-
const formatted = formatProgressMessage(msg);
|
|
82
|
-
await this.bus.publishOutbound({
|
|
83
|
-
channel: this.currentContext.channel,
|
|
84
|
-
chat_id: this.currentContext.chatId,
|
|
85
|
-
content: formatted,
|
|
86
|
-
type: "message"
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Send heartbeat for long-running tasks
|
|
92
|
-
*/
|
|
93
|
-
async sendHeartbeat(elapsedMs, stage) {
|
|
94
|
-
if (!this.currentContext) return;
|
|
95
|
-
log.info({
|
|
96
|
-
elapsedMs,
|
|
97
|
-
stage
|
|
98
|
-
}, "Progress heartbeat");
|
|
99
|
-
const formatted = formatHeartbeatMessage(elapsedMs, stage);
|
|
100
|
-
await this.bus.publishOutbound({
|
|
101
|
-
channel: this.currentContext.channel,
|
|
102
|
-
chat_id: this.currentContext.chatId,
|
|
103
|
-
content: formatted,
|
|
104
|
-
type: "message"
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Map tool name to progress stage
|
|
109
|
-
*/
|
|
110
|
-
getToolStage(toolName) {
|
|
111
|
-
const name = toolName.toLowerCase();
|
|
112
|
-
if (name.includes("read") || name.includes("file")) return "reading";
|
|
113
|
-
if (name.includes("search") || name.includes("grep") || name.includes("web")) return "searching";
|
|
114
|
-
if (name.includes("write") || name.includes("edit")) return "writing";
|
|
115
|
-
if (name.includes("bash") || name.includes("shell") || name.includes("exec")) return "executing";
|
|
116
|
-
return "executing";
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Update progress via stream
|
|
120
|
-
*/
|
|
121
|
-
updateProgress(text, stage, detail) {
|
|
122
|
-
if (this.currentStreamHandle?.updateProgress) this.currentStreamHandle.updateProgress(text, stage, detail);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Set progress stage
|
|
126
|
-
*/
|
|
127
|
-
setProgress(stage, detail) {
|
|
128
|
-
if (this.currentStreamHandle?.setProgress) this.currentStreamHandle.setProgress(stage, detail);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Send a direct message to the current context
|
|
132
|
-
*/
|
|
133
|
-
async sendMessage(content) {
|
|
134
|
-
if (!this.currentContext) {
|
|
135
|
-
log.warn({
|
|
136
|
-
hasStreamHandle: Boolean(this.currentStreamHandle),
|
|
137
|
-
contentPreview: content.slice(0, 80)
|
|
138
|
-
}, "Outbound message skipped: no session context (setContext not called or cleared)");
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
await this.bus.publishOutbound({
|
|
142
|
-
channel: this.currentContext.channel,
|
|
143
|
-
chat_id: this.currentContext.chatId,
|
|
144
|
-
content,
|
|
145
|
-
type: "message"
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Get the progress manager instance
|
|
150
|
-
*/
|
|
151
|
-
getProgressManager() {
|
|
152
|
-
return this.progressManager;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
//#endregion
|
|
156
|
-
export { FeedbackCoordinator };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress Feedback Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages real-time progress feedback for long-running agent tasks.
|
|
5
|
-
* Provides:
|
|
6
|
-
* - Tool/end notifications execution start
|
|
7
|
-
* - Thinking indicators
|
|
8
|
-
* - Progress stage updates
|
|
9
|
-
* - Stream integration for real-time display
|
|
10
|
-
*/
|
|
11
|
-
export type ProgressStage = 'thinking' | 'searching' | 'reading' | 'writing' | 'executing' | 'analyzing' | 'idle';
|
|
12
|
-
export interface ProgressUpdate {
|
|
13
|
-
stage: ProgressStage;
|
|
14
|
-
detail?: string;
|
|
15
|
-
toolName?: string;
|
|
16
|
-
toolArgs?: Record<string, unknown>;
|
|
17
|
-
timestamp: number;
|
|
18
|
-
}
|
|
19
|
-
export interface ProgressFeedbackConfig {
|
|
20
|
-
level: 'minimal' | 'normal' | 'verbose';
|
|
21
|
-
showThinking: boolean;
|
|
22
|
-
streamToolProgress: boolean;
|
|
23
|
-
heartbeatEnabled: boolean;
|
|
24
|
-
heartbeatIntervalMs: number;
|
|
25
|
-
longTaskThresholdMs: number;
|
|
26
|
-
showErrorAccumulation: boolean;
|
|
27
|
-
showRequestLimitWarning: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface ProgressMessage {
|
|
30
|
-
type: 'start' | 'update' | 'complete' | 'error' | 'warning' | 'thinking';
|
|
31
|
-
stage: ProgressStage;
|
|
32
|
-
message: string;
|
|
33
|
-
detail?: string;
|
|
34
|
-
toolName?: string;
|
|
35
|
-
toolArgs?: Record<string, unknown>;
|
|
36
|
-
}
|
|
37
|
-
export interface ProgressCallbacks {
|
|
38
|
-
onProgress?: (msg: ProgressMessage) => void;
|
|
39
|
-
onStreamStart?: (toolName: string, toolArgs: Record<string, unknown>) => void;
|
|
40
|
-
onStreamUpdate?: (toolName: string, partialResult: string) => void;
|
|
41
|
-
onStreamEnd?: (toolName: string, result: string, isError: boolean) => void;
|
|
42
|
-
onThinking?: (thinking: string) => void;
|
|
43
|
-
onHeartbeat?: (elapsedMs: number, currentStage: ProgressStage) => void;
|
|
44
|
-
}
|
|
45
|
-
export declare class ProgressFeedbackManager {
|
|
46
|
-
private config;
|
|
47
|
-
private callbacks;
|
|
48
|
-
private currentStage;
|
|
49
|
-
private currentTool;
|
|
50
|
-
private taskStartTime;
|
|
51
|
-
private heartbeatTimer?;
|
|
52
|
-
private streamActive;
|
|
53
|
-
constructor(config?: Partial<ProgressFeedbackConfig>);
|
|
54
|
-
setCallbacks(callbacks: ProgressCallbacks): void;
|
|
55
|
-
startTask(): void;
|
|
56
|
-
endTask(): void;
|
|
57
|
-
private startHeartbeat;
|
|
58
|
-
private stopHeartbeat;
|
|
59
|
-
private mapToolToStage;
|
|
60
|
-
private formatToolName;
|
|
61
|
-
onToolStart(toolName: string, toolArgs?: Record<string, unknown>): void;
|
|
62
|
-
onToolUpdate(toolName: string, partialResult: unknown): void;
|
|
63
|
-
onToolEnd(toolName: string, result: unknown, isError?: boolean): void;
|
|
64
|
-
onThinking(thinking: string): void;
|
|
65
|
-
onTurnStart(): void;
|
|
66
|
-
onMessageStart(): void;
|
|
67
|
-
onMessageUpdate(_content: string): void;
|
|
68
|
-
onAgentEnd(): void;
|
|
69
|
-
getCurrentState(): {
|
|
70
|
-
stage: ProgressStage;
|
|
71
|
-
tool: string | null;
|
|
72
|
-
elapsedMs: number;
|
|
73
|
-
};
|
|
74
|
-
setConfig(config: Partial<ProgressFeedbackConfig>): void;
|
|
75
|
-
getStageEmoji(stage: ProgressStage): string;
|
|
76
|
-
getStageLabel(stage: ProgressStage): string;
|
|
77
|
-
/**
|
|
78
|
-
* Notify about accumulated tool errors
|
|
79
|
-
* Enhanced feedback for tool failures
|
|
80
|
-
*/
|
|
81
|
-
onToolErrorAccumulated(toolName: string, failureCount: number, maxFailures: number, remainingAttempts?: number): void;
|
|
82
|
-
/**
|
|
83
|
-
* Notify about request limit status
|
|
84
|
-
* Enhanced feedback for approaching/ reaching request limits
|
|
85
|
-
*/
|
|
86
|
-
onRequestLimitStatus(count: number, limit: number, remaining: number, isWarning: boolean, shouldStop: boolean): void;
|
|
87
|
-
}
|
|
88
|
-
export declare const progressFeedbackManager: ProgressFeedbackManager;
|
|
89
|
-
export declare function formatProgressMessage(msg: ProgressMessage, parseMode?: 'Markdown' | 'HTML'): string;
|
|
90
|
-
export declare function formatHeartbeatMessage(elapsedMs: number, stage: ProgressStage, detail?: string): string;
|
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
//#region src/agent/lifecycle/progress.ts
|
|
4
|
-
init_logger();
|
|
5
|
-
const log = createLogger("ProgressFeedback");
|
|
6
|
-
const DEFAULT_CONFIG = {
|
|
7
|
-
level: "normal",
|
|
8
|
-
showThinking: true,
|
|
9
|
-
streamToolProgress: true,
|
|
10
|
-
heartbeatEnabled: true,
|
|
11
|
-
heartbeatIntervalMs: 2e4,
|
|
12
|
-
longTaskThresholdMs: 3e4,
|
|
13
|
-
showErrorAccumulation: true,
|
|
14
|
-
showRequestLimitWarning: true
|
|
15
|
-
};
|
|
16
|
-
const TOOL_STAGE_MAP = {
|
|
17
|
-
"read": "reading",
|
|
18
|
-
"read_file": "reading",
|
|
19
|
-
"read_multiple": "reading",
|
|
20
|
-
"glob": "reading",
|
|
21
|
-
"find": "reading",
|
|
22
|
-
"list_dir": "reading",
|
|
23
|
-
"ls": "reading",
|
|
24
|
-
"memory_get": "reading",
|
|
25
|
-
"grep": "searching",
|
|
26
|
-
"web_search": "searching",
|
|
27
|
-
"search": "searching",
|
|
28
|
-
"memory_search": "searching",
|
|
29
|
-
"session_search": "searching",
|
|
30
|
-
"find_files": "searching",
|
|
31
|
-
"web_fetch": "reading",
|
|
32
|
-
"fetch": "reading",
|
|
33
|
-
"curl": "reading",
|
|
34
|
-
"wget": "reading",
|
|
35
|
-
"write": "writing",
|
|
36
|
-
"write_file": "writing",
|
|
37
|
-
"write_multiple": "writing",
|
|
38
|
-
"edit": "writing",
|
|
39
|
-
"apply_patch": "writing",
|
|
40
|
-
"patch": "writing",
|
|
41
|
-
"create": "writing",
|
|
42
|
-
"mkdir": "writing",
|
|
43
|
-
"delete": "writing",
|
|
44
|
-
"remove": "writing",
|
|
45
|
-
"bash": "executing",
|
|
46
|
-
"exec_command": "executing",
|
|
47
|
-
"update_plan": "thinking",
|
|
48
|
-
"exec": "executing",
|
|
49
|
-
"run": "executing",
|
|
50
|
-
"command": "executing",
|
|
51
|
-
"node": "executing",
|
|
52
|
-
"python": "executing",
|
|
53
|
-
"npm": "executing",
|
|
54
|
-
"pnpm": "executing",
|
|
55
|
-
"git": "executing",
|
|
56
|
-
"docker": "executing",
|
|
57
|
-
"kubectl": "executing",
|
|
58
|
-
"message": "idle",
|
|
59
|
-
"send": "idle",
|
|
60
|
-
"reply": "idle",
|
|
61
|
-
"analyze": "analyzing",
|
|
62
|
-
"compare": "analyzing",
|
|
63
|
-
"diff": "analyzing",
|
|
64
|
-
"summarize": "analyzing"
|
|
65
|
-
};
|
|
66
|
-
const STAGE_EMOJI = {
|
|
67
|
-
"thinking": "🤔",
|
|
68
|
-
"searching": "🔍",
|
|
69
|
-
"reading": "📖",
|
|
70
|
-
"writing": "✍️",
|
|
71
|
-
"executing": "⚙️",
|
|
72
|
-
"analyzing": "📊",
|
|
73
|
-
"idle": "💬"
|
|
74
|
-
};
|
|
75
|
-
const STAGE_LABEL = {
|
|
76
|
-
"thinking": "Thinking",
|
|
77
|
-
"searching": "Searching",
|
|
78
|
-
"reading": "Reading",
|
|
79
|
-
"writing": "Writing",
|
|
80
|
-
"executing": "Executing",
|
|
81
|
-
"analyzing": "Analyzing",
|
|
82
|
-
"idle": "Ready"
|
|
83
|
-
};
|
|
84
|
-
var ProgressFeedbackManager = class {
|
|
85
|
-
config;
|
|
86
|
-
callbacks = {};
|
|
87
|
-
currentStage = "idle";
|
|
88
|
-
currentTool = null;
|
|
89
|
-
taskStartTime = 0;
|
|
90
|
-
heartbeatTimer;
|
|
91
|
-
streamActive = false;
|
|
92
|
-
constructor(config = {}) {
|
|
93
|
-
this.config = {
|
|
94
|
-
...DEFAULT_CONFIG,
|
|
95
|
-
...config
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
setCallbacks(callbacks) {
|
|
99
|
-
this.callbacks = {
|
|
100
|
-
...this.callbacks,
|
|
101
|
-
...callbacks
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
startTask() {
|
|
105
|
-
this.taskStartTime = Date.now();
|
|
106
|
-
if (this.config.heartbeatEnabled) this.startHeartbeat();
|
|
107
|
-
}
|
|
108
|
-
endTask() {
|
|
109
|
-
this.stopHeartbeat();
|
|
110
|
-
this.currentStage = "idle";
|
|
111
|
-
this.currentTool = null;
|
|
112
|
-
this.taskStartTime = 0;
|
|
113
|
-
this.streamActive = false;
|
|
114
|
-
}
|
|
115
|
-
startHeartbeat() {
|
|
116
|
-
this.stopHeartbeat();
|
|
117
|
-
this.heartbeatTimer = setInterval(() => {
|
|
118
|
-
const elapsed = Date.now() - this.taskStartTime;
|
|
119
|
-
if (elapsed >= this.config.longTaskThresholdMs) this.callbacks.onHeartbeat?.(elapsed, this.currentStage);
|
|
120
|
-
}, this.config.heartbeatIntervalMs);
|
|
121
|
-
}
|
|
122
|
-
stopHeartbeat() {
|
|
123
|
-
if (this.heartbeatTimer) {
|
|
124
|
-
clearInterval(this.heartbeatTimer);
|
|
125
|
-
this.heartbeatTimer = void 0;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
mapToolToStage(toolName) {
|
|
129
|
-
const normalizedName = toolName.toLowerCase();
|
|
130
|
-
const toCheck = [normalizedName, normalizedName.replace(/_/g, "")];
|
|
131
|
-
const sortedKeys = Object.keys(TOOL_STAGE_MAP).sort((a, b) => b.length - a.length);
|
|
132
|
-
for (const name of toCheck) for (const key of sortedKeys) if (name.includes(key)) return TOOL_STAGE_MAP[key];
|
|
133
|
-
return "executing";
|
|
134
|
-
}
|
|
135
|
-
formatToolName(toolName) {
|
|
136
|
-
return toolName.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
137
|
-
}
|
|
138
|
-
onToolStart(toolName, toolArgs = {}) {
|
|
139
|
-
if (this.config.level === "minimal") return;
|
|
140
|
-
this.currentTool = toolName;
|
|
141
|
-
this.currentStage = this.mapToolToStage(toolName);
|
|
142
|
-
this.streamActive = true;
|
|
143
|
-
const formattedName = this.formatToolName(toolName);
|
|
144
|
-
const emoji = STAGE_EMOJI[this.currentStage];
|
|
145
|
-
const label = STAGE_LABEL[this.currentStage];
|
|
146
|
-
let detail = "";
|
|
147
|
-
if (toolArgs.path) detail = `📁 ${toolArgs.path}`;
|
|
148
|
-
else if (toolArgs.query) detail = `🔎 ${toolArgs.query}`;
|
|
149
|
-
else if (toolArgs.command) {
|
|
150
|
-
const cmd = String(toolArgs.command);
|
|
151
|
-
detail = `⚡ ${cmd.length > 50 ? cmd.slice(0, 50) + "..." : cmd}`;
|
|
152
|
-
}
|
|
153
|
-
const message = {
|
|
154
|
-
type: "start",
|
|
155
|
-
stage: this.currentStage,
|
|
156
|
-
message: `${emoji} ${label}: ${formattedName}`,
|
|
157
|
-
detail: detail || void 0,
|
|
158
|
-
toolName,
|
|
159
|
-
toolArgs
|
|
160
|
-
};
|
|
161
|
-
if (this.config.level === "verbose" || this.config.streamToolProgress) this.callbacks.onProgress?.(message);
|
|
162
|
-
this.callbacks.onStreamStart?.(toolName, toolArgs);
|
|
163
|
-
log.debug({
|
|
164
|
-
toolName,
|
|
165
|
-
stage: this.currentStage
|
|
166
|
-
}, "Tool execution started");
|
|
167
|
-
}
|
|
168
|
-
onToolUpdate(toolName, partialResult) {
|
|
169
|
-
if (this.config.level === "minimal") return;
|
|
170
|
-
if (!this.streamActive || !this.config.streamToolProgress) return;
|
|
171
|
-
let displayResult = "";
|
|
172
|
-
if (typeof partialResult === "string") displayResult = partialResult.slice(0, 200);
|
|
173
|
-
else if (partialResult && typeof partialResult === "object") {
|
|
174
|
-
const result = partialResult;
|
|
175
|
-
if (result.output) displayResult = String(result.output).slice(0, 200);
|
|
176
|
-
else if (result.content) displayResult = String(result.content).slice(0, 200);
|
|
177
|
-
else if (result.text) displayResult = String(result.text).slice(0, 200);
|
|
178
|
-
}
|
|
179
|
-
this.callbacks.onStreamUpdate?.(toolName, displayResult);
|
|
180
|
-
}
|
|
181
|
-
onToolEnd(toolName, result, isError = false) {
|
|
182
|
-
if (this.config.level === "minimal" && !isError) return;
|
|
183
|
-
const wasActive = this.streamActive;
|
|
184
|
-
this.streamActive = false;
|
|
185
|
-
let resultSummary = "";
|
|
186
|
-
if (result && typeof result === "object") {
|
|
187
|
-
const res = result;
|
|
188
|
-
if (res.content && Array.isArray(res.content)) {
|
|
189
|
-
const textContent = res.content.find((c) => typeof c === "object" && c !== null && c.type === "text");
|
|
190
|
-
if (textContent) resultSummary = String(textContent.text || "").slice(0, 100);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const message = {
|
|
194
|
-
type: isError ? "error" : "complete",
|
|
195
|
-
stage: this.currentStage,
|
|
196
|
-
message: isError ? `❌ Tool failed: ${this.formatToolName(toolName)}` : `✅ Done: ${this.formatToolName(toolName)}`,
|
|
197
|
-
toolName
|
|
198
|
-
};
|
|
199
|
-
if (wasActive) this.callbacks.onStreamEnd?.(toolName, resultSummary, isError);
|
|
200
|
-
if (isError || this.config.level !== "minimal") this.callbacks.onProgress?.(message);
|
|
201
|
-
if (this.currentTool === toolName) {
|
|
202
|
-
this.currentTool = null;
|
|
203
|
-
this.currentStage = "idle";
|
|
204
|
-
}
|
|
205
|
-
log.debug({
|
|
206
|
-
toolName,
|
|
207
|
-
isError
|
|
208
|
-
}, "Tool execution ended");
|
|
209
|
-
}
|
|
210
|
-
onThinking(thinking) {
|
|
211
|
-
if (!this.config.showThinking || this.config.level === "minimal") return;
|
|
212
|
-
const displayThinking = thinking.length > 100 ? thinking.slice(0, 100) + "..." : thinking;
|
|
213
|
-
this.callbacks.onThinking?.(displayThinking);
|
|
214
|
-
}
|
|
215
|
-
onTurnStart() {
|
|
216
|
-
if (this.config.level === "minimal") return;
|
|
217
|
-
this.currentStage = "thinking";
|
|
218
|
-
this.taskStartTime = Date.now();
|
|
219
|
-
if (this.config.heartbeatEnabled && !this.heartbeatTimer) this.startHeartbeat();
|
|
220
|
-
}
|
|
221
|
-
onMessageStart() {}
|
|
222
|
-
onMessageUpdate(_content) {}
|
|
223
|
-
onAgentEnd() {
|
|
224
|
-
this.endTask();
|
|
225
|
-
}
|
|
226
|
-
getCurrentState() {
|
|
227
|
-
return {
|
|
228
|
-
stage: this.currentStage,
|
|
229
|
-
tool: this.currentTool,
|
|
230
|
-
elapsedMs: this.taskStartTime ? Date.now() - this.taskStartTime : 0
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
setConfig(config) {
|
|
234
|
-
this.config = {
|
|
235
|
-
...this.config,
|
|
236
|
-
...config
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
getStageEmoji(stage) {
|
|
240
|
-
return STAGE_EMOJI[stage] || "💬";
|
|
241
|
-
}
|
|
242
|
-
getStageLabel(stage) {
|
|
243
|
-
return STAGE_LABEL[stage] || "Unknown";
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Notify about accumulated tool errors
|
|
247
|
-
* Enhanced feedback for tool failures
|
|
248
|
-
*/
|
|
249
|
-
onToolErrorAccumulated(toolName, failureCount, maxFailures, remainingAttempts) {
|
|
250
|
-
if (!this.config.showErrorAccumulation) return;
|
|
251
|
-
if (this.config.level === "minimal") return;
|
|
252
|
-
const remaining = remainingAttempts ?? maxFailures - failureCount;
|
|
253
|
-
const percentage = failureCount / maxFailures * 100;
|
|
254
|
-
let message;
|
|
255
|
-
let type = percentage >= 100 ? "error" : "warning";
|
|
256
|
-
if (percentage >= 100) message = `❌ ${this.formatToolName(toolName)} has reached maximum failures (${maxFailures}/${maxFailures})`;
|
|
257
|
-
else if (percentage >= 50) message = `⚠️ ${this.formatToolName(toolName)} failed ${failureCount}/${maxFailures} times`;
|
|
258
|
-
else message = `⚠️ ${this.formatToolName(toolName)} failed ${failureCount} time${failureCount > 1 ? "s" : ""}`;
|
|
259
|
-
const progressMsg = {
|
|
260
|
-
type,
|
|
261
|
-
stage: "executing",
|
|
262
|
-
message,
|
|
263
|
-
detail: remaining > 0 ? `Remaining attempts: ${remaining}` : "Stopping tool execution",
|
|
264
|
-
toolName
|
|
265
|
-
};
|
|
266
|
-
this.callbacks.onProgress?.(progressMsg);
|
|
267
|
-
const atCap = maxFailures > 0 && failureCount >= maxFailures;
|
|
268
|
-
const summary = atCap ? `Tool "${toolName}" reached max failures (${failureCount}/${maxFailures})` : `Tool "${toolName}" failures ${failureCount}/${maxFailures} (${remaining} attempt(s) left)`;
|
|
269
|
-
if (atCap) log.error({
|
|
270
|
-
toolName,
|
|
271
|
-
failureCount,
|
|
272
|
-
maxFailures,
|
|
273
|
-
remaining
|
|
274
|
-
}, summary);
|
|
275
|
-
else log.warn({
|
|
276
|
-
toolName,
|
|
277
|
-
failureCount,
|
|
278
|
-
maxFailures,
|
|
279
|
-
remaining
|
|
280
|
-
}, summary);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Notify about request limit status
|
|
284
|
-
* Enhanced feedback for approaching/ reaching request limits
|
|
285
|
-
*/
|
|
286
|
-
onRequestLimitStatus(count, limit, remaining, isWarning, shouldStop) {
|
|
287
|
-
if (!this.config.showRequestLimitWarning) return;
|
|
288
|
-
if (this.config.level === "minimal") return;
|
|
289
|
-
if (!isWarning && !shouldStop) return;
|
|
290
|
-
const percentage = count / limit * 100;
|
|
291
|
-
let message;
|
|
292
|
-
let type = shouldStop ? "error" : "warning";
|
|
293
|
-
if (shouldStop) message = `❌ Request limit reached (${count}/${limit})`;
|
|
294
|
-
else if (percentage >= 90) message = `⚠️ Request limit warning (${count}/${limit})`;
|
|
295
|
-
else message = `⚠️ Approaching request limit (${count}/${limit})`;
|
|
296
|
-
const progressMsg = {
|
|
297
|
-
type,
|
|
298
|
-
stage: "thinking",
|
|
299
|
-
message,
|
|
300
|
-
detail: remaining > 0 ? `Remaining requests: ${remaining}` : "Stopping execution"
|
|
301
|
-
};
|
|
302
|
-
this.callbacks.onProgress?.(progressMsg);
|
|
303
|
-
const summary = shouldStop ? `LLM request limit reached (${count}/${limit}); stopping turn` : `LLM request budget ${count}/${limit} (${remaining} left)`;
|
|
304
|
-
if (shouldStop) log.error({
|
|
305
|
-
count,
|
|
306
|
-
limit,
|
|
307
|
-
remaining,
|
|
308
|
-
shouldStop
|
|
309
|
-
}, summary);
|
|
310
|
-
else log.warn({
|
|
311
|
-
count,
|
|
312
|
-
limit,
|
|
313
|
-
remaining,
|
|
314
|
-
shouldStop
|
|
315
|
-
}, summary);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
const progressFeedbackManager = new ProgressFeedbackManager();
|
|
319
|
-
function formatProgressMessage(msg, parseMode = "HTML") {
|
|
320
|
-
const emoji = STAGE_EMOJI[msg.stage];
|
|
321
|
-
if (parseMode === "HTML") {
|
|
322
|
-
let html = `<b>${emoji} ${msg.message}</b>`;
|
|
323
|
-
if (msg.detail) html += `\n${msg.detail}`;
|
|
324
|
-
return html;
|
|
325
|
-
} else {
|
|
326
|
-
let md = `**${emoji} ${msg.message}**`;
|
|
327
|
-
if (msg.detail) md += `\n${msg.detail}`;
|
|
328
|
-
return md;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function formatHeartbeatMessage(elapsedMs, stage, detail) {
|
|
332
|
-
const seconds = Math.floor(elapsedMs / 1e3);
|
|
333
|
-
let message = `${STAGE_EMOJI[stage]} Still ${STAGE_LABEL[stage].toLowerCase()}...`;
|
|
334
|
-
if (detail) message += `\n${detail}`;
|
|
335
|
-
message += `\n⏱️ ${seconds}s elapsed`;
|
|
336
|
-
return message;
|
|
337
|
-
}
|
|
338
|
-
//#endregion
|
|
339
|
-
export { ProgressFeedbackManager, formatHeartbeatMessage, formatProgressMessage, progressFeedbackManager };
|