@hailer/mcp 1.1.16 → 1.1.17-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/CLAUDE.md +117 -320
- package/.claude/commands/app-squad.md +86 -90
- package/.claude/commands/audit-squad.md +19 -19
- package/.claude/commands/autoplan.md +3 -3
- package/.claude/commands/cleanup-squad.md +16 -16
- package/.claude/commands/config-squad.md +30 -30
- package/.claude/commands/crud-squad.md +23 -23
- package/.claude/commands/data-squad.md +21 -21
- package/.claude/commands/debug-squad.md +44 -44
- package/.claude/commands/doc-squad.md +16 -16
- package/.claude/commands/help:agents.md +130 -99
- package/.claude/commands/help:commands.md +15 -15
- package/.claude/commands/help:faq.md +17 -17
- package/.claude/commands/help:plugins.md +1 -1
- package/.claude/commands/help:skills.md +18 -24
- package/.claude/commands/hotfix-squad.md +22 -22
- package/.claude/commands/integration-squad.md +22 -22
- package/.claude/commands/janitor-squad.md +31 -31
- package/.claude/commands/learn-auto.md +5 -5
- package/.claude/commands/learn.md +12 -20
- package/.claude/commands/onboard-squad.md +39 -49
- package/.claude/commands/plan-workspace.md +2 -2
- package/.claude/commands/publish.md +32 -37
- package/.claude/commands/review-squad.md +27 -27
- package/.claude/commands/stats.md +26 -12
- package/.claude/commands/swarm.md +25 -25
- package/.claude/skills/chrome-mcp-reference/SKILL.md +5 -0
- package/.claude/skills/hailer-api-client/SKILL.md +55 -16
- package/.claude/skills/hailer-app-builder/SKILL.md +4 -270
- package/.claude/skills/hailer-apps-pictures/SKILL.md +3 -3
- package/.claude/skills/hailer-design-system/SKILL.md +96 -4
- package/.claude/skills/hailer-monolith-automations/SKILL.md +138 -116
- package/.claude/skills/hailer-permissions-system/SKILL.md +6 -9
- package/.claude/skills/hailer-project-protocol/SKILL.md +20 -110
- package/.claude/skills/integration-patterns/SKILL.md +6 -6
- package/.claude/skills/lsp-setup/SKILL.md +8 -9
- package/.claude/skills/sdk-activity-patterns/SKILL.md +238 -0
- package/.claude/skills/{SDK-document-templates → sdk-document-templates}/SKILL.md +13 -340
- package/.claude/skills/{SDK-function-fields → sdk-function-fields}/SKILL.md +8 -40
- package/.claude/skills/{SDK-insight-queries → sdk-insight-queries}/SKILL.md +114 -392
- package/.claude/skills/{SDK-ws-config-skill → sdk-ws-config-skill}/SKILL.md +79 -310
- package/.claude/skills/zapier-hailer-patterns/SKILL.md +84 -361
- package/.opencode/package-lock.json +117 -0
- package/CLAUDE.md +5 -358
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +10 -127
- package/dist/app.js.map +1 -1
- package/dist/bot/bot-manager.d.ts +3 -14
- package/dist/bot/bot-manager.d.ts.map +1 -1
- package/dist/bot/bot-manager.js +13 -4
- package/dist/bot/bot-manager.js.map +1 -1
- package/dist/bot/bot.d.ts +23 -102
- package/dist/bot/bot.d.ts.map +1 -1
- package/dist/bot/bot.js +356 -1212
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/services/bot-permissions.d.ts +50 -0
- package/dist/bot/services/bot-permissions.d.ts.map +1 -0
- package/dist/bot/services/bot-permissions.js +198 -0
- package/dist/bot/services/bot-permissions.js.map +1 -0
- package/dist/bot/services/index.d.ts +4 -2
- package/dist/bot/services/index.d.ts.map +1 -1
- package/dist/bot/services/index.js +10 -5
- package/dist/bot/services/index.js.map +1 -1
- package/dist/bot/services/message-classifier.d.ts +1 -1
- package/dist/bot/services/message-classifier.d.ts.map +1 -1
- package/dist/bot/services/message-classifier.js.map +1 -1
- package/dist/bot/services/signal-router.d.ts +32 -0
- package/dist/bot/services/signal-router.d.ts.map +1 -0
- package/dist/bot/services/signal-router.js +132 -0
- package/dist/bot/services/signal-router.js.map +1 -0
- package/dist/bot/services/system-prompt.d.ts +12 -0
- package/dist/bot/services/system-prompt.d.ts.map +1 -0
- package/dist/bot/services/system-prompt.js +93 -0
- package/dist/bot/services/system-prompt.js.map +1 -0
- package/dist/bot/services/types.d.ts +7 -34
- package/dist/bot/services/types.d.ts.map +1 -1
- package/dist/bot/services/types.js +0 -3
- package/dist/bot/services/types.js.map +1 -1
- package/dist/bot/services/workspace-refresh.d.ts +47 -0
- package/dist/bot/services/workspace-refresh.d.ts.map +1 -0
- package/dist/bot/services/workspace-refresh.js +154 -0
- package/dist/bot/services/workspace-refresh.js.map +1 -0
- package/dist/bot-config/constants.d.ts +0 -36
- package/dist/bot-config/constants.d.ts.map +1 -1
- package/dist/bot-config/constants.js +1 -76
- package/dist/bot-config/constants.js.map +1 -1
- package/dist/bot-config/context.d.ts +2 -42
- package/dist/bot-config/context.d.ts.map +1 -1
- package/dist/bot-config/context.js +13 -134
- package/dist/bot-config/context.js.map +1 -1
- package/dist/bot-config/index.d.ts +6 -15
- package/dist/bot-config/index.d.ts.map +1 -1
- package/dist/bot-config/index.js +5 -80
- package/dist/bot-config/index.js.map +1 -1
- package/dist/bot-config/loader.d.ts +16 -4
- package/dist/bot-config/loader.d.ts.map +1 -1
- package/dist/bot-config/loader.js +187 -96
- package/dist/bot-config/loader.js.map +1 -1
- package/dist/bot-config/persistence.d.ts +1 -52
- package/dist/bot-config/persistence.d.ts.map +1 -1
- package/dist/bot-config/persistence.js +3 -213
- package/dist/bot-config/persistence.js.map +1 -1
- package/dist/bot-config/state.d.ts +0 -41
- package/dist/bot-config/state.d.ts.map +1 -1
- package/dist/bot-config/state.js +0 -151
- package/dist/bot-config/state.js.map +1 -1
- package/dist/bot-config/tools.d.ts +1 -1
- package/dist/bot-config/tools.js +27 -27
- package/dist/bot-config/tools.js.map +1 -1
- package/dist/bot-config/types.d.ts +39 -32
- package/dist/bot-config/types.d.ts.map +1 -1
- package/dist/bot-config/types.js +0 -3
- package/dist/bot-config/types.js.map +1 -1
- package/dist/bot-config/webhooks.d.ts +0 -4
- package/dist/bot-config/webhooks.d.ts.map +1 -1
- package/dist/bot-config/webhooks.js +0 -13
- package/dist/bot-config/webhooks.js.map +1 -1
- package/dist/commands/seed-config.js +16 -31
- package/dist/commands/seed-config.js.map +1 -1
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -15
- package/dist/config.js.map +1 -1
- package/dist/mcp/hailer-clients.js +2 -2
- package/dist/mcp/hailer-clients.js.map +1 -1
- package/dist/mcp/tool-registry.d.ts +10 -115
- package/dist/mcp/tool-registry.d.ts.map +1 -1
- package/dist/mcp/tool-registry.js +39 -363
- package/dist/mcp/tool-registry.js.map +1 -1
- package/dist/mcp/tools/activity.d.ts +3 -0
- package/dist/mcp/tools/activity.d.ts.map +1 -1
- package/dist/mcp/tools/activity.js +8 -1
- package/dist/mcp/tools/activity.js.map +1 -1
- package/dist/mcp/tools/app-core.d.ts +3 -0
- package/dist/mcp/tools/app-core.d.ts.map +1 -1
- package/dist/mcp/tools/app-core.js +9 -2
- package/dist/mcp/tools/app-core.js.map +1 -1
- package/dist/mcp/tools/app-marketplace.d.ts +3 -0
- package/dist/mcp/tools/app-marketplace.d.ts.map +1 -1
- package/dist/mcp/tools/app-marketplace.js +13 -1
- package/dist/mcp/tools/app-marketplace.js.map +1 -1
- package/dist/mcp/tools/app-member.d.ts +3 -0
- package/dist/mcp/tools/app-member.d.ts.map +1 -1
- package/dist/mcp/tools/app-member.js +6 -1
- package/dist/mcp/tools/app-member.js.map +1 -1
- package/dist/mcp/tools/app-scaffold.d.ts +3 -0
- package/dist/mcp/tools/app-scaffold.d.ts.map +1 -1
- package/dist/mcp/tools/app-scaffold.js +15 -11
- package/dist/mcp/tools/app-scaffold.js.map +1 -1
- package/dist/mcp/tools/company.d.ts +3 -0
- package/dist/mcp/tools/company.d.ts.map +1 -1
- package/dist/mcp/tools/company.js +5 -1
- package/dist/mcp/tools/company.js.map +1 -1
- package/dist/mcp/tools/discussion.d.ts +3 -0
- package/dist/mcp/tools/discussion.d.ts.map +1 -1
- package/dist/mcp/tools/discussion.js +13 -2
- package/dist/mcp/tools/discussion.js.map +1 -1
- package/dist/mcp/tools/file.d.ts +3 -0
- package/dist/mcp/tools/file.d.ts.map +1 -1
- package/dist/mcp/tools/file.js +6 -1
- package/dist/mcp/tools/file.js.map +1 -1
- package/dist/mcp/tools/index.d.ts +7 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +34 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/insight.d.ts +3 -0
- package/dist/mcp/tools/insight.d.ts.map +1 -1
- package/dist/mcp/tools/insight.js +18 -8
- package/dist/mcp/tools/insight.js.map +1 -1
- package/dist/mcp/tools/user.d.ts +3 -0
- package/dist/mcp/tools/user.d.ts.map +1 -1
- package/dist/mcp/tools/user.js +6 -1
- package/dist/mcp/tools/user.js.map +1 -1
- package/dist/mcp/tools/workflow-permissions.d.ts +3 -0
- package/dist/mcp/tools/workflow-permissions.d.ts.map +1 -1
- package/dist/mcp/tools/workflow-permissions.js +8 -1
- package/dist/mcp/tools/workflow-permissions.js.map +1 -1
- package/dist/mcp/tools/workflow.d.ts +3 -0
- package/dist/mcp/tools/workflow.d.ts.map +1 -1
- package/dist/mcp/tools/workflow.js +29 -28
- package/dist/mcp/tools/workflow.js.map +1 -1
- package/dist/mcp/utils/index.d.ts +4 -11
- package/dist/mcp/utils/index.d.ts.map +1 -1
- package/dist/mcp/utils/index.js +5 -36
- package/dist/mcp/utils/index.js.map +1 -1
- package/dist/mcp/utils/role-utils.d.ts +0 -32
- package/dist/mcp/utils/role-utils.d.ts.map +1 -1
- package/dist/mcp/utils/role-utils.js +0 -73
- package/dist/mcp/utils/role-utils.js.map +1 -1
- package/dist/mcp/utils/tool-helpers.d.ts +0 -25
- package/dist/mcp/utils/tool-helpers.d.ts.map +1 -1
- package/dist/mcp/utils/tool-helpers.js +0 -34
- package/dist/mcp/utils/tool-helpers.js.map +1 -1
- package/dist/mcp/webhook-handler.d.ts +4 -34
- package/dist/mcp/webhook-handler.d.ts.map +1 -1
- package/dist/mcp/webhook-handler.js +57 -74
- package/dist/mcp/webhook-handler.js.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +3 -78
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -2
- package/.claude/agents/agent-ada-skill-builder.md +0 -94
- package/.claude/agents/agent-alejandro-function-fields.md +0 -342
- package/.claude/agents/agent-bjorn-config-audit.md +0 -103
- package/.claude/agents/agent-builder-agent-creator.md +0 -130
- package/.claude/agents/agent-code-simplifier.md +0 -53
- package/.claude/agents/agent-dmitri-activity-crud.md +0 -159
- package/.claude/agents/agent-giuseppe-app-builder.md +0 -208
- package/.claude/agents/agent-gunther-mcp-tools.md +0 -39
- package/.claude/agents/agent-helga-workflow-config.md +0 -204
- package/.claude/agents/agent-igor-activity-mover-automation.md +0 -125
- package/.claude/agents/agent-ingrid-doc-templates.md +0 -261
- package/.claude/agents/agent-ivan-monolith.md +0 -154
- package/.claude/agents/agent-kenji-data-reader.md +0 -86
- package/.claude/agents/agent-lars-code-inspector.md +0 -102
- package/.claude/agents/agent-marco-mockup-builder.md +0 -110
- package/.claude/agents/agent-marcus-api-documenter.md +0 -323
- package/.claude/agents/agent-marketplace-publisher.md +0 -280
- package/.claude/agents/agent-marketplace-reviewer.md +0 -309
- package/.claude/agents/agent-permissions-handler.md +0 -208
- package/.claude/agents/agent-simple-writer.md +0 -48
- package/.claude/agents/agent-svetlana-code-review.md +0 -171
- package/.claude/agents/agent-tanya-test-runner.md +0 -333
- package/.claude/agents/agent-ui-designer.md +0 -100
- package/.claude/agents/agent-viktor-sql-insights.md +0 -212
- package/.claude/agents/agent-web-search.md +0 -55
- package/.claude/agents/agent-yevgeni-discussions.md +0 -45
- package/.claude/agents/agent-zara-zapier.md +0 -159
- package/.claude/skills/SDK-activity-patterns/SKILL.md +0 -428
- package/.claude/skills/SDK-generate-skill/SKILL.md +0 -92
- package/.claude/skills/SDK-init-skill/SKILL.md +0 -127
- package/.claude/skills/agent-structure/SKILL.md +0 -98
- package/.claude/skills/delegation-routing/SKILL.md +0 -202
- package/.claude/skills/frontend-design/SKILL.md +0 -254
- package/.claude/skills/hailer-activity-mover/SKILL.md +0 -213
- package/.claude/skills/hailer-rest-api/SKILL.md +0 -61
- package/.claude/skills/hailer-rest-api/hailer-activities.md +0 -184
- package/.claude/skills/hailer-rest-api/hailer-admin.md +0 -473
- package/.claude/skills/hailer-rest-api/hailer-calendar.md +0 -256
- package/.claude/skills/hailer-rest-api/hailer-feed.md +0 -249
- package/.claude/skills/hailer-rest-api/hailer-insights.md +0 -195
- package/.claude/skills/hailer-rest-api/hailer-messaging.md +0 -276
- package/.claude/skills/hailer-rest-api/hailer-workflows.md +0 -283
- package/.claude/skills/insight-join-patterns/SKILL.md +0 -174
- package/.claude/skills/json-only-output/SKILL.md +0 -72
- package/.claude/skills/mcp-direct-tools/SKILL.md +0 -153
- package/.claude/skills/optional-parameters/SKILL.md +0 -72
- package/.claude/skills/tool-parameter-usage/SKILL.md +0 -126
- package/.claude/skills/tool-response-verification/SKILL.md +0 -92
- package/.opencode/agent/agent-ada-skill-builder.md +0 -35
- package/.opencode/agent/agent-alejandro-function-fields.md +0 -39
- package/.opencode/agent/agent-bjorn-config-audit.md +0 -36
- package/.opencode/agent/agent-builder-agent-creator.md +0 -39
- package/.opencode/agent/agent-code-simplifier.md +0 -31
- package/.opencode/agent/agent-dmitri-activity-crud.md +0 -40
- package/.opencode/agent/agent-giuseppe-app-builder.md +0 -37
- package/.opencode/agent/agent-gunther-mcp-tools.md +0 -39
- package/.opencode/agent/agent-helga-workflow-config.md +0 -204
- package/.opencode/agent/agent-igor-activity-mover-automation.md +0 -46
- package/.opencode/agent/agent-ingrid-doc-templates.md +0 -39
- package/.opencode/agent/agent-ivan-monolith.md +0 -46
- package/.opencode/agent/agent-kenji-data-reader.md +0 -53
- package/.opencode/agent/agent-lars-code-inspector.md +0 -28
- package/.opencode/agent/agent-marco-mockup-builder.md +0 -42
- package/.opencode/agent/agent-marcus-api-documenter.md +0 -53
- package/.opencode/agent/agent-marketplace-publisher.md +0 -44
- package/.opencode/agent/agent-marketplace-reviewer.md +0 -42
- package/.opencode/agent/agent-permissions-handler.md +0 -50
- package/.opencode/agent/agent-simple-writer.md +0 -45
- package/.opencode/agent/agent-svetlana-code-review.md +0 -39
- package/.opencode/agent/agent-tanya-test-runner.md +0 -57
- package/.opencode/agent/agent-ui-designer.md +0 -56
- package/.opencode/agent/agent-viktor-sql-insights.md +0 -34
- package/.opencode/agent/agent-web-search.md +0 -42
- package/.opencode/agent/agent-yevgeni-discussions.md +0 -37
- package/.opencode/agent/agent-zara-zapier.md +0 -53
- package/.opencode/commands/app-squad.md +0 -135
- package/.opencode/commands/audit-squad.md +0 -158
- package/.opencode/commands/autoplan.md +0 -563
- package/.opencode/commands/cleanup-squad.md +0 -98
- package/.opencode/commands/config-squad.md +0 -106
- package/.opencode/commands/crud-squad.md +0 -87
- package/.opencode/commands/data-squad.md +0 -97
- package/.opencode/commands/debug-squad.md +0 -303
- package/.opencode/commands/doc-squad.md +0 -65
- package/.opencode/commands/handoff.md +0 -137
- package/.opencode/commands/health.md +0 -49
- package/.opencode/commands/help-agents.md +0 -151
- package/.opencode/commands/help-commands.md +0 -32
- package/.opencode/commands/help-faq.md +0 -29
- package/.opencode/commands/help-plugins.md +0 -28
- package/.opencode/commands/help-skills.md +0 -7
- package/.opencode/commands/help-tools.md +0 -40
- package/.opencode/commands/help.md +0 -28
- package/.opencode/commands/hotfix-squad.md +0 -112
- package/.opencode/commands/integration-squad.md +0 -82
- package/.opencode/commands/janitor-squad.md +0 -167
- package/.opencode/commands/learn-auto.md +0 -120
- package/.opencode/commands/learn.md +0 -120
- package/.opencode/commands/mcp-list.md +0 -27
- package/.opencode/commands/onboard-squad.md +0 -140
- package/.opencode/commands/plan-workspace.md +0 -732
- package/.opencode/commands/prd.md +0 -131
- package/.opencode/commands/project-status.md +0 -82
- package/.opencode/commands/publish.md +0 -138
- package/.opencode/commands/recap.md +0 -69
- package/.opencode/commands/restore.md +0 -64
- package/.opencode/commands/review-squad.md +0 -152
- package/.opencode/commands/save.md +0 -24
- package/.opencode/commands/stats.md +0 -19
- package/.opencode/commands/swarm.md +0 -210
- package/.opencode/commands/tool-builder.md +0 -39
- package/.opencode/commands/ws-pull.md +0 -44
|
@@ -2,132 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Bot Configuration Persistence
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Workspace management and config reload from Hailer API.
|
|
6
6
|
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.cleanupBotConfig = void 0;
|
|
42
|
-
exports.initBotConfigPersistence = initBotConfigPersistence;
|
|
43
|
-
exports.initWorkspaceSchema = initWorkspaceSchema;
|
|
44
|
-
exports.isPersistenceInitialized = isPersistenceInitialized;
|
|
45
8
|
exports.setActiveWorkspace = setActiveWorkspace;
|
|
46
|
-
exports.getActiveWorkspace = getActiveWorkspace;
|
|
47
9
|
exports.reloadConfigFromHailer = reloadConfigFromHailer;
|
|
48
|
-
exports.getLocalBotCredentials = getLocalBotCredentials;
|
|
49
|
-
exports.getAllLocalBotCredentials = getAllLocalBotCredentials;
|
|
50
|
-
exports.getPersistenceStatus = getPersistenceStatus;
|
|
51
|
-
const fs = __importStar(require("fs"));
|
|
52
10
|
const logger_1 = require("../lib/logger");
|
|
53
|
-
const signal_handler_1 = require("../mcp/signal-handler");
|
|
54
|
-
const constants_1 = require("./constants");
|
|
55
11
|
const context_1 = require("./context");
|
|
56
|
-
const loader_1 = require("./loader");
|
|
57
12
|
const logger = (0, logger_1.createLogger)({ component: 'BotConfigPersistence' });
|
|
58
13
|
// ============================================================================
|
|
59
|
-
// State
|
|
60
|
-
// ============================================================================
|
|
61
|
-
let persistenceInitialized = false;
|
|
62
|
-
let hailerClient = null;
|
|
63
|
-
// ============================================================================
|
|
64
|
-
// Initialization
|
|
65
|
-
// ============================================================================
|
|
66
|
-
/**
|
|
67
|
-
* Initialize bot config persistence
|
|
68
|
-
*
|
|
69
|
-
* Sets up signal handler and loads bot configuration from files.
|
|
70
|
-
*/
|
|
71
|
-
async function initBotConfigPersistence(client) {
|
|
72
|
-
if (persistenceInitialized) {
|
|
73
|
-
logger.debug('Bot config persistence already initialized');
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
hailerClient = client;
|
|
77
|
-
// Set up signal handler for real-time activity signals
|
|
78
|
-
try {
|
|
79
|
-
signal_handler_1.SignalHandler.getOrCreate(client.getClient());
|
|
80
|
-
logger.debug('Signal handler initialized for bot config monitoring');
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
logger.warn('Failed to initialize signal handler', {
|
|
84
|
-
error: error instanceof Error ? error.message : String(error)
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
// Load bot configs from .bot-config/*.json
|
|
88
|
-
const contexts = (0, loader_1.loadBotConfigs)();
|
|
89
|
-
logger.debug('Loaded bot configs', { count: contexts.length });
|
|
90
|
-
persistenceInitialized = true;
|
|
91
|
-
logger.debug('Bot config persistence initialized');
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Initialize workspace schema for a specific workspace
|
|
95
|
-
*
|
|
96
|
-
* Discovers the Agent Directory in the workspace and caches field IDs.
|
|
97
|
-
*/
|
|
98
|
-
async function initWorkspaceSchema(client, workspaceId) {
|
|
99
|
-
// Check if we already have a context for this workspace
|
|
100
|
-
const existingContexts = (0, context_1.listBotContexts)();
|
|
101
|
-
if (existingContexts.includes(workspaceId)) {
|
|
102
|
-
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
103
|
-
const schema = ctx.getSchema();
|
|
104
|
-
if (schema?.agentDirectoryWorkflowId) {
|
|
105
|
-
logger.debug('Workspace schema already initialized', { workspaceId });
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Try to initialize from API
|
|
110
|
-
try {
|
|
111
|
-
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
112
|
-
await ctx.initializeFromApi(client);
|
|
113
|
-
logger.debug('Workspace schema initialized from API', { workspaceId });
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
logger.warn('Failed to initialize workspace schema', {
|
|
118
|
-
workspaceId,
|
|
119
|
-
error: error instanceof Error ? error.message : String(error)
|
|
120
|
-
});
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Check if persistence is initialized
|
|
126
|
-
*/
|
|
127
|
-
function isPersistenceInitialized() {
|
|
128
|
-
return persistenceInitialized;
|
|
129
|
-
}
|
|
130
|
-
// ============================================================================
|
|
131
14
|
// Workspace Management
|
|
132
15
|
// ============================================================================
|
|
133
16
|
let activeWorkspaceId = null;
|
|
@@ -138,21 +21,13 @@ function setActiveWorkspace(workspaceId) {
|
|
|
138
21
|
activeWorkspaceId = workspaceId;
|
|
139
22
|
logger.debug('Active workspace set', { workspaceId });
|
|
140
23
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Get the active workspace ID
|
|
143
|
-
*/
|
|
144
|
-
function getActiveWorkspace() {
|
|
145
|
-
return activeWorkspaceId;
|
|
146
|
-
}
|
|
147
24
|
/**
|
|
148
25
|
* Reload bot configuration from Hailer
|
|
149
26
|
*
|
|
150
27
|
* Re-discovers the Agent Directory and reloads credentials.
|
|
151
|
-
* If no client is provided, uses the stored hailerClient.
|
|
152
28
|
*/
|
|
153
29
|
async function reloadConfigFromHailer(client) {
|
|
154
|
-
|
|
155
|
-
if (!clientToUse) {
|
|
30
|
+
if (!client) {
|
|
156
31
|
logger.warn('No Hailer client available for config reload');
|
|
157
32
|
return;
|
|
158
33
|
}
|
|
@@ -163,7 +38,7 @@ async function reloadConfigFromHailer(client) {
|
|
|
163
38
|
}
|
|
164
39
|
try {
|
|
165
40
|
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
166
|
-
await ctx.initializeFromApi(
|
|
41
|
+
await ctx.initializeFromApi(client);
|
|
167
42
|
logger.debug('Bot config reloaded from Hailer', { workspaceId });
|
|
168
43
|
}
|
|
169
44
|
catch (error) {
|
|
@@ -173,89 +48,4 @@ async function reloadConfigFromHailer(client) {
|
|
|
173
48
|
});
|
|
174
49
|
}
|
|
175
50
|
}
|
|
176
|
-
// ============================================================================
|
|
177
|
-
// Credentials
|
|
178
|
-
// ============================================================================
|
|
179
|
-
/**
|
|
180
|
-
* Load local credentials from .bot-credentials.json
|
|
181
|
-
*/
|
|
182
|
-
function loadLocalCredentials() {
|
|
183
|
-
try {
|
|
184
|
-
if (fs.existsSync(constants_1.LOCAL_CREDENTIALS_FILE)) {
|
|
185
|
-
const content = fs.readFileSync(constants_1.LOCAL_CREDENTIALS_FILE, 'utf-8');
|
|
186
|
-
return JSON.parse(content);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
logger.warn('Failed to load local credentials', {
|
|
191
|
-
error: error instanceof Error ? error.message : String(error)
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
return {};
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get local bot credentials for daemon creation
|
|
198
|
-
*
|
|
199
|
-
* Looks up credentials by user ID or bot ID.
|
|
200
|
-
*/
|
|
201
|
-
function getLocalBotCredentials(userIdOrBotId) {
|
|
202
|
-
// First try local credentials file
|
|
203
|
-
const localCreds = loadLocalCredentials();
|
|
204
|
-
if (localCreds[userIdOrBotId]) {
|
|
205
|
-
return localCreds[userIdOrBotId];
|
|
206
|
-
}
|
|
207
|
-
// Then try bot contexts
|
|
208
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
209
|
-
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
210
|
-
const creds = ctx.getCredentials(userIdOrBotId);
|
|
211
|
-
if (creds) {
|
|
212
|
-
return {
|
|
213
|
-
email: creds.email,
|
|
214
|
-
password: creds.password,
|
|
215
|
-
displayName: creds.displayName
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Get all local bot credentials
|
|
223
|
-
*/
|
|
224
|
-
function getAllLocalBotCredentials() {
|
|
225
|
-
const result = {};
|
|
226
|
-
// Load from file
|
|
227
|
-
const localCreds = loadLocalCredentials();
|
|
228
|
-
Object.assign(result, localCreds);
|
|
229
|
-
// Add from bot contexts
|
|
230
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
231
|
-
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
232
|
-
const allCreds = ctx.getAllCredentials();
|
|
233
|
-
for (const creds of allCreds) {
|
|
234
|
-
result[creds.userId] = {
|
|
235
|
-
email: creds.email,
|
|
236
|
-
password: creds.password,
|
|
237
|
-
displayName: creds.displayName
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Get persistence status (for debugging)
|
|
245
|
-
*/
|
|
246
|
-
function getPersistenceStatus() {
|
|
247
|
-
return {
|
|
248
|
-
initialized: persistenceInitialized,
|
|
249
|
-
workspaceCount: (0, context_1.listBotContexts)().length,
|
|
250
|
-
hasClient: hailerClient !== null
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
// ============================================================================
|
|
254
|
-
// Cleanup
|
|
255
|
-
// ============================================================================
|
|
256
|
-
/**
|
|
257
|
-
* Cleanup bot config (alias for cleanupBotState)
|
|
258
|
-
*/
|
|
259
|
-
var state_1 = require("./state");
|
|
260
|
-
Object.defineProperty(exports, "cleanupBotConfig", { enumerable: true, get: function () { return state_1.cleanupBotState; } });
|
|
261
51
|
//# sourceMappingURL=persistence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../src/bot-config/persistence.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../src/bot-config/persistence.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAiBH,gDAGC;AAOD,wDAsBC;AA/CD,0CAA6C;AAE7C,uCAA2D;AAE3D,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC,CAAC;AAEnE,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAE5C;;GAEG;AACH,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,iBAAiB,GAAG,WAAW,CAAC;IAChC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAAC,MAAwB;IACnE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAC5D,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAG,iBAAiB,IAAI,IAAA,yBAAe,GAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,WAAW,CAAC,CAAC;QACvC,MAAM,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE;YAClD,WAAW;YACX,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -4,43 +4,6 @@
|
|
|
4
4
|
* Manages which bots are enabled/disabled.
|
|
5
5
|
* Delegates to BotContext for storage.
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
* Register callback for bot state changes
|
|
9
|
-
*/
|
|
10
|
-
export declare function onBotStateChange(callback: (userId: string, enabled: boolean) => void): void;
|
|
11
|
-
/**
|
|
12
|
-
* Register callback for daemon restart needs
|
|
13
|
-
*/
|
|
14
|
-
export declare function onDaemonRestartNeeded(callback: () => void): void;
|
|
15
|
-
/**
|
|
16
|
-
* Notify that daemon restart is needed (debounced)
|
|
17
|
-
*/
|
|
18
|
-
export declare function notifyDaemonRestartNeeded(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Cleanup function - clear pending timers and callbacks
|
|
21
|
-
*/
|
|
22
|
-
export declare function cleanupBotState(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get bot state for all workspaces (merged)
|
|
25
|
-
* Returns userId -> enabled map
|
|
26
|
-
*/
|
|
27
|
-
export declare function getBotState(): Record<string, boolean>;
|
|
28
|
-
/**
|
|
29
|
-
* Get bot state for a specific workspace
|
|
30
|
-
*/
|
|
31
|
-
export declare function getBotContextBotState(workspaceId: string): Record<string, boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Get bot user ID (returns the userId itself for compatibility)
|
|
34
|
-
*/
|
|
35
|
-
export declare function getBotUserId(userId: string): string | null;
|
|
36
|
-
/**
|
|
37
|
-
* Get bot type for a user ID
|
|
38
|
-
*/
|
|
39
|
-
export declare function getBotType(userId: string): string | null;
|
|
40
|
-
/**
|
|
41
|
-
* Get all enabled bots with their types (all workspaces)
|
|
42
|
-
*/
|
|
43
|
-
export declare function getEnabledBotsWithTypes(): Map<string, string | null>;
|
|
44
7
|
/**
|
|
45
8
|
* Set bot enabled state
|
|
46
9
|
*
|
|
@@ -49,8 +12,4 @@ export declare function getEnabledBotsWithTypes(): Map<string, string | null>;
|
|
|
49
12
|
* - setBotEnabled(userId, enabled) - auto-find workspace (backward compat)
|
|
50
13
|
*/
|
|
51
14
|
export declare function setBotEnabled(workspaceIdOrUserId: string, userIdOrEnabled: string | boolean, enabledOptional?: boolean): void;
|
|
52
|
-
/**
|
|
53
|
-
* Set bot user ID (for compatibility - updates state map)
|
|
54
|
-
*/
|
|
55
|
-
export declare function setBotUserId(workspaceId: string, userId: string, botType?: string | null): void;
|
|
56
15
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/bot-config/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/bot-config/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,mBAAmB,EAAE,MAAM,EAC3B,eAAe,EAAE,MAAM,GAAG,OAAO,EACjC,eAAe,CAAC,EAAE,OAAO,GACxB,IAAI,CA2BN"}
|
package/dist/bot-config/state.js
CHANGED
|
@@ -6,141 +6,10 @@
|
|
|
6
6
|
* Delegates to BotContext for storage.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.onBotStateChange = onBotStateChange;
|
|
10
|
-
exports.onDaemonRestartNeeded = onDaemonRestartNeeded;
|
|
11
|
-
exports.notifyDaemonRestartNeeded = notifyDaemonRestartNeeded;
|
|
12
|
-
exports.cleanupBotState = cleanupBotState;
|
|
13
|
-
exports.getBotState = getBotState;
|
|
14
|
-
exports.getBotContextBotState = getBotContextBotState;
|
|
15
|
-
exports.getBotUserId = getBotUserId;
|
|
16
|
-
exports.getBotType = getBotType;
|
|
17
|
-
exports.getEnabledBotsWithTypes = getEnabledBotsWithTypes;
|
|
18
9
|
exports.setBotEnabled = setBotEnabled;
|
|
19
|
-
exports.setBotUserId = setBotUserId;
|
|
20
10
|
const logger_1 = require("../lib/logger");
|
|
21
11
|
const context_1 = require("./context");
|
|
22
12
|
const logger = (0, logger_1.createLogger)({ component: 'BotState' });
|
|
23
|
-
// ============================================================================
|
|
24
|
-
// Callbacks
|
|
25
|
-
// ============================================================================
|
|
26
|
-
// Global callbacks for bot state changes (cross-workspace)
|
|
27
|
-
const stateChangeCallbacks = [];
|
|
28
|
-
const daemonRestartCallbacks = [];
|
|
29
|
-
// Debounce mechanism for restart triggers
|
|
30
|
-
let restartDebounceTimer = null;
|
|
31
|
-
const RESTART_DEBOUNCE_MS = 500;
|
|
32
|
-
/**
|
|
33
|
-
* Register callback for bot state changes
|
|
34
|
-
*/
|
|
35
|
-
function onBotStateChange(callback) {
|
|
36
|
-
stateChangeCallbacks.push(callback);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Register callback for daemon restart needs
|
|
40
|
-
*/
|
|
41
|
-
function onDaemonRestartNeeded(callback) {
|
|
42
|
-
daemonRestartCallbacks.push(callback);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Notify that daemon restart is needed (debounced)
|
|
46
|
-
*/
|
|
47
|
-
function notifyDaemonRestartNeeded() {
|
|
48
|
-
if (restartDebounceTimer) {
|
|
49
|
-
logger.debug('Daemon restart already pending, resetting debounce timer');
|
|
50
|
-
clearTimeout(restartDebounceTimer);
|
|
51
|
-
}
|
|
52
|
-
restartDebounceTimer = setTimeout(() => {
|
|
53
|
-
restartDebounceTimer = null;
|
|
54
|
-
logger.debug('Notifying daemon restart needed');
|
|
55
|
-
daemonRestartCallbacks.forEach(cb => {
|
|
56
|
-
try {
|
|
57
|
-
cb();
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
logger.error('Daemon restart callback failed', { error });
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}, RESTART_DEBOUNCE_MS);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Cleanup function - clear pending timers and callbacks
|
|
67
|
-
*/
|
|
68
|
-
function cleanupBotState() {
|
|
69
|
-
if (restartDebounceTimer) {
|
|
70
|
-
clearTimeout(restartDebounceTimer);
|
|
71
|
-
restartDebounceTimer = null;
|
|
72
|
-
}
|
|
73
|
-
stateChangeCallbacks.length = 0;
|
|
74
|
-
daemonRestartCallbacks.length = 0;
|
|
75
|
-
logger.debug('Bot state cleanup completed');
|
|
76
|
-
}
|
|
77
|
-
// ============================================================================
|
|
78
|
-
// State Access
|
|
79
|
-
// ============================================================================
|
|
80
|
-
/**
|
|
81
|
-
* Get bot state for all workspaces (merged)
|
|
82
|
-
* Returns userId -> enabled map
|
|
83
|
-
*/
|
|
84
|
-
function getBotState() {
|
|
85
|
-
const result = {};
|
|
86
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
87
|
-
const ctx = (0, context_1.getExistingBotContext)(workspaceId);
|
|
88
|
-
if (ctx) {
|
|
89
|
-
const states = ctx.getAllBotStates();
|
|
90
|
-
Object.assign(result, states);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get bot state for a specific workspace
|
|
97
|
-
*/
|
|
98
|
-
function getBotContextBotState(workspaceId) {
|
|
99
|
-
const ctx = (0, context_1.getExistingBotContext)(workspaceId);
|
|
100
|
-
if (!ctx)
|
|
101
|
-
return {};
|
|
102
|
-
return ctx.getAllBotStates();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get bot user ID (returns the userId itself for compatibility)
|
|
106
|
-
*/
|
|
107
|
-
function getBotUserId(userId) {
|
|
108
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
109
|
-
const ctx = (0, context_1.getExistingBotContext)(workspaceId);
|
|
110
|
-
if (ctx?.getBotState(userId)) {
|
|
111
|
-
return userId;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get bot type for a user ID
|
|
118
|
-
*/
|
|
119
|
-
function getBotType(userId) {
|
|
120
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
121
|
-
const ctx = (0, context_1.getExistingBotContext)(workspaceId);
|
|
122
|
-
const state = ctx?.getBotState(userId);
|
|
123
|
-
if (state)
|
|
124
|
-
return state.botType;
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get all enabled bots with their types (all workspaces)
|
|
130
|
-
*/
|
|
131
|
-
function getEnabledBotsWithTypes() {
|
|
132
|
-
const result = new Map();
|
|
133
|
-
for (const workspaceId of (0, context_1.listBotContexts)()) {
|
|
134
|
-
const ctx = (0, context_1.getExistingBotContext)(workspaceId);
|
|
135
|
-
if (ctx) {
|
|
136
|
-
const enabled = ctx.getEnabledBotsWithTypes();
|
|
137
|
-
for (const [userId, botType] of enabled) {
|
|
138
|
-
result.set(userId, botType);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
13
|
/**
|
|
145
14
|
* Set bot enabled state
|
|
146
15
|
*
|
|
@@ -152,12 +21,9 @@ function setBotEnabled(workspaceIdOrUserId, userIdOrEnabled, enabledOptional) {
|
|
|
152
21
|
let workspaceId;
|
|
153
22
|
let userId;
|
|
154
23
|
let enabled;
|
|
155
|
-
// Detect which signature was used
|
|
156
24
|
if (typeof userIdOrEnabled === 'boolean') {
|
|
157
|
-
// 2-argument form: setBotEnabled(userId, enabled)
|
|
158
25
|
userId = workspaceIdOrUserId;
|
|
159
26
|
enabled = userIdOrEnabled;
|
|
160
|
-
// Find workspace that has this bot
|
|
161
27
|
const workspaces = (0, context_1.listBotContexts)();
|
|
162
28
|
workspaceId = workspaces[0] || 'default';
|
|
163
29
|
for (const wsId of workspaces) {
|
|
@@ -169,29 +35,12 @@ function setBotEnabled(workspaceIdOrUserId, userIdOrEnabled, enabledOptional) {
|
|
|
169
35
|
}
|
|
170
36
|
}
|
|
171
37
|
else {
|
|
172
|
-
// 3-argument form: setBotEnabled(workspaceId, userId, enabled)
|
|
173
38
|
workspaceId = workspaceIdOrUserId;
|
|
174
39
|
userId = userIdOrEnabled;
|
|
175
40
|
enabled = enabledOptional;
|
|
176
41
|
}
|
|
177
42
|
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
178
43
|
ctx.setBotEnabled(userId, enabled);
|
|
179
|
-
// Notify global listeners
|
|
180
|
-
stateChangeCallbacks.forEach(cb => cb(userId, enabled));
|
|
181
44
|
logger.info('Bot state changed', { workspaceId, userId, enabled });
|
|
182
|
-
// If orchestrator state changes, trigger daemon restart
|
|
183
|
-
const state = ctx.getBotState(userId);
|
|
184
|
-
if (state?.botType === 'orchestrator') {
|
|
185
|
-
logger.info('Orchestrator state changed, triggering daemon restart');
|
|
186
|
-
notifyDaemonRestartNeeded();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Set bot user ID (for compatibility - updates state map)
|
|
191
|
-
*/
|
|
192
|
-
function setBotUserId(workspaceId, userId, botType = null) {
|
|
193
|
-
const ctx = (0, context_1.getBotContext)(workspaceId);
|
|
194
|
-
ctx.setBotType(userId, botType);
|
|
195
|
-
logger.debug('Bot user ID set', { workspaceId, userId, botType });
|
|
196
45
|
}
|
|
197
46
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/bot-config/state.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/bot-config/state.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAcH,sCA+BC;AA3CD,0CAA6C;AAC7C,uCAAkF;AAElF,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,mBAA2B,EAC3B,eAAiC,EACjC,eAAyB;IAEzB,IAAI,WAAmB,CAAC;IACxB,IAAI,MAAc,CAAC;IACnB,IAAI,OAAgB,CAAC;IAErB,IAAI,OAAO,eAAe,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,GAAG,mBAAmB,CAAC;QAC7B,OAAO,GAAG,eAAe,CAAC;QAC1B,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;QACrC,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;QACzC,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;YAC9B,MAAM,GAAG,GAAG,IAAA,+BAAqB,EAAC,IAAI,CAAC,CAAC;YACxC,IAAI,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC7B,WAAW,GAAG,IAAI,CAAC;gBACnB,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,mBAAmB,CAAC;QAClC,MAAM,GAAG,eAAyB,CAAC;QACnC,OAAO,GAAG,eAAgB,CAAC;IAC7B,CAAC;IAED,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,WAAW,CAAC,CAAC;IACvC,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const enableBotTool: Tool;
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const disableBotTool: Tool;
|
|
20
20
|
/**
|
|
21
|
-
* Check
|
|
21
|
+
* Check bot status from Agent Directory
|
|
22
22
|
*/
|
|
23
23
|
export declare const checkSpecialistStatusTool: Tool;
|
|
24
24
|
/**
|
package/dist/bot-config/tools.js
CHANGED
|
@@ -129,17 +129,17 @@ exports.disableBotTool = {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
/**
|
|
132
|
-
* Check
|
|
132
|
+
* Check bot status from Agent Directory
|
|
133
133
|
*/
|
|
134
134
|
exports.checkSpecialistStatusTool = {
|
|
135
|
-
name: '
|
|
135
|
+
name: 'check_bot_status',
|
|
136
136
|
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
137
|
-
description: 'Check real-time status of AI
|
|
137
|
+
description: 'Check real-time status of AI bots from Agent Directory. Returns which bots are deployed (active) vs retired (disabled).',
|
|
138
138
|
schema: zod_1.z.object({
|
|
139
|
-
|
|
139
|
+
botName: zod_1.z.string().optional().describe("Optional: specific bot name to check (e.g., 'Hailer Expert', 'Bug Fixer'). If not provided, returns all bots.")
|
|
140
140
|
}),
|
|
141
141
|
execute: async (params, context) => {
|
|
142
|
-
const {
|
|
142
|
+
const { botName } = params;
|
|
143
143
|
// Get the first available bot context
|
|
144
144
|
const workspaceId = getPrimaryWorkspaceId();
|
|
145
145
|
if (!workspaceId) {
|
|
@@ -174,9 +174,9 @@ exports.checkSpecialistStatusTool = {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
try {
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
// Fetch deployed (active)
|
|
177
|
+
const deployedBots = [];
|
|
178
|
+
const retiredBots = [];
|
|
179
|
+
// Fetch deployed (active) bots
|
|
180
180
|
const deployedActivities = await client.fetchActivityList(schema.agentDirectoryWorkflowId, schema.deployedPhaseId, 100, { returnFlat: true });
|
|
181
181
|
const deployedList = Array.isArray(deployedActivities)
|
|
182
182
|
? deployedActivities
|
|
@@ -184,21 +184,21 @@ exports.checkSpecialistStatusTool = {
|
|
|
184
184
|
for (const activity of deployedList) {
|
|
185
185
|
const botType = activity.fields?.botType || null;
|
|
186
186
|
const name = activity.name || 'Unknown';
|
|
187
|
-
if (
|
|
188
|
-
const normalizedSearch =
|
|
187
|
+
if (botName) {
|
|
188
|
+
const normalizedSearch = botName.toLowerCase();
|
|
189
189
|
const normalizedName = name.toLowerCase();
|
|
190
190
|
const normalizedBotType = (botType || '').toLowerCase();
|
|
191
191
|
if (!normalizedName.includes(normalizedSearch) && !normalizedBotType.includes(normalizedSearch)) {
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
deployedBots.push({
|
|
196
196
|
name,
|
|
197
197
|
botType,
|
|
198
198
|
activityId: activity._id
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
// Fetch retired (disabled)
|
|
201
|
+
// Fetch retired (disabled) bots
|
|
202
202
|
const retiredActivities = await client.fetchActivityList(schema.agentDirectoryWorkflowId, schema.retiredPhaseId, 100, { returnFlat: true });
|
|
203
203
|
const retiredList = Array.isArray(retiredActivities)
|
|
204
204
|
? retiredActivities
|
|
@@ -206,15 +206,15 @@ exports.checkSpecialistStatusTool = {
|
|
|
206
206
|
for (const activity of retiredList) {
|
|
207
207
|
const botType = activity.fields?.botType || null;
|
|
208
208
|
const name = activity.name || 'Unknown';
|
|
209
|
-
if (
|
|
210
|
-
const normalizedSearch =
|
|
209
|
+
if (botName) {
|
|
210
|
+
const normalizedSearch = botName.toLowerCase();
|
|
211
211
|
const normalizedName = name.toLowerCase();
|
|
212
212
|
const normalizedBotType = (botType || '').toLowerCase();
|
|
213
213
|
if (!normalizedName.includes(normalizedSearch) && !normalizedBotType.includes(normalizedSearch)) {
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
retiredBots.push({
|
|
218
218
|
name,
|
|
219
219
|
botType,
|
|
220
220
|
activityId: activity._id
|
|
@@ -222,29 +222,29 @@ exports.checkSpecialistStatusTool = {
|
|
|
222
222
|
}
|
|
223
223
|
// Format output
|
|
224
224
|
let output = '**Specialist Status** (live from Agent Directory)\n\n';
|
|
225
|
-
if (
|
|
225
|
+
if (deployedBots.length > 0) {
|
|
226
226
|
output += '✅ **Deployed (Active):**\n';
|
|
227
|
-
for (const
|
|
228
|
-
const typeDisplay =
|
|
229
|
-
output += `- ${
|
|
227
|
+
for (const bot of deployedBots) {
|
|
228
|
+
const typeDisplay = bot.botType ? ` (${bot.botType})` : '';
|
|
229
|
+
output += `- ${bot.name}${typeDisplay}\n`;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
233
|
output += '✅ **Deployed (Active):** None\n';
|
|
234
234
|
}
|
|
235
235
|
output += '\n';
|
|
236
|
-
if (
|
|
236
|
+
if (retiredBots.length > 0) {
|
|
237
237
|
output += '❌ **Retired (Disabled):**\n';
|
|
238
|
-
for (const
|
|
239
|
-
const typeDisplay =
|
|
240
|
-
output += `- ${
|
|
238
|
+
for (const bot of retiredBots) {
|
|
239
|
+
const typeDisplay = bot.botType ? ` (${bot.botType})` : '';
|
|
240
|
+
output += `- ${bot.name}${typeDisplay}\n`;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
else {
|
|
244
244
|
output += '❌ **Retired (Disabled):** None\n';
|
|
245
245
|
}
|
|
246
|
-
if (
|
|
247
|
-
output = `**No
|
|
246
|
+
if (botName && deployedBots.length === 0 && retiredBots.length === 0) {
|
|
247
|
+
output = `**No bots found matching "${botName}"**\n\nTry searching without a filter to see all bots.`;
|
|
248
248
|
}
|
|
249
249
|
return {
|
|
250
250
|
content: [{
|
|
@@ -254,13 +254,13 @@ exports.checkSpecialistStatusTool = {
|
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
catch (error) {
|
|
257
|
-
logger.error('Failed to check
|
|
257
|
+
logger.error('Failed to check bot status', {
|
|
258
258
|
error: error instanceof Error ? error.message : String(error)
|
|
259
259
|
});
|
|
260
260
|
return {
|
|
261
261
|
content: [{
|
|
262
262
|
type: 'text',
|
|
263
|
-
text: `**Error checking
|
|
263
|
+
text: `**Error checking bot status**\n\n${error instanceof Error ? error.message : String(error)}`
|
|
264
264
|
}],
|
|
265
265
|
isError: true
|
|
266
266
|
};
|