@masons/agent-network 0.6.14 → 0.6.16
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/_vendor/runtime-adapter-client/conformance.d.ts +8 -0
- package/dist/_vendor/runtime-adapter-client/conformance.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/conformance.js +75 -0
- package/dist/_vendor/runtime-adapter-client/icm.d.ts +6 -0
- package/dist/_vendor/runtime-adapter-client/icm.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/icm.js +86 -0
- package/dist/_vendor/runtime-adapter-client/index.d.ts +7 -0
- package/dist/_vendor/runtime-adapter-client/index.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/index.js +6 -0
- package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.d.ts +300 -0
- package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.js +3112 -0
- package/dist/_vendor/runtime-adapter-client/send-admission.d.ts +89 -0
- package/dist/_vendor/runtime-adapter-client/send-admission.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/send-admission.js +169 -0
- package/dist/_vendor/runtime-adapter-client/types.d.ts +632 -0
- package/dist/_vendor/runtime-adapter-client/types.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/types.js +33 -0
- package/dist/_vendor/runtime-adapter-client/work-target.d.ts +5 -0
- package/dist/_vendor/runtime-adapter-client/work-target.d.ts.map +1 -0
- package/dist/_vendor/runtime-adapter-client/work-target.js +47 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +103 -31
- package/dist/connector-client.d.ts +2 -4
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +9 -62
- package/dist/connector-url-boundary.d.ts +0 -5
- package/dist/connector-url-boundary.d.ts.map +1 -1
- package/dist/connector-url-boundary.js +0 -13
- package/dist/conversation-manager.d.ts +2 -2
- package/dist/conversation-manager.d.ts.map +1 -1
- package/dist/conversation-manager.js +24 -16
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +26 -13
- package/dist/services-retained-recipient.d.ts +58 -0
- package/dist/services-retained-recipient.d.ts.map +1 -0
- package/dist/services-retained-recipient.js +324 -0
- package/dist/turn-context.d.ts +4 -0
- package/dist/turn-context.d.ts.map +1 -1
- package/dist/turn-context.js +18 -0
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const RUNTIME_ASSIGNMENT_FAILURE_CATEGORIES = [
|
|
2
|
+
"assignment_in_progress",
|
|
3
|
+
"target_unavailable_before_acceptance",
|
|
4
|
+
"acceptance_rejected",
|
|
5
|
+
"processing_failed_or_expired",
|
|
6
|
+
"reply_handle_stale",
|
|
7
|
+
];
|
|
8
|
+
export const RUNTIME_PROCESSING_STATES = [
|
|
9
|
+
"assigned_to_runtime_target",
|
|
10
|
+
"adapter_accepted",
|
|
11
|
+
"processing_started",
|
|
12
|
+
"reply_requested",
|
|
13
|
+
"reply_emitted",
|
|
14
|
+
"processing_failed",
|
|
15
|
+
"waiting_for_runtime_capability",
|
|
16
|
+
"target_lost_before_acceptance",
|
|
17
|
+
"processing_interrupted",
|
|
18
|
+
"expired",
|
|
19
|
+
];
|
|
20
|
+
export const ADAPTER_RUNTIME_PROCESSING_STATES = [
|
|
21
|
+
"adapter_accepted",
|
|
22
|
+
"processing_started",
|
|
23
|
+
"processing_failed",
|
|
24
|
+
"waiting_for_runtime_capability",
|
|
25
|
+
"target_lost_before_acceptance",
|
|
26
|
+
"processing_interrupted",
|
|
27
|
+
"expired",
|
|
28
|
+
];
|
|
29
|
+
export const SYSTEM_RUNTIME_PROCESSING_STATES = [
|
|
30
|
+
"assigned_to_runtime_target",
|
|
31
|
+
"reply_requested",
|
|
32
|
+
"reply_emitted",
|
|
33
|
+
];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuntimeWorkTargetRef } from "./types.js";
|
|
2
|
+
export declare function parseRuntimeWorkTargetRef(value: unknown): RuntimeWorkTargetRef | null;
|
|
3
|
+
export declare function isRuntimeWorkTargetRef(value: unknown): value is RuntimeWorkTargetRef;
|
|
4
|
+
export declare function sameRuntimeWorkTargetRef(left: RuntimeWorkTargetRef, right: RuntimeWorkTargetRef): boolean;
|
|
5
|
+
//# sourceMappingURL=work-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-target.d.ts","sourceRoot":"","sources":["../../../src/_vendor/runtime-adapter-client/work-target.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,oBAAoB,GAAG,IAAI,CAiC7B;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,oBAAoB,CAE/B;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,oBAAoB,EAC1B,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAeT"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function parseRuntimeWorkTargetRef(value) {
|
|
2
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3
|
+
return null;
|
|
4
|
+
const raw = value;
|
|
5
|
+
if (raw.kind !== "projection_endpoint" ||
|
|
6
|
+
typeof raw.projection_endpoint_id !== "string" ||
|
|
7
|
+
raw.projection_endpoint_id.trim().length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const projectionEndpointId = raw.projection_endpoint_id.trim();
|
|
11
|
+
if (raw.background_exchange_mode === "resident_endpoint") {
|
|
12
|
+
if (raw.runtime_session_id !== undefined)
|
|
13
|
+
return null;
|
|
14
|
+
return {
|
|
15
|
+
kind: "projection_endpoint",
|
|
16
|
+
projection_endpoint_id: projectionEndpointId,
|
|
17
|
+
background_exchange_mode: "resident_endpoint",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if ((raw.background_exchange_mode === "adapter_managed_turn" ||
|
|
21
|
+
raw.background_exchange_mode === "session_attached_pull") &&
|
|
22
|
+
typeof raw.runtime_session_id === "string" &&
|
|
23
|
+
raw.runtime_session_id.trim().length > 0) {
|
|
24
|
+
return {
|
|
25
|
+
kind: "projection_endpoint",
|
|
26
|
+
projection_endpoint_id: projectionEndpointId,
|
|
27
|
+
runtime_session_id: raw.runtime_session_id.trim(),
|
|
28
|
+
background_exchange_mode: raw.background_exchange_mode,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function isRuntimeWorkTargetRef(value) {
|
|
34
|
+
return parseRuntimeWorkTargetRef(value) !== null;
|
|
35
|
+
}
|
|
36
|
+
export function sameRuntimeWorkTargetRef(left, right) {
|
|
37
|
+
if (left.kind !== right.kind ||
|
|
38
|
+
left.projection_endpoint_id !== right.projection_endpoint_id ||
|
|
39
|
+
left.background_exchange_mode !== right.background_exchange_mode) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (left.background_exchange_mode === "resident_endpoint") {
|
|
43
|
+
return right.background_exchange_mode === "resident_endpoint";
|
|
44
|
+
}
|
|
45
|
+
return (right.background_exchange_mode === left.background_exchange_mode &&
|
|
46
|
+
left.runtime_session_id === right.runtime_session_id);
|
|
47
|
+
}
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,kCAAkC,CAAC;AAa1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,kCAAkC,CAAC;AAa1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAkD9D,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAOD,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAGD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAaD,iBAAS,iCAAiC,CACxC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,eAAO,MAAM,4CAA4C,0CACtB,CAAC;AA+gBpC,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,mBAAmB,CAiRlE,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -2,15 +2,16 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import createDebug from "debug";
|
|
3
3
|
import { clearConnectorClient, clearConversationManager, extractNetworkConfig, getDmScope, initConnectorClient, initConversationManager, initToolConfig, isIdentityLinksConfigured, requirePlatformConfig, requirePluginRuntime, } from "./config.js";
|
|
4
4
|
import { ConnectorClient } from "./connector-client.js";
|
|
5
|
-
import { resolveMstpAuthority } from "./connector-url-boundary.js";
|
|
6
5
|
import { ConversationManager } from "./conversation-manager.js";
|
|
7
6
|
import { clearEnvironmentContext } from "./environment-context.js";
|
|
8
7
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
9
8
|
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, setCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
9
|
+
import { ServicesRetainedRecipientConsumer, } from "./services-retained-recipient.js";
|
|
10
10
|
import { createReplyTraceMetadata, ensureTraceMetadata, } from "./trace-metadata.js";
|
|
11
|
-
import { setCurrentTurnSender } from "./turn-context.js";
|
|
11
|
+
import { setCurrentTurnReplyRoute, setCurrentTurnSender, setCurrentTurnSenderAddress, } from "./turn-context.js";
|
|
12
12
|
import { checkForUpdate } from "./update-check.js";
|
|
13
13
|
const dbg = createDebug("agent-network:channel");
|
|
14
|
+
const SERVICES_RETAINED_INBOX_PEER = "agent-network:services-retained-node-inbox";
|
|
14
15
|
let notificationAttempted = false;
|
|
15
16
|
let identityLinkingNudgePending = false;
|
|
16
17
|
let storedOwnerPassportAddress = null;
|
|
@@ -111,7 +112,7 @@ function isDuplicate(from, content, sentAt) {
|
|
|
111
112
|
}
|
|
112
113
|
return false;
|
|
113
114
|
}
|
|
114
|
-
async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
115
|
+
async function handleAddressedMessage(event, conversationManager, client, ctx, options = {}) {
|
|
115
116
|
const fromAddress = event.from;
|
|
116
117
|
dbg("routing inbound message from=%s contentLength=%d", fromAddress, event.content.length);
|
|
117
118
|
const inboundTrace = ensureTraceMetadata(event.metadata);
|
|
@@ -122,16 +123,21 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
122
123
|
console.warn(`[agent-network:channel] invalid traceparent from=${fromAddress} traceId=${inboundTrace.traceId} spanName=receive`);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
if (
|
|
126
|
+
if (!options.servicesRetained &&
|
|
127
|
+
isDuplicate(fromAddress, event.content, event.sentAt)) {
|
|
126
128
|
dbg("duplicate message suppressed from=%s sentAt=%s", fromAddress, event.sentAt);
|
|
127
|
-
return;
|
|
129
|
+
return true;
|
|
128
130
|
}
|
|
129
131
|
const inboundCorrelationId = typeof metadata.correlation_id === "string"
|
|
130
132
|
? metadata.correlation_id
|
|
131
133
|
: undefined;
|
|
132
134
|
const inboundMessageId = typeof event.messageId === "string" ? event.messageId : undefined;
|
|
133
|
-
const nodeRef = tryProjectNodeRef(metadata);
|
|
134
|
-
if (
|
|
135
|
+
const nodeRef = options.servicesRetained ? null : tryProjectNodeRef(metadata);
|
|
136
|
+
if (options.servicesRetained) {
|
|
137
|
+
setCurrentTurnIsOwner(false);
|
|
138
|
+
setCurrentTurnOwnerSignal(null);
|
|
139
|
+
}
|
|
140
|
+
else if (nodeRef) {
|
|
135
141
|
setCurrentTurnIsOwner(false);
|
|
136
142
|
setCurrentTurnOwnerSignal(null);
|
|
137
143
|
dbg("Full Node sender: kind=%s mstpAddress=%s handle=%s", nodeRef.kind, nodeRef.mstpAddress, nodeRef.handle ?? "(absent)");
|
|
@@ -162,34 +168,39 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
162
168
|
setCurrentTurnOwnerSignal(null);
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
|
-
const contact =
|
|
166
|
-
? deriveNodeName(nodeRef, fromAddress)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
const contact = options.senderName ??
|
|
172
|
+
(nodeRef ? deriveNodeName(nodeRef, fromAddress) : deriveSenderName(event));
|
|
173
|
+
const replyAddress = options.routableReplyAddress ??
|
|
174
|
+
(options.servicesRetained ? undefined : fromAddress);
|
|
175
|
+
setCurrentTurnReplyRoute(replyAddress ? "routable" : "unavailable");
|
|
176
|
+
if (replyAddress && !conversationManager.getContactByAddress(replyAddress)) {
|
|
177
|
+
conversationManager.registerInbound(contact, replyAddress);
|
|
170
178
|
}
|
|
171
|
-
setCurrentTurnSender(
|
|
179
|
+
setCurrentTurnSender(contact);
|
|
180
|
+
setCurrentTurnSenderAddress(replyAddress ?? null);
|
|
172
181
|
let runtime;
|
|
173
182
|
try {
|
|
174
183
|
runtime = requirePluginRuntime();
|
|
175
184
|
}
|
|
176
185
|
catch {
|
|
177
186
|
dbg("plugin runtime not available, dropping message from=%s", fromAddress);
|
|
178
|
-
return;
|
|
187
|
+
return false;
|
|
179
188
|
}
|
|
180
189
|
if (!runtime.channel) {
|
|
181
190
|
dbg("channelRuntime not available, dropping message from=%s", fromAddress);
|
|
182
|
-
return;
|
|
191
|
+
return false;
|
|
183
192
|
}
|
|
184
|
-
const senderId = fromAddress;
|
|
193
|
+
const senderId = options.runtimePeerId ?? fromAddress;
|
|
185
194
|
const senderName = contact;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
195
|
+
if (replyAddress) {
|
|
196
|
+
conversationManager.recordInboundEnvelope(replyAddress, {
|
|
197
|
+
traceparent: typeof metadata.traceparent === "string"
|
|
198
|
+
? metadata.traceparent
|
|
199
|
+
: undefined,
|
|
200
|
+
correlationId: inboundCorrelationId,
|
|
201
|
+
messageId: inboundMessageId,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
193
204
|
try {
|
|
194
205
|
const route = await runtime.channel.routing.resolveAgentRoute({
|
|
195
206
|
cfg: ctx.cfg,
|
|
@@ -211,7 +222,8 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
211
222
|
Timestamp: event.sentAt ? new Date(event.sentAt).getTime() : Date.now(),
|
|
212
223
|
Provider: "agent-network",
|
|
213
224
|
Surface: "agent-network",
|
|
214
|
-
MessageSid:
|
|
225
|
+
MessageSid: options.messageSid ??
|
|
226
|
+
`an:${extractHandleFromAddress(fromAddress)}:${randomUUID()}`,
|
|
215
227
|
CommandAuthorized: true,
|
|
216
228
|
OriginatingChannel: "agent-network",
|
|
217
229
|
OriginatingTo: senderId,
|
|
@@ -230,9 +242,11 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
230
242
|
console.error(`[agent-network:${ctx.accountId}] session record error:`, err);
|
|
231
243
|
},
|
|
232
244
|
});
|
|
233
|
-
|
|
245
|
+
if (replyAddress)
|
|
246
|
+
client.sendTyping(replyAddress, true);
|
|
234
247
|
let replyDelivered = false;
|
|
235
248
|
let suppressedBlocks = 0;
|
|
249
|
+
let dispatchError;
|
|
236
250
|
try {
|
|
237
251
|
await runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
238
252
|
ctx: msgCtx,
|
|
@@ -242,6 +256,10 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
242
256
|
const text = payload.text;
|
|
243
257
|
if (!text)
|
|
244
258
|
return;
|
|
259
|
+
if (!replyAddress) {
|
|
260
|
+
suppressedBlocks++;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
245
263
|
if (!conversationManager.hasConversation(senderId)) {
|
|
246
264
|
suppressedBlocks++;
|
|
247
265
|
return;
|
|
@@ -250,7 +268,7 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
250
268
|
correlationId: inboundCorrelationId,
|
|
251
269
|
messageId: inboundMessageId,
|
|
252
270
|
});
|
|
253
|
-
const deliverResult = await conversationManager.send(
|
|
271
|
+
const deliverResult = await conversationManager.send(replyAddress, text, replyTrace.metadata);
|
|
254
272
|
if (deliverResult.status === "sent") {
|
|
255
273
|
replyDelivered = true;
|
|
256
274
|
}
|
|
@@ -260,26 +278,49 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
260
278
|
dbg("deliver reply senderId=%s status=%s contentLength=%d traceId=%s originalTraceId=%s spanName=send", senderId, deliverResult.status, text.length, replyTrace.traceId, replyTrace.originalTraceId ?? "(absent)");
|
|
261
279
|
},
|
|
262
280
|
onError: (err) => {
|
|
281
|
+
dispatchError = err;
|
|
263
282
|
console.error(`[agent-network:${ctx.accountId}] dispatch error:`, err);
|
|
264
283
|
},
|
|
265
284
|
},
|
|
266
285
|
});
|
|
286
|
+
if (dispatchError)
|
|
287
|
+
throw dispatchError;
|
|
267
288
|
if (suppressedBlocks > 0) {
|
|
268
|
-
console.warn(
|
|
289
|
+
console.warn(options.servicesRetained
|
|
290
|
+
? `[agent-network:${ctx.accountId}] reply not routed for Services-retained message: canonical envelope has no reply address blocks=${suppressedBlocks}`
|
|
291
|
+
: `[agent-network:${ctx.accountId}] reply suppressed (conversation ended) from=${senderId} blocks=${suppressedBlocks}`);
|
|
269
292
|
}
|
|
270
293
|
else if (!replyDelivered) {
|
|
271
294
|
console.log(`[agent-network:${ctx.accountId}] dispatch completed without in-turn reply text from=${senderId} (tool-path reply or silence)`);
|
|
272
295
|
}
|
|
273
296
|
}
|
|
274
297
|
finally {
|
|
275
|
-
|
|
298
|
+
if (replyAddress)
|
|
299
|
+
client.sendTyping(replyAddress, false);
|
|
276
300
|
conversationManager.commitEndedConversations();
|
|
277
301
|
}
|
|
302
|
+
return true;
|
|
278
303
|
}
|
|
279
304
|
catch (err) {
|
|
280
305
|
console.error(`[agent-network:${ctx.accountId}] inbound dispatch failed from=${fromAddress}:`, err);
|
|
306
|
+
return false;
|
|
281
307
|
}
|
|
282
308
|
}
|
|
309
|
+
function servicesRetainedSenderName(message) {
|
|
310
|
+
const { display_name: displayName, handle } = message.envelope.sender;
|
|
311
|
+
if (displayName && handle)
|
|
312
|
+
return `${displayName} (handle: ${handle})`;
|
|
313
|
+
return displayName ?? handle ?? "MASONS sender unavailable";
|
|
314
|
+
}
|
|
315
|
+
function servicesRetainedBody(message) {
|
|
316
|
+
const sender = servicesRetainedSenderName(message);
|
|
317
|
+
const displayName = message.envelope.sender.display_name;
|
|
318
|
+
const handle = message.envelope.sender.handle;
|
|
319
|
+
return [
|
|
320
|
+
`[MASONS canonical message_ref=${JSON.stringify(message.envelope.message_ref)}; sender_display_name=${displayName === undefined ? "absent" : JSON.stringify(displayName)}; sender_handle=${handle === undefined ? "absent" : JSON.stringify(handle)}; sender_label=${JSON.stringify(sender)}; content_type=${JSON.stringify(message.contentType)}]`,
|
|
321
|
+
message.envelope.content,
|
|
322
|
+
].join("\n\n");
|
|
323
|
+
}
|
|
283
324
|
const accounts = new Map();
|
|
284
325
|
export const agentNetworkChannel = {
|
|
285
326
|
id: "agent-network",
|
|
@@ -353,14 +394,36 @@ export const agentNetworkChannel = {
|
|
|
353
394
|
initToolConfig(ctx.cfg);
|
|
354
395
|
const { connectorUrl, token } = ctx.account;
|
|
355
396
|
const client = new ConnectorClient(connectorUrl, token);
|
|
356
|
-
const
|
|
397
|
+
const conversationManager = new ConversationManager(client);
|
|
398
|
+
const servicesRetainedRecipient = new ServicesRetainedRecipientConsumer({
|
|
357
399
|
apiHost: requirePlatformConfig().apiHost,
|
|
358
|
-
|
|
400
|
+
runtimeKey: token,
|
|
401
|
+
logger: {
|
|
402
|
+
info: (message) => console.log(`[agent-network:${ctx.accountId}] ${message}`),
|
|
403
|
+
warn: (message) => console.warn(`[agent-network:${ctx.accountId}] ${message}`),
|
|
404
|
+
error: (message, error) => console.error(`[agent-network:${ctx.accountId}] ${message}`, error ?? ""),
|
|
405
|
+
},
|
|
406
|
+
present: async (message) => handleAddressedMessage({
|
|
407
|
+
event: "MESSAGE_RECEIVED",
|
|
408
|
+
messageId: message.envelope.message_ref,
|
|
409
|
+
from: SERVICES_RETAINED_INBOX_PEER,
|
|
410
|
+
content: servicesRetainedBody(message),
|
|
411
|
+
contentType: message.contentType,
|
|
412
|
+
metadata: {},
|
|
413
|
+
...(message.envelope.sent_at && {
|
|
414
|
+
sentAt: message.envelope.sent_at,
|
|
415
|
+
}),
|
|
416
|
+
}, conversationManager, client, ctx, {
|
|
417
|
+
runtimePeerId: SERVICES_RETAINED_INBOX_PEER,
|
|
418
|
+
senderName: servicesRetainedSenderName(message),
|
|
419
|
+
messageSid: `an:${message.envelope.message_ref}`,
|
|
420
|
+
servicesRetained: true,
|
|
421
|
+
}),
|
|
359
422
|
});
|
|
360
|
-
const conversationManager = new ConversationManager(client, mstpAuthority);
|
|
361
423
|
const state = {
|
|
362
424
|
client,
|
|
363
425
|
conversationManager,
|
|
426
|
+
servicesRetainedRecipient,
|
|
364
427
|
};
|
|
365
428
|
accounts.set(ctx.accountId, state);
|
|
366
429
|
client.on("message_received", async (event) => {
|
|
@@ -368,6 +431,12 @@ export const agentNetworkChannel = {
|
|
|
368
431
|
return;
|
|
369
432
|
await handleAddressedMessage(event, conversationManager, client, ctx);
|
|
370
433
|
});
|
|
434
|
+
client.on("custody_pending", () => {
|
|
435
|
+
void servicesRetainedRecipient.requestDrain();
|
|
436
|
+
});
|
|
437
|
+
client.on("connected", () => {
|
|
438
|
+
void servicesRetainedRecipient.requestDrain();
|
|
439
|
+
});
|
|
371
440
|
client.on("delivery_pending", (event) => {
|
|
372
441
|
dbg("legacy delivery_pending ignored count=%d upTo=%s", event.count, event.upTo);
|
|
373
442
|
});
|
|
@@ -379,6 +448,7 @@ export const agentNetworkChannel = {
|
|
|
379
448
|
console.error(`[agent-network:${ctx.accountId}]`, err.message);
|
|
380
449
|
});
|
|
381
450
|
ctx.abortSignal.addEventListener("abort", () => {
|
|
451
|
+
void servicesRetainedRecipient.stop();
|
|
382
452
|
client.disconnect();
|
|
383
453
|
}, { once: true });
|
|
384
454
|
const networkCfg = extractNetworkConfig(ctx.cfg);
|
|
@@ -388,6 +458,7 @@ export const agentNetworkChannel = {
|
|
|
388
458
|
dbg("connected account=%s", ctx.accountId);
|
|
389
459
|
initConnectorClient(client);
|
|
390
460
|
initConversationManager(conversationManager);
|
|
461
|
+
void servicesRetainedRecipient.start();
|
|
391
462
|
await new Promise((resolve) => {
|
|
392
463
|
if (ctx.abortSignal.aborted) {
|
|
393
464
|
resolve();
|
|
@@ -402,6 +473,7 @@ export const agentNetworkChannel = {
|
|
|
402
473
|
dbg("stopping account %s", ctx.accountId);
|
|
403
474
|
const state = accounts.get(ctx.accountId);
|
|
404
475
|
if (state) {
|
|
476
|
+
await state.servicesRetainedRecipient.stop();
|
|
405
477
|
clearConversationManager();
|
|
406
478
|
clearConnectorClient();
|
|
407
479
|
state.client.removeAllListeners();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import { type AddressedMessageEvent, type DeliveryPendingEvent, type DeliveryStatusEvent, type SendAckEvent, type StructuredErrorEvent } from "./types.js";
|
|
2
|
+
import { type AddressedMessageEvent, type CustodyPendingEvent, type DeliveryPendingEvent, type DeliveryStatusEvent, type SendAckEvent, type StructuredErrorEvent } from "./types.js";
|
|
3
3
|
export declare class ConnectorError extends Error {
|
|
4
4
|
readonly code: string;
|
|
5
5
|
readonly to?: string;
|
|
@@ -7,6 +7,7 @@ export declare class ConnectorError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
type ConnectorClientEvents = {
|
|
9
9
|
message_received: (event: AddressedMessageEvent) => void;
|
|
10
|
+
custody_pending: (event: CustodyPendingEvent) => void;
|
|
10
11
|
send_ack: (event: SendAckEvent) => void;
|
|
11
12
|
delivery_pending: (event: DeliveryPendingEvent) => void;
|
|
12
13
|
delivery_status: (event: DeliveryStatusEvent) => void;
|
|
@@ -27,7 +28,6 @@ export declare class ConnectorClient extends EventEmitter {
|
|
|
27
28
|
private registerReject;
|
|
28
29
|
private registerTimer;
|
|
29
30
|
private lastKnownSeq;
|
|
30
|
-
private highestWireSeq;
|
|
31
31
|
private readonly pendingSeqMessages;
|
|
32
32
|
private readonly seenPayloadIds;
|
|
33
33
|
private readonly seenPayloadIdOrder;
|
|
@@ -56,8 +56,6 @@ export declare class ConnectorClient extends EventEmitter {
|
|
|
56
56
|
private dispatchAddressed;
|
|
57
57
|
private handleAddressedMessage;
|
|
58
58
|
private handleDeliverySkip;
|
|
59
|
-
private adoptLedgerDeliveryCursor;
|
|
60
|
-
private adoptDeliveredFloor;
|
|
61
59
|
private acceptContiguous;
|
|
62
60
|
private drainPendingSeqMessagesFrom;
|
|
63
61
|
private rememberPayloadId;
|
|
@@ -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,EAEzB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"connector-client.d.ts","sourceRoot":"","sources":["../src/connector-client.ts"],"names":[],"mappings":"AACA,OAAO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+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, isDeliveryCursor, isDeliveryPending, isDeliverySkip, isDeliveryStatus, isRegisterAck, isSendAck, isStructuredError, REGISTER_ACK_TIMEOUT_MS, SEND_ACK_TIMEOUT_MS, } from "./types.js";
|
|
6
|
+
import { CURRENT_PROTOCOL_VERSION, isAddressedMessage, isCustodyPending, isDeliveryCursor, isDeliveryPending, isDeliverySkip, 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");
|
|
@@ -36,7 +36,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
36
36
|
registerReject = null;
|
|
37
37
|
registerTimer = null;
|
|
38
38
|
lastKnownSeq;
|
|
39
|
-
highestWireSeq = 0;
|
|
40
39
|
pendingSeqMessages = new Map();
|
|
41
40
|
seenPayloadIds = new Set();
|
|
42
41
|
seenPayloadIdOrder = [];
|
|
@@ -127,7 +126,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
127
126
|
const ws = new WebSocket(this.url, { handshakeTimeout: 10_000 });
|
|
128
127
|
this.ws = ws;
|
|
129
128
|
ws.on("open", () => {
|
|
130
|
-
this.highestWireSeq = 0;
|
|
131
129
|
this.sendRegister();
|
|
132
130
|
this.startRegisterTimeout();
|
|
133
131
|
});
|
|
@@ -203,6 +201,11 @@ export class ConnectorClient extends EventEmitter {
|
|
|
203
201
|
this.handleAddressedMessage(parsed);
|
|
204
202
|
return;
|
|
205
203
|
}
|
|
204
|
+
if (isCustodyPending(parsed)) {
|
|
205
|
+
dbg("CUSTODY_PENDING");
|
|
206
|
+
this.emit("custody_pending", parsed);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
206
209
|
if (isDeliveryPending(parsed)) {
|
|
207
210
|
dbg("DELIVERY_PENDING count=%d upTo=%s", parsed.count, parsed.upTo);
|
|
208
211
|
this.emit("delivery_pending", parsed);
|
|
@@ -214,34 +217,10 @@ export class ConnectorClient extends EventEmitter {
|
|
|
214
217
|
return;
|
|
215
218
|
}
|
|
216
219
|
if (isDeliveryCursor(parsed)) {
|
|
217
|
-
if (parsed.deliveredSeq !== undefined &&
|
|
218
|
-
parsed.deliveredSeq > this.highestWireSeq) {
|
|
219
|
-
this.highestWireSeq = parsed.deliveredSeq;
|
|
220
|
-
}
|
|
221
220
|
const floor = this.lastKnownSeq ?? 0;
|
|
222
|
-
dbg("DELIVERY_CURSOR deliverySeq=%d deliveredSeq=%s local=%d", parsed.deliverySeq, parsed.deliveredSeq ?? "none", floor);
|
|
223
|
-
if (parsed.
|
|
224
|
-
this.
|
|
225
|
-
}
|
|
226
|
-
const reconciledFloor = this.lastKnownSeq ?? 0;
|
|
227
|
-
if (parsed.deliverySeq > reconciledFloor) {
|
|
228
|
-
this.requestGapFill(reconciledFloor);
|
|
229
|
-
}
|
|
230
|
-
else if (parsed.deliveredSeq !== undefined &&
|
|
231
|
-
this.lastKnownSeq !== undefined &&
|
|
232
|
-
parsed.deliveredSeq < this.lastKnownSeq) {
|
|
233
|
-
if (parsed.deliverySeq < this.lastKnownSeq &&
|
|
234
|
-
this.highestWireSeq <= parsed.deliverySeq) {
|
|
235
|
-
const adopted = parsed.deliveredSeq;
|
|
236
|
-
console.warn(`[agent-network] delivery cursor unattainable: local claim ${this.lastKnownSeq} exceeds the ledger's highest reserved seq ${parsed.deliverySeq}; adopting the ledger floor ${adopted}. Messages are being recovered from that point.`);
|
|
237
|
-
this.adoptLedgerDeliveryCursor(adopted);
|
|
238
|
-
if (parsed.deliverySeq > adopted) {
|
|
239
|
-
this.requestGapFill(adopted);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.ackDelivery(this.lastKnownSeq);
|
|
244
|
-
}
|
|
221
|
+
dbg("DELIVERY_CURSOR (legacy) deliverySeq=%d deliveredSeq=%s local=%d", parsed.deliverySeq, parsed.deliveredSeq ?? "none", floor);
|
|
222
|
+
if (parsed.deliverySeq > floor) {
|
|
223
|
+
this.requestGapFill(floor);
|
|
245
224
|
}
|
|
246
225
|
return;
|
|
247
226
|
}
|
|
@@ -265,8 +244,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
265
244
|
this.emit("message_received", message);
|
|
266
245
|
return;
|
|
267
246
|
}
|
|
268
|
-
if (message.seq > this.highestWireSeq)
|
|
269
|
-
this.highestWireSeq = message.seq;
|
|
270
247
|
const floor = this.lastKnownSeq ?? 0;
|
|
271
248
|
if (message.seq <= floor)
|
|
272
249
|
return;
|
|
@@ -278,8 +255,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
278
255
|
this.acceptContiguous(message);
|
|
279
256
|
}
|
|
280
257
|
handleDeliverySkip(event) {
|
|
281
|
-
if (event.seq > this.highestWireSeq)
|
|
282
|
-
this.highestWireSeq = event.seq;
|
|
283
258
|
const floor = this.lastKnownSeq ?? 0;
|
|
284
259
|
if (event.seq <= floor)
|
|
285
260
|
return;
|
|
@@ -291,28 +266,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
291
266
|
this.drainPendingSeqMessagesFrom(event.seq + 1);
|
|
292
267
|
this.ackDelivery(this.lastKnownSeq);
|
|
293
268
|
}
|
|
294
|
-
adoptLedgerDeliveryCursor(seq) {
|
|
295
|
-
this.pendingSeqMessages.clear();
|
|
296
|
-
this.seenPayloadIds.clear();
|
|
297
|
-
this.seenPayloadIdOrder.length = 0;
|
|
298
|
-
this.lastKnownSeq = seq;
|
|
299
|
-
}
|
|
300
|
-
adoptDeliveredFloor(seq) {
|
|
301
|
-
if (!Number.isInteger(seq) || seq < 0)
|
|
302
|
-
return;
|
|
303
|
-
const floor = this.lastKnownSeq ?? 0;
|
|
304
|
-
if (seq <= floor)
|
|
305
|
-
return;
|
|
306
|
-
this.lastKnownSeq = seq;
|
|
307
|
-
for (const pendingSeq of [...this.pendingSeqMessages.keys()]) {
|
|
308
|
-
if (pendingSeq <= seq)
|
|
309
|
-
this.pendingSeqMessages.delete(pendingSeq);
|
|
310
|
-
}
|
|
311
|
-
this.drainPendingSeqMessagesFrom(seq + 1);
|
|
312
|
-
if (this.lastKnownSeq > seq) {
|
|
313
|
-
this.ackDelivery(this.lastKnownSeq);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
269
|
acceptContiguous(message) {
|
|
317
270
|
const seq = message.seq;
|
|
318
271
|
if (typeof seq !== "number")
|
|
@@ -367,12 +320,6 @@ export class ConnectorClient extends EventEmitter {
|
|
|
367
320
|
}
|
|
368
321
|
dbg("delivery cursor initialized from register ack: %d", ack.deliverySeq);
|
|
369
322
|
}
|
|
370
|
-
else if (typeof ack.deliverySeq === "number" &&
|
|
371
|
-
this.lastKnownSeq !== undefined &&
|
|
372
|
-
ack.deliverySeq < this.lastKnownSeq) {
|
|
373
|
-
this.ackDelivery(this.lastKnownSeq);
|
|
374
|
-
dbg("delivery cursor re-ack requested: server=%d local=%d", ack.deliverySeq, this.lastKnownSeq);
|
|
375
|
-
}
|
|
376
323
|
this.backoffMs = BACKOFF_INITIAL_MS;
|
|
377
324
|
this.alreadyConnectedRetries = 0;
|
|
378
325
|
this.resolveRegister();
|
|
@@ -9,9 +9,4 @@ export declare function resolveConnectorUrlForSetup(input: {
|
|
|
9
9
|
configuredConnectorUrl?: string;
|
|
10
10
|
defaultConnectorUrl?: string;
|
|
11
11
|
}): string;
|
|
12
|
-
export declare const MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST: Record<string, string>;
|
|
13
|
-
export declare function resolveMstpAuthority(input: {
|
|
14
|
-
apiHost: string;
|
|
15
|
-
connectorUrl: string;
|
|
16
|
-
}): string;
|
|
17
12
|
//# sourceMappingURL=connector-url-boundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-url-boundary.d.ts","sourceRoot":"","sources":["../src/connector-url-boundary.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGrE,CAAC;AAEF,eAAO,MAAM,qCAAqC,aAGhD,CAAC;AAEH,qBAAa,8BAA+B,SAAQ,KAAK;IAC9C,IAAI,SAAoC;CAClD;AA+CD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,MAAM,CA4BT
|
|
1
|
+
{"version":3,"file":"connector-url-boundary.d.ts","sourceRoot":"","sources":["../src/connector-url-boundary.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGrE,CAAC;AAEF,eAAO,MAAM,qCAAqC,aAGhD,CAAC;AAEH,qBAAa,8BAA+B,SAAQ,KAAK;IAC9C,IAAI,SAAoC;CAClD;AA+CD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,MAAM,CA4BT"}
|
|
@@ -64,16 +64,3 @@ export function resolveConnectorUrlForSetup(input) {
|
|
|
64
64
|
}
|
|
65
65
|
throw new ConnectorUrlConfigurationError(`connectorUrl is required for self-hosted apiHost "${normalizeHost(input.apiHost)}". Configure the Connector transport URL explicitly; the MASONS preview Connector default is only used for MASONS Cloud accounts.`);
|
|
66
66
|
}
|
|
67
|
-
export const MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST = {
|
|
68
|
-
"api.masons.ai": "masons.ai",
|
|
69
|
-
"preview-api.masons.ai": "preview.masons.ai",
|
|
70
|
-
};
|
|
71
|
-
export function resolveMstpAuthority(input) {
|
|
72
|
-
const cloudAuthority = MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST[normalizeHost(input.apiHost)];
|
|
73
|
-
if (cloudAuthority)
|
|
74
|
-
return cloudAuthority;
|
|
75
|
-
const parsed = parseUrl(input.connectorUrl);
|
|
76
|
-
if (parsed)
|
|
77
|
-
return parsed.host;
|
|
78
|
-
return input.connectorUrl.replace(/^wss?:\/\//, "").replace(/\/.*$/, "");
|
|
79
|
-
}
|
|
@@ -28,9 +28,9 @@ export interface InboundEnvelope {
|
|
|
28
28
|
export declare const REPLY_CORRELATION_MAX_AGE_MS: number;
|
|
29
29
|
export declare class ConversationManager {
|
|
30
30
|
private readonly client;
|
|
31
|
-
private readonly mstpAuthority;
|
|
32
31
|
private readonly conversations;
|
|
33
|
-
|
|
32
|
+
private readonly pendingOutreach;
|
|
33
|
+
constructor(client: ConnectorClient);
|
|
34
34
|
send(contact: string, content: string, metadata?: Record<string, unknown>): Promise<SendResult>;
|
|
35
35
|
registerInbound(contact: string, address: string): void;
|
|
36
36
|
recordInboundEnvelope(address: string, envelope: Omit<InboundEnvelope, "receivedAt">): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-manager.d.ts","sourceRoot":"","sources":["../src/conversation-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation-manager.d.ts","sourceRoot":"","sources":["../src/conversation-manager.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAa7E,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC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