@moxt-ai/mobius 0.0.154 → 0.0.155
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/cli.js +34 -317
- package/dist/cli.js.map +4 -4
- package/dist/daemon-turn-registry.d.ts +13 -13
- package/dist/index.js +33 -316
- package/dist/index.js.map +4 -4
- package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
- package/dist/relay-connection/run-relay-connection.js +2 -15
- package/dist/relay-connection/run-relay-connection.js.map +1 -1
- package/dist/relay-connection/session-event-publisher.d.ts +4 -9
- package/dist/relay-connection/session-event-publisher.d.ts.map +1 -1
- package/dist/relay-connection/session-event-publisher.js +26 -140
- package/dist/relay-connection/session-event-publisher.js.map +1 -1
- package/dist/run-daemon.js +1 -1
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +37 -320
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
- package/dist/relay-connection/session-event-queue.d.ts +0 -14
- package/dist/relay-connection/session-event-queue.d.ts.map +0 -1
- package/dist/relay-connection/session-event-queue.js +0 -75
- package/dist/relay-connection/session-event-queue.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.155",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -29338,16 +29338,8 @@ function decodeSessionQueuedEvent(encoded) {
|
|
|
29338
29338
|
function decodeRuntimeLivenessReadyEvent(encoded) {
|
|
29339
29339
|
const value = parseJson2(encoded);
|
|
29340
29340
|
assertKind(value, RUNTIME_LIVENESS_READY_KIND);
|
|
29341
|
-
|
|
29342
|
-
|
|
29343
|
-
return { kind: RUNTIME_LIVENESS_READY_KIND };
|
|
29344
|
-
}
|
|
29345
|
-
assertExactKeys(value, ["kind", "sessionEventDelivery"]);
|
|
29346
|
-
const sessionEventDelivery = readString2(value, "sessionEventDelivery", 32);
|
|
29347
|
-
if (sessionEventDelivery !== "reliable-v1") {
|
|
29348
|
-
throw new ProtocolMessageError("Unsupported Session event delivery mode");
|
|
29349
|
-
}
|
|
29350
|
-
return { kind: RUNTIME_LIVENESS_READY_KIND, sessionEventDelivery };
|
|
29341
|
+
assertExactKeys(value, ["kind"]);
|
|
29342
|
+
return { kind: RUNTIME_LIVENESS_READY_KIND };
|
|
29351
29343
|
}
|
|
29352
29344
|
function decodeRuntimeHeartbeatEvent(encoded) {
|
|
29353
29345
|
const value = parseJson2(encoded);
|
|
@@ -29814,60 +29806,13 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
|
|
|
29814
29806
|
|
|
29815
29807
|
// ../protocol/src/session-events.ts
|
|
29816
29808
|
var SESSION_EVENT_KIND = "session.event";
|
|
29817
|
-
var SESSION_EVENT_ACK_KIND = "session.event.ack";
|
|
29818
|
-
var SESSION_EVENT_DEFERRED_KIND = "session.event.deferred";
|
|
29819
|
-
var SESSION_EVENT_REJECTED_KIND = "session.event.rejected";
|
|
29820
29809
|
var SESSION_FORKED_KIND = "session.forked";
|
|
29821
|
-
var SessionEventRejectionCode = {
|
|
29822
|
-
IdempotencyConflict: "idempotency_conflict",
|
|
29823
|
-
InvalidEvent: "invalid_event",
|
|
29824
|
-
RecordingRejected: "recording_rejected"
|
|
29825
|
-
};
|
|
29826
29810
|
var MAX_RECORDED_EVENT_LENGTH = 8 * 1024 * 1024;
|
|
29827
|
-
var
|
|
29828
|
-
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
29829
|
-
payload: external_exports.string().min(2).max(MAX_RECORDED_EVENT_LENGTH),
|
|
29830
|
-
sessionId: identifierStringSchema
|
|
29831
|
-
}).readonly();
|
|
29832
|
-
var reliableDeliverySchema = external_exports.strictObject({
|
|
29833
|
-
eventId: identifierStringSchema,
|
|
29834
|
-
kind: external_exports.literal("reliable"),
|
|
29835
|
-
sourceSeq: external_exports.string().regex(/^(?:0|[1-9][0-9]*)$/u).max(40),
|
|
29836
|
-
streamId: identifierStringSchema
|
|
29837
|
-
}).readonly();
|
|
29838
|
-
var reliableSessionEventEnvelopeSchema = external_exports.strictObject({
|
|
29839
|
-
delivery: reliableDeliverySchema,
|
|
29811
|
+
var sessionEventEnvelopeSchema = external_exports.strictObject({
|
|
29840
29812
|
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
29841
29813
|
payload: external_exports.string().min(2).max(MAX_RECORDED_EVENT_LENGTH),
|
|
29842
29814
|
sessionId: identifierStringSchema
|
|
29843
29815
|
}).readonly();
|
|
29844
|
-
var eventEnvelopeSchema = external_exports.union([ephemeralEventEnvelopeSchema, reliableSessionEventEnvelopeSchema]).readonly();
|
|
29845
|
-
var acknowledgementOutcomeSchema = external_exports.discriminatedUnion("kind", [
|
|
29846
|
-
external_exports.strictObject({ kind: external_exports.literal("relayed") }).readonly(),
|
|
29847
|
-
external_exports.strictObject({
|
|
29848
|
-
kind: external_exports.literal("recorded"),
|
|
29849
|
-
providerId: identifierStringSchema,
|
|
29850
|
-
recordingEpoch: identifierStringSchema
|
|
29851
|
-
}).readonly()
|
|
29852
|
-
]);
|
|
29853
|
-
var eventAcknowledgementSchema = external_exports.strictObject({
|
|
29854
|
-
eventId: identifierStringSchema,
|
|
29855
|
-
kind: external_exports.literal(SESSION_EVENT_ACK_KIND),
|
|
29856
|
-
outcome: acknowledgementOutcomeSchema,
|
|
29857
|
-
sessionId: identifierStringSchema
|
|
29858
|
-
}).readonly();
|
|
29859
|
-
var eventDeferredSchema = external_exports.strictObject({
|
|
29860
|
-
eventId: identifierStringSchema,
|
|
29861
|
-
kind: external_exports.literal(SESSION_EVENT_DEFERRED_KIND),
|
|
29862
|
-
retryAfterMilliseconds: external_exports.number().int().min(100).max(6e4),
|
|
29863
|
-
sessionId: identifierStringSchema
|
|
29864
|
-
}).readonly();
|
|
29865
|
-
var eventRejectedSchema = external_exports.strictObject({
|
|
29866
|
-
code: external_exports.enum(SessionEventRejectionCode),
|
|
29867
|
-
eventId: identifierStringSchema,
|
|
29868
|
-
kind: external_exports.literal(SESSION_EVENT_REJECTED_KIND),
|
|
29869
|
-
sessionId: identifierStringSchema
|
|
29870
|
-
}).readonly();
|
|
29871
29816
|
var SESSION_QUEUE_CHANGED_KIND = "session.queue.changed";
|
|
29872
29817
|
var sessionQueueChangedSchema = external_exports.strictObject({ kind: external_exports.literal(SESSION_QUEUE_CHANGED_KIND), sessionId: identifierStringSchema }).readonly();
|
|
29873
29818
|
var sessionForkedSchema = external_exports.strictObject({
|
|
@@ -29900,14 +29845,8 @@ var encode4 = (message, schema) => {
|
|
|
29900
29845
|
}
|
|
29901
29846
|
return JSON.stringify(decoded.data);
|
|
29902
29847
|
};
|
|
29903
|
-
var decodeSessionEventEnvelope = (encoded) => decode5(encoded,
|
|
29904
|
-
var encodeSessionEventEnvelope = (message) => encode4(message,
|
|
29905
|
-
var decodeSessionEventAcknowledgement = (encoded) => decode5(encoded, eventAcknowledgementSchema);
|
|
29906
|
-
var encodeSessionEventAcknowledgement = (message) => encode4(message, eventAcknowledgementSchema);
|
|
29907
|
-
var decodeSessionEventDeferred = (encoded) => decode5(encoded, eventDeferredSchema);
|
|
29908
|
-
var encodeSessionEventDeferred = (message) => encode4(message, eventDeferredSchema);
|
|
29909
|
-
var decodeSessionEventRejected = (encoded) => decode5(encoded, eventRejectedSchema);
|
|
29910
|
-
var encodeSessionEventRejected = (message) => encode4(message, eventRejectedSchema);
|
|
29848
|
+
var decodeSessionEventEnvelope = (encoded) => decode5(encoded, sessionEventEnvelopeSchema);
|
|
29849
|
+
var encodeSessionEventEnvelope = (message) => encode4(message, sessionEventEnvelopeSchema);
|
|
29911
29850
|
function decodeRecordedSessionEvent(encoded) {
|
|
29912
29851
|
const kind = decodeMessageKind(encoded);
|
|
29913
29852
|
switch (kind) {
|
|
@@ -30081,21 +30020,6 @@ var serviceToDaemonSignatures = {
|
|
|
30081
30020
|
encodeSessionElicitationRespondCommand,
|
|
30082
30021
|
decodeSessionElicitationRespondCommand
|
|
30083
30022
|
),
|
|
30084
|
-
[SESSION_EVENT_ACK_KIND]: defineMessageSignature(
|
|
30085
|
-
SESSION_EVENT_ACK_KIND,
|
|
30086
|
-
encodeSessionEventAcknowledgement,
|
|
30087
|
-
decodeSessionEventAcknowledgement
|
|
30088
|
-
),
|
|
30089
|
-
[SESSION_EVENT_DEFERRED_KIND]: defineMessageSignature(
|
|
30090
|
-
SESSION_EVENT_DEFERRED_KIND,
|
|
30091
|
-
encodeSessionEventDeferred,
|
|
30092
|
-
decodeSessionEventDeferred
|
|
30093
|
-
),
|
|
30094
|
-
[SESSION_EVENT_REJECTED_KIND]: defineMessageSignature(
|
|
30095
|
-
SESSION_EVENT_REJECTED_KIND,
|
|
30096
|
-
encodeSessionEventRejected,
|
|
30097
|
-
decodeSessionEventRejected
|
|
30098
|
-
),
|
|
30099
30023
|
[SESSION_LIVE_HISTORY_LOAD_KIND]: defineMessageSignature(
|
|
30100
30024
|
SESSION_LIVE_HISTORY_LOAD_KIND,
|
|
30101
30025
|
encodeSessionLiveHistoryLoad,
|
|
@@ -31154,7 +31078,7 @@ var AuditStore = class {
|
|
|
31154
31078
|
};
|
|
31155
31079
|
|
|
31156
31080
|
// src/run-daemon.ts
|
|
31157
|
-
import { createHash as createHash6, randomUUID as
|
|
31081
|
+
import { createHash as createHash6, randomUUID as randomUUID7 } from "node:crypto";
|
|
31158
31082
|
import { join as join18 } from "node:path";
|
|
31159
31083
|
import { styleText } from "node:util";
|
|
31160
31084
|
|
|
@@ -46840,7 +46764,6 @@ async function runRelayConnection({
|
|
|
46840
46764
|
}) {
|
|
46841
46765
|
const relayUrl = new URL(config2.relayUrl);
|
|
46842
46766
|
relayUrl.searchParams.set("liveness", "1");
|
|
46843
|
-
relayUrl.searchParams.set("sessionEventDelivery", "reliable-v1");
|
|
46844
46767
|
const socket = await connectRelay(relayUrl, signal);
|
|
46845
46768
|
diagnostics.connectionOpened(connectionEpoch);
|
|
46846
46769
|
const connectionController = new AbortController();
|
|
@@ -46960,10 +46883,7 @@ async function runRelayConnection({
|
|
|
46960
46883
|
const message = decodeServiceToDaemonMessage(encoded);
|
|
46961
46884
|
const kind = message.kind;
|
|
46962
46885
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
46963
|
-
publisher.connect(
|
|
46964
|
-
socket,
|
|
46965
|
-
message.sessionEventDelivery === "reliable-v1" ? "reliable" : "ephemeral"
|
|
46966
|
-
);
|
|
46886
|
+
publisher.connect(socket);
|
|
46967
46887
|
connectionLiveness.start();
|
|
46968
46888
|
return;
|
|
46969
46889
|
}
|
|
@@ -46971,18 +46891,6 @@ async function runRelayConnection({
|
|
|
46971
46891
|
connectionLiveness.acknowledge(message);
|
|
46972
46892
|
return;
|
|
46973
46893
|
}
|
|
46974
|
-
if (kind === SESSION_EVENT_ACK_KIND) {
|
|
46975
|
-
publisher.acknowledge(message);
|
|
46976
|
-
return;
|
|
46977
|
-
}
|
|
46978
|
-
if (kind === SESSION_EVENT_DEFERRED_KIND) {
|
|
46979
|
-
publisher.defer(message);
|
|
46980
|
-
return;
|
|
46981
|
-
}
|
|
46982
|
-
if (kind === SESSION_EVENT_REJECTED_KIND) {
|
|
46983
|
-
publisher.reject(message);
|
|
46984
|
-
return;
|
|
46985
|
-
}
|
|
46986
46894
|
commands.handle(message);
|
|
46987
46895
|
} catch (error62) {
|
|
46988
46896
|
console.error("Mobius daemon rejected a message", error62);
|
|
@@ -47009,233 +46917,42 @@ async function runRelayConnection({
|
|
|
47009
46917
|
|
|
47010
46918
|
// src/relay-connection/session-event-publisher.ts
|
|
47011
46919
|
import { WebSocket as WebSocket9 } from "undici";
|
|
47012
|
-
|
|
47013
|
-
// src/relay-connection/session-event-queue.ts
|
|
47014
|
-
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
47015
|
-
var STANDARD_EVENT_BYTES = 96 * 1024 * 1024;
|
|
47016
|
-
var CRITICAL_EVENT_BYTES = 128 * 1024 * 1024;
|
|
47017
|
-
var SessionEventQueueCapacityError = class extends Error {
|
|
47018
|
-
code = "session_event_queue_full";
|
|
47019
|
-
constructor() {
|
|
47020
|
-
super("The in-memory Session event queue is full");
|
|
47021
|
-
this.name = "SessionEventQueueCapacityError";
|
|
47022
|
-
}
|
|
47023
|
-
};
|
|
47024
|
-
var SessionEventQueue = class {
|
|
47025
|
-
#streamId = randomUUID7();
|
|
47026
|
-
#events = /* @__PURE__ */ new Map();
|
|
47027
|
-
#nextSourceSeq = 1;
|
|
47028
|
-
#totalBytes = 0;
|
|
47029
|
-
enqueueBatch = (sessionId, payloads, critical) => {
|
|
47030
|
-
if (payloads.length < 1 || payloads.length > 32) {
|
|
47031
|
-
throw new Error("A Session event batch must contain between 1 and 32 events");
|
|
47032
|
-
}
|
|
47033
|
-
if (!Number.isSafeInteger(this.#nextSourceSeq + payloads.length)) {
|
|
47034
|
-
throw new Error("The Session event source sequence is exhausted");
|
|
47035
|
-
}
|
|
47036
|
-
const entries = payloads.map((payload, index) => {
|
|
47037
|
-
const envelope2 = {
|
|
47038
|
-
delivery: {
|
|
47039
|
-
eventId: randomUUID7(),
|
|
47040
|
-
kind: "reliable",
|
|
47041
|
-
sourceSeq: (this.#nextSourceSeq + index).toString(),
|
|
47042
|
-
streamId: this.#streamId
|
|
47043
|
-
},
|
|
47044
|
-
kind: SESSION_EVENT_KIND,
|
|
47045
|
-
payload,
|
|
47046
|
-
sessionId
|
|
47047
|
-
};
|
|
47048
|
-
return { envelope: envelope2, byteLength: Buffer.byteLength(encodeSessionEventEnvelope(envelope2), "utf8") };
|
|
47049
|
-
});
|
|
47050
|
-
const byteLength = entries.reduce((total, entry) => total + entry.byteLength, 0);
|
|
47051
|
-
if (this.#totalBytes + byteLength > (critical ? CRITICAL_EVENT_BYTES : STANDARD_EVENT_BYTES)) {
|
|
47052
|
-
throw new SessionEventQueueCapacityError();
|
|
47053
|
-
}
|
|
47054
|
-
for (const entry of entries) {
|
|
47055
|
-
this.#events.set(entry.envelope.delivery.eventId, entry);
|
|
47056
|
-
}
|
|
47057
|
-
this.#nextSourceSeq += entries.length;
|
|
47058
|
-
this.#totalBytes += byteLength;
|
|
47059
|
-
};
|
|
47060
|
-
pending = (limit, excludedEventIds) => {
|
|
47061
|
-
const result = [];
|
|
47062
|
-
for (const [eventId, entry] of this.#events) {
|
|
47063
|
-
if (!excludedEventIds.has(eventId)) {
|
|
47064
|
-
result.push(entry.envelope);
|
|
47065
|
-
if (result.length === limit) {
|
|
47066
|
-
break;
|
|
47067
|
-
}
|
|
47068
|
-
}
|
|
47069
|
-
}
|
|
47070
|
-
return result;
|
|
47071
|
-
};
|
|
47072
|
-
remove = (eventId, sessionId) => {
|
|
47073
|
-
const entry = this.#events.get(eventId);
|
|
47074
|
-
if (entry === void 0 || entry.envelope.sessionId !== sessionId) {
|
|
47075
|
-
return false;
|
|
47076
|
-
}
|
|
47077
|
-
this.#events.delete(eventId);
|
|
47078
|
-
this.#totalBytes -= entry.byteLength;
|
|
47079
|
-
return true;
|
|
47080
|
-
};
|
|
47081
|
-
clear = () => {
|
|
47082
|
-
this.#events.clear();
|
|
47083
|
-
this.#totalBytes = 0;
|
|
47084
|
-
};
|
|
47085
|
-
};
|
|
47086
|
-
|
|
47087
|
-
// src/relay-connection/session-event-publisher.ts
|
|
47088
|
-
var SESSION_EVENT_REPLAY_WINDOW = 16;
|
|
47089
|
-
var SESSION_EVENT_REPLAY_BYTE_LIMIT = 32 * 1024 * 1024;
|
|
47090
|
-
function reservesSessionEventCapacity(event) {
|
|
47091
|
-
if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND || event.kind === SESSION_FORKED_KIND || event.kind === SESSION_READY_KIND) {
|
|
47092
|
-
return true;
|
|
47093
|
-
}
|
|
47094
|
-
return event.kind === AGENT_ACTIVITY_KIND && (event.activityType === "progress" || event.activityType === "reasoning") && (event.status === "completed" || event.status === "failed");
|
|
47095
|
-
}
|
|
46920
|
+
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
47096
46921
|
var DaemonSessionEventPublisher = class {
|
|
47097
|
-
#
|
|
47098
|
-
|
|
47099
|
-
|
|
47100
|
-
#timer;
|
|
47101
|
-
#connection = { kind: "disconnected" };
|
|
47102
|
-
#deferredReplay = null;
|
|
47103
|
-
#inFlightBytes = 0;
|
|
47104
|
-
constructor(timer) {
|
|
47105
|
-
this.#timer = timer;
|
|
47106
|
-
}
|
|
47107
|
-
acknowledge = (acknowledgement) => {
|
|
47108
|
-
if (!this.#queue.remove(acknowledgement.eventId, acknowledgement.sessionId)) {
|
|
47109
|
-
return;
|
|
47110
|
-
}
|
|
47111
|
-
this.#removeInFlight(acknowledgement.eventId);
|
|
47112
|
-
this.#publishNextBatch();
|
|
47113
|
-
};
|
|
47114
|
-
close = () => {
|
|
47115
|
-
this.#deferredReplay?.cancel();
|
|
47116
|
-
this.#deferredReplay = null;
|
|
47117
|
-
this.#connection = { kind: "disconnected" };
|
|
47118
|
-
this.#clearInFlight();
|
|
47119
|
-
this.#queue.clear();
|
|
47120
|
-
};
|
|
47121
|
-
connect = (socket, delivery) => {
|
|
47122
|
-
this.#connection = { delivery, kind: "connected", socket };
|
|
47123
|
-
this.#clearInFlight();
|
|
47124
|
-
this.#publishNextBatch();
|
|
47125
|
-
};
|
|
47126
|
-
defer = (deferred) => {
|
|
47127
|
-
if (!this.#inFlight.has(deferred.eventId)) {
|
|
47128
|
-
return;
|
|
47129
|
-
}
|
|
47130
|
-
this.#clearInFlight();
|
|
47131
|
-
if (this.#deferredReplay !== null) {
|
|
47132
|
-
return;
|
|
47133
|
-
}
|
|
47134
|
-
this.#deferredReplay = this.#timer.schedule(() => {
|
|
47135
|
-
this.#deferredReplay = null;
|
|
47136
|
-
this.#publishNextBatch();
|
|
47137
|
-
}, deferred.retryAfterMilliseconds);
|
|
46922
|
+
#socket = null;
|
|
46923
|
+
connect = (socket) => {
|
|
46924
|
+
this.#socket = socket;
|
|
47138
46925
|
};
|
|
47139
46926
|
disconnect = (socket) => {
|
|
47140
|
-
if (this.#
|
|
47141
|
-
|
|
47142
|
-
}
|
|
47143
|
-
this.#connection = { kind: "disconnected" };
|
|
47144
|
-
this.#clearInFlight();
|
|
47145
|
-
};
|
|
47146
|
-
publish = (sessionId, event) => {
|
|
47147
|
-
try {
|
|
47148
|
-
this.#queue.enqueueBatch(
|
|
47149
|
-
sessionId,
|
|
47150
|
-
[encodeRecordedSessionEvent(event)],
|
|
47151
|
-
reservesSessionEventCapacity(event)
|
|
47152
|
-
);
|
|
47153
|
-
} catch (error62) {
|
|
47154
|
-
if (!(error62 instanceof SessionEventQueueCapacityError)) {
|
|
47155
|
-
throw error62;
|
|
47156
|
-
}
|
|
47157
|
-
if (!this.#reportedCapacityKinds.has(event.kind)) {
|
|
47158
|
-
this.#reportedCapacityKinds.add(event.kind);
|
|
47159
|
-
console.warn(`Mobius daemon could not buffer "${event.kind}" because the Session event queue is full`);
|
|
47160
|
-
}
|
|
47161
|
-
return;
|
|
47162
|
-
}
|
|
47163
|
-
this.#publishNextBatch();
|
|
47164
|
-
};
|
|
47165
|
-
publishBatch = (sessionId, events) => {
|
|
47166
|
-
const critical = events.some(reservesSessionEventCapacity);
|
|
47167
|
-
this.#queue.enqueueBatch(sessionId, events.map(encodeRecordedSessionEvent), critical);
|
|
47168
|
-
this.#publishNextBatch();
|
|
47169
|
-
};
|
|
47170
|
-
reject = (rejection) => {
|
|
47171
|
-
if (!this.#queue.remove(rejection.eventId, rejection.sessionId)) {
|
|
47172
|
-
return;
|
|
46927
|
+
if (this.#socket === socket) {
|
|
46928
|
+
this.#socket = null;
|
|
47173
46929
|
}
|
|
47174
|
-
this.#removeInFlight(rejection.eventId);
|
|
47175
|
-
console.error(`Mobius Relay rejected Session event ${rejection.eventId} with code ${rejection.code}`);
|
|
47176
|
-
this.#publishNextBatch();
|
|
47177
46930
|
};
|
|
47178
|
-
|
|
47179
|
-
this.#
|
|
47180
|
-
this.#inFlightBytes = 0;
|
|
46931
|
+
close = () => {
|
|
46932
|
+
this.#socket = null;
|
|
47181
46933
|
};
|
|
47182
|
-
|
|
47183
|
-
|
|
46934
|
+
publish = (sessionId, event) => {
|
|
46935
|
+
const socket = this.#socket;
|
|
46936
|
+
if (socket === null || socket.readyState !== WebSocket9.OPEN) {
|
|
47184
46937
|
return;
|
|
47185
46938
|
}
|
|
47186
|
-
|
|
47187
|
-
|
|
47188
|
-
|
|
47189
|
-
|
|
47190
|
-
|
|
47191
|
-
|
|
47192
|
-
|
|
47193
|
-
const encoded = encodeDaemonToServiceMessage(
|
|
47194
|
-
this.#connection.delivery === "reliable" ? envelope2 : {
|
|
47195
|
-
kind: envelope2.kind,
|
|
47196
|
-
payload: envelope2.payload,
|
|
47197
|
-
sessionId: envelope2.sessionId
|
|
47198
|
-
}
|
|
47199
|
-
);
|
|
47200
|
-
const byteLength = Buffer.byteLength(encoded, "utf8");
|
|
47201
|
-
if (this.#inFlightBytes + byteLength > SESSION_EVENT_REPLAY_BYTE_LIMIT) {
|
|
47202
|
-
return;
|
|
47203
|
-
}
|
|
47204
|
-
if (!this.#send(encoded)) {
|
|
47205
|
-
this.#clearInFlight();
|
|
47206
|
-
return;
|
|
47207
|
-
}
|
|
47208
|
-
if (this.#connection.delivery === "ephemeral") {
|
|
47209
|
-
this.#queue.remove(envelope2.delivery.eventId, envelope2.sessionId);
|
|
47210
|
-
sent += 1;
|
|
47211
|
-
continue;
|
|
47212
|
-
}
|
|
47213
|
-
this.#inFlight.set(envelope2.delivery.eventId, { byteLength });
|
|
47214
|
-
this.#inFlightBytes += byteLength;
|
|
47215
|
-
sent += 1;
|
|
47216
|
-
}
|
|
47217
|
-
if (sent === 0) {
|
|
47218
|
-
return;
|
|
47219
|
-
}
|
|
47220
|
-
}
|
|
47221
|
-
};
|
|
47222
|
-
#removeInFlight = (eventId) => {
|
|
47223
|
-
const inFlight = this.#inFlight.get(eventId);
|
|
47224
|
-
if (inFlight === void 0) {
|
|
46939
|
+
const encoded = encodeDaemonToServiceMessage({
|
|
46940
|
+
kind: SESSION_EVENT_KIND,
|
|
46941
|
+
payload: encodeRecordedSessionEvent(event),
|
|
46942
|
+
sessionId
|
|
46943
|
+
});
|
|
46944
|
+
if (socket.bufferedAmount + Buffer.byteLength(encoded, "utf8") > MAX_BUFFERED_BYTES) {
|
|
46945
|
+
socket.close(1013, "Live event transport overloaded");
|
|
47225
46946
|
return;
|
|
47226
46947
|
}
|
|
47227
|
-
this.#inFlight.delete(eventId);
|
|
47228
|
-
this.#inFlightBytes -= inFlight.byteLength;
|
|
47229
|
-
};
|
|
47230
|
-
#send = (encoded) => {
|
|
47231
|
-
if (this.#connection.kind !== "connected" || this.#connection.socket.readyState !== WebSocket9.OPEN) {
|
|
47232
|
-
return false;
|
|
47233
|
-
}
|
|
47234
46948
|
try {
|
|
47235
|
-
|
|
47236
|
-
return true;
|
|
46949
|
+
socket.send(encoded);
|
|
47237
46950
|
} catch {
|
|
47238
|
-
|
|
46951
|
+
}
|
|
46952
|
+
};
|
|
46953
|
+
publishBatch = (sessionId, events) => {
|
|
46954
|
+
for (const event of events) {
|
|
46955
|
+
this.publish(sessionId, event);
|
|
47239
46956
|
}
|
|
47240
46957
|
};
|
|
47241
46958
|
};
|
|
@@ -47297,7 +47014,7 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
47297
47014
|
{
|
|
47298
47015
|
agentId: agent.id,
|
|
47299
47016
|
kind: AGENT_INSTALL_REQUEST_KIND,
|
|
47300
|
-
requestId: `automatic-integration-${
|
|
47017
|
+
requestId: `automatic-integration-${randomUUID7()}`
|
|
47301
47018
|
},
|
|
47302
47019
|
signal
|
|
47303
47020
|
);
|
|
@@ -47319,7 +47036,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47319
47036
|
join18(stateDirectory, "sessions", `${createHash6("sha256").update(config2.channelId).digest("hex")}.sqlite`)
|
|
47320
47037
|
);
|
|
47321
47038
|
const operations = new DaemonOperationState();
|
|
47322
|
-
const publisher = new DaemonSessionEventPublisher(
|
|
47039
|
+
const publisher = new DaemonSessionEventPublisher();
|
|
47323
47040
|
const activeTurns = new DaemonTurnRegistry(operations);
|
|
47324
47041
|
const recordSessionEvent = (sessionId, event) => {
|
|
47325
47042
|
publisher.publish(sessionId, activeTurns.recordEvent(event));
|