@wabot-dev/framework 0.9.27 → 2.0.0-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/README.md +27 -0
- package/bin/skills.mjs +151 -0
- package/bin/wabot-skills.mjs +120 -0
- package/dist/build/build.js +1031 -8
- package/dist/src/addon/chat-bot/in-memory/InMemoryChatMemory.js +1 -3
- package/dist/src/addon/chat-bot/xai/XAIChatAdapter.js +180 -0
- package/dist/src/addon/chat-controller/cmd/cmdChannelSocketPath.js +1 -5
- package/dist/src/addon/chat-controller/hubspot/@hubspot.js +28 -0
- package/dist/src/addon/chat-controller/hubspot/HubSpotChannel.js +81 -0
- package/dist/src/addon/chat-controller/hubspot/HubSpotChannelConfig.js +20 -0
- package/dist/src/addon/chat-controller/hubspot/HubSpotReceiver.js +42 -0
- package/dist/src/addon/chat-controller/hubspot/HubSpotSender.js +118 -0
- package/dist/src/addon/chat-controller/hubspot/HubSpotWebhookController.js +122 -0
- package/dist/src/addon/chat-controller/hubspot/downloadHubSpotAttachments.js +45 -0
- package/dist/src/addon/chat-controller/hubspot/hubspotChannelName.js +3 -0
- package/dist/src/addon/chat-controller/hubspot/verifyHubSpotSignatureV3.js +28 -0
- package/dist/src/addon/chat-controller/{telegram/markdownToTelegramHtml.js → markdown/markdownToChatHtml.js} +5 -8
- package/dist/src/addon/chat-controller/slack/@slack.js +22 -0
- package/dist/src/addon/chat-controller/slack/SlackChannel.js +187 -0
- package/dist/src/addon/chat-controller/slack/SlackChannelConfig.js +12 -0
- package/dist/src/addon/chat-controller/slack/markdownToSlackMrkdwn.js +38 -0
- package/dist/src/addon/chat-controller/slack/slackChannelName.js +3 -0
- package/dist/src/addon/chat-controller/telegram/TelegramChannel.js +2 -2
- package/dist/src/addon/ui/preact/PreactRenderer.js +86 -0
- package/dist/src/addon/ui/preact/outlet.js +22 -0
- package/dist/src/addon/ui/preact/preactClientRuntime.js +67 -0
- package/dist/src/core/repository/CrudRepository.js +7 -7
- package/dist/src/feature/async/computeDedupKey.js +1 -1
- package/dist/src/feature/chat-controller/runChatControllers.js +4 -1
- package/dist/src/feature/pg/@pgExtension.js +2 -4
- package/dist/src/feature/project-runner/ProjectRunner.js +62 -10
- package/dist/src/feature/project-runner/scanner.js +1 -1
- package/dist/src/feature/repository/@memExtension.js +1 -2
- package/dist/src/feature/rest-controller/runRestControllers.js +11 -6
- package/dist/src/feature/ui-controller/actions.js +35 -0
- package/dist/src/feature/ui-controller/bundler/UiBundler.js +191 -0
- package/dist/src/feature/ui-controller/bundler/devMiddleware.js +41 -0
- package/dist/src/feature/ui-controller/bundler/index.js +4 -0
- package/dist/src/feature/ui-controller/bundler/manifest.js +34 -0
- package/dist/src/feature/ui-controller/bundler/navRuntime.js +236 -0
- package/dist/src/feature/ui-controller/bundler/pageAssets.js +30 -0
- package/dist/src/feature/ui-controller/document/escape.js +17 -0
- package/dist/src/feature/ui-controller/document/helpers.js +13 -0
- package/dist/src/feature/ui-controller/document/renderDocument.js +43 -0
- package/dist/src/feature/ui-controller/island/IslandRegistry.js +68 -0
- package/dist/src/feature/ui-controller/island/island.js +40 -0
- package/dist/src/feature/ui-controller/island/serialize.js +35 -0
- package/dist/src/feature/ui-controller/metadata/@action.js +18 -0
- package/dist/src/feature/ui-controller/metadata/@uiController.js +19 -0
- package/dist/src/feature/ui-controller/metadata/@uiMiddleware.js +20 -0
- package/dist/src/feature/ui-controller/metadata/@view.js +18 -0
- package/dist/src/feature/ui-controller/metadata/UiControllerMetadataStore.js +107 -0
- package/dist/src/feature/ui-controller/renderer/UiRendererRegistry.js +42 -0
- package/dist/src/feature/ui-controller/runUiControllers.js +285 -0
- package/dist/src/index.d.ts +640 -3
- package/dist/src/index.js +32 -3
- package/dist/src/testing/LlmJudge.js +93 -0
- package/dist/src/testing/MockChatAdapter.js +68 -0
- package/dist/src/testing/TestChatMemory.js +73 -0
- package/dist/src/testing/asyncHarness.js +66 -0
- package/dist/src/testing/auth.js +114 -0
- package/dist/src/testing/chatBotHarness.js +88 -0
- package/dist/src/testing/chatControllerHarness.js +94 -0
- package/dist/src/testing/conformance/chatAdapterConformanceCases.js +656 -0
- package/dist/src/testing/fixtures.js +53 -0
- package/dist/src/testing/helpers.js +42 -0
- package/dist/src/testing/index.d.ts +818 -0
- package/dist/src/testing/index.js +14 -0
- package/dist/src/testing/repositories.js +34 -0
- package/dist/src/testing/restHarness.js +127 -0
- package/dist/src/testing/testImageBase64.js +5 -0
- package/dist/src/testing/uiHarness.js +102 -0
- package/dist/src/testing/validation.js +66 -0
- package/dist/src/ui/client.js +6 -0
- package/dist/src/ui/index.d.ts +427 -0
- package/dist/src/ui/index.js +29 -0
- package/dist/src/ui/jsx-dev-runtime.d.ts +1 -0
- package/dist/src/ui/jsx-dev-runtime.js +1 -0
- package/dist/src/ui/jsx-runtime.d.ts +1 -0
- package/dist/src/ui/jsx-runtime.js +1 -0
- package/package.json +48 -11
- package/skills/wabot-async/SKILL.md +143 -0
- package/skills/wabot-auth/SKILL.md +153 -0
- package/skills/wabot-chat/SKILL.md +140 -0
- package/skills/wabot-di-config/SKILL.md +117 -0
- package/skills/wabot-framework/SKILL.md +81 -0
- package/skills/wabot-framework/references/quickstart.md +85 -0
- package/skills/wabot-mindset/SKILL.md +159 -0
- package/skills/wabot-ops/SKILL.md +151 -0
- package/skills/wabot-persistence/SKILL.md +159 -0
- package/skills/wabot-rest-socket/SKILL.md +167 -0
- package/skills/wabot-testing/SKILL.md +214 -0
- package/skills/wabot-ui/SKILL.md +201 -0
- package/skills/wabot-validation/SKILL.md +108 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { InMemoryLocker } from '../addon/lock/InMemoryLocker.js';
|
|
2
|
+
import { container } from '../core/injection/index.js';
|
|
3
|
+
import { Locker } from '../core/lock/Locker.js';
|
|
4
|
+
import { ChatAdapter } from '../feature/chat-bot/ChatAdapter.js';
|
|
5
|
+
import '../feature/chat-bot/ChatAdapterRegistry.js';
|
|
6
|
+
import '../feature/chat-bot/ChatBot.js';
|
|
7
|
+
import '../feature/chat-bot/ChatOperator.js';
|
|
8
|
+
import { ChatRepository } from '../feature/chat-bot/ChatRepository.js';
|
|
9
|
+
import '../feature/chat-bot/UnionChatAdapter.js';
|
|
10
|
+
import '../feature/chat-bot/metadata/ChatAdapterMetadataStore.js';
|
|
11
|
+
import 'uuid';
|
|
12
|
+
import '../feature/chat-bot/metadata/ChatBotMetadataStore.js';
|
|
13
|
+
import '../core/error/setupErrorHandlers.js';
|
|
14
|
+
import '../feature/chat-controller/metadata/ControllerMetadataStore.js';
|
|
15
|
+
import { ChatResolver } from '../feature/chat-controller/ChatResolver.js';
|
|
16
|
+
import { prepareChatContainer } from '../feature/chat-controller/runChatControllers.js';
|
|
17
|
+
import { humanMessage } from './fixtures.js';
|
|
18
|
+
import { MockChatAdapter } from './MockChatAdapter.js';
|
|
19
|
+
import { TestChatRepository } from './TestChatMemory.js';
|
|
20
|
+
import { Container } from '../core/injection/Container.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Drives a @chatController end-to-end without a real channel: resolves the
|
|
24
|
+
* Chat, prepares the per-message container (same code path as production,
|
|
25
|
+
* including @chatBot injection) and invokes the controller method.
|
|
26
|
+
*/
|
|
27
|
+
class ChatControllerHarness {
|
|
28
|
+
adapter;
|
|
29
|
+
chatRepository = new TestChatRepository();
|
|
30
|
+
chatConnection;
|
|
31
|
+
channelContainer;
|
|
32
|
+
options;
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.options = options;
|
|
35
|
+
this.adapter = options.adapter ?? new MockChatAdapter();
|
|
36
|
+
this.chatConnection = options.chatConnection ?? {
|
|
37
|
+
chatType: 'PRIVATE',
|
|
38
|
+
channelName: 'TestChannel',
|
|
39
|
+
id: 'test-chat',
|
|
40
|
+
};
|
|
41
|
+
const child = container.createChildContainer();
|
|
42
|
+
child.register(Container, { useValue: child });
|
|
43
|
+
child.register(Locker, { useToken: InMemoryLocker });
|
|
44
|
+
child.registerInstance(ChatRepository, this.chatRepository);
|
|
45
|
+
child.registerInstance(ChatAdapter, this.adapter);
|
|
46
|
+
for (const [token, instance] of options.register ?? []) {
|
|
47
|
+
child.registerInstance(token, instance);
|
|
48
|
+
}
|
|
49
|
+
this.channelContainer = child;
|
|
50
|
+
}
|
|
51
|
+
/** Deliver a message to a controller method, as if it came from a channel. */
|
|
52
|
+
async invoke(methodName, message) {
|
|
53
|
+
const controllerCtor = this.options.controller;
|
|
54
|
+
if (typeof controllerCtor.prototype[methodName] !== 'function') {
|
|
55
|
+
throw new Error(`ChatControllerHarness: ${controllerCtor.name} has no method '${methodName}'`);
|
|
56
|
+
}
|
|
57
|
+
const chatResolver = this.channelContainer.resolve(ChatResolver);
|
|
58
|
+
const chat = await chatResolver.resolve(this.chatConnection);
|
|
59
|
+
const memory = await this.chatRepository.findMemory(chat.id);
|
|
60
|
+
const itemsBefore = memory ? memory.all().length : 0;
|
|
61
|
+
const replies = [];
|
|
62
|
+
const receivedMessage = {
|
|
63
|
+
message: humanMessage(message),
|
|
64
|
+
reply: async (reply) => {
|
|
65
|
+
replies.push(reply);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const chatContainer = await prepareChatContainer(this.channelContainer, {
|
|
69
|
+
chat,
|
|
70
|
+
authInfo: this.options.authInfo,
|
|
71
|
+
...receivedMessage,
|
|
72
|
+
});
|
|
73
|
+
const controller = chatContainer.resolve(controllerCtor);
|
|
74
|
+
await controller[methodName](receivedMessage);
|
|
75
|
+
const items = (await this.history()).slice(itemsBefore);
|
|
76
|
+
const toolCalls = items
|
|
77
|
+
.filter((item) => item.type === 'functionCall')
|
|
78
|
+
.map((item) => item.functionCall);
|
|
79
|
+
return { replies, toolCalls, items };
|
|
80
|
+
}
|
|
81
|
+
/** Full chat history (data form) of the harness conversation. */
|
|
82
|
+
async history() {
|
|
83
|
+
const chat = await this.chatRepository.findByConnection(this.chatConnection);
|
|
84
|
+
if (!chat)
|
|
85
|
+
return [];
|
|
86
|
+
const memory = await this.chatRepository.findMemory(chat.id);
|
|
87
|
+
return memory ? memory.allData() : [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function createChatControllerHarness(options) {
|
|
91
|
+
return new ChatControllerHarness(options);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { ChatControllerHarness, createChatControllerHarness };
|