@hardlydifficult/chat 1.1.121 → 1.1.122
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 +24 -22
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -304,7 +304,7 @@ createChatClient({
|
|
|
304
304
|
### Discord
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
|
-
import { DiscordChatClient } from '@hardlydifficult/chat
|
|
307
|
+
import { DiscordChatClient } from '@hardlydifficult/chat';
|
|
308
308
|
|
|
309
309
|
const client = new DiscordChatClient({
|
|
310
310
|
token: 'your-bot-token',
|
|
@@ -317,7 +317,7 @@ await client.start();
|
|
|
317
317
|
### Slack
|
|
318
318
|
|
|
319
319
|
```typescript
|
|
320
|
-
import { SlackChatClient } from '@hardlydifficult/chat
|
|
320
|
+
import { SlackChatClient } from '@hardlydifficult/chat';
|
|
321
321
|
|
|
322
322
|
const client = new SlackChatClient({
|
|
323
323
|
token: process.env.SLACK_BOT_TOKEN!,
|
|
@@ -351,22 +351,22 @@ Platform-specific message formatting utilities transform abstract document block
|
|
|
351
351
|
#### Discord Output
|
|
352
352
|
|
|
353
353
|
```typescript
|
|
354
|
-
import {
|
|
354
|
+
import { toDiscordEmbed } from '@hardlydifficult/chat';
|
|
355
355
|
|
|
356
356
|
const blocks = [
|
|
357
357
|
{ type: 'header', text: 'Welcome' },
|
|
358
358
|
{ type: 'code', language: 'ts', content: 'console.log("hi");' },
|
|
359
359
|
];
|
|
360
360
|
|
|
361
|
-
const payload =
|
|
361
|
+
const payload = toDiscordEmbed(blocks); // Discord embed structure
|
|
362
362
|
```
|
|
363
363
|
|
|
364
364
|
#### Slack Output
|
|
365
365
|
|
|
366
366
|
```typescript
|
|
367
|
-
import {
|
|
367
|
+
import { toSlackBlocks } from '@hardlydifficult/chat';
|
|
368
368
|
|
|
369
|
-
const payload =
|
|
369
|
+
const payload = toSlackBlocks(blocks); // Slack Block Kit structure
|
|
370
370
|
```
|
|
371
371
|
|
|
372
372
|
## Typing
|
|
@@ -597,10 +597,10 @@ await slackChatClient.removeAllReactions(channelId, ts, botUserId);
|
|
|
597
597
|
Match users by ID, mention, or fuzzy alias.
|
|
598
598
|
|
|
599
599
|
```typescript
|
|
600
|
-
import {
|
|
600
|
+
import { findBestMemberMatch } from '@hardlydifficult/chat';
|
|
601
601
|
|
|
602
|
-
const member =
|
|
603
|
-
const
|
|
602
|
+
const member = findBestMemberMatch(guildMembers, '@alice'); // mentions
|
|
603
|
+
const member2 = findBestMemberMatch(guildMembers, 'alice'); // fuzzy match
|
|
604
604
|
```
|
|
605
605
|
|
|
606
606
|
### Job Lifecycle (Threaded Commands)
|
|
@@ -608,15 +608,17 @@ const member = findMember(guildMembers, 'alice'); // fuzzy match
|
|
|
608
608
|
Long-running commands support cancel/dismiss flow.
|
|
609
609
|
|
|
610
610
|
```typescript
|
|
611
|
-
import {
|
|
611
|
+
import { setupJobLifecycle } from '@hardlydifficult/chat';
|
|
612
612
|
|
|
613
|
-
|
|
613
|
+
const handle = setupJobLifecycle({
|
|
614
|
+
originalMessage: message,
|
|
614
615
|
thread,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
616
|
+
abortController: new AbortController(),
|
|
617
|
+
ownerUsername: message.author.username,
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
// Later, when work completes:
|
|
621
|
+
handle.complete();
|
|
620
622
|
```
|
|
621
623
|
|
|
622
624
|
### Error Handling
|
|
@@ -624,13 +626,13 @@ await withCancelListener(
|
|
|
624
626
|
Map worker error codes to user-friendly messages.
|
|
625
627
|
|
|
626
628
|
```typescript
|
|
627
|
-
import {
|
|
629
|
+
import { formatWorkerError, RECOVERABLE_WORKER_ERRORS } from '@hardlydifficult/chat';
|
|
628
630
|
|
|
629
|
-
if (
|
|
631
|
+
if (RECOVERABLE_WORKER_ERRORS.has(error.code)) {
|
|
630
632
|
// Retry logic
|
|
631
633
|
}
|
|
632
634
|
|
|
633
|
-
const message =
|
|
635
|
+
const message = formatWorkerError(error.code);
|
|
634
636
|
```
|
|
635
637
|
|
|
636
638
|
### Constants
|
|
@@ -638,10 +640,10 @@ const message = formatErrorMessage(error.code);
|
|
|
638
640
|
Platform message length limits.
|
|
639
641
|
|
|
640
642
|
```typescript
|
|
641
|
-
import {
|
|
643
|
+
import { MESSAGE_LIMITS } from '@hardlydifficult/chat';
|
|
642
644
|
|
|
643
|
-
console.log(DISCORD_MAX_MESSAGE_LENGTH); // 2000
|
|
644
|
-
console.log(SLACK_MAX_MESSAGE_LENGTH); // 4000
|
|
645
|
+
console.log(MESSAGE_LIMITS.DISCORD_MAX_MESSAGE_LENGTH); // 2000
|
|
646
|
+
console.log(MESSAGE_LIMITS.SLACK_MAX_MESSAGE_LENGTH); // 4000
|
|
645
647
|
```
|
|
646
648
|
|
|
647
649
|
## Platform Setup
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { createMessageTracker, type MessageTracker } from "./MessageTracker";
|
|
|
11
11
|
export { DiscordChatClient } from "./discord";
|
|
12
12
|
export { SlackChatClient } from "./slack";
|
|
13
13
|
export { type Command, type CommandContext, type ArgShape, type ParseResult, type Agent, type CoreBotState, CommandRegistry, type RegisteredCommand, CommandDispatcher, type DispatcherOptions, setupJobLifecycle, type JobLifecycleOptions, type JobLifecycleHandle, EMOJI_CANCEL, EMOJI_DISMISS, formatWorkerError, RECOVERABLE_WORKER_ERRORS, } from "./commands";
|
|
14
|
+
export { findBestMemberMatch, extractMentionId } from "./memberMatching";
|
|
15
|
+
export { toDiscordEmbed, toSlackBlocks } from "./outputters";
|
|
14
16
|
import { type ChatClient } from "./ChatClient";
|
|
15
17
|
import type { ChatConfig } from "./types";
|
|
16
18
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|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AAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAW/D"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RECOVERABLE_WORKER_ERRORS = exports.formatWorkerError = exports.EMOJI_DISMISS = exports.EMOJI_CANCEL = exports.setupJobLifecycle = exports.CommandDispatcher = exports.CommandRegistry = exports.SlackChatClient = exports.DiscordChatClient = exports.createMessageTracker = exports.Thread = exports.StreamingReply = exports.EditableStreamReply = exports.MessageBatch = exports.Message = exports.Channel = exports.ChatClient = exports.MESSAGE_LIMITS = void 0;
|
|
3
|
+
exports.toSlackBlocks = exports.toDiscordEmbed = exports.extractMentionId = exports.findBestMemberMatch = exports.RECOVERABLE_WORKER_ERRORS = exports.formatWorkerError = exports.EMOJI_DISMISS = exports.EMOJI_CANCEL = exports.setupJobLifecycle = exports.CommandDispatcher = exports.CommandRegistry = exports.SlackChatClient = exports.DiscordChatClient = exports.createMessageTracker = exports.Thread = exports.StreamingReply = exports.EditableStreamReply = exports.MessageBatch = exports.Message = exports.Channel = exports.ChatClient = exports.MESSAGE_LIMITS = void 0;
|
|
4
4
|
exports.createChatClient = createChatClient;
|
|
5
5
|
// Constants
|
|
6
6
|
var constants_1 = require("./constants");
|
|
@@ -36,6 +36,13 @@ Object.defineProperty(exports, "EMOJI_CANCEL", { enumerable: true, get: function
|
|
|
36
36
|
Object.defineProperty(exports, "EMOJI_DISMISS", { enumerable: true, get: function () { return commands_1.EMOJI_DISMISS; } });
|
|
37
37
|
Object.defineProperty(exports, "formatWorkerError", { enumerable: true, get: function () { return commands_1.formatWorkerError; } });
|
|
38
38
|
Object.defineProperty(exports, "RECOVERABLE_WORKER_ERRORS", { enumerable: true, get: function () { return commands_1.RECOVERABLE_WORKER_ERRORS; } });
|
|
39
|
+
// Utilities
|
|
40
|
+
var memberMatching_1 = require("./memberMatching");
|
|
41
|
+
Object.defineProperty(exports, "findBestMemberMatch", { enumerable: true, get: function () { return memberMatching_1.findBestMemberMatch; } });
|
|
42
|
+
Object.defineProperty(exports, "extractMentionId", { enumerable: true, get: function () { return memberMatching_1.extractMentionId; } });
|
|
43
|
+
var outputters_1 = require("./outputters");
|
|
44
|
+
Object.defineProperty(exports, "toDiscordEmbed", { enumerable: true, get: function () { return outputters_1.toDiscordEmbed; } });
|
|
45
|
+
Object.defineProperty(exports, "toSlackBlocks", { enumerable: true, get: function () { return outputters_1.toSlackBlocks; } });
|
|
39
46
|
const discord_2 = require("./discord");
|
|
40
47
|
const slack_2 = require("./slack");
|
|
41
48
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAiGA,4CAWC;AA/ED,YAAY;AACZ,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AAEvB,eAAe;AACf,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mDAA6E;AAApE,sHAAA,oBAAoB,OAAA;AAE7B,2BAA2B;AAC3B,qCAA8C;AAArC,4GAAA,iBAAiB,OAAA;AAC1B,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AAExB,WAAW;AACX,uCAkBoB;AAXlB,2GAAA,eAAe,OAAA;AAEf,6GAAA,iBAAiB,OAAA;AAEjB,6GAAA,iBAAiB,OAAA;AAGjB,wGAAA,YAAY,OAAA;AACZ,yGAAA,aAAa,OAAA;AACb,6GAAA,iBAAiB,OAAA;AACjB,qHAAA,yBAAyB,OAAA;AAG3B,YAAY;AACZ,mDAAyE;AAAhE,qHAAA,mBAAmB,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAC9C,2CAA6D;AAApD,4GAAA,cAAc,OAAA;AAAE,2GAAA,aAAa,OAAA;AAItC,uCAA8C;AAC9C,mCAA0C;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