@mulmobridge/client 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mime.d.ts +9 -6
- package/dist/mime.js +7 -4
- package/dist/reply.d.ts +8 -0
- package/dist/reply.js +19 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { createBridgeClient, requireBearerToken, type MessageAck, type PushEvent
|
|
|
2
2
|
export { readBridgeToken, TOKEN_FILE_PATH } from "./token.js";
|
|
3
3
|
export { readBridgeEnvOptions } from "./options.js";
|
|
4
4
|
export { chunkText } from "./text.js";
|
|
5
|
+
export { formatAckReply } from "./reply.js";
|
|
5
6
|
export { mimeFromExtension, isImageMime, isPdfMime, isSupportedAttachmentMime, isNativeAttachmentMime, parseDataUrl, buildDataUrl, type ParsedDataUrl, } from "./mime.js";
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { createBridgeClient, requireBearerToken } from "./client.js";
|
|
|
3
3
|
export { readBridgeToken, TOKEN_FILE_PATH } from "./token.js";
|
|
4
4
|
export { readBridgeEnvOptions } from "./options.js";
|
|
5
5
|
export { chunkText } from "./text.js";
|
|
6
|
+
export { formatAckReply } from "./reply.js";
|
|
6
7
|
export { mimeFromExtension, isImageMime, isPdfMime, isSupportedAttachmentMime, isNativeAttachmentMime, parseDataUrl, buildDataUrl, } from "./mime.js";
|
package/dist/mime.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/** Infer MIME type from a file extension (case-insensitive).
|
|
2
2
|
* Returns the fallback if the extension is not recognised. */
|
|
3
3
|
export declare function mimeFromExtension(ext: string, fallback?: string): string;
|
|
4
|
-
/** True when the MIME type is an image Claude can see via vision.
|
|
5
|
-
|
|
4
|
+
/** True when the MIME type is an image Claude can see via vision.
|
|
5
|
+
* Tolerates `undefined` so callers can pass an attachment's optional
|
|
6
|
+
* `mimeType` directly. */
|
|
7
|
+
export declare function isImageMime(mimeType: string | undefined): boolean;
|
|
6
8
|
/** True when the MIME type is a PDF document Claude can read natively
|
|
7
|
-
* via `type: "document"` content blocks. */
|
|
8
|
-
export declare function isPdfMime(mimeType: string): boolean;
|
|
9
|
+
* via `type: "document"` content blocks. Tolerates `undefined`. */
|
|
10
|
+
export declare function isPdfMime(mimeType: string | undefined): boolean;
|
|
9
11
|
/** True when the attachment can be sent to Claude directly as a
|
|
10
|
-
* native content block (image or PDF) — no conversion needed.
|
|
11
|
-
|
|
12
|
+
* native content block (image or PDF) — no conversion needed.
|
|
13
|
+
* Tolerates `undefined`. */
|
|
14
|
+
export declare function isNativeAttachmentMime(mimeType: string | undefined): boolean;
|
|
12
15
|
export declare const isSupportedAttachmentMime: typeof isNativeAttachmentMime;
|
|
13
16
|
export interface ParsedDataUrl {
|
|
14
17
|
mimeType: string;
|
package/dist/mime.js
CHANGED
|
@@ -31,17 +31,20 @@ const EXT_TO_MIME = {
|
|
|
31
31
|
export function mimeFromExtension(ext, fallback = "application/octet-stream") {
|
|
32
32
|
return EXT_TO_MIME[ext.toLowerCase()] ?? fallback;
|
|
33
33
|
}
|
|
34
|
-
/** True when the MIME type is an image Claude can see via vision.
|
|
34
|
+
/** True when the MIME type is an image Claude can see via vision.
|
|
35
|
+
* Tolerates `undefined` so callers can pass an attachment's optional
|
|
36
|
+
* `mimeType` directly. */
|
|
35
37
|
export function isImageMime(mimeType) {
|
|
36
|
-
return mimeType.startsWith("image/");
|
|
38
|
+
return typeof mimeType === "string" && mimeType.startsWith("image/");
|
|
37
39
|
}
|
|
38
40
|
/** True when the MIME type is a PDF document Claude can read natively
|
|
39
|
-
* via `type: "document"` content blocks. */
|
|
41
|
+
* via `type: "document"` content blocks. Tolerates `undefined`. */
|
|
40
42
|
export function isPdfMime(mimeType) {
|
|
41
43
|
return mimeType === "application/pdf";
|
|
42
44
|
}
|
|
43
45
|
/** True when the attachment can be sent to Claude directly as a
|
|
44
|
-
* native content block (image or PDF) — no conversion needed.
|
|
46
|
+
* native content block (image or PDF) — no conversion needed.
|
|
47
|
+
* Tolerates `undefined`. */
|
|
45
48
|
export function isNativeAttachmentMime(mimeType) {
|
|
46
49
|
return isImageMime(mimeType) || isPdfMime(mimeType);
|
|
47
50
|
}
|
package/dist/reply.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MessageAck } from "./client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Format a `MessageAck` as a single user-facing string.
|
|
4
|
+
*
|
|
5
|
+
* - `ok` ack → `reply` content (or empty string if absent).
|
|
6
|
+
* - Failed ack → `"Error[ (status)]: <error or 'unknown'>"`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatAckReply(ack: MessageAck): string;
|
package/dist/reply.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Shared reply formatting for bridges.
|
|
2
|
+
//
|
|
3
|
+
// Every bridge converts a `MessageAck` from `BridgeClient.send()`
|
|
4
|
+
// into a single string to send back over its native transport. The
|
|
5
|
+
// happy-path / error-path shape is identical across bridges
|
|
6
|
+
// (LINE / Slack / Teams / Mastodon / XMPP all do the same thing
|
|
7
|
+
// modulo the send call), so the formatting belongs here.
|
|
8
|
+
/**
|
|
9
|
+
* Format a `MessageAck` as a single user-facing string.
|
|
10
|
+
*
|
|
11
|
+
* - `ok` ack → `reply` content (or empty string if absent).
|
|
12
|
+
* - Failed ack → `"Error[ (status)]: <error or 'unknown'>"`.
|
|
13
|
+
*/
|
|
14
|
+
export function formatAckReply(ack) {
|
|
15
|
+
if (ack.ok)
|
|
16
|
+
return ack.reply ?? "";
|
|
17
|
+
const status = ack.status ? ` (${ack.status})` : "";
|
|
18
|
+
return `Error${status}: ${ack.error ?? "unknown"}`;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulmobridge/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Socket.io client library for MulmoBridge — shared by all bridge implementations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"socket.io-client": "^4.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^
|
|
52
|
+
"@types/node": "^26.1.0",
|
|
53
53
|
"typescript": "^6.0.3"
|
|
54
54
|
}
|
|
55
55
|
}
|