@masons/agent-network 0.4.23 → 0.4.25
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 +3 -2
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +11 -5
- package/dist/connector-client.d.ts +7 -1
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +29 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +10 -22
- package/dist/types.d.ts +21 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/channel.d.ts
CHANGED
|
@@ -19,11 +19,12 @@ interface ChannelConfigAdapter<T> {
|
|
|
19
19
|
isEnabled?(account: T, cfg: Record<string, unknown>): boolean;
|
|
20
20
|
}
|
|
21
21
|
interface OutboundDeliveryResult {
|
|
22
|
-
|
|
22
|
+
channel: string;
|
|
23
|
+
messageId: string;
|
|
23
24
|
}
|
|
24
25
|
interface ChannelOutboundContext {
|
|
25
26
|
text: string;
|
|
26
|
-
|
|
27
|
+
to: string;
|
|
27
28
|
accountId: string;
|
|
28
29
|
}
|
|
29
30
|
interface ChannelOutboundAdapter {
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA2B9D,oEAAoE;AACpE,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oB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C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;CAC1B;AAuDD,UAAU,qBAAqB,CAAC,CAAC,GAAG,OAAO;IACzC,YAAY,CAAC,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,WAAW,CAAC,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAED,UAAU,yBAAyB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;IAClD,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD;AAsQD,eAAO,MAAM,mBAAmB,EAAE,yBAwNjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -177,6 +177,9 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
177
177
|
storePath,
|
|
178
178
|
sessionKey,
|
|
179
179
|
ctx: msgCtx,
|
|
180
|
+
onRecordError: (err) => {
|
|
181
|
+
console.error(`[agent-network:${ctx.accountId}] session record error:`, err);
|
|
182
|
+
},
|
|
180
183
|
});
|
|
181
184
|
// Typing: address-based
|
|
182
185
|
client.sendTyping(fromAddress, true);
|
|
@@ -273,14 +276,17 @@ export const agentNetworkChannel = {
|
|
|
273
276
|
outbound: {
|
|
274
277
|
deliveryMode: "direct",
|
|
275
278
|
async sendText(ctx) {
|
|
276
|
-
// ctx.
|
|
279
|
+
// ctx.to is the routable address (senderId from inbound dispatch).
|
|
277
280
|
// ConversationManager.send() handles address resolution transparently.
|
|
278
281
|
const state = accounts.get(ctx.accountId);
|
|
279
282
|
if (!state)
|
|
280
|
-
return {
|
|
281
|
-
const result = await state.conversationManager.send(ctx.
|
|
282
|
-
dbg("sendText
|
|
283
|
-
return {
|
|
283
|
+
return { channel: "agent-network", messageId: "" };
|
|
284
|
+
const result = await state.conversationManager.send(ctx.to, ctx.text);
|
|
285
|
+
dbg("sendText to=%s status=%s contentLength=%d", ctx.to, result.status, ctx.text.length);
|
|
286
|
+
return {
|
|
287
|
+
channel: "agent-network",
|
|
288
|
+
messageId: `an:${randomUUID()}`,
|
|
289
|
+
};
|
|
284
290
|
},
|
|
285
291
|
},
|
|
286
292
|
gateway: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import { type AddressedMessageEvent, type DeliveryPendingEvent, type SendAckEvent, type StructuredErrorEvent } from "./types.js";
|
|
2
|
+
import { type AddressedMessageEvent, type DeliveryPendingEvent, type DeliveryStatusEvent, type SendAckEvent, type StructuredErrorEvent } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Error with machine-readable `code` from Connector structured errors.
|
|
5
5
|
* Thrown by `send()` when the Connector responds with ERROR { code }.
|
|
@@ -13,6 +13,7 @@ type ConnectorClientEvents = {
|
|
|
13
13
|
message_received: (event: AddressedMessageEvent) => void;
|
|
14
14
|
send_ack: (event: SendAckEvent) => void;
|
|
15
15
|
delivery_pending: (event: DeliveryPendingEvent) => void;
|
|
16
|
+
delivery_status: (event: DeliveryStatusEvent) => void;
|
|
16
17
|
structured_error: (event: StructuredErrorEvent) => void;
|
|
17
18
|
error: (error: Error) => void;
|
|
18
19
|
connected: () => void;
|
|
@@ -29,6 +30,11 @@ export declare class ConnectorClient extends EventEmitter {
|
|
|
29
30
|
private registerResolve;
|
|
30
31
|
private registerReject;
|
|
31
32
|
private registerTimer;
|
|
33
|
+
/** Delivery cursor — highest recipientSeq received from Connector (#1133).
|
|
34
|
+
* Sent on REGISTER so the Connector can fill any gap. In-memory only —
|
|
35
|
+
* survives Connector restarts (Plugin stays alive), lost on Plugin restart
|
|
36
|
+
* (graceful degradation: no gap fill, same as pre-#1133 behavior). */
|
|
37
|
+
private lastKnownSeq;
|
|
32
38
|
/** Pending SEND_ACK correlation map for address-based sends. */
|
|
33
39
|
private pendingSends;
|
|
34
40
|
constructor(url: string, token: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-client.d.ts","sourceRoot":"","sources":["../src/connector-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAEL,KAAK,qBAAqB,EAI1B,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"connector-client.d.ts","sourceRoot":"","sources":["../src/connector-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAEL,KAAK,qBAAqB,EAI1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAWxB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAepB;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;gBACT,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM;CAMvD;AAID,KAAK,qBAAqB,GAAG;IAC3B,gBAAgB,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,gBAAgB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACxD,eAAe,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;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AAO,CAAC,WAAW,CAqBjB;IAEF,OAAO,CAAC,WAAW,CAIjB;IAIF,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,iBAAiB;IAqBzB,wCAAwC;IACxC,OAAO,CAAC,SAAS;CAclB"}
|
package/dist/connector-client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter } from "node:events";
|
|
|
3
3
|
import createDebug from "debug";
|
|
4
4
|
import WebSocket from "ws";
|
|
5
5
|
import { setEnvironmentContext } from "./environment-context.js";
|
|
6
|
-
import { CURRENT_PROTOCOL_VERSION, isAddressedMessage, isDeliveryPending, isRegisterAck, isSendAck, isStructuredError, REGISTER_ACK_TIMEOUT_MS, SEND_ACK_TIMEOUT_MS, } from "./types.js";
|
|
6
|
+
import { CURRENT_PROTOCOL_VERSION, isAddressedMessage, isDeliveryPending, isDeliveryStatus, isRegisterAck, isSendAck, isStructuredError, REGISTER_ACK_TIMEOUT_MS, SEND_ACK_TIMEOUT_MS, } from "./types.js";
|
|
7
7
|
import { PLUGIN_VERSION } from "./version.js";
|
|
8
8
|
const dbg = createDebug("agent-network:connector");
|
|
9
9
|
const dbgMsg = createDebug("agent-network:connector:msg");
|
|
@@ -39,6 +39,11 @@ export class ConnectorClient extends EventEmitter {
|
|
|
39
39
|
registerResolve = null;
|
|
40
40
|
registerReject = null;
|
|
41
41
|
registerTimer = null;
|
|
42
|
+
/** Delivery cursor — highest recipientSeq received from Connector (#1133).
|
|
43
|
+
* Sent on REGISTER so the Connector can fill any gap. In-memory only —
|
|
44
|
+
* survives Connector restarts (Plugin stays alive), lost on Plugin restart
|
|
45
|
+
* (graceful degradation: no gap fill, same as pre-#1133 behavior). */
|
|
46
|
+
lastKnownSeq;
|
|
42
47
|
/** Pending SEND_ACK correlation map for address-based sends. */
|
|
43
48
|
pendingSends = new Map();
|
|
44
49
|
constructor(url, token) {
|
|
@@ -151,7 +156,11 @@ export class ConnectorClient extends EventEmitter {
|
|
|
151
156
|
token: this.token,
|
|
152
157
|
protocolVersion: CURRENT_PROTOCOL_VERSION,
|
|
153
158
|
clientVersion: PLUGIN_VERSION,
|
|
159
|
+
...(this.lastKnownSeq !== undefined
|
|
160
|
+
? { lastKnownSeq: this.lastKnownSeq }
|
|
161
|
+
: {}),
|
|
154
162
|
};
|
|
163
|
+
dbg("REGISTER lastKnownSeq=%s", this.lastKnownSeq ?? "none");
|
|
155
164
|
this.sendEvent(event);
|
|
156
165
|
}
|
|
157
166
|
startRegisterTimeout() {
|
|
@@ -207,7 +216,12 @@ export class ConnectorClient extends EventEmitter {
|
|
|
207
216
|
return;
|
|
208
217
|
}
|
|
209
218
|
if (isAddressedMessage(parsed)) {
|
|
210
|
-
dbgMsg("MESSAGE_RECEIVED from=%s contentLength=%d", parsed.from, parsed.content.length);
|
|
219
|
+
dbgMsg("MESSAGE_RECEIVED from=%s contentLength=%d seq=%s", parsed.from, parsed.content.length, parsed.seq ?? "none");
|
|
220
|
+
// Advance delivery cursor (#1133)
|
|
221
|
+
if (typeof parsed.seq === "number" &&
|
|
222
|
+
(this.lastKnownSeq === undefined || parsed.seq > this.lastKnownSeq)) {
|
|
223
|
+
this.lastKnownSeq = parsed.seq;
|
|
224
|
+
}
|
|
211
225
|
this.emit("message_received", parsed);
|
|
212
226
|
return;
|
|
213
227
|
}
|
|
@@ -216,6 +230,11 @@ export class ConnectorClient extends EventEmitter {
|
|
|
216
230
|
this.emit("delivery_pending", parsed);
|
|
217
231
|
return;
|
|
218
232
|
}
|
|
233
|
+
if (isDeliveryStatus(parsed)) {
|
|
234
|
+
dbg("DELIVERY_STATUS messageId=%s status=%s", parsed.messageId, parsed.status);
|
|
235
|
+
this.emit("delivery_status", parsed);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
219
238
|
if (isStructuredError(parsed)) {
|
|
220
239
|
dbg("ERROR code=%s message=%s", parsed.code, parsed.message);
|
|
221
240
|
this.handleStructuredError(parsed);
|
|
@@ -235,6 +254,14 @@ export class ConnectorClient extends EventEmitter {
|
|
|
235
254
|
// Store agent + owner identity from enriched REGISTER_ACK (#969).
|
|
236
255
|
// Old Connectors omit these fields — setEnvironmentContext handles undefined.
|
|
237
256
|
setEnvironmentContext(ack.agent, ack.owner);
|
|
257
|
+
// Initialize delivery cursor from server (#1133).
|
|
258
|
+
// Only set on first connect (lastKnownSeq === undefined). On reconnect,
|
|
259
|
+
// the Plugin already has a cursor from previous MESSAGE_RECEIVED events.
|
|
260
|
+
if (typeof ack.deliverySeq === "number" &&
|
|
261
|
+
this.lastKnownSeq === undefined) {
|
|
262
|
+
this.lastKnownSeq = ack.deliverySeq;
|
|
263
|
+
dbg("delivery cursor initialized: %d", ack.deliverySeq);
|
|
264
|
+
}
|
|
238
265
|
this.backoffMs = BACKOFF_INITIAL_MS;
|
|
239
266
|
this.alreadyConnectedRetries = 0;
|
|
240
267
|
this.resolveRegister();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AUTHORIZED_TOKEN_TTL_MS, SETUP_CODE_CHARSET, SETUP_CODE_LENGTH, SETUP_CODE_TTL_MS, } from "./constants.js";
|
|
2
2
|
export type { AgentNetworkAccount } from "./config-schema.js";
|
|
3
|
-
export type { AddressedMessageEvent, DeliveryPendingEvent, RegisterAckEvent, SendAckEvent, StructuredErrorEvent, } from "./types.js";
|
|
3
|
+
export type { AddressedMessageEvent, DeliveryPendingEvent, DeliveryStatusEvent, RegisterAckEvent, SendAckEvent, StructuredErrorEvent, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAIxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAIxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -14,16 +14,16 @@ declare const plugin: {
|
|
|
14
14
|
name: string;
|
|
15
15
|
description: string;
|
|
16
16
|
configSchema: {
|
|
17
|
-
type:
|
|
17
|
+
type: string;
|
|
18
18
|
additionalProperties: boolean;
|
|
19
19
|
properties: {
|
|
20
20
|
apiHost: {
|
|
21
|
-
type:
|
|
21
|
+
type: string;
|
|
22
22
|
description: string;
|
|
23
23
|
default: string;
|
|
24
24
|
};
|
|
25
25
|
updateCheck: {
|
|
26
|
-
type:
|
|
26
|
+
type: string;
|
|
27
27
|
description: string;
|
|
28
28
|
default: boolean;
|
|
29
29
|
};
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AA4HA,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;CACnE;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;kBAaI,iBAAiB;CAyVhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// OpenClaw Plugin entry point.
|
|
2
2
|
// Loaded by OpenClaw Gateway via the "openclaw.extensions" field in package.json.
|
|
3
3
|
// NOT imported by index.ts to avoid pulling ws/typebox into Next.js app bundles.
|
|
4
|
+
import pluginManifest from "../openclaw.plugin.json" with { type: "json" };
|
|
4
5
|
import { agentNetworkChannel } from "./channel.js";
|
|
5
6
|
import { configureInteractive } from "./cli-setup.js";
|
|
6
7
|
import { detectPendingState, getConversationManager, getDmScope, getStateCacheGeneration, initPluginRuntime, } from "./config.js";
|
|
@@ -97,23 +98,8 @@ const plugin = {
|
|
|
97
98
|
// configSchema MUST be on the plugin export object (not just openclaw.plugin.json).
|
|
98
99
|
// Gateway validates user config via AJV against this schema BEFORE calling register().
|
|
99
100
|
// Missing configSchema → register() is never called (silent skip, no error logged).
|
|
100
|
-
//
|
|
101
|
-
configSchema:
|
|
102
|
-
type: "object",
|
|
103
|
-
additionalProperties: false,
|
|
104
|
-
properties: {
|
|
105
|
-
apiHost: {
|
|
106
|
-
type: "string",
|
|
107
|
-
description: "MASONS Platform API host",
|
|
108
|
-
default: "preview-platform.masons.ai",
|
|
109
|
-
},
|
|
110
|
-
updateCheck: {
|
|
111
|
-
type: "boolean",
|
|
112
|
-
description: "Check for plugin updates on startup (default: true)",
|
|
113
|
-
default: true,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
101
|
+
// Imported from openclaw.plugin.json — single source of truth.
|
|
102
|
+
configSchema: pluginManifest.configSchema,
|
|
117
103
|
register(api) {
|
|
118
104
|
// Capture runtime for inbound message dispatch (Pathway 1: module-level singleton).
|
|
119
105
|
// api.runtime is the full PluginRuntime (includes .channel for routing/reply/session).
|
|
@@ -403,11 +389,13 @@ const plugin = {
|
|
|
403
389
|
// Use prependSystemContext for stable tool awareness (KV-cacheable).
|
|
404
390
|
// Use prependContext for dynamic setup state.
|
|
405
391
|
//
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
//
|
|
392
|
+
// Workaround for OpenClaw issue #59546: prependSystemContext is silently
|
|
393
|
+
// ignored in the gateway reply path (confirmed in v2026.4.1, still open).
|
|
394
|
+
// To ensure tool awareness is never lost for gateway-mode users, we
|
|
395
|
+
// include TOOL_CONTEXT in both prependSystemContext (for KV-cache benefit
|
|
396
|
+
// on desktop) and prependContext (as fallback for gateway mode).
|
|
397
|
+
// Cost: ~434 tokens duplicated per turn on desktop OpenClaw.
|
|
398
|
+
// Remove this duplication once #59546 is fixed upstream.
|
|
411
399
|
const systemContext = state.hasCredentials ? TOOL_CONTEXT : undefined;
|
|
412
400
|
if (systemContext && dynamicContext) {
|
|
413
401
|
return {
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface RegisterEvent {
|
|
|
6
6
|
token: string;
|
|
7
7
|
protocolVersion: number;
|
|
8
8
|
clientVersion?: string;
|
|
9
|
+
/** Delivery cursor — highest recipientSeq the Plugin has received.
|
|
10
|
+
* When present, Connector fills the gap since this seq on REGISTER.
|
|
11
|
+
* When absent, no gap fill (backward compat / first connect). (#1133) */
|
|
12
|
+
lastKnownSeq?: number;
|
|
9
13
|
}
|
|
10
14
|
/** Send a message directly to a routable address. */
|
|
11
15
|
export interface AddressedSendEvent {
|
|
@@ -42,6 +46,9 @@ export interface RegisterAckEvent {
|
|
|
42
46
|
handle: string;
|
|
43
47
|
displayName?: string;
|
|
44
48
|
};
|
|
49
|
+
/** Current delivery sequence for this agent. Plugin stores as initial
|
|
50
|
+
* lastKnownSeq. (#1133) */
|
|
51
|
+
deliverySeq?: number;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* Delivery confirmation for a sent message.
|
|
@@ -63,6 +70,10 @@ export interface AddressedMessageEvent {
|
|
|
63
70
|
metadata: Record<string, unknown>;
|
|
64
71
|
/** ISO 8601. Present when message was stored and delivered later. */
|
|
65
72
|
sentAt?: string;
|
|
73
|
+
/** Recipient delivery sequence number. Plugin updates lastKnownSeq =
|
|
74
|
+
* max(lastKnownSeq, seq). Present for messages from `messages` collection
|
|
75
|
+
* (online delivery + gap fill). (#1133) */
|
|
76
|
+
seq?: number;
|
|
66
77
|
}
|
|
67
78
|
/** Notification that stored messages have been delivered. */
|
|
68
79
|
export interface DeliveryPendingEvent {
|
|
@@ -78,11 +89,20 @@ export interface StructuredErrorEvent {
|
|
|
78
89
|
code: string;
|
|
79
90
|
message: string;
|
|
80
91
|
}
|
|
92
|
+
/** Delivery status notification for a stored message. */
|
|
93
|
+
export interface DeliveryStatusEvent {
|
|
94
|
+
event: "DELIVERY_STATUS";
|
|
95
|
+
messageId: string;
|
|
96
|
+
status: "delivered";
|
|
97
|
+
/** ISO 8601 — when the delivery occurred. */
|
|
98
|
+
deliveredAt?: string;
|
|
99
|
+
}
|
|
81
100
|
export type PluginToConnectorEvent = RegisterEvent | AddressedSendEvent | AddressedTypingEvent | AddressedDeliveryAckEvent;
|
|
82
|
-
export type ConnectorToPluginEvent = RegisterAckEvent | SendAckEvent | AddressedMessageEvent | DeliveryPendingEvent | StructuredErrorEvent;
|
|
101
|
+
export type ConnectorToPluginEvent = RegisterAckEvent | SendAckEvent | AddressedMessageEvent | DeliveryPendingEvent | DeliveryStatusEvent | StructuredErrorEvent;
|
|
83
102
|
export declare function isRegisterAck(data: unknown): data is RegisterAckEvent;
|
|
84
103
|
export declare function isSendAck(data: unknown): data is SendAckEvent;
|
|
85
104
|
export declare function isAddressedMessage(data: unknown): data is AddressedMessageEvent;
|
|
86
105
|
export declare function isDeliveryPending(data: unknown): data is DeliveryPendingEvent;
|
|
106
|
+
export declare function isDeliveryStatus(data: unknown): data is DeliveryStatusEvent;
|
|
87
107
|
export declare function isStructuredError(data: unknown): data is StructuredErrorEvent;
|
|
88
108
|
//# 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;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;
|
|
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;IACvB;;8EAE0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,E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I,mBAAmB,CAO3E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAO7E"}
|
package/dist/types.js
CHANGED
|
@@ -31,6 +31,12 @@ export function isDeliveryPending(data) {
|
|
|
31
31
|
typeof data.count === "number" &&
|
|
32
32
|
typeof data.upTo === "string");
|
|
33
33
|
}
|
|
34
|
+
export function isDeliveryStatus(data) {
|
|
35
|
+
return (isObject(data) &&
|
|
36
|
+
data.event === "DELIVERY_STATUS" &&
|
|
37
|
+
typeof data.messageId === "string" &&
|
|
38
|
+
typeof data.status === "string");
|
|
39
|
+
}
|
|
34
40
|
export function isStructuredError(data) {
|
|
35
41
|
return (isObject(data) &&
|
|
36
42
|
data.event === "ERROR" &&
|
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.25";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.25",
|
|
4
4
|
"description": "MASONS plugin for OpenClaw — connect your agent to the agent network",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "MASONS.ai <hello@masons.ai> (https://masons.ai)",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"masons"
|
|
14
14
|
],
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=20"
|
|
16
|
+
"node": ">=20.10"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"publishConfig": {
|