@hailer/mcp 0.1.17 → 0.2.1
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/app.js +24 -20
- package/dist/core.d.ts +33 -9
- package/dist/core.js +279 -147
- package/dist/mcp/UserContextCache.js +18 -0
- package/dist/mcp/hailer-clients.d.ts +9 -1
- package/dist/mcp/hailer-clients.js +13 -3
- package/dist/mcp/signal-handler.js +1 -1
- package/dist/mcp/tool-registry.d.ts +3 -1
- package/dist/mcp/tool-registry.js +4 -1
- package/dist/mcp/tools/activity.js +43 -34
- package/dist/mcp/tools/bot-config/constants.d.ts +23 -0
- package/dist/mcp/tools/bot-config/constants.js +94 -0
- package/dist/mcp/tools/{bot-config.d.ts → bot-config/core.d.ts} +6 -6
- package/dist/mcp/tools/{bot-config.js → bot-config/core.js} +15 -15
- package/dist/mcp/tools/bot-config/index.d.ts +10 -0
- package/dist/mcp/tools/bot-config/index.js +59 -0
- package/dist/mcp/tools/bot-config/tools.d.ts +7 -0
- package/dist/mcp/tools/bot-config/tools.js +15 -0
- package/dist/mcp/tools/bot-config/types.d.ts +50 -0
- package/dist/mcp/tools/bot-config/types.js +6 -0
- package/dist/mcp/tools/bug-fixer-tools.d.ts +21 -0
- package/dist/mcp/tools/{giuseppe-tools.js → bug-fixer-tools.js} +61 -61
- package/dist/mcp/tools/user.js +10 -29
- package/dist/mcp/tools/workflow.js +36 -2
- package/dist/mcp/utils/data-transformers.d.ts +0 -8
- package/dist/mcp/utils/data-transformers.js +0 -28
- package/dist/mcp/utils/index.d.ts +4 -1
- package/dist/mcp/utils/index.js +17 -3
- package/dist/mcp/utils/pagination.d.ts +40 -0
- package/dist/mcp/utils/pagination.js +55 -0
- package/dist/mcp/utils/response-builder.d.ts +53 -0
- package/dist/mcp/utils/response-builder.js +110 -0
- package/dist/mcp/utils/tool-helpers.d.ts +0 -8
- package/dist/mcp/utils/tool-helpers.js +0 -24
- package/dist/mcp/utils/types.d.ts +1 -33
- package/dist/mcp-server.d.ts +2 -2
- package/dist/mcp-server.js +161 -139
- package/package.json +1 -1
- package/REFACTOR_STATUS.md +0 -127
- package/dist/agents/bot-manager.d.ts +0 -48
- package/dist/agents/bot-manager.js +0 -254
- package/dist/agents/factory.d.ts +0 -150
- package/dist/agents/factory.js +0 -650
- package/dist/agents/giuseppe/ai.d.ts +0 -83
- package/dist/agents/giuseppe/ai.js +0 -466
- package/dist/agents/giuseppe/bot.d.ts +0 -110
- package/dist/agents/giuseppe/bot.js +0 -780
- package/dist/agents/giuseppe/config.d.ts +0 -25
- package/dist/agents/giuseppe/config.js +0 -227
- package/dist/agents/giuseppe/files.d.ts +0 -52
- package/dist/agents/giuseppe/files.js +0 -338
- package/dist/agents/giuseppe/git.d.ts +0 -48
- package/dist/agents/giuseppe/git.js +0 -298
- package/dist/agents/giuseppe/index.d.ts +0 -97
- package/dist/agents/giuseppe/index.js +0 -258
- package/dist/agents/giuseppe/lsp.d.ts +0 -113
- package/dist/agents/giuseppe/lsp.js +0 -485
- package/dist/agents/giuseppe/monitor.d.ts +0 -118
- package/dist/agents/giuseppe/monitor.js +0 -621
- package/dist/agents/giuseppe/prompt.d.ts +0 -5
- package/dist/agents/giuseppe/prompt.js +0 -94
- package/dist/agents/giuseppe/registries/pending-classification.d.ts +0 -28
- package/dist/agents/giuseppe/registries/pending-classification.js +0 -50
- package/dist/agents/giuseppe/registries/pending-fix.d.ts +0 -30
- package/dist/agents/giuseppe/registries/pending-fix.js +0 -42
- package/dist/agents/giuseppe/registries/pending.d.ts +0 -27
- package/dist/agents/giuseppe/registries/pending.js +0 -49
- package/dist/agents/giuseppe/specialist.d.ts +0 -47
- package/dist/agents/giuseppe/specialist.js +0 -237
- package/dist/agents/giuseppe/types.d.ts +0 -123
- package/dist/agents/giuseppe/types.js +0 -9
- package/dist/agents/hailer-expert/index.d.ts +0 -8
- package/dist/agents/hailer-expert/index.js +0 -14
- package/dist/agents/hal/daemon.d.ts +0 -142
- package/dist/agents/hal/daemon.js +0 -1103
- package/dist/agents/hal/definitions.d.ts +0 -55
- package/dist/agents/hal/definitions.js +0 -263
- package/dist/agents/hal/index.d.ts +0 -3
- package/dist/agents/hal/index.js +0 -8
- package/dist/agents/index.d.ts +0 -18
- package/dist/agents/index.js +0 -48
- package/dist/agents/shared/base.d.ts +0 -216
- package/dist/agents/shared/base.js +0 -846
- package/dist/agents/shared/services/agent-registry.d.ts +0 -107
- package/dist/agents/shared/services/agent-registry.js +0 -629
- package/dist/agents/shared/services/conversation-manager.d.ts +0 -50
- package/dist/agents/shared/services/conversation-manager.js +0 -136
- package/dist/agents/shared/services/mcp-client.d.ts +0 -56
- package/dist/agents/shared/services/mcp-client.js +0 -124
- package/dist/agents/shared/services/message-classifier.d.ts +0 -37
- package/dist/agents/shared/services/message-classifier.js +0 -187
- package/dist/agents/shared/services/message-formatter.d.ts +0 -89
- package/dist/agents/shared/services/message-formatter.js +0 -371
- package/dist/agents/shared/services/session-logger.d.ts +0 -106
- package/dist/agents/shared/services/session-logger.js +0 -446
- package/dist/agents/shared/services/tool-executor.d.ts +0 -41
- package/dist/agents/shared/services/tool-executor.js +0 -169
- package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -125
- package/dist/agents/shared/services/workspace-schema-cache.js +0 -578
- package/dist/agents/shared/specialist.d.ts +0 -91
- package/dist/agents/shared/specialist.js +0 -399
- package/dist/agents/shared/tool-schema-loader.d.ts +0 -62
- package/dist/agents/shared/tool-schema-loader.js +0 -232
- package/dist/agents/shared/types.d.ts +0 -327
- package/dist/agents/shared/types.js +0 -121
- package/dist/client/agents/base.d.ts +0 -207
- package/dist/client/agents/base.js +0 -744
- package/dist/client/agents/definitions.d.ts +0 -53
- package/dist/client/agents/definitions.js +0 -263
- package/dist/client/agents/orchestrator.d.ts +0 -141
- package/dist/client/agents/orchestrator.js +0 -1062
- package/dist/client/agents/specialist.d.ts +0 -86
- package/dist/client/agents/specialist.js +0 -340
- package/dist/client/bot-entrypoint.d.ts +0 -7
- package/dist/client/bot-entrypoint.js +0 -103
- package/dist/client/bot-manager.d.ts +0 -44
- package/dist/client/bot-manager.js +0 -173
- package/dist/client/bot-runner.d.ts +0 -35
- package/dist/client/bot-runner.js +0 -188
- package/dist/client/chat-agent-daemon.d.ts +0 -464
- package/dist/client/chat-agent-daemon.js +0 -1774
- package/dist/client/daemon-factory.d.ts +0 -106
- package/dist/client/daemon-factory.js +0 -301
- package/dist/client/factory.d.ts +0 -111
- package/dist/client/factory.js +0 -314
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.js +0 -38
- package/dist/client/multi-bot-manager.d.ts +0 -42
- package/dist/client/multi-bot-manager.js +0 -161
- package/dist/client/orchestrator-daemon.d.ts +0 -87
- package/dist/client/orchestrator-daemon.js +0 -444
- package/dist/client/server.d.ts +0 -8
- package/dist/client/server.js +0 -251
- package/dist/client/services/agent-registry.d.ts +0 -108
- package/dist/client/services/agent-registry.js +0 -630
- package/dist/client/services/conversation-manager.d.ts +0 -50
- package/dist/client/services/conversation-manager.js +0 -136
- package/dist/client/services/mcp-client.d.ts +0 -48
- package/dist/client/services/mcp-client.js +0 -105
- package/dist/client/services/message-classifier.d.ts +0 -37
- package/dist/client/services/message-classifier.js +0 -187
- package/dist/client/services/message-formatter.d.ts +0 -84
- package/dist/client/services/message-formatter.js +0 -353
- package/dist/client/services/session-logger.d.ts +0 -106
- package/dist/client/services/session-logger.js +0 -446
- package/dist/client/services/tool-executor.d.ts +0 -41
- package/dist/client/services/tool-executor.js +0 -169
- package/dist/client/services/workspace-schema-cache.d.ts +0 -149
- package/dist/client/services/workspace-schema-cache.js +0 -732
- package/dist/client/specialist-daemon.d.ts +0 -77
- package/dist/client/specialist-daemon.js +0 -197
- package/dist/client/specialists.d.ts +0 -53
- package/dist/client/specialists.js +0 -178
- package/dist/client/tool-schema-loader.d.ts +0 -62
- package/dist/client/tool-schema-loader.js +0 -232
- package/dist/client/types.d.ts +0 -327
- package/dist/client/types.js +0 -121
- package/dist/commands/seed-config.d.ts +0 -9
- package/dist/commands/seed-config.js +0 -372
- package/dist/lib/context-manager.d.ts +0 -111
- package/dist/lib/context-manager.js +0 -431
- package/dist/lib/prompt-length-manager.d.ts +0 -81
- package/dist/lib/prompt-length-manager.js +0 -457
- package/dist/mcp/tools/giuseppe-tools.d.ts +0 -21
- package/dist/modules/bug-reports/bug-config.d.ts +0 -25
- package/dist/modules/bug-reports/bug-config.js +0 -187
- package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
- package/dist/modules/bug-reports/bug-monitor.js +0 -510
- package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
- package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
- package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
- package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
- package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
- package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
- package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
- package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
- package/dist/modules/bug-reports/giuseppe-files.js +0 -375
- package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
- package/dist/modules/bug-reports/giuseppe-git.js +0 -298
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
- package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
- package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
- package/dist/modules/bug-reports/index.d.ts +0 -77
- package/dist/modules/bug-reports/index.js +0 -215
- package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
- package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
- package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
- package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
- package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
- package/dist/modules/bug-reports/pending-registry.js +0 -49
- package/dist/modules/bug-reports/types.d.ts +0 -123
- package/dist/modules/bug-reports/types.js +0 -9
- package/dist/routes/agents.d.ts +0 -44
- package/dist/routes/agents.js +0 -311
- package/dist/services/agent-credential-store.d.ts +0 -73
- package/dist/services/agent-credential-store.js +0 -212
- package/dist/services/bug-monitor.d.ts +0 -23
- package/dist/services/bug-monitor.js +0 -275
|
@@ -1,1062 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Orchestrator Daemon (HAL)
|
|
4
|
-
*
|
|
5
|
-
* The main conversational bot that handles general chat and coordinates
|
|
6
|
-
* with specialist bots when tasks are too complex.
|
|
7
|
-
*
|
|
8
|
-
* HAL can:
|
|
9
|
-
* - Handle general conversation and simple queries
|
|
10
|
-
* - Detect when a task needs specialist help
|
|
11
|
-
* - Invite specialist bots to the discussion
|
|
12
|
-
* - Hand off context to specialists
|
|
13
|
-
* - Summarize specialist responses for users
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.OrchestratorDaemon = void 0;
|
|
17
|
-
const base_1 = require("./base");
|
|
18
|
-
const definitions_1 = require("./definitions");
|
|
19
|
-
const logger_1 = require("../../lib/logger");
|
|
20
|
-
const pending_fix_registry_1 = require("../../modules/bug-reports/pending-fix-registry");
|
|
21
|
-
const pending_classification_registry_1 = require("../../modules/bug-reports/pending-classification-registry");
|
|
22
|
-
const discussion_lock_1 = require("../../lib/discussion-lock");
|
|
23
|
-
class OrchestratorDaemon extends base_1.ChatAgentDaemon {
|
|
24
|
-
orchestratorLogger;
|
|
25
|
-
specialists = new Map();
|
|
26
|
-
activeSpecialistsInDiscussion = new Map(); // discussionId -> Set<specialistUserId>
|
|
27
|
-
specialistUserIds = new Map(); // specialistKey -> userId
|
|
28
|
-
toolsUsedInCurrentMessage = false; // Track if tools were used in current message processing
|
|
29
|
-
lastToolsUsed = []; // Track which tools were used (for silent success detection)
|
|
30
|
-
lastToolsFailed = false; // Track if any tool failed (to allow error reporting)
|
|
31
|
-
// Tools that should NOT trigger confirmation messages back to source chat (on SUCCESS only)
|
|
32
|
-
static SILENT_SUCCESS_TOOLS = new Set(['join_discussion']);
|
|
33
|
-
// Cross-discussion memory - remembers recent activity context
|
|
34
|
-
lastKnownActivityId = null;
|
|
35
|
-
lastKnownActivityName = null;
|
|
36
|
-
lastKnownActivityTime = 0;
|
|
37
|
-
static CONTEXT_MEMORY_TIMEOUT = 5 * 60 * 1000; // 5 minutes
|
|
38
|
-
constructor(config) {
|
|
39
|
-
super(config);
|
|
40
|
-
this.orchestratorLogger = (0, logger_1.createLogger)({
|
|
41
|
-
component: "OrchestratorDaemon",
|
|
42
|
-
botId: config.botClient.userId,
|
|
43
|
-
});
|
|
44
|
-
// Register specialists from config
|
|
45
|
-
for (const [key, specialist] of Object.entries(definitions_1.SPECIALISTS)) {
|
|
46
|
-
this.specialists.set(key, specialist);
|
|
47
|
-
}
|
|
48
|
-
// Set specialist user IDs if provided
|
|
49
|
-
if (config.specialistUserIds) {
|
|
50
|
-
this.specialistUserIds = config.specialistUserIds;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Trigger HAL to respond in a discussion with specific context
|
|
55
|
-
* Used when bug monitor needs HAL to naturally inform users about Giuseppe being disabled
|
|
56
|
-
*/
|
|
57
|
-
async respondWithContext(discussionId, activityId, contextMessage) {
|
|
58
|
-
this.orchestratorLogger.info('Triggering contextual response', { discussionId, activityId });
|
|
59
|
-
try {
|
|
60
|
-
// Join the discussion first using MCP tool
|
|
61
|
-
await this.callMcpTool("join_discussion", { activityId });
|
|
62
|
-
// Get workspace ID from bot client cache
|
|
63
|
-
const workspaceId = this.config.botClient.workspaceCache?.currentWorkspace?._id || '';
|
|
64
|
-
// Create a synthetic incoming message with the context
|
|
65
|
-
const syntheticMessage = {
|
|
66
|
-
id: `synthetic-${Date.now()}`,
|
|
67
|
-
discussionId,
|
|
68
|
-
linkedActivityId: activityId,
|
|
69
|
-
workspaceId,
|
|
70
|
-
content: contextMessage,
|
|
71
|
-
senderName: 'System',
|
|
72
|
-
senderId: 'system',
|
|
73
|
-
timestamp: Date.now(),
|
|
74
|
-
priority: 'high',
|
|
75
|
-
priorityReason: 'system_notification',
|
|
76
|
-
isReplyToBot: false,
|
|
77
|
-
isMention: false,
|
|
78
|
-
isDirectMessage: false,
|
|
79
|
-
};
|
|
80
|
-
// Process through normal LLM pipeline
|
|
81
|
-
// This will make HAL respond naturally with the context
|
|
82
|
-
await this['processMessage'](syntheticMessage);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
this.orchestratorLogger.error('Failed to respond with context', { error });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// ===== AGENT DIRECTORY OVERRIDES =====
|
|
89
|
-
/**
|
|
90
|
-
* Override agent name for Agent Directory
|
|
91
|
-
* Uses the actual Hailer user name from BotClient (set in workspace)
|
|
92
|
-
*/
|
|
93
|
-
getAgentName() {
|
|
94
|
-
// Use parent implementation which gets name from BotClient
|
|
95
|
-
return super.getAgentName();
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Override agent description for Agent Directory
|
|
99
|
-
*/
|
|
100
|
-
getAgentDescription() {
|
|
101
|
-
return "HAL - the main Hailer Assistant orchestrator. Handles general conversation and coordinates specialist bots for complex tasks.";
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Override Position details for Orchestrator
|
|
105
|
-
*/
|
|
106
|
-
getPositionDetails() {
|
|
107
|
-
return {
|
|
108
|
-
name: "HAL Orchestrator",
|
|
109
|
-
purpose: "Main point of contact for users. Handles general conversation, triages requests, and coordinates specialist bots for complex tasks.",
|
|
110
|
-
personaTone: "Sharp, efficient, and helpful. Professional but approachable. Uses clear, concise language.",
|
|
111
|
-
coreCapabilities: "- Monitor all workspace discussions\n- Respond to general queries and greetings\n- Detect when specialist help is needed\n- Invite specialists to discussions\n- Coordinate multi-step workflows\n- Execute MCP tools for data operations",
|
|
112
|
-
boundaries: "- Never fabricate data - always use tools\n- Don't attempt complex technical tasks alone\n- Hand off to specialists for: bulk operations, report creation, workflow setup\n- Don't share credentials or sensitive config",
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Orchestrator only needs basic tools - complex ops go to specialists
|
|
117
|
-
*/
|
|
118
|
-
getToolWhitelist() {
|
|
119
|
-
return [
|
|
120
|
-
// Workflow discovery
|
|
121
|
-
"list_workflows",
|
|
122
|
-
"list_workflow_phases",
|
|
123
|
-
"get_workflow_schema",
|
|
124
|
-
"list_workflows_minimal",
|
|
125
|
-
// Activity operations
|
|
126
|
-
"list_activities",
|
|
127
|
-
"show_activity_by_id",
|
|
128
|
-
"count_activities",
|
|
129
|
-
"create_activity",
|
|
130
|
-
"update_activity",
|
|
131
|
-
// Discussion tools
|
|
132
|
-
"join_discussion",
|
|
133
|
-
"add_discussion_message",
|
|
134
|
-
"invite_discussion_members",
|
|
135
|
-
"fetch_discussion_messages",
|
|
136
|
-
"get_activity_from_discussion",
|
|
137
|
-
"list_my_discussions",
|
|
138
|
-
// User lookup
|
|
139
|
-
"search_workspace_users",
|
|
140
|
-
// App tools (read-only)
|
|
141
|
-
"list_apps",
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Preprocess tool input - inject context for certain tools
|
|
146
|
-
* Uses cross-discussion memory to maintain context awareness
|
|
147
|
-
*/
|
|
148
|
-
preprocessToolInput(toolName, input) {
|
|
149
|
-
// Force compact output for schema tools (avoid verbose field dumps in discussions)
|
|
150
|
-
if (toolName === "get_workflow_schema") {
|
|
151
|
-
return { ...input, compact: true };
|
|
152
|
-
}
|
|
153
|
-
// Auto-inject sourceActivityId for join_discussion
|
|
154
|
-
if (toolName === "join_discussion") {
|
|
155
|
-
// Debug: Log current context state
|
|
156
|
-
this.orchestratorLogger.debug("join_discussion context check", {
|
|
157
|
-
currentLinkedActivityId: this.currentLinkedActivityId || "none",
|
|
158
|
-
lastKnownActivityId: this.lastKnownActivityId || "none",
|
|
159
|
-
inputSourceActivityId: input.sourceActivityId || "none",
|
|
160
|
-
currentDiscussionId: this.currentDiscussionId || "none",
|
|
161
|
-
});
|
|
162
|
-
if (!input.sourceActivityId) {
|
|
163
|
-
// First try current message's linked activity
|
|
164
|
-
const currentActivityId = this.currentLinkedActivityId;
|
|
165
|
-
// Fall back to recent memory if within timeout
|
|
166
|
-
const memoryStillValid = Date.now() - this.lastKnownActivityTime < OrchestratorDaemon.CONTEXT_MEMORY_TIMEOUT;
|
|
167
|
-
const sourceActivityId = currentActivityId || (memoryStillValid ? this.lastKnownActivityId : null);
|
|
168
|
-
if (sourceActivityId) {
|
|
169
|
-
this.orchestratorLogger.info("Auto-injected sourceActivityId", {
|
|
170
|
-
sourceActivityId,
|
|
171
|
-
fromCurrentMessage: !!currentActivityId,
|
|
172
|
-
fromMemory: !currentActivityId && !!sourceActivityId,
|
|
173
|
-
});
|
|
174
|
-
input = { ...input, sourceActivityId };
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
this.orchestratorLogger.debug("No sourceActivityId available to inject", {
|
|
178
|
-
currentLinkedActivityId: this.currentLinkedActivityId,
|
|
179
|
-
lastKnownActivityId: this.lastKnownActivityId,
|
|
180
|
-
memoryStillValid,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// Always inject a default welcomeReason if user is being invited
|
|
185
|
-
// This ensures welcome messages are always posted
|
|
186
|
-
if (input.inviteUserId && !input.welcomeReason) {
|
|
187
|
-
const reason = this.lastKnownActivityName
|
|
188
|
-
? `Added from ${this.lastKnownActivityName} discussion`
|
|
189
|
-
: "Added to this discussion";
|
|
190
|
-
this.orchestratorLogger.debug("Auto-injected welcomeReason", { reason });
|
|
191
|
-
input = { ...input, welcomeReason: reason };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return input;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Override to detect tool failures for silent success feature
|
|
198
|
-
*/
|
|
199
|
-
async executeToolsAndContinue(toolUseBlocks, originalMessage) {
|
|
200
|
-
// Reset failure flag before executing tools
|
|
201
|
-
this.lastToolsFailed = false;
|
|
202
|
-
// Handle local tools (not sent to MCP)
|
|
203
|
-
const localToolResults = [];
|
|
204
|
-
const mcpToolBlocks = [];
|
|
205
|
-
for (const toolBlock of toolUseBlocks) {
|
|
206
|
-
if (toolBlock.name === 'trigger_giuseppe_retry') {
|
|
207
|
-
// Handle locally - trigger Giuseppe retry
|
|
208
|
-
const input = toolBlock.input;
|
|
209
|
-
const explanation = input.explanation || '';
|
|
210
|
-
const discussionId = originalMessage.discussionId;
|
|
211
|
-
const pendingFix = pending_fix_registry_1.pendingFixRegistry.getPendingFix(discussionId);
|
|
212
|
-
if (!pendingFix) {
|
|
213
|
-
localToolResults.push({
|
|
214
|
-
type: 'tool_result',
|
|
215
|
-
tool_use_id: toolBlock.id,
|
|
216
|
-
content: 'No pending fix found for this discussion. The fix may have already been approved or cancelled.',
|
|
217
|
-
is_error: true,
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
// Trigger the retry
|
|
222
|
-
const success = await pending_fix_registry_1.pendingFixRegistry.triggerRetry(discussionId, explanation);
|
|
223
|
-
localToolResults.push({
|
|
224
|
-
type: 'tool_result',
|
|
225
|
-
tool_use_id: toolBlock.id,
|
|
226
|
-
content: success
|
|
227
|
-
? `✅ Triggered Giuseppe retry with explanation: "${explanation.substring(0, 100)}...". Giuseppe will analyze and apply a new fix.`
|
|
228
|
-
: '❌ Failed to trigger retry. Giuseppe may not be available.',
|
|
229
|
-
is_error: !success,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else if (toolBlock.name === 'confirm_bug_fix') {
|
|
234
|
-
// Handle locally - trigger Giuseppe fix confirmation
|
|
235
|
-
const discussionId = originalMessage.discussionId;
|
|
236
|
-
const hasPending = pending_classification_registry_1.pendingClassificationRegistry.has(discussionId);
|
|
237
|
-
if (!hasPending) {
|
|
238
|
-
localToolResults.push({
|
|
239
|
-
type: 'tool_result',
|
|
240
|
-
tool_use_id: toolBlock.id,
|
|
241
|
-
content: 'No pending classification found for this discussion. Giuseppe may have already processed it.',
|
|
242
|
-
is_error: true,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
const success = await pending_classification_registry_1.pendingClassificationRegistry.triggerFixIt(discussionId);
|
|
247
|
-
localToolResults.push({
|
|
248
|
-
type: 'tool_result',
|
|
249
|
-
tool_use_id: toolBlock.id,
|
|
250
|
-
content: success
|
|
251
|
-
? '✅ Triggered Giuseppe to proceed with bug fix.'
|
|
252
|
-
: '❌ Failed to trigger fix. Giuseppe may not be available.',
|
|
253
|
-
is_error: !success,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else if (toolBlock.name === 'decline_bug_report') {
|
|
258
|
-
// Handle locally - trigger Giuseppe decline
|
|
259
|
-
const discussionId = originalMessage.discussionId;
|
|
260
|
-
const hasPending = pending_classification_registry_1.pendingClassificationRegistry.has(discussionId);
|
|
261
|
-
if (!hasPending) {
|
|
262
|
-
localToolResults.push({
|
|
263
|
-
type: 'tool_result',
|
|
264
|
-
tool_use_id: toolBlock.id,
|
|
265
|
-
content: 'No pending classification found for this discussion. Giuseppe may have already processed it.',
|
|
266
|
-
is_error: true,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
const success = await pending_classification_registry_1.pendingClassificationRegistry.triggerNotABug(discussionId);
|
|
271
|
-
localToolResults.push({
|
|
272
|
-
type: 'tool_result',
|
|
273
|
-
tool_use_id: toolBlock.id,
|
|
274
|
-
content: success
|
|
275
|
-
? '✅ Marked as not a bug. Report moved to Declined.'
|
|
276
|
-
: '❌ Failed to decline. Giuseppe may not be available.',
|
|
277
|
-
is_error: !success,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
// Send to MCP
|
|
283
|
-
mcpToolBlocks.push(toolBlock);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
// If we handled all tools locally, skip MCP execution
|
|
287
|
-
if (mcpToolBlocks.length === 0 && localToolResults.length > 0) {
|
|
288
|
-
const conversation = this.conversationManager.getConversation(originalMessage.discussionId);
|
|
289
|
-
conversation.push({
|
|
290
|
-
role: 'user',
|
|
291
|
-
content: localToolResults,
|
|
292
|
-
});
|
|
293
|
-
// Continue with LLM
|
|
294
|
-
const response = await this.client.messages.create({
|
|
295
|
-
model: this.config.model || 'claude-haiku-4-5-20251001',
|
|
296
|
-
max_tokens: 2000,
|
|
297
|
-
system: this.getSystemPrompt(),
|
|
298
|
-
messages: conversation,
|
|
299
|
-
tools: this.getToolsWithGiuseppeRetry(),
|
|
300
|
-
});
|
|
301
|
-
await this.handleLlmResponse(response, originalMessage);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
// If we have local results, add them to be processed together with MCP results
|
|
305
|
-
// (for now, just continue with original flow for MCP tools)
|
|
306
|
-
// Get current activity session
|
|
307
|
-
const sessionKey = this.currentLinkedActivityId || this.currentDiscussionId || "default";
|
|
308
|
-
const session = this.sessionLogger.getSession(sessionKey);
|
|
309
|
-
// Store the user's request that triggered these tool calls (for context)
|
|
310
|
-
if (session && !session.triggerRequest) {
|
|
311
|
-
session.triggerRequest = originalMessage.content.substring(0, 500);
|
|
312
|
-
session.requestedBy = originalMessage.senderName;
|
|
313
|
-
session.requestedById = originalMessage.senderId;
|
|
314
|
-
}
|
|
315
|
-
// Execute tools using the tool executor service
|
|
316
|
-
const toolResults = await this.toolExecutor.executeTools(toolUseBlocks, {
|
|
317
|
-
session,
|
|
318
|
-
preprocessToolInput: this.preprocessToolInput.bind(this),
|
|
319
|
-
});
|
|
320
|
-
// Check if any tool failed (detect various error patterns)
|
|
321
|
-
const anyToolFailed = toolResults.some(r => {
|
|
322
|
-
if (r.is_error)
|
|
323
|
-
return true;
|
|
324
|
-
// Check for error patterns in content (MCP tools return error text)
|
|
325
|
-
const content = r.content.toLowerCase();
|
|
326
|
-
return content.includes('error') || content.includes('failed') || content.includes('❌');
|
|
327
|
-
});
|
|
328
|
-
if (anyToolFailed) {
|
|
329
|
-
this.lastToolsFailed = true;
|
|
330
|
-
this.orchestratorLogger.debug("Tool failure detected", {
|
|
331
|
-
tools: this.lastToolsUsed,
|
|
332
|
-
failedCount: toolResults.filter(r => r.is_error).length,
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
// Get conversation for this discussion
|
|
336
|
-
const conversation = this.conversationManager.getConversation(originalMessage.discussionId);
|
|
337
|
-
// Add tool results to conversation
|
|
338
|
-
conversation.push({
|
|
339
|
-
role: "user",
|
|
340
|
-
content: toolResults,
|
|
341
|
-
});
|
|
342
|
-
// Continue with LLM
|
|
343
|
-
const response = await this.client.messages.create({
|
|
344
|
-
model: this.config.model || "claude-haiku-4-5-20251001",
|
|
345
|
-
max_tokens: 2000,
|
|
346
|
-
system: this.getSystemPrompt(),
|
|
347
|
-
messages: conversation,
|
|
348
|
-
tools: this.minimalTools,
|
|
349
|
-
});
|
|
350
|
-
// Track token usage in session
|
|
351
|
-
if (session && response.usage) {
|
|
352
|
-
session.metrics.inputTokens += response.usage.input_tokens;
|
|
353
|
-
session.metrics.outputTokens += response.usage.output_tokens;
|
|
354
|
-
session.lastActivityTime = Date.now();
|
|
355
|
-
}
|
|
356
|
-
// Recursively handle (might need more tools or finally respond)
|
|
357
|
-
await this.handleLlmResponse(response, originalMessage);
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Update cross-discussion memory when processing messages
|
|
361
|
-
* Call this when entering an activity discussion to remember context
|
|
362
|
-
*/
|
|
363
|
-
updateContextMemory(activityId, activityName) {
|
|
364
|
-
if (activityId) {
|
|
365
|
-
this.lastKnownActivityId = activityId;
|
|
366
|
-
this.lastKnownActivityName = activityName;
|
|
367
|
-
this.lastKnownActivityTime = Date.now();
|
|
368
|
-
this.orchestratorLogger.debug("Updated context memory", { activityId, activityName });
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Override to update cross-discussion memory when entering activity discussions
|
|
373
|
-
* Also checks if a specialist bot (like Giuseppe) has locked this discussion
|
|
374
|
-
*/
|
|
375
|
-
async extractIncomingMessage(signal) {
|
|
376
|
-
const message = await super.extractIncomingMessage(signal);
|
|
377
|
-
if (!message)
|
|
378
|
-
return null;
|
|
379
|
-
// Check if this discussion is locked by a specialist bot (e.g., Giuseppe handling a bug)
|
|
380
|
-
if ((0, discussion_lock_1.isDiscussionLocked)(message.discussionId, 'hal')) {
|
|
381
|
-
this.orchestratorLogger.debug('Discussion locked by specialist, skipping', {
|
|
382
|
-
discussionId: message.discussionId
|
|
383
|
-
});
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
// Update context memory if this message is from an activity discussion
|
|
387
|
-
if (message.linkedActivityId) {
|
|
388
|
-
this.updateContextMemory(message.linkedActivityId, message.linkedActivityName || null);
|
|
389
|
-
}
|
|
390
|
-
return message;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Register a specialist's Hailer user ID
|
|
394
|
-
* Called during initialization when we know the specialist bot's user ID
|
|
395
|
-
*/
|
|
396
|
-
registerSpecialistUserId(specialistKey, userId) {
|
|
397
|
-
this.specialistUserIds.set(specialistKey, userId);
|
|
398
|
-
const specialist = this.specialists.get(specialistKey);
|
|
399
|
-
if (specialist) {
|
|
400
|
-
specialist.botUserId = userId;
|
|
401
|
-
this.orchestratorLogger.info("Specialist registered", {
|
|
402
|
-
key: specialistKey,
|
|
403
|
-
name: specialist.name,
|
|
404
|
-
userId,
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Check if a specialist is already active in a discussion
|
|
410
|
-
*/
|
|
411
|
-
isSpecialistActiveInDiscussion(discussionId, specialistUserId) {
|
|
412
|
-
const active = this.activeSpecialistsInDiscussion.get(discussionId);
|
|
413
|
-
return active?.has(specialistUserId) ?? false;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Mark a specialist as active in a discussion
|
|
417
|
-
*/
|
|
418
|
-
markSpecialistActive(discussionId, specialistUserId) {
|
|
419
|
-
if (!this.activeSpecialistsInDiscussion.has(discussionId)) {
|
|
420
|
-
this.activeSpecialistsInDiscussion.set(discussionId, new Set());
|
|
421
|
-
}
|
|
422
|
-
this.activeSpecialistsInDiscussion.get(discussionId).add(specialistUserId);
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Invite a specialist to a discussion
|
|
426
|
-
*/
|
|
427
|
-
async inviteSpecialist(specialist, discussionId, handoffContext) {
|
|
428
|
-
const specialistUserId = specialist.botUserId;
|
|
429
|
-
if (!specialistUserId) {
|
|
430
|
-
this.orchestratorLogger.warn("Specialist has no user ID", {
|
|
431
|
-
name: specialist.name,
|
|
432
|
-
});
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
// Check if already active
|
|
436
|
-
if (this.isSpecialistActiveInDiscussion(discussionId, specialistUserId)) {
|
|
437
|
-
this.orchestratorLogger.debug("Specialist already in discussion", {
|
|
438
|
-
name: specialist.name,
|
|
439
|
-
discussionId,
|
|
440
|
-
});
|
|
441
|
-
// Just tag them again
|
|
442
|
-
await this.postResponse(discussionId, `@"${specialist.name}" - ${handoffContext}`);
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
this.orchestratorLogger.info("Inviting specialist to discussion", {
|
|
447
|
-
name: specialist.name,
|
|
448
|
-
userId: specialistUserId,
|
|
449
|
-
discussionId,
|
|
450
|
-
});
|
|
451
|
-
// Invite using MCP tool
|
|
452
|
-
await this.callMcpTool("invite_discussion_members", {
|
|
453
|
-
discussionId,
|
|
454
|
-
userIds: [specialistUserId],
|
|
455
|
-
});
|
|
456
|
-
this.markSpecialistActive(discussionId, specialistUserId);
|
|
457
|
-
// Post handoff message
|
|
458
|
-
await this.postResponse(discussionId, `@"${specialist.name}" - ${handoffContext}`);
|
|
459
|
-
this.orchestratorLogger.info("Specialist invited successfully", {
|
|
460
|
-
name: specialist.name,
|
|
461
|
-
discussionId,
|
|
462
|
-
});
|
|
463
|
-
return true;
|
|
464
|
-
}
|
|
465
|
-
catch (error) {
|
|
466
|
-
this.orchestratorLogger.error("Failed to invite specialist", {
|
|
467
|
-
name: specialist.name,
|
|
468
|
-
discussionId,
|
|
469
|
-
error: error instanceof Error ? error.message : String(error),
|
|
470
|
-
});
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Override getTools to include Giuseppe retry tool when there's a pending fix
|
|
476
|
-
*/
|
|
477
|
-
getTools() {
|
|
478
|
-
// Always include the Giuseppe retry tool so LLM knows about it
|
|
479
|
-
return this.getToolsWithGiuseppeRetry();
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Get tools list with Giuseppe retry tool added
|
|
483
|
-
*/
|
|
484
|
-
getToolsWithGiuseppeRetry() {
|
|
485
|
-
const giuseppeRetryTool = {
|
|
486
|
-
name: 'trigger_giuseppe_retry',
|
|
487
|
-
description: 'Trigger Giuseppe to retry fixing a bug with new explanation. Use this after gathering enough info about what went wrong with the previous fix. Only works in discussions with a pending bug fix.',
|
|
488
|
-
input_schema: {
|
|
489
|
-
type: 'object',
|
|
490
|
-
properties: {
|
|
491
|
-
explanation: {
|
|
492
|
-
type: 'string',
|
|
493
|
-
description: 'Clear explanation of what is wrong with the current fix and what the expected behavior should be. Include: (1) what is broken, (2) expected vs actual behavior, (3) any specific details the user mentioned.',
|
|
494
|
-
},
|
|
495
|
-
},
|
|
496
|
-
required: ['explanation'],
|
|
497
|
-
},
|
|
498
|
-
};
|
|
499
|
-
const confirmBugFixTool = {
|
|
500
|
-
name: 'confirm_bug_fix',
|
|
501
|
-
description: 'Confirm that a bug report should be fixed. Use when user indicates they want the bug fixed (variations of "fix it", "yes fix", "please fix", etc.). Only works in discussions with a pending classification.',
|
|
502
|
-
input_schema: {
|
|
503
|
-
type: 'object',
|
|
504
|
-
properties: {},
|
|
505
|
-
required: [],
|
|
506
|
-
},
|
|
507
|
-
};
|
|
508
|
-
const declineBugReportTool = {
|
|
509
|
-
name: 'decline_bug_report',
|
|
510
|
-
description: 'Decline a bug report as not actually a bug. Use when user indicates it\'s not a bug (variations of "not a bug", "feature request", "not actually broken", etc.). Only works in discussions with a pending classification.',
|
|
511
|
-
input_schema: {
|
|
512
|
-
type: 'object',
|
|
513
|
-
properties: {},
|
|
514
|
-
required: [],
|
|
515
|
-
},
|
|
516
|
-
};
|
|
517
|
-
return [...this.minimalTools, giuseppeRetryTool, confirmBugFixTool, declineBugReportTool];
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Get pending fix context for a discussion (if any)
|
|
521
|
-
*/
|
|
522
|
-
getPendingFixContext(discussionId) {
|
|
523
|
-
const pendingFix = pending_fix_registry_1.pendingFixRegistry.getPendingFix(discussionId);
|
|
524
|
-
if (!pendingFix) {
|
|
525
|
-
return '';
|
|
526
|
-
}
|
|
527
|
-
return `
|
|
528
|
-
<pending_bug_fix>
|
|
529
|
-
**IMPORTANT: This discussion has a pending bug fix from Giuseppe!**
|
|
530
|
-
|
|
531
|
-
- Bug ID: ${pendingFix.bugId}
|
|
532
|
-
- State: ${pendingFix.state}
|
|
533
|
-
- Fix Summary: ${pendingFix.fixSummary}
|
|
534
|
-
|
|
535
|
-
**Your role:**
|
|
536
|
-
- If user says "approved" → Giuseppe handles it automatically (you do nothing)
|
|
537
|
-
- If user expresses ANY dissatisfaction (denied, not working, still broken, etc.):
|
|
538
|
-
1. Ask what's wrong (if not clear)
|
|
539
|
-
2. Gather: what's broken + expected behavior
|
|
540
|
-
3. Use trigger_giuseppe_retry tool with the explanation
|
|
541
|
-
|
|
542
|
-
**Remember:** You're gathering info for Giuseppe. Be concise, ask ONE question at a time.
|
|
543
|
-
</pending_bug_fix>
|
|
544
|
-
`;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Get pending classification context for a discussion (if any)
|
|
548
|
-
*/
|
|
549
|
-
getPendingClassificationContext(discussionId) {
|
|
550
|
-
const pending = pending_classification_registry_1.pendingClassificationRegistry.getPendingClassification(discussionId);
|
|
551
|
-
if (!pending) {
|
|
552
|
-
return '';
|
|
553
|
-
}
|
|
554
|
-
const classificationLabel = pending.classification === 'bug' ? 'Bug' :
|
|
555
|
-
pending.classification === 'feature_request' ? 'Feature Request' : 'Unclear';
|
|
556
|
-
return `
|
|
557
|
-
<pending_classification>
|
|
558
|
-
**IMPORTANT: Giuseppe just classified this report and is waiting for user decision!**
|
|
559
|
-
|
|
560
|
-
- Bug: ${pending.bugName}
|
|
561
|
-
- App: ${pending.appName || pending.appId || 'Unknown'}
|
|
562
|
-
- Classification: ${classificationLabel}
|
|
563
|
-
- Reason: ${pending.reason}
|
|
564
|
-
|
|
565
|
-
**User options:**
|
|
566
|
-
- "fix it" → Giuseppe will proceed to fix the bug
|
|
567
|
-
- "not a bug" → Report will be moved to Declined
|
|
568
|
-
|
|
569
|
-
**Your role - Use tools for user intent:**
|
|
570
|
-
- User wants to fix the bug → Call confirm_bug_fix tool
|
|
571
|
-
- User says it's not a bug / feature request → Call decline_bug_report tool
|
|
572
|
-
- User has questions → Help explain the classification
|
|
573
|
-
|
|
574
|
-
**Detecting intent (use tools, don't wait for exact words):**
|
|
575
|
-
- "fix it", "yes fix", "go ahead", "please fix", "fix this" → confirm_bug_fix
|
|
576
|
-
- "not a bug", "feature request", "not broken", "close it", "decline" → decline_bug_report
|
|
577
|
-
|
|
578
|
-
**Remember:** Use the tools to trigger actions. Don't tell user to type magic words.
|
|
579
|
-
</pending_classification>
|
|
580
|
-
`;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Override system prompt to include orchestrator capabilities
|
|
584
|
-
*/
|
|
585
|
-
getSystemPrompt() {
|
|
586
|
-
const now = new Date();
|
|
587
|
-
const { firstName, lastName } = this.getAgentName();
|
|
588
|
-
const fullName = `${firstName} ${lastName}`.trim();
|
|
589
|
-
// Build specialist info for prompt
|
|
590
|
-
const specialistInfo = Array.from(this.specialists.entries())
|
|
591
|
-
.map(([key, spec]) => {
|
|
592
|
-
const hasUserId = !!spec.botUserId;
|
|
593
|
-
return `- **${spec.name}** ${hasUserId ? "(available)" : "(not configured)"}
|
|
594
|
-
Expertise: ${spec.expertise.join(", ")}
|
|
595
|
-
Triggers: ${spec.triggerKeywords.slice(0, 5).join(", ")}`;
|
|
596
|
-
})
|
|
597
|
-
.join("\n\n");
|
|
598
|
-
return `<identity>
|
|
599
|
-
You are ${fullName} - the Hailer Assistant. Sharp, efficient, and helpful.
|
|
600
|
-
Bot ID: ${this.botClient.userId}
|
|
601
|
-
|
|
602
|
-
You're the main point of contact for users. You handle general conversation
|
|
603
|
-
and simple tasks yourself, but can bring in specialist bots for complex work.
|
|
604
|
-
</identity>
|
|
605
|
-
|
|
606
|
-
<current_time>${now.toISOString()}</current_time>
|
|
607
|
-
|
|
608
|
-
<personality>
|
|
609
|
-
**BUSINESS MODE** (default):
|
|
610
|
-
- Professional, direct, competent
|
|
611
|
-
- Get things done efficiently
|
|
612
|
-
- Provide accurate information
|
|
613
|
-
|
|
614
|
-
**SARCASM MODE** (for ridiculous requests):
|
|
615
|
-
- Dry wit, not mean-spirited
|
|
616
|
-
- Still help after the gentle mockery
|
|
617
|
-
</personality>
|
|
618
|
-
|
|
619
|
-
<decision_framework>
|
|
620
|
-
For each message, decide:
|
|
621
|
-
|
|
622
|
-
1. **HIGH PRIORITY** (priority="high") - ALWAYS RESPOND:
|
|
623
|
-
- Direct messages (1:1) -> respond helpfully
|
|
624
|
-
- @mentions -> respond (even if just a greeting - acknowledge and ask how you can help)
|
|
625
|
-
- Replies to your messages -> respond
|
|
626
|
-
- **NEVER use <ignore/> for HIGH priority. Always acknowledge the user.**
|
|
627
|
-
|
|
628
|
-
2. **NORMAL PRIORITY** (general chat) - STRICT FILTERING:
|
|
629
|
-
|
|
630
|
-
**RESPOND ONLY IF the message:**
|
|
631
|
-
- Explicitly asks about Hailer (workflows, activities, insights, apps, discussions)
|
|
632
|
-
- Requests to find/list/create/update workspace data
|
|
633
|
-
- Discusses a specific activity, customer, project, or workflow by name
|
|
634
|
-
- You can genuinely help with workspace-related context
|
|
635
|
-
- Is a complex task needing specialist help
|
|
636
|
-
|
|
637
|
-
**IGNORE (output <ignore/>) for NORMAL priority if:**
|
|
638
|
-
- Random characters, gibberish, keyboard mashing (no real words, repeated patterns)
|
|
639
|
-
- General chit-chat unrelated to workspace ("how are you", jokes)
|
|
640
|
-
- Conversations between other users that don't need you
|
|
641
|
-
- Bare greetings without a question ("hi", "hey") - but NOT if HIGH priority!
|
|
642
|
-
- Off-topic discussions (sports, weather, personal chat)
|
|
643
|
-
- Anything you're uncertain about
|
|
644
|
-
|
|
645
|
-
**CRITICAL:** For NORMAL priority only - if no clear workspace-related question/task, output <ignore/>.
|
|
646
|
-
When in doubt about NORMAL priority, IGNORE. Your DEFAULT for normal priority is <ignore/>.
|
|
647
|
-
|
|
648
|
-
3. **RESPOND FORMAT** (only when you have something helpful):
|
|
649
|
-
<respond discussion="DISCUSSION_ID">
|
|
650
|
-
Your response
|
|
651
|
-
</respond>
|
|
652
|
-
|
|
653
|
-
4. **IGNORE FORMAT** (use liberally - this is your DEFAULT):
|
|
654
|
-
<ignore/>
|
|
655
|
-
</decision_framework>
|
|
656
|
-
|
|
657
|
-
<specialists>
|
|
658
|
-
You can invite specialist bots when tasks are too complex.
|
|
659
|
-
|
|
660
|
-
${specialistInfo}
|
|
661
|
-
|
|
662
|
-
**When to invite a specialist:**
|
|
663
|
-
- Creating new workflows/pipelines
|
|
664
|
-
- Setting up reports/insights/dashboards
|
|
665
|
-
- Bulk operations (10+ items)
|
|
666
|
-
- Complex multi-step data tasks
|
|
667
|
-
- Workflow configuration changes
|
|
668
|
-
|
|
669
|
-
**When to handle yourself:**
|
|
670
|
-
- General chat, greetings
|
|
671
|
-
- Simple queries (list activities, show details)
|
|
672
|
-
- Single create/update operations
|
|
673
|
-
- Questions about the conversation
|
|
674
|
-
- Clarifying user requirements
|
|
675
|
-
|
|
676
|
-
<invite_syntax>
|
|
677
|
-
<invite specialist="hailerExpert">
|
|
678
|
-
Clear description of what you need done.
|
|
679
|
-
Include relevant context from the conversation.
|
|
680
|
-
</invite>
|
|
681
|
-
</invite_syntax>
|
|
682
|
-
|
|
683
|
-
<handoff_rules>
|
|
684
|
-
CRITICAL: When you've already gathered IDs (workflows, fields, phases), include them formatted in the handoff.
|
|
685
|
-
|
|
686
|
-
<bad_handoff>
|
|
687
|
-
"Create an insight for the Injuries workflow showing player data"
|
|
688
|
-
</bad_handoff>
|
|
689
|
-
|
|
690
|
-
<good_handoff>
|
|
691
|
-
"Create insight for Injuries workflow:
|
|
692
|
-
- workflowId: 691ffdf84217e9e8434e56ad
|
|
693
|
-
- Fields: { name: 'playerName', fieldId: '691ffdf84217e9e8434e56b1' }, { name: 'injuryType', fieldId: '691ffdf84217e9e8434e56b2' }
|
|
694
|
-
- Query: SELECT name as \"Activity\", playerName, injuryType FROM injuries ORDER BY name"
|
|
695
|
-
</good_handoff>
|
|
696
|
-
|
|
697
|
-
<insight_field_format>
|
|
698
|
-
Always format fields as: { name: 'Column Name', fieldId: 'FIELD_ID' }
|
|
699
|
-
Use 'fieldId' not 'id' for the field identifier.
|
|
700
|
-
</insight_field_format>
|
|
701
|
-
</handoff_rules>
|
|
702
|
-
|
|
703
|
-
<after_invite>
|
|
704
|
-
1. I invite them to the discussion
|
|
705
|
-
2. I post your handoff message mentioning them
|
|
706
|
-
3. They see it and take action
|
|
707
|
-
</after_invite>
|
|
708
|
-
</specialists>
|
|
709
|
-
|
|
710
|
-
<giuseppe_autonomous>
|
|
711
|
-
**Giuseppe - Autonomous Bug Fixer**
|
|
712
|
-
|
|
713
|
-
Giuseppe is SPECIAL - he works AUTONOMOUSLY, not through invites!
|
|
714
|
-
|
|
715
|
-
**How Giuseppe works:**
|
|
716
|
-
1. Users create a bug report in the "Bug Reports" workflow
|
|
717
|
-
2. Giuseppe automatically detects new bugs and starts fixing them
|
|
718
|
-
3. He analyzes the code, generates a fix, tests it
|
|
719
|
-
4. He asks the user to verify with "approved" or "denied"
|
|
720
|
-
5. On "approved" → Giuseppe publishes to production automatically
|
|
721
|
-
6. On "denied" or complaint → YOU (HAL) gather info, then trigger Giuseppe retry
|
|
722
|
-
|
|
723
|
-
**YOUR ROLE IN BUG FIX DENIALS:**
|
|
724
|
-
When a discussion has a pending bug fix and the user expresses dissatisfaction:
|
|
725
|
-
1. YOU handle the conversation - ask what's wrong, what behavior they expected
|
|
726
|
-
2. Gather enough context: what's broken, expected vs actual behavior
|
|
727
|
-
3. Once you have clear info, use trigger_giuseppe_retry tool to pass the explanation
|
|
728
|
-
4. Giuseppe will receive your gathered info and retry the fix
|
|
729
|
-
|
|
730
|
-
**Detecting denial signals:**
|
|
731
|
-
- "denied", "not working", "still broken", "wrong", "doesn't work"
|
|
732
|
-
- Any complaint about the fix behavior
|
|
733
|
-
- User describing unexpected behavior
|
|
734
|
-
|
|
735
|
-
**Gathering info (ask ONE question at a time):**
|
|
736
|
-
- "What behavior are you seeing?"
|
|
737
|
-
- "What did you expect to happen instead?"
|
|
738
|
-
- "Is the issue consistent or intermittent?"
|
|
739
|
-
|
|
740
|
-
**When to trigger retry:**
|
|
741
|
-
Once you have: (1) what's wrong, (2) expected behavior → trigger the retry
|
|
742
|
-
|
|
743
|
-
**When someone mentions bugs (NEW bugs):**
|
|
744
|
-
- Tell them to create a bug report in "Bug Reports" workflow
|
|
745
|
-
- Explain Giuseppe will pick it up automatically
|
|
746
|
-
- Offer to help create the bug report for them
|
|
747
|
-
</giuseppe_autonomous>
|
|
748
|
-
|
|
749
|
-
<your_tools>
|
|
750
|
-
You have access to basic MCP tools for simple operations:
|
|
751
|
-
- list_workflows, list_workflow_phases, get_workflow_schema
|
|
752
|
-
- list_activities, show_activity_by_id, count_activities
|
|
753
|
-
- create_activity, update_activity (single operations)
|
|
754
|
-
- search_workspace_users
|
|
755
|
-
- Discussion tools (join_discussion, add_discussion_message, invite_discussion_members)
|
|
756
|
-
|
|
757
|
-
For complex operations (workflow creation, insights, bulk ops), invite a specialist.
|
|
758
|
-
|
|
759
|
-
**CRITICAL for join_discussion when inviting users:**
|
|
760
|
-
ALWAYS pass these parameters from the incoming message:
|
|
761
|
-
- inviteUserId = user_id attribute
|
|
762
|
-
- sourceActivityId = activity_id attribute (creates "came from" link!)
|
|
763
|
-
- welcomeReason = why they're being invited
|
|
764
|
-
|
|
765
|
-
**join_discussion ID types:**
|
|
766
|
-
- HailerTags like [hailerTag|Name](ID) usually contain ACTIVITY IDs, not discussion IDs
|
|
767
|
-
- When user references an activity/player/customer by tag, use: activityId parameter
|
|
768
|
-
- Only use discussionId for direct discussion links (rare)
|
|
769
|
-
- The tool auto-detects: if discussionId fails, it tries as activityId
|
|
770
|
-
|
|
771
|
-
**SILENT SUCCESS for join_discussion:**
|
|
772
|
-
After successfully joining a discussion, do NOT post a confirmation message back to the source chat.
|
|
773
|
-
The action is self-evident (bot appears in target discussion). Only report ERRORS back to source chat.
|
|
774
|
-
|
|
775
|
-
**CRITICAL - Extract IDs from context:**
|
|
776
|
-
The <incoming> tag contains IDs. ALWAYS use them:
|
|
777
|
-
- activityId attribute → pass to show_activity_by_id, update_activity
|
|
778
|
-
- discussionId attribute → pass to get_activity_from_discussion, add_discussion_message
|
|
779
|
-
|
|
780
|
-
**NEVER call tools with empty parameters {}** - always extract from context first.
|
|
781
|
-
|
|
782
|
-
**update_activity formats:**
|
|
783
|
-
- Single mode: use \`activityId\` parameter
|
|
784
|
-
- Bulk mode (activities array): use \`_id\` inside each object, NOT \`activityId\`
|
|
785
|
-
|
|
786
|
-
**Field values must be plain:**
|
|
787
|
-
- numericunit: just the number → \`78\` (NOT \`{"type":"numericunit","value":78}\`)
|
|
788
|
-
- text: just the string → \`"hello"\`
|
|
789
|
-
- activitylink: just the ID → \`"abc123..."\`
|
|
790
|
-
</your_tools>
|
|
791
|
-
|
|
792
|
-
<tagging>
|
|
793
|
-
**Activity Tags:** #ACTIVITY_ID (24-char hex)
|
|
794
|
-
- Correct: "Check out #691ffe874217e9e8434e57fc"
|
|
795
|
-
- Wrong: "Check out #691ffe874217e9e8434e57fc (Name)" - name auto-displays
|
|
796
|
-
|
|
797
|
-
**User Mentions:** @"Full Name" or @userId
|
|
798
|
-
</tagging>
|
|
799
|
-
|
|
800
|
-
<agentic_loop>
|
|
801
|
-
**CRITICAL: Complete work before responding!**
|
|
802
|
-
|
|
803
|
-
You work in a single-turn loop. When you respond with <respond>, your turn ENDS.
|
|
804
|
-
There is NO "next turn" unless a new message arrives.
|
|
805
|
-
|
|
806
|
-
**WRONG - promising future work:**
|
|
807
|
-
<respond discussion="...">
|
|
808
|
-
I found 29 players. Let me check which ones are injured...
|
|
809
|
-
</respond>
|
|
810
|
-
→ This posts the message but NEVER calls any tools!
|
|
811
|
-
|
|
812
|
-
**RIGHT - complete the work first:**
|
|
813
|
-
1. Call list_activities with injury filter
|
|
814
|
-
2. Get results
|
|
815
|
-
3. THEN respond with the actual answer:
|
|
816
|
-
<respond discussion="...">
|
|
817
|
-
Found 3 injured players: #player1, #player2, #player3
|
|
818
|
-
</respond>
|
|
819
|
-
|
|
820
|
-
**RULE: Never say "let me check" or "give me a second" - just DO IT by calling tools.**
|
|
821
|
-
Only use <respond> when you have the FINAL answer to share.
|
|
822
|
-
</agentic_loop>
|
|
823
|
-
|
|
824
|
-
<rules>
|
|
825
|
-
- Be concise - snappy responses, not essays
|
|
826
|
-
- Use your memory - reference past conversations
|
|
827
|
-
- For HIGH priority: respond immediately
|
|
828
|
-
- For NORMAL priority: your DEFAULT is <ignore/>. Only break if you see a clear workspace question.
|
|
829
|
-
- **Gibberish test:** No recognizable words, no vowels, repeated patterns = <ignore/>
|
|
830
|
-
- **Relevance test:** Is this about workflows/activities/insights? If not = <ignore/>
|
|
831
|
-
- When inviting specialists, explain to the user what's happening
|
|
832
|
-
- After specialist responds, summarize for the user if needed
|
|
833
|
-
- **Complete work before responding** - Never say "I'm going to do X", just DO X with tool calls
|
|
834
|
-
</rules>
|
|
835
|
-
|
|
836
|
-
${this.currentDiscussionId ? this.getPendingFixContext(this.currentDiscussionId) : ''}
|
|
837
|
-
${this.currentDiscussionId ? this.getPendingClassificationContext(this.currentDiscussionId) : ''}`;
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Override response handling to detect specialist invitations
|
|
841
|
-
*/
|
|
842
|
-
async handleLlmResponse(response, originalMessage) {
|
|
843
|
-
// Get conversation for this discussion
|
|
844
|
-
const conversation = this.conversationManager.getConversation(originalMessage.discussionId);
|
|
845
|
-
// Add assistant response to conversation
|
|
846
|
-
// Cast response content to MessageParam content type (ContentBlock[] → ContentBlockParam[])
|
|
847
|
-
conversation.push({
|
|
848
|
-
role: "assistant",
|
|
849
|
-
content: response.content,
|
|
850
|
-
});
|
|
851
|
-
// Check for specialist invitation in text content
|
|
852
|
-
const textBlocks = response.content.filter((block) => block.type === "text");
|
|
853
|
-
const textContent = textBlocks.map((b) => b.text).join("\n");
|
|
854
|
-
// Look for <invite specialist="...">...</invite> pattern
|
|
855
|
-
const inviteMatch = textContent.match(/<invite specialist="(\w+)">([\s\S]*?)<\/invite>/);
|
|
856
|
-
if (inviteMatch) {
|
|
857
|
-
const [fullMatch, specialistKey, handoffContext] = inviteMatch;
|
|
858
|
-
const specialist = this.specialists.get(specialistKey);
|
|
859
|
-
if (specialist && specialist.botUserId) {
|
|
860
|
-
this.orchestratorLogger.info("LLM requested specialist invitation", {
|
|
861
|
-
specialist: specialistKey,
|
|
862
|
-
discussionId: originalMessage.discussionId,
|
|
863
|
-
});
|
|
864
|
-
// Extract any text before the invite tag to post as acknowledgment
|
|
865
|
-
const preInviteText = textContent
|
|
866
|
-
.substring(0, textContent.indexOf("<invite"))
|
|
867
|
-
.trim();
|
|
868
|
-
// Check for respond wrapper
|
|
869
|
-
const respondMatch = preInviteText.match(/<respond discussion="([^"]+)">([\s\S]*)/);
|
|
870
|
-
if (respondMatch) {
|
|
871
|
-
const [, discussionId, content] = respondMatch;
|
|
872
|
-
const cleanContent = content.replace(/<\/respond>.*$/s, "").trim();
|
|
873
|
-
if (cleanContent) {
|
|
874
|
-
await this.postResponse(discussionId, cleanContent);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
else if (preInviteText) {
|
|
878
|
-
// No respond wrapper, but there's text - might be for high priority
|
|
879
|
-
if (originalMessage.priority === "high") {
|
|
880
|
-
await this.postResponse(originalMessage.discussionId, preInviteText);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
// Invite the specialist
|
|
884
|
-
const invited = await this.inviteSpecialist(specialist, originalMessage.discussionId, handoffContext.trim());
|
|
885
|
-
if (!invited) {
|
|
886
|
-
// Failed to invite - let user know
|
|
887
|
-
await this.postResponse(originalMessage.discussionId, `I tried to bring in ${specialist.name} but couldn't reach them. Let me try handling this myself...`);
|
|
888
|
-
// Continue with normal handling
|
|
889
|
-
}
|
|
890
|
-
return; // Don't continue with normal response handling
|
|
891
|
-
}
|
|
892
|
-
else {
|
|
893
|
-
this.orchestratorLogger.warn("Specialist not available", {
|
|
894
|
-
key: specialistKey,
|
|
895
|
-
hasSpecialist: !!specialist,
|
|
896
|
-
hasUserId: !!specialist?.botUserId,
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
// Check for tool calls
|
|
901
|
-
const toolUseBlocks = response.content.filter((block) => block.type === "tool_use");
|
|
902
|
-
if (toolUseBlocks.length > 0) {
|
|
903
|
-
// Mark that tools were used - subsequent responses should be posted
|
|
904
|
-
this.toolsUsedInCurrentMessage = true;
|
|
905
|
-
// Track which tools were used (for silent success detection)
|
|
906
|
-
this.lastToolsUsed = toolUseBlocks.map(b => b.name);
|
|
907
|
-
// Execute tools and continue conversation
|
|
908
|
-
await this.executeToolsAndContinue(toolUseBlocks, originalMessage);
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
// Check for regular response (no invite, no tools)
|
|
912
|
-
if (textBlocks.length > 0) {
|
|
913
|
-
const responseText = textContent.trim();
|
|
914
|
-
this.orchestratorLogger.info("LLM raw response", {
|
|
915
|
-
discussion: originalMessage.discussionId,
|
|
916
|
-
priority: originalMessage.priority,
|
|
917
|
-
responseLength: responseText.length,
|
|
918
|
-
fullResponse: responseText.substring(0, 500),
|
|
919
|
-
hasIgnoreTag: responseText.includes("<ignore"),
|
|
920
|
-
hasRespondTag: responseText.includes("<respond"),
|
|
921
|
-
});
|
|
922
|
-
// Check for IGNORE decision - remove from context to keep it clean
|
|
923
|
-
if (responseText.includes("<decision>IGNORE</decision>") ||
|
|
924
|
-
responseText.includes("<ignore")) {
|
|
925
|
-
this.orchestratorLogger.debug("LLM decided to ignore - removing from context", {
|
|
926
|
-
discussion: originalMessage.discussionId,
|
|
927
|
-
});
|
|
928
|
-
// Stop typing indicator
|
|
929
|
-
this.stopTypingIndicator();
|
|
930
|
-
// Remove both the assistant's response AND the incoming message from context
|
|
931
|
-
conversation.pop(); // Remove assistant response we just added
|
|
932
|
-
conversation.pop(); // Remove the incoming message
|
|
933
|
-
this.toolsUsedInCurrentMessage = false; // Reset for next message
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
// Check for explicit response directive
|
|
937
|
-
const responseMatch = responseText.match(/<respond discussion="([^"]+)">([\s\S]*?)<\/respond>/);
|
|
938
|
-
if (responseMatch) {
|
|
939
|
-
const targetDiscussion = responseMatch[1];
|
|
940
|
-
const content = responseMatch[2].trim();
|
|
941
|
-
// SILENT SUCCESS: Skip confirmation if we just ran a silent tool successfully (not on error)
|
|
942
|
-
const usedSilentTool = this.lastToolsUsed.some(t => OrchestratorDaemon.SILENT_SUCCESS_TOOLS.has(t));
|
|
943
|
-
if (usedSilentTool && !this.lastToolsFailed) {
|
|
944
|
-
this.orchestratorLogger.debug("Suppressing confirmation for silent success tool", {
|
|
945
|
-
discussion: originalMessage.discussionId,
|
|
946
|
-
tools: this.lastToolsUsed,
|
|
947
|
-
});
|
|
948
|
-
// Stop typing indicator
|
|
949
|
-
this.stopTypingIndicator();
|
|
950
|
-
// NOTE: Don't pop from context - keep conversation valid for future messages
|
|
951
|
-
this.toolsUsedInCurrentMessage = false;
|
|
952
|
-
this.lastToolsUsed = [];
|
|
953
|
-
this.lastToolsFailed = false;
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
await this.postResponse(targetDiscussion, content);
|
|
957
|
-
this.toolsUsedInCurrentMessage = false; // Reset for next message
|
|
958
|
-
this.lastToolsUsed = [];
|
|
959
|
-
this.lastToolsFailed = false;
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
// For high priority messages, always send substantive responses
|
|
963
|
-
// (unless we just ran a silent success tool)
|
|
964
|
-
if (originalMessage.priority === "high" &&
|
|
965
|
-
responseText &&
|
|
966
|
-
!responseText.includes("<thinking>") &&
|
|
967
|
-
!responseText.startsWith("I'll") &&
|
|
968
|
-
responseText.length > 10) {
|
|
969
|
-
// SILENT SUCCESS: Skip confirmation if we just ran a silent tool successfully (not on error)
|
|
970
|
-
const usedSilentTool = this.lastToolsUsed.some(t => OrchestratorDaemon.SILENT_SUCCESS_TOOLS.has(t));
|
|
971
|
-
if (usedSilentTool && !this.lastToolsFailed) {
|
|
972
|
-
this.orchestratorLogger.debug("Suppressing high-priority confirmation for silent success tool", {
|
|
973
|
-
discussion: originalMessage.discussionId,
|
|
974
|
-
tools: this.lastToolsUsed,
|
|
975
|
-
});
|
|
976
|
-
// Stop typing indicator
|
|
977
|
-
this.stopTypingIndicator();
|
|
978
|
-
// NOTE: Don't pop from context - keep conversation valid for future messages
|
|
979
|
-
this.toolsUsedInCurrentMessage = false;
|
|
980
|
-
this.lastToolsUsed = [];
|
|
981
|
-
this.lastToolsFailed = false;
|
|
982
|
-
return;
|
|
983
|
-
}
|
|
984
|
-
await this.postResponse(originalMessage.discussionId, responseText);
|
|
985
|
-
this.toolsUsedInCurrentMessage = false; // Reset for next message
|
|
986
|
-
this.lastToolsUsed = [];
|
|
987
|
-
this.lastToolsFailed = false;
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
// For normal priority:
|
|
991
|
-
// - If tools were used, post substantive responses (LLM was doing real work)
|
|
992
|
-
// - Otherwise, require explicit <respond> tag
|
|
993
|
-
if (originalMessage.priority === "normal") {
|
|
994
|
-
// SILENT SUCCESS: Skip confirmation if we just ran a silent tool successfully (not on error)
|
|
995
|
-
const usedSilentTool = this.lastToolsUsed.some(t => OrchestratorDaemon.SILENT_SUCCESS_TOOLS.has(t));
|
|
996
|
-
const shouldSuppressSilent = usedSilentTool && !this.lastToolsFailed;
|
|
997
|
-
if (this.toolsUsedInCurrentMessage && responseText.length > 50 && !responseText.includes("<ignore") && !shouldSuppressSilent) {
|
|
998
|
-
// Tools were used and we have a substantive response - post it
|
|
999
|
-
this.orchestratorLogger.info("Posting tool-assisted response", {
|
|
1000
|
-
discussion: originalMessage.discussionId,
|
|
1001
|
-
responseLength: responseText.length,
|
|
1002
|
-
});
|
|
1003
|
-
await this.postResponse(originalMessage.discussionId, responseText);
|
|
1004
|
-
this.toolsUsedInCurrentMessage = false; // Reset for next message
|
|
1005
|
-
this.lastToolsUsed = [];
|
|
1006
|
-
this.lastToolsFailed = false;
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
if (shouldSuppressSilent) {
|
|
1010
|
-
this.orchestratorLogger.debug("Suppressing normal-priority confirmation for silent success tool", {
|
|
1011
|
-
discussion: originalMessage.discussionId,
|
|
1012
|
-
tools: this.lastToolsUsed,
|
|
1013
|
-
});
|
|
1014
|
-
// Stop typing indicator
|
|
1015
|
-
this.stopTypingIndicator();
|
|
1016
|
-
// NOTE: Don't pop from context when tools were used - keep conversation valid
|
|
1017
|
-
this.toolsUsedInCurrentMessage = false;
|
|
1018
|
-
this.lastToolsUsed = [];
|
|
1019
|
-
this.lastToolsFailed = false;
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
this.orchestratorLogger.debug("Normal priority without <respond> tag - removing from context", {
|
|
1023
|
-
discussion: originalMessage.discussionId,
|
|
1024
|
-
responsePreview: responseText.substring(0, 100),
|
|
1025
|
-
toolsUsed: this.toolsUsedInCurrentMessage,
|
|
1026
|
-
});
|
|
1027
|
-
// Stop typing indicator
|
|
1028
|
-
this.stopTypingIndicator();
|
|
1029
|
-
// Remove from context - we didn't respond (only safe when no tools were used)
|
|
1030
|
-
if (!this.toolsUsedInCurrentMessage) {
|
|
1031
|
-
conversation.pop(); // Remove assistant response
|
|
1032
|
-
conversation.pop(); // Remove incoming message
|
|
1033
|
-
}
|
|
1034
|
-
this.toolsUsedInCurrentMessage = false; // Reset for next message
|
|
1035
|
-
this.lastToolsUsed = [];
|
|
1036
|
-
this.lastToolsFailed = false;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Get orchestrator status including specialist info
|
|
1042
|
-
*/
|
|
1043
|
-
getOrchestratorStatus() {
|
|
1044
|
-
const specialists = Array.from(this.specialists.entries()).map(([key, spec]) => ({
|
|
1045
|
-
key,
|
|
1046
|
-
name: spec.name,
|
|
1047
|
-
available: !!spec.botUserId,
|
|
1048
|
-
userId: spec.botUserId,
|
|
1049
|
-
}));
|
|
1050
|
-
const activeInDiscussions = {};
|
|
1051
|
-
for (const [discussionId, userIds] of this.activeSpecialistsInDiscussion) {
|
|
1052
|
-
activeInDiscussions[discussionId] = Array.from(userIds);
|
|
1053
|
-
}
|
|
1054
|
-
return {
|
|
1055
|
-
conversationState: this.getConversationState(),
|
|
1056
|
-
specialists,
|
|
1057
|
-
activeInDiscussions,
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
exports.OrchestratorDaemon = OrchestratorDaemon;
|
|
1062
|
-
//# sourceMappingURL=orchestrator.js.map
|