@masons/agent-network 0.4.24 → 0.4.26
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 +8 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +30 -15
- package/dist/connector-client.d.ts +5 -0
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +23 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +42 -19
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { AgentNetworkAccount } from "./config-schema.js";
|
|
2
2
|
/** Get the stored owner Passport address (first is_owner visit). */
|
|
3
3
|
export declare function getOwnerPassportAddress(): string | null;
|
|
4
|
+
/**
|
|
5
|
+
* Consume the identity linking nudge flag. Destructive read — returns true
|
|
6
|
+
* at most once per detection cycle. Called by before_prompt_build on
|
|
7
|
+
* non-Passport owner turns to deliver the nudge where the action is relevant.
|
|
8
|
+
*/
|
|
9
|
+
export declare function consumeIdentityLinkingNudge(): boolean;
|
|
10
|
+
/** Test-only: set the nudge flag without going through the detection path. */
|
|
11
|
+
export declare function _setNudgePendingForTesting(value: boolean): void;
|
|
4
12
|
interface ChannelMeta {
|
|
5
13
|
name: string;
|
|
6
14
|
description: string;
|
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;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAk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C,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACzE;AAED,UAAU,qBAAqB,CAAC,CAAC,GAAG,OAAO;IACzC,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;AA8PD,eAAO,MAAM,mBAAmB,EAAE,yBAyNjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -5,7 +5,6 @@ import { ConnectorClient } from "./connector-client.js";
|
|
|
5
5
|
import { ConversationManager } from "./conversation-manager.js";
|
|
6
6
|
import { clearEnvironmentContext } from "./environment-context.js";
|
|
7
7
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
8
|
-
import { ownerNotesQueue } from "./owner-notes.js";
|
|
9
8
|
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, } from "./owner-session-state.js";
|
|
10
9
|
import { setCurrentTurnSender } from "./turn-context.js";
|
|
11
10
|
import { checkForUpdate } from "./update-check.js";
|
|
@@ -14,6 +13,13 @@ const dbg = createDebug("agent-network:channel");
|
|
|
14
13
|
// Reset on startAccount(). isIdentityLinksConfigured() provides the
|
|
15
14
|
// cross-restart idempotency (checks config file).
|
|
16
15
|
let notificationAttempted = false;
|
|
16
|
+
// Identity linking nudge — set when the owner first visits via Passport and
|
|
17
|
+
// cross-channel linking is available. Delivered on the owner's next
|
|
18
|
+
// non-Passport turn (Telegram/Feishu) where the linking action is relevant.
|
|
19
|
+
// Separate from ownerNotesQueue to avoid the Passport drain deadlock (#1158):
|
|
20
|
+
// the queue drains on ALL owner turns (including Passport), but this nudge
|
|
21
|
+
// only fires on non-Passport owner turns.
|
|
22
|
+
let identityLinkingNudgePending = false;
|
|
17
23
|
// Owner's Passport address: recorded on first is_owner MESSAGE_RECEIVED.
|
|
18
24
|
// Used by masons_link_identity tool to auto-include the Passport entry.
|
|
19
25
|
let storedOwnerPassportAddress = null;
|
|
@@ -21,6 +27,21 @@ let storedOwnerPassportAddress = null;
|
|
|
21
27
|
export function getOwnerPassportAddress() {
|
|
22
28
|
return storedOwnerPassportAddress;
|
|
23
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Consume the identity linking nudge flag. Destructive read — returns true
|
|
32
|
+
* at most once per detection cycle. Called by before_prompt_build on
|
|
33
|
+
* non-Passport owner turns to deliver the nudge where the action is relevant.
|
|
34
|
+
*/
|
|
35
|
+
export function consumeIdentityLinkingNudge() {
|
|
36
|
+
if (!identityLinkingNudgePending)
|
|
37
|
+
return false;
|
|
38
|
+
identityLinkingNudgePending = false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
/** Test-only: set the nudge flag without going through the detection path. */
|
|
42
|
+
export function _setNudgePendingForTesting(value) {
|
|
43
|
+
identityLinkingNudgePending = value;
|
|
44
|
+
}
|
|
24
45
|
// --- Sender identity ---
|
|
25
46
|
/**
|
|
26
47
|
* Extract a human-readable name from the sender's metadata.
|
|
@@ -98,24 +119,17 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
98
119
|
storedOwnerPassportAddress = fromAddress;
|
|
99
120
|
dbg("recorded owner Passport address: %s", fromAddress);
|
|
100
121
|
}
|
|
101
|
-
// --- dmScope-aware
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
// -
|
|
105
|
-
//
|
|
106
|
-
// - Sent once per startAccount lifecycle (in-memory idempotency)
|
|
107
|
-
// Content is channel-agnostic and language-neutral (semantic event, not identity claim).
|
|
122
|
+
// --- dmScope-aware identity linking nudge (#986 redesign, #1158 fix) ---
|
|
123
|
+
// Detect that identity linking is available but not configured.
|
|
124
|
+
// Sets a flag (NOT enqueued into ownerNotesQueue) for delivery on the
|
|
125
|
+
// owner's next non-Passport turn, where the linking action is relevant.
|
|
126
|
+
// Separated from the queue to avoid the Passport drain deadlock (#1158).
|
|
108
127
|
if (getDmScope() !== "main" &&
|
|
109
128
|
!isIdentityLinksConfigured() &&
|
|
110
129
|
!notificationAttempted) {
|
|
111
130
|
notificationAttempted = true;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"Cross-channel identity linking is available but not configured. " +
|
|
115
|
-
"The owner can link their identity across channels so conversations share context.",
|
|
116
|
-
timestamp: Date.now(),
|
|
117
|
-
});
|
|
118
|
-
dbg("queued identity linking notification (dmScope=%s)", getDmScope());
|
|
131
|
+
identityLinkingNudgePending = true;
|
|
132
|
+
dbg("identity linking nudge pending (dmScope=%s)", getDmScope());
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
setCurrentTurnIsOwner(isOwnerAddress(fromAddress));
|
|
@@ -294,6 +308,7 @@ export const agentNetworkChannel = {
|
|
|
294
308
|
dbg("starting account %s", ctx.accountId);
|
|
295
309
|
// Reset per-session state
|
|
296
310
|
notificationAttempted = false;
|
|
311
|
+
identityLinkingNudgePending = false;
|
|
297
312
|
storedOwnerPassportAddress = null;
|
|
298
313
|
// Defensive: clear stale singletons from a previous cycle.
|
|
299
314
|
// The abort handler intentionally leaves them alive for in-flight tool
|
|
@@ -30,6 +30,11 @@ export declare class ConnectorClient extends EventEmitter {
|
|
|
30
30
|
private registerResolve;
|
|
31
31
|
private registerReject;
|
|
32
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;
|
|
33
38
|
/** Pending SEND_ACK correlation map for address-based sends. */
|
|
34
39
|
private pendingSends;
|
|
35
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,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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AqB,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO;IACV,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO;IAOzD,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,aAAa,CAgBnB;IAEF,6CAA6C;IAC7C,OAAO,CAAC,iBAAiB;IAkDzB,OAAO,CAAC,iBAAiB;IA6DzB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAUrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,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
|
@@ -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
|
}
|
|
@@ -240,6 +254,14 @@ export class ConnectorClient extends EventEmitter {
|
|
|
240
254
|
// Store agent + owner identity from enriched REGISTER_ACK (#969).
|
|
241
255
|
// Old Connectors omit these fields — setEnvironmentContext handles undefined.
|
|
242
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
|
+
}
|
|
243
265
|
this.backoffMs = BACKOFF_INITIAL_MS;
|
|
244
266
|
this.alreadyConnectedRetries = 0;
|
|
245
267
|
this.resolveRegister();
|
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":"AAiJA,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;CAkWhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
import pluginManifest from "../openclaw.plugin.json" with { type: "json" };
|
|
5
|
-
import { agentNetworkChannel } from "./channel.js";
|
|
5
|
+
import { agentNetworkChannel, consumeIdentityLinkingNudge } from "./channel.js";
|
|
6
6
|
import { configureInteractive } from "./cli-setup.js";
|
|
7
7
|
import { detectPendingState, getConversationManager, getDmScope, getStateCacheGeneration, initPluginRuntime, } from "./config.js";
|
|
8
8
|
import { getAgentIdentity } from "./environment-context.js";
|
|
@@ -30,6 +30,24 @@ function formatTimeAgo(timestamp) {
|
|
|
30
30
|
const days = Math.floor(hours / 24);
|
|
31
31
|
return `${days}d ago`;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Drain ownerNotesQueue and format into an "[Agent Network — Updates]" block.
|
|
35
|
+
* Returns null if the queue was empty.
|
|
36
|
+
*/
|
|
37
|
+
function drainAndFormatNotes(reportInstruction) {
|
|
38
|
+
const notes = ownerNotesQueue.drain();
|
|
39
|
+
if (notes.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
const lines = notes.map((n) => {
|
|
42
|
+
const fromStr = n.from ? `@${n.from}` : "agent";
|
|
43
|
+
const timeStr = formatTimeAgo(n.timestamp);
|
|
44
|
+
return `• ${fromStr} (${timeStr}): "${n.content}"`;
|
|
45
|
+
});
|
|
46
|
+
return ("[Agent Network — Updates]\n" +
|
|
47
|
+
"The following happened on the agent network since your last turn:\n" +
|
|
48
|
+
`${lines.join("\n")}\n` +
|
|
49
|
+
reportInstruction);
|
|
50
|
+
}
|
|
33
51
|
/** Max active interactions to inject into context to avoid noise. */
|
|
34
52
|
const MAX_INTERACTIONS = 5;
|
|
35
53
|
/**
|
|
@@ -268,12 +286,10 @@ const plugin = {
|
|
|
268
286
|
// Owner visiting via Passport — no routing warning needed.
|
|
269
287
|
// The LLM's text reply goes to the owner (the visitor IS the owner).
|
|
270
288
|
//
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
//
|
|
275
|
-
// Draining here would consume notifications on the same turn that
|
|
276
|
-
// generated them, leaving nothing for the target channel.
|
|
289
|
+
// Drain ownerNotesQueue (#1158). General notes from network turns
|
|
290
|
+
// should reach the owner wherever they are — including Passport.
|
|
291
|
+
// The identity linking nudge is handled separately (boolean flag
|
|
292
|
+
// in channel.ts) and delivered only on non-Passport owner turns.
|
|
277
293
|
dynamicContext =
|
|
278
294
|
"[Agent Network — Owner via Passport] Your owner (Principal) is talking to you " +
|
|
279
295
|
"via Passport (your public web chat page where visitors can reach you). " +
|
|
@@ -281,6 +297,10 @@ const plugin = {
|
|
|
281
297
|
"Your text reply goes directly to your owner. " +
|
|
282
298
|
"You can share information freely — no information boundary applies. " +
|
|
283
299
|
"Do NOT use masons_note_for_owner — your owner is right here.";
|
|
300
|
+
const notesBlock = drainAndFormatNotes("Report these to your owner now — they are right here.");
|
|
301
|
+
if (notesBlock) {
|
|
302
|
+
dynamicContext += `\n\n${notesBlock}`;
|
|
303
|
+
}
|
|
284
304
|
}
|
|
285
305
|
else {
|
|
286
306
|
// Turn triggered by a remote agent/stranger — routing warning +
|
|
@@ -317,18 +337,21 @@ const plugin = {
|
|
|
317
337
|
}
|
|
318
338
|
else {
|
|
319
339
|
// Owner turn (or other channel) — drain pending notes if any.
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
"
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
340
|
+
const notesBlock = drainAndFormatNotes("Report these to your owner.");
|
|
341
|
+
if (notesBlock) {
|
|
342
|
+
dynamicContext = notesBlock;
|
|
343
|
+
}
|
|
344
|
+
// Identity linking nudge — delivered here (non-Passport owner turn)
|
|
345
|
+
// where the linking action is relevant (#1158).
|
|
346
|
+
if (consumeIdentityLinkingNudge()) {
|
|
347
|
+
const nudge = "[Agent Network — Identity Linking Available]\n" +
|
|
348
|
+
"Your owner visited via Passport (verified). " +
|
|
349
|
+
"Cross-channel identity linking is available but not configured. " +
|
|
350
|
+
"The owner can link their identity across channels so conversations share context. " +
|
|
351
|
+
"Suggest using masons_link_identity.";
|
|
352
|
+
dynamicContext = dynamicContext
|
|
353
|
+
? `${dynamicContext}\n\n${nudge}`
|
|
354
|
+
: nudge;
|
|
332
355
|
}
|
|
333
356
|
// Append interaction space on owner turns too (#873).
|
|
334
357
|
// Gives the agent awareness of active network interactions.
|
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 {
|
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,MAA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EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;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,mBAAmB,GACnB,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,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,mBAAmB,CAO3E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAO7E"}
|
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.26";
|
package/package.json
CHANGED