@codebolt/codeboltjs 5.0.8 → 5.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Codebolt.d.ts +48 -5
- package/dist/core/Codebolt.js +76 -16
- package/dist/core/websocket.js +16 -18
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -3
- package/dist/modules/agentDeliberation.js +3 -1
- package/dist/modules/dynamicPanel.d.ts +106 -0
- package/dist/modules/dynamicPanel.js +122 -0
- package/dist/modules/environment.d.ts +24 -0
- package/dist/modules/environment.js +51 -0
- package/dist/modules/mcp.js +3 -0
- package/dist/tools/actionBlock/action-block-start.js +1 -4
- package/dist/tools/actionPlan/action-plan-create.js +1 -2
- package/dist/tools/completion/attempt-completion.d.ts +25 -0
- package/dist/tools/completion/attempt-completion.js +45 -0
- package/dist/tools/completion/index.d.ts +3 -0
- package/dist/tools/completion/index.js +9 -0
- package/dist/tools/environment/environment-create.d.ts +23 -0
- package/dist/tools/environment/environment-create.js +90 -0
- package/dist/tools/environment/environment-delete.d.ts +17 -0
- package/dist/tools/environment/environment-delete.js +70 -0
- package/dist/tools/environment/environment-get.d.ts +17 -0
- package/dist/tools/environment/environment-get.js +73 -0
- package/dist/tools/environment/environment-list.d.ts +15 -0
- package/dist/tools/environment/environment-list.js +72 -0
- package/dist/tools/environment/environment-providers.d.ts +24 -0
- package/dist/tools/environment/environment-providers.js +130 -0
- package/dist/tools/environment/environment-restart.d.ts +17 -0
- package/dist/tools/environment/environment-restart.js +70 -0
- package/dist/tools/environment/environment-send-message.d.ts +19 -0
- package/dist/tools/environment/environment-send-message.js +74 -0
- package/dist/tools/environment/environment-start.d.ts +17 -0
- package/dist/tools/environment/environment-start.js +70 -0
- package/dist/tools/environment/environment-statistics.d.ts +15 -0
- package/dist/tools/environment/environment-statistics.js +69 -0
- package/dist/tools/environment/environment-status.d.ts +17 -0
- package/dist/tools/environment/environment-status.js +72 -0
- package/dist/tools/environment/environment-stop.d.ts +17 -0
- package/dist/tools/environment/environment-stop.js +70 -0
- package/dist/tools/environment/environment-update.d.ts +19 -0
- package/dist/tools/environment/environment-update.js +74 -0
- package/dist/tools/environment/index.d.ts +31 -0
- package/dist/tools/environment/index.js +61 -0
- package/dist/tools/index.d.ts +20 -3
- package/dist/tools/index.js +55 -8
- package/dist/tools/job/index.d.ts +3 -1
- package/dist/tools/job/index.js +5 -1
- package/dist/tools/job/job-remove-dependency.d.ts +28 -0
- package/dist/tools/job/job-remove-dependency.js +86 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +38 -1
- package/dist/tools/requirementPlan/requirement-plan-review.js +1 -1
- package/dist/tools/thread/thread-create-background.js +1 -1
- package/dist/tools/tool-search.d.ts +49 -0
- package/dist/tools/tool-search.js +140 -0
- package/dist/tools/toolSearch/index.d.ts +9 -0
- package/dist/tools/toolSearch/index.js +15 -0
- package/dist/tools/toolSearch/tool-search-tool.d.ts +32 -0
- package/dist/tools/toolSearch/tool-search-tool.js +110 -0
- package/dist/tools/utils/schema-validator.d.ts +1 -0
- package/dist/tools/utils/schema-validator.js +13 -1
- package/dist/types/agentDeliberation.d.ts +15 -1
- package/dist/types/agentDeliberation.js +2 -0
- package/package.json +20 -19
- package/dist/modules/codeboltEvent.d.ts +0 -57
- package/dist/modules/codeboltEvent.js +0 -217
- package/dist/tools/browser/browser-action.d.ts +0 -56
- package/dist/tools/browser/browser-action.js +0 -265
- package/dist/tools/codeboltEvent/event-add-running-agent.d.ts +0 -25
- package/dist/tools/codeboltEvent/event-add-running-agent.js +0 -69
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.js +0 -64
- package/dist/tools/codeboltEvent/event-get-running-agent-count.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-get-running-agent-count.js +0 -55
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.js +0 -56
- package/dist/tools/codeboltEvent/event-wait-for-external-event.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-wait-for-external-event.js +0 -55
- package/dist/tools/codeboltEvent/index.d.ts +0 -19
- package/dist/tools/codeboltEvent/index.js +0 -33
- package/dist/tools/event/event-add-running-agent.d.ts +0 -32
- package/dist/tools/event/event-add-running-agent.js +0 -77
- package/dist/tools/event/event-check-agent-event.d.ts +0 -19
- package/dist/tools/event/event-check-agent-event.js +0 -63
- package/dist/tools/event/event-check-completion.d.ts +0 -19
- package/dist/tools/event/event-check-completion.js +0 -73
- package/dist/tools/event/event-check-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-check-grouped-completion.js +0 -63
- package/dist/tools/event/event-get-running-count.d.ts +0 -19
- package/dist/tools/event/event-get-running-count.js +0 -55
- package/dist/tools/event/event-on-agent-event.d.ts +0 -19
- package/dist/tools/event/event-on-agent-event.js +0 -63
- package/dist/tools/event/event-on-completion.d.ts +0 -19
- package/dist/tools/event/event-on-completion.js +0 -73
- package/dist/tools/event/event-on-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-on-grouped-completion.js +0 -63
- package/dist/tools/event/event-wait-any.d.ts +0 -19
- package/dist/tools/event/event-wait-any.js +0 -66
- package/dist/tools/event/index.d.ts +0 -25
- package/dist/tools/event/index.js +0 -48
- package/dist/tools/git/git-action.d.ts +0 -48
- package/dist/tools/git/git-action.js +0 -279
- package/dist/tools/kvStore/kv-store-create-instance.d.ts +0 -26
- package/dist/tools/kvStore/kv-store-create-instance.js +0 -79
- package/dist/tools/kvStore/kv-store-get.d.ts +0 -30
- package/dist/tools/kvStore/kv-store-get.js +0 -80
- package/dist/tools/kvStore/kv-store-set.d.ts +0 -38
- package/dist/tools/kvStore/kv-store-set.js +0 -86
- package/dist/tools/memoryIngestion/mi-create-pipeline.d.ts +0 -44
- package/dist/tools/memoryIngestion/mi-create-pipeline.js +0 -114
- package/dist/tools/memoryIngestion/mi-list.d.ts +0 -22
- package/dist/tools/memoryIngestion/mi-list.js +0 -66
- package/dist/tools/orchestration/agent-details.d.ts +0 -15
- package/dist/tools/orchestration/agent-details.js +0 -98
- package/dist/tools/orchestration/agent-find.d.ts +0 -18
- package/dist/tools/orchestration/agent-find.js +0 -125
- package/dist/tools/orchestration/agent-list.d.ts +0 -13
- package/dist/tools/orchestration/agent-list.js +0 -106
- package/dist/tools/orchestration/agent-management.d.ts +0 -44
- package/dist/tools/orchestration/agent-management.js +0 -250
- package/dist/tools/orchestration/agent-start.d.ts +0 -18
- package/dist/tools/orchestration/agent-start.js +0 -90
- package/dist/tools/orchestration/index.d.ts +0 -49
- package/dist/tools/orchestration/index.js +0 -102
- package/dist/tools/orchestration/task-assign.d.ts +0 -18
- package/dist/tools/orchestration/task-assign.js +0 -84
- package/dist/tools/orchestration/task-create.d.ts +0 -20
- package/dist/tools/orchestration/task-create.js +0 -97
- package/dist/tools/orchestration/task-delete.d.ts +0 -16
- package/dist/tools/orchestration/task-delete.js +0 -77
- package/dist/tools/orchestration/task-execute.d.ts +0 -18
- package/dist/tools/orchestration/task-execute.js +0 -84
- package/dist/tools/orchestration/task-get.d.ts +0 -16
- package/dist/tools/orchestration/task-get.js +0 -89
- package/dist/tools/orchestration/task-list.d.ts +0 -13
- package/dist/tools/orchestration/task-list.js +0 -74
- package/dist/tools/orchestration/task-management.d.ts +0 -52
- package/dist/tools/orchestration/task-management.js +0 -231
- package/dist/tools/orchestration/task-update.d.ts +0 -22
- package/dist/tools/orchestration/task-update.js +0 -96
- package/dist/tools/orchestration/thread-create-background.d.ts +0 -18
- package/dist/tools/orchestration/thread-create-background.js +0 -94
- package/dist/tools/orchestration/thread-create-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-create-start.js +0 -85
- package/dist/tools/orchestration/thread-create.d.ts +0 -16
- package/dist/tools/orchestration/thread-create.js +0 -85
- package/dist/tools/orchestration/thread-delete.d.ts +0 -16
- package/dist/tools/orchestration/thread-delete.js +0 -77
- package/dist/tools/orchestration/thread-get-messages.d.ts +0 -24
- package/dist/tools/orchestration/thread-get-messages.js +0 -122
- package/dist/tools/orchestration/thread-get.d.ts +0 -16
- package/dist/tools/orchestration/thread-get.js +0 -85
- package/dist/tools/orchestration/thread-list.d.ts +0 -16
- package/dist/tools/orchestration/thread-list.js +0 -85
- package/dist/tools/orchestration/thread-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-start.js +0 -82
- package/dist/tools/orchestration/thread-update-status.d.ts +0 -18
- package/dist/tools/orchestration/thread-update-status.js +0 -89
- package/dist/tools/orchestration/thread-update.d.ts +0 -18
- package/dist/tools/orchestration/thread-update.js +0 -89
package/dist/core/Codebolt.d.ts
CHANGED
|
@@ -413,11 +413,7 @@ declare class Codebolt {
|
|
|
413
413
|
importTodos: (params: {
|
|
414
414
|
data: string;
|
|
415
415
|
format?: "json" | "markdown";
|
|
416
|
-
mergeStrategy
|
|
417
|
-
* @method isReady
|
|
418
|
-
* @description Checks if the Codebolt instance is ready for use.
|
|
419
|
-
* @returns {boolean} True if the instance is ready, false otherwise.
|
|
420
|
-
*/: "replace" | "merge";
|
|
416
|
+
mergeStrategy?: "replace" | "merge";
|
|
421
417
|
listId?: string;
|
|
422
418
|
}) => Promise<import("@codebolt/types/sdk").ImportTodosResponse>;
|
|
423
419
|
};
|
|
@@ -901,6 +897,35 @@ declare class Codebolt {
|
|
|
901
897
|
getPendingExternalEventCount: () => number;
|
|
902
898
|
waitForAnyExternalEvent: () => Promise<import("../modules/agentEventQueue").UnifiedExternalEvent>;
|
|
903
899
|
};
|
|
900
|
+
dynamicPanel: {
|
|
901
|
+
open: (panelId: string, title: string, html: string, opts?: import("../modules/dynamicPanel").DynamicPanelOpenOptions) => Promise<import("../modules/dynamicPanel").DynamicPanelOpenResponse>;
|
|
902
|
+
update: (panelId: string, html: string) => Promise<import("../modules/dynamicPanel").DynamicPanelResponse>;
|
|
903
|
+
close: (panelId: string) => Promise<import("../modules/dynamicPanel").DynamicPanelResponse>;
|
|
904
|
+
send: (panelId: string, data: any) => Promise<import("../modules/dynamicPanel").DynamicPanelResponse>;
|
|
905
|
+
list: () => Promise<import("../modules/dynamicPanel").DynamicPanelListResponse>;
|
|
906
|
+
onMessage: (panelId: string, handler: (data: any) => void) => void;
|
|
907
|
+
offMessage: (panelId: string) => void;
|
|
908
|
+
};
|
|
909
|
+
environment: {
|
|
910
|
+
listEnvironments: () => Promise<any>;
|
|
911
|
+
getEnvironment: (environmentId: string) => Promise<any>;
|
|
912
|
+
createEnvironment: (environmentData: {
|
|
913
|
+
name: string;
|
|
914
|
+
description?: string;
|
|
915
|
+
provider: any;
|
|
916
|
+
config?: any;
|
|
917
|
+
}) => Promise<any>;
|
|
918
|
+
updateEnvironment: (environmentId: string, updateData: any) => Promise<any>;
|
|
919
|
+
deleteEnvironment: (environmentId: string) => Promise<any>;
|
|
920
|
+
startEnvironment: (environmentId: string) => Promise<any>;
|
|
921
|
+
stopEnvironment: (environmentId: string) => Promise<any>;
|
|
922
|
+
restartEnvironment: (environmentId: string) => Promise<any>;
|
|
923
|
+
getEnvironmentStatus: (environmentId: string) => Promise<any>;
|
|
924
|
+
getRunningProviders: () => Promise<any>;
|
|
925
|
+
getLocalProviders: () => Promise<any>;
|
|
926
|
+
getEnvironmentStatistics: () => Promise<any>;
|
|
927
|
+
sendMessageToEnvironment: (environmentId: string, message: any) => Promise<any>;
|
|
928
|
+
};
|
|
904
929
|
/**
|
|
905
930
|
* User message utilities for accessing current user message and context
|
|
906
931
|
*/
|
|
@@ -989,6 +1014,24 @@ declare class Codebolt {
|
|
|
989
1014
|
* @returns {void}
|
|
990
1015
|
*/
|
|
991
1016
|
onProviderStart(handler: (initvars: ProviderInitVars) => void | Promise<void> | any | Promise<any>): void;
|
|
1017
|
+
/**
|
|
1018
|
+
* Sets up a listener for plugin start events.
|
|
1019
|
+
* Called when a plugin process connects and receives its context from the server.
|
|
1020
|
+
* @param {Function} handler - The handler function to call when the plugin receives its start message.
|
|
1021
|
+
* @returns {void}
|
|
1022
|
+
*/
|
|
1023
|
+
onPluginStart(handler: (context: {
|
|
1024
|
+
pluginId: string;
|
|
1025
|
+
pluginDir: string;
|
|
1026
|
+
manifest: any;
|
|
1027
|
+
}) => void | Promise<void> | any | Promise<any>): void;
|
|
1028
|
+
/**
|
|
1029
|
+
* Sets up a listener for graceful plugin stop requests from the server.
|
|
1030
|
+
* The handler should perform cleanup (close panels, unsubscribe events, etc.)
|
|
1031
|
+
* @param {Function} handler - The handler function to call when the server requests plugin stop.
|
|
1032
|
+
* @returns {void}
|
|
1033
|
+
*/
|
|
1034
|
+
onPluginStop(handler: () => void | Promise<void>): void;
|
|
992
1035
|
/**
|
|
993
1036
|
* Sets up a listener for provider agent start events.
|
|
994
1037
|
* @param {Function} handler - The handler function to call when provider agent starts.
|
package/dist/core/Codebolt.js
CHANGED
|
@@ -65,6 +65,8 @@ const agentPortfolio_1 = __importDefault(require("../modules/agentPortfolio"));
|
|
|
65
65
|
const orchestrator_1 = __importDefault(require("../modules/orchestrator"));
|
|
66
66
|
const backgroundChildThreads_1 = __importDefault(require("../modules/backgroundChildThreads"));
|
|
67
67
|
const agentEventQueue_1 = __importDefault(require("../modules/agentEventQueue"));
|
|
68
|
+
const dynamicPanel_1 = __importDefault(require("../modules/dynamicPanel"));
|
|
69
|
+
const environment_1 = __importDefault(require("../modules/environment"));
|
|
68
70
|
/**
|
|
69
71
|
* @class Codebolt
|
|
70
72
|
* @description This class provides a unified interface to interact with various modules.
|
|
@@ -139,6 +141,8 @@ class Codebolt {
|
|
|
139
141
|
this.orchestrator = orchestrator_1.default;
|
|
140
142
|
this.backgroundChildThreads = backgroundChildThreads_1.default;
|
|
141
143
|
this.agentEventQueue = agentEventQueue_1.default;
|
|
144
|
+
this.dynamicPanel = dynamicPanel_1.default;
|
|
145
|
+
this.environment = environment_1.default;
|
|
142
146
|
/**
|
|
143
147
|
* User message utilities for accessing current user message and context
|
|
144
148
|
*/
|
|
@@ -475,6 +479,62 @@ class Codebolt {
|
|
|
475
479
|
console.error('Failed to set up provider start handler:', error);
|
|
476
480
|
});
|
|
477
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Sets up a listener for plugin start events.
|
|
484
|
+
* Called when a plugin process connects and receives its context from the server.
|
|
485
|
+
* @param {Function} handler - The handler function to call when the plugin receives its start message.
|
|
486
|
+
* @returns {void}
|
|
487
|
+
*/
|
|
488
|
+
onPluginStart(handler) {
|
|
489
|
+
this.waitForReady().then(() => {
|
|
490
|
+
const handlePluginStart = async (response) => {
|
|
491
|
+
if (response.type === "pluginStartMessage") {
|
|
492
|
+
try {
|
|
493
|
+
await handler({
|
|
494
|
+
pluginId: response.pluginId,
|
|
495
|
+
pluginDir: response.pluginDir,
|
|
496
|
+
manifest: response.manifest,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
catch (error) {
|
|
500
|
+
console.error('Error in plugin start handler:', error);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
websocket_1.default.messageManager.on('message', handlePluginStart);
|
|
505
|
+
}).catch(error => {
|
|
506
|
+
console.error('Failed to set up plugin start handler:', error);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Sets up a listener for graceful plugin stop requests from the server.
|
|
511
|
+
* The handler should perform cleanup (close panels, unsubscribe events, etc.)
|
|
512
|
+
* @param {Function} handler - The handler function to call when the server requests plugin stop.
|
|
513
|
+
* @returns {void}
|
|
514
|
+
*/
|
|
515
|
+
onPluginStop(handler) {
|
|
516
|
+
this.waitForReady().then(() => {
|
|
517
|
+
const handlePluginStop = async (response) => {
|
|
518
|
+
if (response.type === "pluginStopMessage") {
|
|
519
|
+
try {
|
|
520
|
+
await handler();
|
|
521
|
+
websocket_1.default.messageManager.send({ type: 'pluginStopResponse', success: true });
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
console.error('Error in plugin stop handler:', error);
|
|
525
|
+
websocket_1.default.messageManager.send({
|
|
526
|
+
type: 'pluginStopResponse',
|
|
527
|
+
success: false,
|
|
528
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
websocket_1.default.messageManager.on('message', handlePluginStop);
|
|
534
|
+
}).catch(error => {
|
|
535
|
+
console.error('Failed to set up plugin stop handler:', error);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
478
538
|
/**
|
|
479
539
|
* Sets up a listener for provider agent start events.
|
|
480
540
|
* @param {Function} handler - The handler function to call when provider agent starts.
|
|
@@ -554,7 +614,7 @@ class Codebolt {
|
|
|
554
614
|
onGetDiffFiles(handler) {
|
|
555
615
|
this.waitForReady().then(() => {
|
|
556
616
|
const handleGetDiffFiles = async (response) => {
|
|
557
|
-
console.log("Get diff files event received");
|
|
617
|
+
// console.log("Get diff files event received");
|
|
558
618
|
if (response.type === "providerGetDiffFiles") {
|
|
559
619
|
try {
|
|
560
620
|
const result = await handler();
|
|
@@ -589,7 +649,7 @@ class Codebolt {
|
|
|
589
649
|
onReadFile(handler) {
|
|
590
650
|
this.waitForReady().then(() => {
|
|
591
651
|
const handleReadFile = async (response) => {
|
|
592
|
-
console.log("Read file event received");
|
|
652
|
+
// console.log("Read file event received");
|
|
593
653
|
if (response.type === "providerReadFile") {
|
|
594
654
|
try {
|
|
595
655
|
const result = await handler(response.path);
|
|
@@ -625,7 +685,7 @@ class Codebolt {
|
|
|
625
685
|
onWriteFile(handler) {
|
|
626
686
|
this.waitForReady().then(() => {
|
|
627
687
|
const handleWriteFile = async (response) => {
|
|
628
|
-
console.log("Write file event received");
|
|
688
|
+
// console.log("Write file event received");
|
|
629
689
|
if (response.type === "providerWriteFile") {
|
|
630
690
|
try {
|
|
631
691
|
const result = await handler(response.path, response.content);
|
|
@@ -661,7 +721,7 @@ class Codebolt {
|
|
|
661
721
|
onDeleteFile(handler) {
|
|
662
722
|
this.waitForReady().then(() => {
|
|
663
723
|
const handleDeleteFile = async (response) => {
|
|
664
|
-
console.log("Delete file event received");
|
|
724
|
+
// console.log("Delete file event received");
|
|
665
725
|
if (response.type === "providerDeleteFile") {
|
|
666
726
|
try {
|
|
667
727
|
const result = await handler(response.path);
|
|
@@ -697,7 +757,7 @@ class Codebolt {
|
|
|
697
757
|
onDeleteFolder(handler) {
|
|
698
758
|
this.waitForReady().then(() => {
|
|
699
759
|
const handleDeleteFolder = async (response) => {
|
|
700
|
-
console.log("Delete folder event received");
|
|
760
|
+
// console.log("Delete folder event received");
|
|
701
761
|
if (response.type === "providerDeleteFolder") {
|
|
702
762
|
try {
|
|
703
763
|
const result = await handler(response.path);
|
|
@@ -733,7 +793,7 @@ class Codebolt {
|
|
|
733
793
|
onRenameItem(handler) {
|
|
734
794
|
this.waitForReady().then(() => {
|
|
735
795
|
const handleRenameItem = async (response) => {
|
|
736
|
-
console.log("Rename item event received");
|
|
796
|
+
// console.log("Rename item event received");
|
|
737
797
|
if (response.type === "providerRenameItem") {
|
|
738
798
|
try {
|
|
739
799
|
const result = await handler(response.oldPath, response.newPath);
|
|
@@ -769,7 +829,7 @@ class Codebolt {
|
|
|
769
829
|
onCreateFolder(handler) {
|
|
770
830
|
this.waitForReady().then(() => {
|
|
771
831
|
const handleCreateFolder = async (response) => {
|
|
772
|
-
console.log("Create folder event received");
|
|
832
|
+
// console.log("Create folder event received");
|
|
773
833
|
if (response.type === "providerCreateFolder") {
|
|
774
834
|
try {
|
|
775
835
|
const result = await handler(response.path);
|
|
@@ -805,7 +865,7 @@ class Codebolt {
|
|
|
805
865
|
onCopyFile(handler) {
|
|
806
866
|
this.waitForReady().then(() => {
|
|
807
867
|
const handleCopyFile = async (response) => {
|
|
808
|
-
console.log("Copy file event received");
|
|
868
|
+
// console.log("Copy file event received");
|
|
809
869
|
if (response.type === "providerCopyFile") {
|
|
810
870
|
try {
|
|
811
871
|
const result = await handler(response.sourcePath, response.destinationPath);
|
|
@@ -841,7 +901,7 @@ class Codebolt {
|
|
|
841
901
|
onCopyFolder(handler) {
|
|
842
902
|
this.waitForReady().then(() => {
|
|
843
903
|
const handleCopyFolder = async (response) => {
|
|
844
|
-
console.log("Copy folder event received");
|
|
904
|
+
// console.log("Copy folder event received");
|
|
845
905
|
if (response.type === "providerCopyFolder") {
|
|
846
906
|
try {
|
|
847
907
|
const result = await handler(response.sourcePath, response.destinationPath);
|
|
@@ -877,7 +937,7 @@ class Codebolt {
|
|
|
877
937
|
onGetFullProject(handler) {
|
|
878
938
|
this.waitForReady().then(() => {
|
|
879
939
|
const handleGetFullProject = async (response) => {
|
|
880
|
-
console.log("Get full project event received");
|
|
940
|
+
// console.log("Get full project event received");
|
|
881
941
|
if (response.type === "providerGetFullProject") {
|
|
882
942
|
try {
|
|
883
943
|
const result = await handler();
|
|
@@ -913,7 +973,7 @@ class Codebolt {
|
|
|
913
973
|
onCloseSignal(handler) {
|
|
914
974
|
this.waitForReady().then(() => {
|
|
915
975
|
const handleCloseSignal = async (response) => {
|
|
916
|
-
console.log("Close signal event received");
|
|
976
|
+
// console.log("Close signal event received");
|
|
917
977
|
if (response.type === "closeSignal") {
|
|
918
978
|
try {
|
|
919
979
|
const result = await handler();
|
|
@@ -947,7 +1007,7 @@ class Codebolt {
|
|
|
947
1007
|
onCreatePatchRequest(handler) {
|
|
948
1008
|
this.waitForReady().then(() => {
|
|
949
1009
|
const handleCreatePatchRequest = async (response) => {
|
|
950
|
-
console.log("Create patch request event received");
|
|
1010
|
+
// console.log("Create patch request event received");
|
|
951
1011
|
if (response.type === "createPatchRequest") {
|
|
952
1012
|
try {
|
|
953
1013
|
const result = await handler();
|
|
@@ -981,7 +1041,7 @@ class Codebolt {
|
|
|
981
1041
|
onCreatePullRequestRequest(handler) {
|
|
982
1042
|
this.waitForReady().then(() => {
|
|
983
1043
|
const handleCreatePullRequestRequest = async (response) => {
|
|
984
|
-
console.log("Create pull request event received");
|
|
1044
|
+
// console.log("Create pull request event received");
|
|
985
1045
|
if (response.type === "createPullRequestRequest") {
|
|
986
1046
|
try {
|
|
987
1047
|
const result = await handler();
|
|
@@ -1015,7 +1075,7 @@ class Codebolt {
|
|
|
1015
1075
|
onMergeAsPatch(handler) {
|
|
1016
1076
|
this.waitForReady().then(() => {
|
|
1017
1077
|
const handleMergeAsPatch = async (response) => {
|
|
1018
|
-
console.log("Merge as patch event received");
|
|
1078
|
+
// console.log("Merge as patch event received");
|
|
1019
1079
|
if (response.type === "providerMergeAsPatch") {
|
|
1020
1080
|
try {
|
|
1021
1081
|
const result = await handler();
|
|
@@ -1051,7 +1111,7 @@ class Codebolt {
|
|
|
1051
1111
|
onSendPR(handler) {
|
|
1052
1112
|
this.waitForReady().then(() => {
|
|
1053
1113
|
const handleSendPR = async (response) => {
|
|
1054
|
-
console.log("Send PR event received");
|
|
1114
|
+
// console.log("Send PR event received");
|
|
1055
1115
|
if (response.type === "providerSendPR") {
|
|
1056
1116
|
try {
|
|
1057
1117
|
const result = await handler();
|
|
@@ -1087,7 +1147,7 @@ class Codebolt {
|
|
|
1087
1147
|
onGetTreeChildren(handler) {
|
|
1088
1148
|
this.waitForReady().then(() => {
|
|
1089
1149
|
const handleGetTreeChildren = async (response) => {
|
|
1090
|
-
console.log("Get tree children event received");
|
|
1150
|
+
// console.log("Get tree children event received");
|
|
1091
1151
|
if (response.type === "providerGetTreeChildren") {
|
|
1092
1152
|
try {
|
|
1093
1153
|
const result = await handler(response.path);
|
package/dist/core/websocket.js
CHANGED
|
@@ -65,31 +65,29 @@ class cbws {
|
|
|
65
65
|
const socketPort = process.env.SOCKET_PORT || '12345';
|
|
66
66
|
const serverUrl = process.env.CODEBOLT_SERVER_URL || 'localhost';
|
|
67
67
|
const threadToken = process.env.threadToken || null;
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// console.log('parentIdParam:', parentIdParam);
|
|
73
|
-
// console.log('parentAgentInstanceIdParam:', parentAgentInstanceIdParam);
|
|
74
|
-
// console.log('agentTask:', agentTask);
|
|
75
|
-
// console.log('socketPort:', socketPort);
|
|
76
|
-
// console.log('serverUrl:', serverUrl);
|
|
77
|
-
// console.log('threadToken:', threadToken);
|
|
78
|
-
// console.log('[WebSocket] Environment variables check:');
|
|
79
|
-
// console.log('process.env.agentId:', process.env.agentId);
|
|
80
|
-
// console.log('process.env.threadToken:', process.env.threadToken);
|
|
81
|
-
// console.log('process.env.parentId:', process.env.parentId);
|
|
82
|
-
// console.log('process.env.agentTask:', process.env.agentTask);
|
|
68
|
+
// Plugin mode detection
|
|
69
|
+
const isPlugin = process.env.IS_PLUGIN === 'true';
|
|
70
|
+
const pluginId = process.env.pluginId || '';
|
|
71
|
+
const pluginToken = process.env.pluginToken || '';
|
|
83
72
|
const threadTokenParam = threadToken ? `&threadToken=${encodeURIComponent(threadToken)}` : '';
|
|
84
73
|
// Add all custom environment variables as URL parameters
|
|
85
|
-
const knownEnvVars = ['SOCKET_PORT', 'CODEBOLT_SERVER_URL', 'agentId', 'parentId', 'parentAgentInstanceId', 'agentTask', 'threadToken', 'Is_Dev', 'PATH', 'NODE_ENV', 'HOME', 'USER', 'SHELL'];
|
|
74
|
+
const knownEnvVars = ['SOCKET_PORT', 'CODEBOLT_SERVER_URL', 'agentId', 'parentId', 'parentAgentInstanceId', 'agentTask', 'threadToken', 'Is_Dev', 'PATH', 'NODE_ENV', 'HOME', 'USER', 'SHELL', 'IS_PLUGIN', 'pluginId', 'pluginToken', 'PLUGIN_DIR', 'instanceId'];
|
|
86
75
|
let customParams = '';
|
|
87
76
|
for (const [key, value] of Object.entries(process.env)) {
|
|
88
77
|
if (!knownEnvVars.includes(key) && value && !key.startsWith('npm_') && !key.startsWith('_')) {
|
|
89
78
|
customParams += `&${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
90
79
|
}
|
|
91
80
|
}
|
|
92
|
-
|
|
81
|
+
let wsUrl;
|
|
82
|
+
if (isPlugin) {
|
|
83
|
+
// Plugins connect to /plugin endpoint with pluginId/pluginToken
|
|
84
|
+
wsUrl = `ws://${serverUrl}:${socketPort}/plugin?id=${uniqueConnectionId}&pluginId=${encodeURIComponent(pluginId)}&pluginToken=${encodeURIComponent(pluginToken)}${customParams}`;
|
|
85
|
+
console.log('[WebSocket] Plugin mode detected, connecting to /plugin endpoint');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Agents connect to /codebolt endpoint (existing behavior)
|
|
89
|
+
wsUrl = `ws://${serverUrl}:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${threadTokenParam}${customParams}${process.env.Is_Dev ? '&dev=true' : ''}`;
|
|
90
|
+
}
|
|
93
91
|
console.log('[WebSocket] Connecting to:', serverUrl);
|
|
94
92
|
this.websocket = new ws_1.default(wsUrl);
|
|
95
93
|
return new Promise((resolve, reject) => {
|
|
@@ -188,7 +186,7 @@ class cbws {
|
|
|
188
186
|
*/
|
|
189
187
|
get messageManager() {
|
|
190
188
|
if (!this.initialized) {
|
|
191
|
-
console.log('[WebSocket] Accessing message manager (not yet initialized)');
|
|
189
|
+
// console.log('[WebSocket] Accessing message manager (not yet initialized)');
|
|
192
190
|
}
|
|
193
191
|
return messageManager_1.default;
|
|
194
192
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -125,5 +125,8 @@ export { default as codemap } from './modules/codemap';
|
|
|
125
125
|
export { default as projectStructure } from './modules/projectStructure';
|
|
126
126
|
export { default as codebaseSearch } from './modules/codebaseSearch';
|
|
127
127
|
export { default as backgroundChildThreads } from './modules/backgroundChildThreads';
|
|
128
|
+
export { default as dynamicPanel } from './modules/dynamicPanel';
|
|
129
|
+
export { default as environment } from './modules/environment';
|
|
130
|
+
export type { DynamicPanelOpenOptions, DynamicPanelOpenResponse, DynamicPanelResponse, DynamicPanelInfo, DynamicPanelListResponse, DynamicPanelMessageEvent, } from './modules/dynamicPanel';
|
|
128
131
|
export { default as tools } from './tools';
|
|
129
132
|
export { Kind, ToolErrorType, ToolConfirmationOutcome, type ToolResult as ToolFrameworkResult, type ToolLocation, type ToolInvocation, type ToolBuilder, type OpenAIToolSchema, type OpenAIFunctionCall, type ToolCallConfirmationDetails, type AnyDeclarativeTool, type AnyToolInvocation, BaseToolInvocation, DeclarativeTool, BaseDeclarativeTool, ToolRegistry, defaultRegistry, allTools, fileTools, searchTools, terminalTools, gitTools, browserTools, agentTools, threadTools, taskTools, orchestratorTools, ReadFileTool, WriteFileTool, EditTool, ListDirectoryTool, ReadManyFilesTool, GlobTool, GrepTool, SearchFilesTool, CodebaseSearchTool, SearchMcpToolTool, ListCodeDefinitionNamesTool, ExecuteCommandTool, GitInitTool, GitStatusTool, GitAddTool, GitCommitTool, GitPushTool, GitPullTool, GitCheckoutTool, GitBranchTool, GitLogsTool, GitDiffTool, GitCloneTool, BrowserNavigateTool, BrowserScreenshotTool, BrowserClickTool, BrowserTypeTool, BrowserScrollTool, BrowserGetContentTool, BrowserGetHtmlTool, BrowserGetMarkdownTool, BrowserGetUrlTool, BrowserCloseTool, BrowserEnterTool, BrowserSearchTool, TaskCreateTool, TaskUpdateTool, TaskDeleteTool, TaskListTool, TaskGetTool, TaskAssignTool, TaskExecuteTool, AgentFindTool, AgentStartTool, AgentListTool, AgentDetailsTool, ThreadCreateTool, ThreadCreateStartTool, ThreadCreateBackgroundTool, ThreadListTool, ThreadGetTool, ThreadStartTool, ThreadUpdateTool, ThreadDeleteTool, ThreadGetMessagesTool, ThreadUpdateStatusTool, OrchestratorListTool, OrchestratorGetTool, OrchestratorGetSettingsTool, OrchestratorCreateTool, OrchestratorUpdateTool, OrchestratorUpdateSettingsTool, OrchestratorDeleteTool, OrchestratorUpdateStatusTool, } from './tools';
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AgentCompletionNotify = exports.AgentInitNotify = exports.SubagentTaskCompletedNotify = exports.StartSubagentTaskResponseNotify = exports.StartSubagentTaskRequestNotify = exports.notificationFunctions = exports.todoNotifications = exports.terminalNotifications = exports.systemNotifications = exports.searchNotifications = exports.mcpNotifications = exports.llmNotifications = exports.historyNotifications = exports.gitNotifications = exports.fsNotifications = exports.dbmemoryNotifications = exports.crawlerNotifications = exports.codeutilsNotifications = exports.chatNotifications = exports.browserNotifications = exports.agentNotifications = exports.executeOnInstance = exports.closeBrowserInstance = exports.openNewBrowserInstance = exports.setActiveBrowserInstance = exports.getBrowserInstance = exports.listBrowserInstances = exports.editFileAndApplyDiff = exports.queryVectorItems = exports.queryVectorItem = exports.addVectorItem = exports.getVector = exports.utils = exports.getMessageId = exports.getUserMessageTimestamp = exports.getUserSessionData = exports.setUserSessionData = exports.getUploadedImages = exports.getRemixPrompt = exports.getSelection = exports.getCurrentFile = exports.getMentionedMCPs = exports.getMentionedFiles = exports.clearUserMessage = exports.hasCurrentUserMessage = exports.getUserMessageText = exports.getCurrentUserMessage = exports.userMessageUtilities = exports.logType = exports.Codebolt = void 0;
|
|
7
7
|
exports.knowledge = exports.search = exports.crawler = exports.codeutils = exports.terminal = exports.chat = exports.browser = exports.agentDeliberation = exports.groupFeedback = exports.mail = exports.llm = exports.git = exports.fs = exports.agentEventQueue = exports.AgentEventPriority = exports.AgentEventStatus = exports.AgentEventType = exports.agentPortfolio = exports.contextRuleEngine = exports.contextAssembly = exports.memoryIngestion = exports.hook = exports.knowledgeGraph = exports.eventLog = exports.orchestrator = exports.persistentMemory = exports.kvStore = exports.reviewMergeRequest = exports.projectStructureUpdateRequest = exports.fileUpdateIntent = exports.episodicMemory = exports.calendar = exports.swarm = exports.requirementPlan = exports.actionBlock = exports.capability = exports.sideExecution = exports.GitStatusRequestNotify = exports.GitRemoteAddRequestNotify = exports.GitPushRequestNotify = exports.GitPullRequestNotify = exports.GitLogsRequestNotify = exports.GitInitRequestNotify = exports.GitDiffRequestNotify = exports.GitCommitRequestNotify = exports.GitCloneRequestNotify = exports.GitCheckoutRequestNotify = exports.GitBranchRequestNotify = exports.GitAddRequestNotify = exports.CommandExecutionRequestNotify = void 0;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.OrchestratorUpdateStatusTool = exports.OrchestratorDeleteTool = exports.OrchestratorUpdateSettingsTool = exports.OrchestratorUpdateTool = exports.OrchestratorCreateTool = exports.OrchestratorGetSettingsTool = void 0;
|
|
8
|
+
exports.GlobTool = exports.ReadManyFilesTool = exports.ListDirectoryTool = exports.EditTool = exports.WriteFileTool = exports.ReadFileTool = exports.orchestratorTools = exports.taskTools = exports.threadTools = exports.agentTools = exports.browserTools = exports.gitTools = exports.terminalTools = exports.searchTools = exports.fileTools = exports.allTools = exports.defaultRegistry = exports.ToolRegistry = exports.BaseDeclarativeTool = exports.DeclarativeTool = exports.BaseToolInvocation = exports.ToolConfirmationOutcome = exports.ToolErrorType = exports.Kind = exports.tools = exports.environment = exports.dynamicPanel = exports.backgroundChildThreads = exports.codebaseSearch = exports.projectStructure = exports.codemap = exports.roadmap = exports.autoTesting = exports.job = exports.todo = exports.actionPlan = exports.memory = exports.agent = exports.mcp = exports.chatSummary = exports.tokenizer = exports.debug = exports.vectordb = exports.thread = exports.task = exports.state = exports.dbmemory = exports.project = exports.outputparsers = exports.rag = void 0;
|
|
9
|
+
exports.ThreadUpdateStatusTool = exports.ThreadGetMessagesTool = exports.ThreadDeleteTool = exports.ThreadUpdateTool = exports.ThreadStartTool = exports.ThreadGetTool = exports.ThreadListTool = exports.ThreadCreateBackgroundTool = exports.ThreadCreateStartTool = exports.ThreadCreateTool = exports.AgentDetailsTool = exports.AgentListTool = exports.AgentStartTool = exports.AgentFindTool = exports.TaskExecuteTool = exports.TaskAssignTool = exports.TaskGetTool = exports.TaskListTool = exports.TaskDeleteTool = exports.TaskUpdateTool = exports.TaskCreateTool = exports.BrowserSearchTool = exports.BrowserEnterTool = exports.BrowserCloseTool = exports.BrowserGetUrlTool = exports.BrowserGetMarkdownTool = exports.BrowserGetHtmlTool = exports.BrowserGetContentTool = exports.BrowserScrollTool = exports.BrowserTypeTool = exports.BrowserClickTool = exports.BrowserScreenshotTool = exports.BrowserNavigateTool = exports.GitCloneTool = exports.GitDiffTool = exports.GitLogsTool = exports.GitBranchTool = exports.GitCheckoutTool = exports.GitPullTool = exports.GitPushTool = exports.GitCommitTool = exports.GitAddTool = exports.GitStatusTool = exports.GitInitTool = exports.ExecuteCommandTool = exports.ListCodeDefinitionNamesTool = exports.SearchMcpToolTool = exports.CodebaseSearchTool = exports.SearchFilesTool = exports.GrepTool = void 0;
|
|
10
|
+
exports.OrchestratorUpdateStatusTool = exports.OrchestratorDeleteTool = exports.OrchestratorUpdateSettingsTool = exports.OrchestratorUpdateTool = exports.OrchestratorCreateTool = exports.OrchestratorGetSettingsTool = exports.OrchestratorGetTool = exports.OrchestratorListTool = void 0;
|
|
11
11
|
const Codebolt_1 = __importDefault(require("./core/Codebolt"));
|
|
12
12
|
exports.Codebolt = Codebolt_1.default;
|
|
13
13
|
// ================================
|
|
@@ -312,6 +312,12 @@ Object.defineProperty(exports, "codebaseSearch", { enumerable: true, get: functi
|
|
|
312
312
|
// Background Child Threads module
|
|
313
313
|
var backgroundChildThreads_1 = require("./modules/backgroundChildThreads");
|
|
314
314
|
Object.defineProperty(exports, "backgroundChildThreads", { enumerable: true, get: function () { return __importDefault(backgroundChildThreads_1).default; } });
|
|
315
|
+
// DynamicPanel module
|
|
316
|
+
var dynamicPanel_1 = require("./modules/dynamicPanel");
|
|
317
|
+
Object.defineProperty(exports, "dynamicPanel", { enumerable: true, get: function () { return __importDefault(dynamicPanel_1).default; } });
|
|
318
|
+
// Environment module
|
|
319
|
+
var environment_1 = require("./modules/environment");
|
|
320
|
+
Object.defineProperty(exports, "environment", { enumerable: true, get: function () { return __importDefault(environment_1).default; } });
|
|
315
321
|
// ================================
|
|
316
322
|
// Tools Module - LLM-ready tool definitions
|
|
317
323
|
// ================================
|
|
@@ -22,7 +22,9 @@ const cbagentDeliberation = {
|
|
|
22
22
|
return websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AgentDeliberationAction.RESPOND, ...params }, lib_1.AgentDeliberationResponseType.RESPOND_RESPONSE);
|
|
23
23
|
},
|
|
24
24
|
vote: async (params) => {
|
|
25
|
-
|
|
25
|
+
const action = params.optionId ? lib_1.AgentDeliberationAction.VOTE_OPTION : lib_1.AgentDeliberationAction.VOTE;
|
|
26
|
+
const responseType = params.optionId ? lib_1.AgentDeliberationResponseType.VOTE_OPTION_RESPONSE : lib_1.AgentDeliberationResponseType.VOTE_RESPONSE;
|
|
27
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({ type: action, ...params }, responseType);
|
|
26
28
|
},
|
|
27
29
|
getWinner: async (params) => {
|
|
28
30
|
return websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AgentDeliberationAction.WINNER, ...params }, lib_1.AgentDeliberationResponseType.WINNER_RESPONSE);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export interface DynamicPanelOpenOptions {
|
|
2
|
+
/** If true, the open() call blocks until the panel sends a { type: 'submit' } message */
|
|
3
|
+
waitForResponse?: boolean;
|
|
4
|
+
/** Timeout in milliseconds for waitForResponse mode (default: 300000 = 5 min) */
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DynamicPanelOpenResponse {
|
|
8
|
+
type: string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: {
|
|
11
|
+
success: boolean;
|
|
12
|
+
panelId: string;
|
|
13
|
+
data?: any;
|
|
14
|
+
};
|
|
15
|
+
error?: string;
|
|
16
|
+
requestId?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DynamicPanelResponse {
|
|
19
|
+
type: string;
|
|
20
|
+
success: boolean;
|
|
21
|
+
data?: any;
|
|
22
|
+
error?: string;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DynamicPanelInfo {
|
|
26
|
+
panelId: string;
|
|
27
|
+
title: string;
|
|
28
|
+
html: string;
|
|
29
|
+
pluginId?: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
}
|
|
32
|
+
export interface DynamicPanelListResponse {
|
|
33
|
+
type: string;
|
|
34
|
+
success: boolean;
|
|
35
|
+
data?: {
|
|
36
|
+
panels: DynamicPanelInfo[];
|
|
37
|
+
};
|
|
38
|
+
error?: string;
|
|
39
|
+
requestId?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DynamicPanelMessageEvent {
|
|
42
|
+
type: 'dynamicPanel.message';
|
|
43
|
+
panelId: string;
|
|
44
|
+
data: any;
|
|
45
|
+
messageId?: string;
|
|
46
|
+
threadId?: string;
|
|
47
|
+
}
|
|
48
|
+
declare const cbdynamicPanel: {
|
|
49
|
+
/**
|
|
50
|
+
* Opens a new DynamicPanel with the given HTML content.
|
|
51
|
+
*
|
|
52
|
+
* When `opts.waitForResponse` is true the call **blocks** until the panel
|
|
53
|
+
* iframe sends a `{ type: 'submit', data: {...} }` message via
|
|
54
|
+
* `window.parent.postMessage()`. The resolved value then contains the
|
|
55
|
+
* submitted data.
|
|
56
|
+
*
|
|
57
|
+
* @param panelId Unique identifier for the panel
|
|
58
|
+
* @param title Human-readable panel title shown in the tab
|
|
59
|
+
* @param html Full HTML document rendered inside the panel iframe
|
|
60
|
+
* @param opts Optional: `waitForResponse`, `timeout`
|
|
61
|
+
*/
|
|
62
|
+
open: (panelId: string, title: string, html: string, opts?: DynamicPanelOpenOptions) => Promise<DynamicPanelOpenResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Replaces the HTML content of an existing DynamicPanel.
|
|
65
|
+
*
|
|
66
|
+
* @param panelId The panel to update
|
|
67
|
+
* @param html New HTML content
|
|
68
|
+
*/
|
|
69
|
+
update: (panelId: string, html: string) => Promise<DynamicPanelResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Closes a DynamicPanel and removes it from the UI.
|
|
72
|
+
*
|
|
73
|
+
* @param panelId The panel to close
|
|
74
|
+
*/
|
|
75
|
+
close: (panelId: string) => Promise<DynamicPanelResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Pushes arbitrary data into the panel's iframe via `postMessage`.
|
|
78
|
+
* The iframe receives this in its `window.addEventListener('message', ...)` handler.
|
|
79
|
+
*
|
|
80
|
+
* @param panelId The target panel
|
|
81
|
+
* @param data Any JSON-serializable payload
|
|
82
|
+
*/
|
|
83
|
+
send: (panelId: string, data: any) => Promise<DynamicPanelResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Lists all currently active DynamicPanels.
|
|
86
|
+
*/
|
|
87
|
+
list: () => Promise<DynamicPanelListResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Registers a handler for messages coming **from** a specific panel's iframe.
|
|
90
|
+
* The iframe sends messages via `window.parent.postMessage({ type: '...', data: {...} }, '*')`.
|
|
91
|
+
*
|
|
92
|
+
* Only one handler per panelId is supported. Calling this again for the
|
|
93
|
+
* same panelId replaces the previous handler.
|
|
94
|
+
*
|
|
95
|
+
* @param panelId The panel to listen to
|
|
96
|
+
* @param handler Callback receiving the message data
|
|
97
|
+
*/
|
|
98
|
+
onMessage: (panelId: string, handler: (data: any) => void) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Removes the message handler for a specific panel.
|
|
101
|
+
*
|
|
102
|
+
* @param panelId The panel to stop listening to
|
|
103
|
+
*/
|
|
104
|
+
offMessage: (panelId: string) => void;
|
|
105
|
+
};
|
|
106
|
+
export default cbdynamicPanel;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Message handler tracking
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const panelMessageHandlers = new Map();
|
|
11
|
+
let messageRouteCleanup = null;
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the global message route for dynamicPanel.message is registered.
|
|
14
|
+
* Incoming messages are dispatched to per-panel handlers.
|
|
15
|
+
*/
|
|
16
|
+
function ensureMessageRoute() {
|
|
17
|
+
if (messageRouteCleanup)
|
|
18
|
+
return;
|
|
19
|
+
messageRouteCleanup = websocket_1.default.messageManager.registerRoute({
|
|
20
|
+
messageTypes: ['dynamicPanel.message'],
|
|
21
|
+
handler: (message) => {
|
|
22
|
+
const handler = panelMessageHandlers.get(message.panelId);
|
|
23
|
+
if (handler) {
|
|
24
|
+
handler(message.data);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// DynamicPanel SDK module
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
const cbdynamicPanel = {
|
|
33
|
+
/**
|
|
34
|
+
* Opens a new DynamicPanel with the given HTML content.
|
|
35
|
+
*
|
|
36
|
+
* When `opts.waitForResponse` is true the call **blocks** until the panel
|
|
37
|
+
* iframe sends a `{ type: 'submit', data: {...} }` message via
|
|
38
|
+
* `window.parent.postMessage()`. The resolved value then contains the
|
|
39
|
+
* submitted data.
|
|
40
|
+
*
|
|
41
|
+
* @param panelId Unique identifier for the panel
|
|
42
|
+
* @param title Human-readable panel title shown in the tab
|
|
43
|
+
* @param html Full HTML document rendered inside the panel iframe
|
|
44
|
+
* @param opts Optional: `waitForResponse`, `timeout`
|
|
45
|
+
*/
|
|
46
|
+
open: async (panelId, title, html, opts) => {
|
|
47
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
48
|
+
type: 'dynamicPanel.open',
|
|
49
|
+
params: { panelId, title, html, ...opts },
|
|
50
|
+
}, 'dynamicPanelOpenResponse', (opts === null || opts === void 0 ? void 0 : opts.waitForResponse) ? (opts.timeout || 300000) : 0);
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Replaces the HTML content of an existing DynamicPanel.
|
|
54
|
+
*
|
|
55
|
+
* @param panelId The panel to update
|
|
56
|
+
* @param html New HTML content
|
|
57
|
+
*/
|
|
58
|
+
update: async (panelId, html) => {
|
|
59
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
60
|
+
type: 'dynamicPanel.update',
|
|
61
|
+
params: { panelId, html },
|
|
62
|
+
}, 'dynamicPanelUpdateResponse');
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Closes a DynamicPanel and removes it from the UI.
|
|
66
|
+
*
|
|
67
|
+
* @param panelId The panel to close
|
|
68
|
+
*/
|
|
69
|
+
close: async (panelId) => {
|
|
70
|
+
// Unregister any local message handler for this panel
|
|
71
|
+
panelMessageHandlers.delete(panelId);
|
|
72
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
73
|
+
type: 'dynamicPanel.close',
|
|
74
|
+
params: { panelId },
|
|
75
|
+
}, 'dynamicPanelCloseResponse');
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Pushes arbitrary data into the panel's iframe via `postMessage`.
|
|
79
|
+
* The iframe receives this in its `window.addEventListener('message', ...)` handler.
|
|
80
|
+
*
|
|
81
|
+
* @param panelId The target panel
|
|
82
|
+
* @param data Any JSON-serializable payload
|
|
83
|
+
*/
|
|
84
|
+
send: async (panelId, data) => {
|
|
85
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
86
|
+
type: 'dynamicPanel.send',
|
|
87
|
+
params: { panelId, data },
|
|
88
|
+
}, 'dynamicPanelSendResponse');
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Lists all currently active DynamicPanels.
|
|
92
|
+
*/
|
|
93
|
+
list: async () => {
|
|
94
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
95
|
+
type: 'dynamicPanel.list',
|
|
96
|
+
params: {},
|
|
97
|
+
}, 'dynamicPanelListResponse');
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Registers a handler for messages coming **from** a specific panel's iframe.
|
|
101
|
+
* The iframe sends messages via `window.parent.postMessage({ type: '...', data: {...} }, '*')`.
|
|
102
|
+
*
|
|
103
|
+
* Only one handler per panelId is supported. Calling this again for the
|
|
104
|
+
* same panelId replaces the previous handler.
|
|
105
|
+
*
|
|
106
|
+
* @param panelId The panel to listen to
|
|
107
|
+
* @param handler Callback receiving the message data
|
|
108
|
+
*/
|
|
109
|
+
onMessage: (panelId, handler) => {
|
|
110
|
+
ensureMessageRoute();
|
|
111
|
+
panelMessageHandlers.set(panelId, handler);
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Removes the message handler for a specific panel.
|
|
115
|
+
*
|
|
116
|
+
* @param panelId The panel to stop listening to
|
|
117
|
+
*/
|
|
118
|
+
offMessage: (panelId) => {
|
|
119
|
+
panelMessageHandlers.delete(panelId);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
exports.default = cbdynamicPanel;
|