@masons/agent-network 0.4.16 → 0.4.17
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/channel.d.ts.map +1 -1
- package/dist/channel.js +154 -195
- package/dist/connector-client.d.ts +46 -24
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +123 -76
- package/dist/conversation-manager.d.ts +40 -33
- package/dist/conversation-manager.d.ts.map +1 -1
- package/dist/conversation-manager.js +103 -80
- package/dist/handle-utils.d.ts +16 -0
- package/dist/handle-utils.d.ts.map +1 -0
- package/dist/handle-utils.js +25 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/owner-session-state.d.ts +11 -18
- package/dist/owner-session-state.d.ts.map +1 -1
- package/dist/owner-session-state.js +17 -26
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +2 -33
- package/dist/types.d.ts +47 -58
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +18 -33
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,89 +1,78 @@
|
|
|
1
|
-
export declare const CURRENT_PROTOCOL_VERSION =
|
|
1
|
+
export declare const CURRENT_PROTOCOL_VERSION = 2;
|
|
2
2
|
export declare const REGISTER_ACK_TIMEOUT_MS = 15000;
|
|
3
|
+
export declare const SEND_ACK_TIMEOUT_MS = 15000;
|
|
3
4
|
export interface RegisterEvent {
|
|
4
5
|
event: "REGISTER";
|
|
5
6
|
token: string;
|
|
6
7
|
protocolVersion: number;
|
|
7
8
|
clientVersion?: string;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
requestId: string;
|
|
12
|
-
target: string;
|
|
13
|
-
secret?: string;
|
|
14
|
-
metadata?: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
export interface SendMessageEvent {
|
|
10
|
+
/** Send a message directly to a routable address. */
|
|
11
|
+
export interface AddressedSendEvent {
|
|
17
12
|
event: "SEND_MESSAGE";
|
|
18
|
-
|
|
13
|
+
messageId: string;
|
|
14
|
+
to: string;
|
|
19
15
|
content: string;
|
|
20
|
-
contentType
|
|
16
|
+
contentType: string;
|
|
21
17
|
metadata?: Record<string, unknown>;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
/** Send a typing indicator to a routable address. */
|
|
20
|
+
export interface AddressedTypingEvent {
|
|
21
|
+
event: "TYPING";
|
|
22
|
+
to: string;
|
|
23
|
+
isTyping: boolean;
|
|
27
24
|
}
|
|
28
|
-
|
|
25
|
+
/** Acknowledge delivery of stored messages up to a timestamp. */
|
|
26
|
+
export interface AddressedDeliveryAckEvent {
|
|
29
27
|
event: "DELIVERY_ACK";
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
export interface TypingStartEvent {
|
|
33
|
-
event: "TYPING_START";
|
|
34
|
-
sessionId: string;
|
|
28
|
+
upTo: string;
|
|
35
29
|
}
|
|
36
|
-
export interface TypingStopEvent {
|
|
37
|
-
event: "TYPING_STOP";
|
|
38
|
-
sessionId: string;
|
|
39
|
-
}
|
|
40
|
-
export type PluginToConnectorEvent = RegisterEvent | CreateSessionEvent | SendMessageEvent | EndSessionEvent | DeliveryAckEvent | TypingStartEvent | TypingStopEvent;
|
|
41
30
|
export interface RegisterAckEvent {
|
|
42
31
|
event: "REGISTER_ACK";
|
|
43
32
|
status: "ok" | "error";
|
|
44
33
|
reason?: string;
|
|
45
34
|
protocolVersion: number;
|
|
46
35
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Delivery confirmation for a sent message.
|
|
38
|
+
*
|
|
39
|
+
* Plugins MUST treat unknown `status` values as successful delivery
|
|
40
|
+
* (forward compatibility).
|
|
41
|
+
*/
|
|
42
|
+
export interface SendAckEvent {
|
|
43
|
+
event: "SEND_ACK";
|
|
44
|
+
messageId: string;
|
|
45
|
+
status: "delivered" | "stored" | "queued";
|
|
54
46
|
}
|
|
55
|
-
|
|
47
|
+
/** Message received from a routable address. */
|
|
48
|
+
export interface AddressedMessageEvent {
|
|
56
49
|
event: "MESSAGE_RECEIVED";
|
|
57
|
-
|
|
50
|
+
from: string;
|
|
58
51
|
content: string;
|
|
59
52
|
contentType: string;
|
|
60
|
-
metadata
|
|
53
|
+
metadata: Record<string, unknown>;
|
|
54
|
+
/** ISO 8601. Present when message was stored and delivered later. */
|
|
55
|
+
sentAt?: string;
|
|
61
56
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
/** Notification that stored messages have been delivered. */
|
|
58
|
+
export interface DeliveryPendingEvent {
|
|
59
|
+
event: "DELIVERY_PENDING";
|
|
60
|
+
count: number;
|
|
61
|
+
upTo: string;
|
|
66
62
|
}
|
|
67
|
-
|
|
63
|
+
/** Structured error with machine-readable code. */
|
|
64
|
+
export interface StructuredErrorEvent {
|
|
68
65
|
event: "ERROR";
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
messageId?: string;
|
|
67
|
+
to?: string;
|
|
68
|
+
code: string;
|
|
71
69
|
message: string;
|
|
72
70
|
}
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
mailboxSessionId: string;
|
|
76
|
-
recipientSessionId: string;
|
|
77
|
-
messageCount: number;
|
|
78
|
-
}
|
|
79
|
-
export type ConnectorToPluginEvent = RegisterAckEvent | SessionCreatedEvent | MessageReceivedEvent | SessionEndedEvent | ErrorEvent | FlushCompleteEvent;
|
|
71
|
+
export type PluginToConnectorEvent = RegisterEvent | AddressedSendEvent | AddressedTypingEvent | AddressedDeliveryAckEvent;
|
|
72
|
+
export type ConnectorToPluginEvent = RegisterAckEvent | SendAckEvent | AddressedMessageEvent | DeliveryPendingEvent | StructuredErrorEvent;
|
|
80
73
|
export declare function isRegisterAck(data: unknown): data is RegisterAckEvent;
|
|
81
|
-
export declare function
|
|
82
|
-
export declare function
|
|
83
|
-
export declare function
|
|
84
|
-
export declare function
|
|
85
|
-
export declare function isFlushComplete(data: unknown): data is FlushCompleteEvent;
|
|
86
|
-
export declare function isDeliveryAck(data: unknown): data is DeliveryAckEvent;
|
|
87
|
-
export declare function isTypingStartEvent(data: unknown): data is TypingStartEvent;
|
|
88
|
-
export declare function isTypingStopEvent(data: unknown): data is TypingStopEvent;
|
|
74
|
+
export declare function isSendAck(data: unknown): data is SendAckEvent;
|
|
75
|
+
export declare function isAddressedMessage(data: unknown): data is AddressedMessageEvent;
|
|
76
|
+
export declare function isDeliveryPending(data: unknown): data is DeliveryPendingEvent;
|
|
77
|
+
export declare function isStructuredError(data: unknown): data is StructuredErrorEvent;
|
|
89
78
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,uBAAuB,QAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAQ1C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CA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AC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,MAAM,MAAM,sBAAsB,GAC9B,aAAa,GACb,kBAAkB,GAClB,oBAAoB,GACpB,yBAAyB,CAAC;AAE9B,MAAM,MAAM,sBAAsB,GAC9B,gBAAgB,GAChB,YAAY,GACZ,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,CAAC;AAUzB,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAErE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAM7D;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,qBAAqB,CAO/B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAO7E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAO7E"}
|
package/dist/types.js
CHANGED
|
@@ -2,53 +2,38 @@
|
|
|
2
2
|
// Must stay wire-compatible with the Connector service.
|
|
3
3
|
// Independently defined — this package does not depend on Connector code.
|
|
4
4
|
// --- Constants ---
|
|
5
|
-
export const CURRENT_PROTOCOL_VERSION =
|
|
5
|
+
export const CURRENT_PROTOCOL_VERSION = 2;
|
|
6
6
|
export const REGISTER_ACK_TIMEOUT_MS = 15_000;
|
|
7
|
-
|
|
7
|
+
export const SEND_ACK_TIMEOUT_MS = 15_000;
|
|
8
|
+
// ==========================================================================
|
|
9
|
+
// Type guards
|
|
10
|
+
// ==========================================================================
|
|
8
11
|
function isObject(data) {
|
|
9
12
|
return typeof data === "object" && data !== null;
|
|
10
13
|
}
|
|
11
14
|
export function isRegisterAck(data) {
|
|
12
15
|
return isObject(data) && data.event === "REGISTER_ACK";
|
|
13
16
|
}
|
|
14
|
-
export function
|
|
17
|
+
export function isSendAck(data) {
|
|
15
18
|
return (isObject(data) &&
|
|
16
|
-
data.event === "
|
|
17
|
-
typeof data.
|
|
19
|
+
data.event === "SEND_ACK" &&
|
|
20
|
+
typeof data.messageId === "string");
|
|
18
21
|
}
|
|
19
|
-
export function
|
|
22
|
+
export function isAddressedMessage(data) {
|
|
20
23
|
return (isObject(data) &&
|
|
21
24
|
data.event === "MESSAGE_RECEIVED" &&
|
|
22
|
-
typeof data.
|
|
25
|
+
typeof data.from === "string" &&
|
|
23
26
|
typeof data.content === "string");
|
|
24
27
|
}
|
|
25
|
-
export function
|
|
28
|
+
export function isDeliveryPending(data) {
|
|
26
29
|
return (isObject(data) &&
|
|
27
|
-
data.event === "
|
|
28
|
-
typeof data.
|
|
30
|
+
data.event === "DELIVERY_PENDING" &&
|
|
31
|
+
typeof data.count === "number" &&
|
|
32
|
+
typeof data.upTo === "string");
|
|
29
33
|
}
|
|
30
|
-
export function
|
|
31
|
-
return (isObject(data) && data.event === "ERROR" && typeof data.message === "string");
|
|
32
|
-
}
|
|
33
|
-
export function isFlushComplete(data) {
|
|
34
|
-
return (isObject(data) &&
|
|
35
|
-
data.event === "FLUSH_COMPLETE" &&
|
|
36
|
-
typeof data.mailboxSessionId === "string" &&
|
|
37
|
-
typeof data.recipientSessionId === "string" &&
|
|
38
|
-
typeof data.messageCount === "number");
|
|
39
|
-
}
|
|
40
|
-
export function isDeliveryAck(data) {
|
|
41
|
-
return (isObject(data) &&
|
|
42
|
-
data.event === "DELIVERY_ACK" &&
|
|
43
|
-
typeof data.mailboxSessionId === "string");
|
|
44
|
-
}
|
|
45
|
-
export function isTypingStartEvent(data) {
|
|
46
|
-
return (isObject(data) &&
|
|
47
|
-
data.event === "TYPING_START" &&
|
|
48
|
-
typeof data.sessionId === "string");
|
|
49
|
-
}
|
|
50
|
-
export function isTypingStopEvent(data) {
|
|
34
|
+
export function isStructuredError(data) {
|
|
51
35
|
return (isObject(data) &&
|
|
52
|
-
data.event === "
|
|
53
|
-
typeof data.
|
|
36
|
+
data.event === "ERROR" &&
|
|
37
|
+
typeof data.code === "string" &&
|
|
38
|
+
typeof data.message === "string");
|
|
54
39
|
}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Plugin version — must match package.json. Validated by prepublishOnly. */
|
|
2
|
-
export const PLUGIN_VERSION = "0.4.
|
|
2
|
+
export const PLUGIN_VERSION = "0.4.17";
|
package/package.json
CHANGED