@mallocbaal/agent-framework 1.0.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 +137 -0
- package/dist/app/app.d.ts +33 -0
- package/dist/app/app.d.ts.map +1 -0
- package/dist/app/app.js +143 -0
- package/dist/app/app.js.map +1 -0
- package/dist/communicator/client.d.ts +36 -0
- package/dist/communicator/client.d.ts.map +1 -0
- package/dist/communicator/client.js +129 -0
- package/dist/communicator/client.js.map +1 -0
- package/dist/communicator/models.d.ts +323 -0
- package/dist/communicator/models.d.ts.map +1 -0
- package/dist/communicator/models.js +6 -0
- package/dist/communicator/models.js.map +1 -0
- package/dist/config/config.d.ts +37 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +81 -0
- package/dist/config/config.js.map +1 -0
- package/dist/dispatcher/dispatcher.d.ts +14 -0
- package/dist/dispatcher/dispatcher.d.ts.map +1 -0
- package/dist/dispatcher/dispatcher.js +28 -0
- package/dist/dispatcher/dispatcher.js.map +1 -0
- package/dist/events/types.d.ts +25 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +4 -0
- package/dist/events/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/pipeline.d.ts +36 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +74 -0
- package/dist/pipeline/pipeline.js.map +1 -0
- package/dist/rabbitmq/consumer.d.ts +23 -0
- package/dist/rabbitmq/consumer.d.ts.map +1 -0
- package/dist/rabbitmq/consumer.js +184 -0
- package/dist/rabbitmq/consumer.js.map +1 -0
- package/dist/saga/events.d.ts +68 -0
- package/dist/saga/events.d.ts.map +1 -0
- package/dist/saga/events.js +7 -0
- package/dist/saga/events.js.map +1 -0
- package/dist/saga/logger.d.ts +9 -0
- package/dist/saga/logger.d.ts.map +1 -0
- package/dist/saga/logger.js +2 -0
- package/dist/saga/logger.js.map +1 -0
- package/dist/saga/minio.d.ts +19 -0
- package/dist/saga/minio.d.ts.map +1 -0
- package/dist/saga/minio.js +140 -0
- package/dist/saga/minio.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# @mallocbaal/agent-framework (TypeScript)
|
|
2
|
+
|
|
3
|
+
TypeScript-библиотека с функционалом, аналогичным Go [agent-framework](../agent-framework): event-driven агенты с RabbitMQ и saga-логированием.
|
|
4
|
+
|
|
5
|
+
**Требования:** Node.js >= 20
|
|
6
|
+
|
|
7
|
+
## Установка
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mallocbaal/agent-framework
|
|
11
|
+
# или из монорепо
|
|
12
|
+
pnpm add @mallocbaal/agent-framework
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Быстрый старт
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { loadConfig, App, type EventHandler, type Event } from '@mallocbaal/agent-framework';
|
|
19
|
+
|
|
20
|
+
class MyAgent implements EventHandler {
|
|
21
|
+
async handle(_ctx: AbortSignal | undefined, event: Event): Promise<void> {
|
|
22
|
+
switch (event.eventType) {
|
|
23
|
+
case 'CLI_FLOW_INIT':
|
|
24
|
+
return this.handleInit(event);
|
|
25
|
+
case 'CLI_FLOW_CONTINUE':
|
|
26
|
+
return this.handleContinue(event);
|
|
27
|
+
case 'CLI_FLOW_END':
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private async handleInit(_event: Event): Promise<void> {
|
|
33
|
+
// инициализация диалога
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private async handleContinue(_event: Event): Promise<void> {
|
|
37
|
+
// обработка сообщения или action
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function main() {
|
|
42
|
+
const config = loadConfig();
|
|
43
|
+
const handler = new MyAgent();
|
|
44
|
+
const app = await App.create({ config, handler });
|
|
45
|
+
await app.run(); // до Ctrl+C или abort
|
|
46
|
+
}
|
|
47
|
+
main().catch(console.error);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Структура (аналог Go)
|
|
51
|
+
|
|
52
|
+
| Модуль | Назначение |
|
|
53
|
+
|---------------|-------------------------------------|
|
|
54
|
+
| `events` | Типы событий CLI_FLOW_* |
|
|
55
|
+
| `config` | Загрузка конфигурации из env |
|
|
56
|
+
| `dispatcher` | Маршрутизация INIT/CONTINUE/END |
|
|
57
|
+
| `rabbitmq` | Consumer с retry |
|
|
58
|
+
| `saga` | SagaLogger, MinIO, типы событий саги|
|
|
59
|
+
| `communicator`| Клиент Communicator (GraphQL) |
|
|
60
|
+
| `pipeline` | Processing + PostProcessing stages |
|
|
61
|
+
| `app` | Жизненный цикл, health, bot register|
|
|
62
|
+
|
|
63
|
+
## Конфигурация (env)
|
|
64
|
+
|
|
65
|
+
- `PORT` — порт health (по умолчанию 8091)
|
|
66
|
+
- `COMMUNICATOR_URL` — URL сервиса communicator
|
|
67
|
+
- `RABBITMQ_URL`, `RABBITMQ_EXCHANGE`, `RABBITMQ_QUEUE`, `RABBITMQ_BINDINGS`, `RABBITMQ_PREFETCH`, `RABBITMQ_MAX_RETRIES`
|
|
68
|
+
- `MINIO_ENDPOINT`, `MINIO_ACCESS_KEY`, `MINIO_SECRET_KEY`, `MINIO_BUCKET`, `MINIO_USE_SSL`
|
|
69
|
+
- `BOT_KEY`, `BOT_NAME`, `BOT_EVENT_STREAM`, `BOT_STREAMING_ENABLED`
|
|
70
|
+
|
|
71
|
+
## EventProcessor + Dispatcher
|
|
72
|
+
|
|
73
|
+
Вместо одного `EventHandler` можно реализовать `EventProcessor` и обернуть в `Dispatcher`:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { Dispatcher, type EventProcessor, type Event } from '@mallocbaal/agent-framework';
|
|
77
|
+
|
|
78
|
+
class MyProcessor implements EventProcessor {
|
|
79
|
+
async handleInit(_ctx, ev: Event) { /* ... */ }
|
|
80
|
+
async handleContinue(_ctx, ev: Event) { /* ... */ }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const processor = new MyProcessor();
|
|
84
|
+
const dispatcher = new Dispatcher(processor);
|
|
85
|
+
const app = await App.create({ config, handler: dispatcher });
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Pipeline
|
|
89
|
+
|
|
90
|
+
Использование паттерна Processing → Communicator → PostProcessing:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import {
|
|
94
|
+
Pipeline,
|
|
95
|
+
createProcessingFunc,
|
|
96
|
+
createPostProcessingFunc,
|
|
97
|
+
createCommunicatorClient,
|
|
98
|
+
loadConfig,
|
|
99
|
+
App,
|
|
100
|
+
type ProcessingStage,
|
|
101
|
+
type PostProcessingStage,
|
|
102
|
+
type Event,
|
|
103
|
+
} from '@mallocbaal/agent-framework';
|
|
104
|
+
|
|
105
|
+
class MyStage implements ProcessingStage, PostProcessingStage {
|
|
106
|
+
async processInit(_, ev) {
|
|
107
|
+
return { contents: [{ type: 'text', order: 0, data: { text: 'Hello!' } }] };
|
|
108
|
+
}
|
|
109
|
+
async processContinue(_, ev) {
|
|
110
|
+
return { contents: [{ type: 'text', order: 0, data: { text: 'You said: ' + (ev.message ?? '') } }] };
|
|
111
|
+
}
|
|
112
|
+
async postProcessInit() {}
|
|
113
|
+
async postProcessContinue() {}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const config = loadConfig();
|
|
117
|
+
const comm = createCommunicatorClient(config.communicator.baseURL);
|
|
118
|
+
const pipeline = new Pipeline(comm, {
|
|
119
|
+
processing: createProcessingFunc(new MyStage()),
|
|
120
|
+
postProcessing: createPostProcessingFunc(new MyStage()),
|
|
121
|
+
}, 'my-agent');
|
|
122
|
+
const app = await App.create({ config, handler: pipeline });
|
|
123
|
+
await app.run();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Health
|
|
127
|
+
|
|
128
|
+
- `GET /healthz` — 200 OK
|
|
129
|
+
- `GET /readyz` — 200 если RabbitMQ доступен, иначе 503
|
|
130
|
+
|
|
131
|
+
## Сборка
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Генерируется `dist/` с ESM и декларациями.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Config } from '../config/config.js';
|
|
2
|
+
import type { Event } from '../events/types.js';
|
|
3
|
+
import type { SagaLogger } from '../saga/logger.js';
|
|
4
|
+
export interface EventHandler {
|
|
5
|
+
handle(ctx: AbortSignal | undefined, event: Event): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface AppOptions {
|
|
8
|
+
config: Config;
|
|
9
|
+
handler: EventHandler;
|
|
10
|
+
/** If true, MinIO saga logger is created from config; otherwise no-op saga. Default true. */
|
|
11
|
+
sagaEnabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class App {
|
|
14
|
+
private readonly cfg;
|
|
15
|
+
private handler;
|
|
16
|
+
private readonly consumer;
|
|
17
|
+
private readonly sagaLogger;
|
|
18
|
+
private readonly communicator;
|
|
19
|
+
private ready;
|
|
20
|
+
private server;
|
|
21
|
+
constructor(cfg: Config, handler: EventHandler, sagaEnabled?: boolean);
|
|
22
|
+
static create(options: AppOptions): Promise<App>;
|
|
23
|
+
setHandler(handler: EventHandler): void;
|
|
24
|
+
getSagaLogger(): SagaLogger;
|
|
25
|
+
private setAiRespondingStatus;
|
|
26
|
+
/**
|
|
27
|
+
* Run the agent: start health server, then consume RabbitMQ until signal aborted.
|
|
28
|
+
*/
|
|
29
|
+
run(signal?: AbortSignal): Promise<void>;
|
|
30
|
+
private startHealthServer;
|
|
31
|
+
close(): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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node:http';
|
|
2
|
+
import { CliFlowContinue } from '../events/types.js';
|
|
3
|
+
import { createConsumer } from '../rabbitmq/consumer.js';
|
|
4
|
+
import { createMinIOSagaLogger, createNoopSagaLogger } from '../saga/minio.js';
|
|
5
|
+
import { createCommunicatorClient } from '../communicator/client.js';
|
|
6
|
+
async function ensureBotRegistered(communicator, cfg) {
|
|
7
|
+
const check = await communicator.checkBot(cfg.bot.key);
|
|
8
|
+
if (check.exists)
|
|
9
|
+
return;
|
|
10
|
+
await communicator.registerBot({
|
|
11
|
+
key: cfg.bot.key,
|
|
12
|
+
name: cfg.bot.name,
|
|
13
|
+
eventStream: cfg.bot.eventStream,
|
|
14
|
+
streamingEnabled: cfg.bot.streamingEnabled,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export class App {
|
|
18
|
+
cfg;
|
|
19
|
+
handler;
|
|
20
|
+
consumer;
|
|
21
|
+
sagaLogger;
|
|
22
|
+
communicator;
|
|
23
|
+
ready = false;
|
|
24
|
+
server = null;
|
|
25
|
+
constructor(cfg, handler, sagaEnabled = true) {
|
|
26
|
+
this.cfg = cfg;
|
|
27
|
+
this.handler = handler;
|
|
28
|
+
this.sagaLogger =
|
|
29
|
+
sagaEnabled && cfg.minIO.endpoint && cfg.minIO.accessKey && cfg.minIO.secretKey
|
|
30
|
+
? createMinIOSagaLogger(cfg.minIO.endpoint, cfg.minIO.accessKey, cfg.minIO.secretKey, cfg.minIO.bucket, cfg.minIO.useSSL)
|
|
31
|
+
: createNoopSagaLogger();
|
|
32
|
+
this.communicator = cfg.communicator.baseURL
|
|
33
|
+
? createCommunicatorClient(cfg.communicator.baseURL, '')
|
|
34
|
+
: null;
|
|
35
|
+
this.consumer = createConsumer(cfg.rabbitMQ.url, cfg.rabbitMQ.exchange, cfg.rabbitMQ.queue, cfg.rabbitMQ.bindings, cfg.rabbitMQ.prefetch, cfg.rabbitMQ.maxRetries);
|
|
36
|
+
}
|
|
37
|
+
static async create(options) {
|
|
38
|
+
const { config, handler, sagaEnabled = true } = options;
|
|
39
|
+
const app = new App(config, handler, sagaEnabled);
|
|
40
|
+
if (app.communicator)
|
|
41
|
+
await ensureBotRegistered(app.communicator, config);
|
|
42
|
+
return app;
|
|
43
|
+
}
|
|
44
|
+
setHandler(handler) {
|
|
45
|
+
this.handler = handler;
|
|
46
|
+
}
|
|
47
|
+
getSagaLogger() {
|
|
48
|
+
return this.sagaLogger;
|
|
49
|
+
}
|
|
50
|
+
async setAiRespondingStatus(chatId, participantId, status) {
|
|
51
|
+
if (!this.communicator)
|
|
52
|
+
return;
|
|
53
|
+
await this.communicator.setAiRespondingStatus(chatId, participantId, status);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Run the agent: start health server, then consume RabbitMQ until signal aborted.
|
|
57
|
+
*/
|
|
58
|
+
async run(signal) {
|
|
59
|
+
this.startHealthServer();
|
|
60
|
+
this.ready = true;
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const effectiveSignal = signal ?? controller.signal;
|
|
63
|
+
const handlerWrapper = async (ctx, ev) => {
|
|
64
|
+
const timeout = AbortSignal.timeout ? AbortSignal.timeout(30_000) : undefined;
|
|
65
|
+
const c = timeout ? mergeSignals(ctx, timeout) : ctx;
|
|
66
|
+
if (ev.eventType === CliFlowContinue) {
|
|
67
|
+
try {
|
|
68
|
+
await this.setAiRespondingStatus(ev.chatId, ev.participantId, 'PROCESSING');
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.warn('[FRAMEWORK] Failed to set AI responding status to PROCESSING:', e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await this.handler.handle(c, ev);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
if (ev.eventType === CliFlowContinue) {
|
|
79
|
+
try {
|
|
80
|
+
await this.setAiRespondingStatus(ev.chatId, ev.participantId, 'DONE');
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
console.warn('[FRAMEWORK] Failed to set AI responding status to DONE:', e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
await this.consumer.consume(effectiveSignal, handlerWrapper);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.consumer.close();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
startHealthServer() {
|
|
96
|
+
const port = parseInt(this.cfg.port, 10) || 8091;
|
|
97
|
+
this.server = http.createServer((req, res) => {
|
|
98
|
+
if (req.url === '/healthz') {
|
|
99
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
100
|
+
res.end('ok');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (req.url === '/readyz') {
|
|
104
|
+
if (!this.ready) {
|
|
105
|
+
res.writeHead(503, { 'Content-Type': 'text/plain' });
|
|
106
|
+
res.end('not ready');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.consumer
|
|
110
|
+
.ping()
|
|
111
|
+
.then(() => {
|
|
112
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
113
|
+
res.end('ready');
|
|
114
|
+
})
|
|
115
|
+
.catch(() => {
|
|
116
|
+
res.writeHead(503, { 'Content-Type': 'text/plain' });
|
|
117
|
+
res.end('rabbitmq not ready');
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
res.writeHead(404);
|
|
122
|
+
res.end();
|
|
123
|
+
});
|
|
124
|
+
this.server.listen(port, () => {
|
|
125
|
+
console.log(`[FRAMEWORK] Health server listening on port ${port}`);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
close() {
|
|
129
|
+
this.consumer.close();
|
|
130
|
+
if (this.server) {
|
|
131
|
+
this.server.close();
|
|
132
|
+
this.server = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function mergeSignals(a, b) {
|
|
137
|
+
const controller = new AbortController();
|
|
138
|
+
const abort = () => controller.abort();
|
|
139
|
+
a?.addEventListener('abort', abort);
|
|
140
|
+
b?.addEventListener('abort', abort);
|
|
141
|
+
return controller.signal;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app/app.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAMrE,KAAK,UAAU,mBAAmB,CAChC,YAAyD,EACzD,GAAW;IAEX,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO;IACzB,MAAM,YAAY,CAAC,WAAW,CAAC;QAC7B,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG;QAChB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI;QAClB,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW;QAChC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,gBAAgB;KAC3C,CAAC,CAAC;AACL,CAAC;AASD,MAAM,OAAO,GAAG;IAOe;IAAqB;IANjC,QAAQ,CAAoC;IAC5C,UAAU,CAAa;IACvB,YAAY,CAAqD;IAC1E,KAAK,GAAG,KAAK,CAAC;IACd,MAAM,GAAuB,IAAI,CAAC;IAE1C,YAA6B,GAAW,EAAU,OAAqB,EAAE,WAAW,GAAG,IAAI;QAA9D,QAAG,GAAH,GAAG,CAA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C,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,OAAO,UAAU,CAAC,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SendChatActionInput, RegisterBotInput, BotCheckResponse, AiRespondingStatus } from './models.js';
|
|
2
|
+
export type { SendChatActionInput, RegisterBotInput, BotCheckResponse, SetAiRespondingStatusInput, CliFlowActionInput, ContentType, AiRespondingStatus, ChatMessage, MessageResponse, SuccessResponse, Bot, BotResponse, ChatMessagesResponse, Chat, ChatFilters, CreateChatInput, UpdateChatSummaryInput, PatchChatMetadataInput, HealthStatus, } from './models.js';
|
|
3
|
+
export interface AgentMessageInputFramework {
|
|
4
|
+
chatId: string;
|
|
5
|
+
contents: MessageContentItemInputFramework[];
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
source?: string;
|
|
8
|
+
eventType?: string;
|
|
9
|
+
botId?: string | null;
|
|
10
|
+
messageId?: string | null;
|
|
11
|
+
visibleForUser?: string | null;
|
|
12
|
+
broadcastedForAllExcept?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface MessageContentItemInputFramework {
|
|
15
|
+
type: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
order?: number;
|
|
18
|
+
data?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** Convenience type for addAgentMessage and pipeline (flexible content items). */
|
|
21
|
+
export type AgentMessageInput = AgentMessageInputFramework;
|
|
22
|
+
/** Convenience type for pipeline content items (type can be string or ContentType). */
|
|
23
|
+
export type MessageContentItemInput = MessageContentItemInputFramework;
|
|
24
|
+
export declare class CommunicatorClient {
|
|
25
|
+
private readonly baseURL;
|
|
26
|
+
private readonly apiKey;
|
|
27
|
+
constructor(baseURL: string, apiKey?: string);
|
|
28
|
+
private graphql;
|
|
29
|
+
addAgentMessage(input: AgentMessageInputFramework): Promise<void>;
|
|
30
|
+
sendChatAction(input: SendChatActionInput): Promise<void>;
|
|
31
|
+
checkBot(key: string): Promise<BotCheckResponse>;
|
|
32
|
+
registerBot(input: RegisterBotInput): Promise<string>;
|
|
33
|
+
setAiRespondingStatus(chatId: string, participantId: string, status: AiRespondingStatus): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare function createCommunicatorClient(baseURL: string, apiKey?: string): CommunicatorClient;
|
|
36
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/communicator/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,mBAAmB,EAEnB,gBAAgB,EAChB,gBAAgB,EAGhB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,eAAe,EACf,GAAG,EACH,WAAW,EACX,oBAAoB,EACpB,IAAI,EACJ,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gCAAgC,EAAE,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,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');
|
|
7
|
+
}
|
|
8
|
+
function toSchemaContents(items) {
|
|
9
|
+
return items.map((c) => {
|
|
10
|
+
const data = { ...(c.data ?? {}) };
|
|
11
|
+
const text = c.content ?? data['text'] ?? data['content'];
|
|
12
|
+
if (text != null)
|
|
13
|
+
data['content'] = text;
|
|
14
|
+
return {
|
|
15
|
+
type: toSchemaContentType(c.type),
|
|
16
|
+
order: c.order ?? 0,
|
|
17
|
+
data,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function toSchemaAgentInput(input) {
|
|
22
|
+
const metadata = { ...(input.metadata ?? {}) };
|
|
23
|
+
if (input.source != null)
|
|
24
|
+
metadata['source'] = input.source;
|
|
25
|
+
if (input.eventType != null)
|
|
26
|
+
metadata['eventType'] = input.eventType;
|
|
27
|
+
return {
|
|
28
|
+
chatId: input.chatId,
|
|
29
|
+
botId: input.botId ?? undefined,
|
|
30
|
+
metadata: Object.keys(metadata).length ? metadata : undefined,
|
|
31
|
+
contents: toSchemaContents(input.contents),
|
|
32
|
+
messageId: input.messageId ?? undefined,
|
|
33
|
+
visibleForUser: input.visibleForUser ?? undefined,
|
|
34
|
+
broadcastedForAllExcept: input.broadcastedForAllExcept ?? undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export class CommunicatorClient {
|
|
38
|
+
baseURL;
|
|
39
|
+
apiKey;
|
|
40
|
+
constructor(baseURL, apiKey = '') {
|
|
41
|
+
this.baseURL = baseURL;
|
|
42
|
+
this.apiKey = apiKey;
|
|
43
|
+
}
|
|
44
|
+
async graphql(query, variables) {
|
|
45
|
+
const url = this.baseURL.replace(/\/$/, '') + '/graphql';
|
|
46
|
+
const body = JSON.stringify({ query, variables });
|
|
47
|
+
const headers = {
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
};
|
|
50
|
+
if (this.apiKey)
|
|
51
|
+
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
52
|
+
const res = await fetch(url, {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers,
|
|
55
|
+
body,
|
|
56
|
+
signal: AbortSignal.timeout(30_000),
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
60
|
+
const json = (await res.json());
|
|
61
|
+
if (json.errors?.length)
|
|
62
|
+
throw new Error(`GraphQL: ${json.errors.map((e) => e.message).join(', ')}`);
|
|
63
|
+
if (!json.data)
|
|
64
|
+
throw new Error('GraphQL: no data');
|
|
65
|
+
return json.data;
|
|
66
|
+
}
|
|
67
|
+
async addAgentMessage(input) {
|
|
68
|
+
if (!input.chatId)
|
|
69
|
+
throw new Error('chatId is required');
|
|
70
|
+
if (!input.contents?.length)
|
|
71
|
+
throw new Error('at least one content item is required');
|
|
72
|
+
const schemaInput = toSchemaAgentInput(input);
|
|
73
|
+
const result = await this.graphql(`mutation AddAgentMessage($input: AgentMessageInput!) {
|
|
74
|
+
addAgentMessage(input: $input) {
|
|
75
|
+
success
|
|
76
|
+
message { id chatId }
|
|
77
|
+
error
|
|
78
|
+
}
|
|
79
|
+
}`, { input: schemaInput });
|
|
80
|
+
const r = result.addAgentMessage;
|
|
81
|
+
if (!r?.success)
|
|
82
|
+
throw new Error(r?.error ?? 'addAgentMessage failed');
|
|
83
|
+
}
|
|
84
|
+
async sendChatAction(input) {
|
|
85
|
+
if (!input.chatId || !input.participantId || !input.action)
|
|
86
|
+
throw new Error('chatId, participantId, action are required');
|
|
87
|
+
const result = await this.graphql(`mutation SendChatAction($input: SendChatActionInput!) {
|
|
88
|
+
sendChatAction(input: $input) { success error }
|
|
89
|
+
}`, {
|
|
90
|
+
input: {
|
|
91
|
+
chatId: input.chatId,
|
|
92
|
+
participantId: input.participantId,
|
|
93
|
+
action: input.action,
|
|
94
|
+
data: input.data ?? null,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const r = result.sendChatAction;
|
|
98
|
+
if (!r?.success)
|
|
99
|
+
throw new Error(r?.error ?? 'sendChatAction failed');
|
|
100
|
+
}
|
|
101
|
+
async checkBot(key) {
|
|
102
|
+
const result = await this.graphql(`query CheckBot($key: String!) { checkBot(key: $key) { success exists id error } }`, { key });
|
|
103
|
+
return result.checkBot;
|
|
104
|
+
}
|
|
105
|
+
async registerBot(input) {
|
|
106
|
+
const result = await this.graphql(`mutation RegisterBot($input: RegisterBotInput!) {
|
|
107
|
+
registerBot(input: $input) { success error bot { id key name } }
|
|
108
|
+
}`, { input });
|
|
109
|
+
const r = result.registerBot;
|
|
110
|
+
if (!r?.success)
|
|
111
|
+
throw new Error(r?.error ?? 'registerBot failed');
|
|
112
|
+
if (!r.bot?.id)
|
|
113
|
+
throw new Error('registerBot: no bot id');
|
|
114
|
+
return r.bot.id;
|
|
115
|
+
}
|
|
116
|
+
async setAiRespondingStatus(chatId, participantId, status) {
|
|
117
|
+
const input = { chatId, participantId, status };
|
|
118
|
+
const result = await this.graphql(`mutation SetAiRespondingStatus($input: SetAiRespondingStatusInput!) {
|
|
119
|
+
setAiRespondingStatus(input: $input) { success error }
|
|
120
|
+
}`, { input });
|
|
121
|
+
const r = result.setAiRespondingStatus;
|
|
122
|
+
if (!r?.success)
|
|
123
|
+
throw new Error(r?.error ?? 'setAiRespondingStatus failed');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function createCommunicatorClient(baseURL, apiKey) {
|
|
127
|
+
return new CommunicatorClient(baseURL, apiKey ?? '');
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/communicator/client.ts"],"names":[],"mappings":"AA6DA,SAAS,mBAAmB,CAAC,IAAY;IACvC,MAAM,OAAO,GAAkB;QAC7B,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ;KAC5F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