usebeeline 0.0.71 → 0.0.72
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/usebeeline.mjs +25 -7
- package/package.json +1 -1
package/dist/usebeeline.mjs
CHANGED
|
@@ -18058,6 +18058,9 @@ async function runServerCommandIntake(options) {
|
|
|
18058
18058
|
let busy;
|
|
18059
18059
|
let wake;
|
|
18060
18060
|
let pushIntakeAcknowledged = false;
|
|
18061
|
+
let reconciliation;
|
|
18062
|
+
let reconciliationError;
|
|
18063
|
+
let stopped = false;
|
|
18061
18064
|
const pending = new Map(first.commands.map((command) => [command.id, command]));
|
|
18062
18065
|
const claimed = /* @__PURE__ */ new Set();
|
|
18063
18066
|
const notify2 = (commands = []) => {
|
|
@@ -18066,6 +18069,21 @@ async function runServerCommandIntake(options) {
|
|
|
18066
18069
|
pending.set(command.id, command);
|
|
18067
18070
|
wake?.(false);
|
|
18068
18071
|
};
|
|
18072
|
+
const requestReconciliation = () => {
|
|
18073
|
+
if (reconciliation)
|
|
18074
|
+
return;
|
|
18075
|
+
reconciliation = api.execute("getAgentCommands", { roomId }).then((page) => {
|
|
18076
|
+
if (page.commandProtocol !== 1)
|
|
18077
|
+
throw new Error("server command protocol changed; refusing intake");
|
|
18078
|
+
if (!stopped)
|
|
18079
|
+
notify2(page.commands);
|
|
18080
|
+
}).catch((error) => {
|
|
18081
|
+
reconciliationError = error;
|
|
18082
|
+
wake?.(false);
|
|
18083
|
+
}).finally(() => {
|
|
18084
|
+
reconciliation = void 0;
|
|
18085
|
+
});
|
|
18086
|
+
};
|
|
18069
18087
|
options.onWake?.(notify2);
|
|
18070
18088
|
const off = api.liveSubscribe?.(roomId, void 0, void 0, (connected, capabilities) => {
|
|
18071
18089
|
const acknowledged = connected && capabilities?.pushIntake === true;
|
|
@@ -18078,6 +18096,8 @@ async function runServerCommandIntake(options) {
|
|
|
18078
18096
|
}, options.presence, notify2);
|
|
18079
18097
|
try {
|
|
18080
18098
|
while (!signal?.aborted) {
|
|
18099
|
+
if (reconciliationError)
|
|
18100
|
+
throw reconciliationError;
|
|
18081
18101
|
if (options.closed && await options.closed())
|
|
18082
18102
|
return;
|
|
18083
18103
|
for (const command of [...pending.values()]) {
|
|
@@ -18085,6 +18105,7 @@ async function runServerCommandIntake(options) {
|
|
|
18085
18105
|
if (busy && command.action !== "stop")
|
|
18086
18106
|
continue;
|
|
18087
18107
|
pending.delete(command.id);
|
|
18108
|
+
claimed.add(command.id);
|
|
18088
18109
|
try {
|
|
18089
18110
|
await api.execute("claimAgentCommand", {
|
|
18090
18111
|
roomId,
|
|
@@ -18092,10 +18113,10 @@ async function runServerCommandIntake(options) {
|
|
|
18092
18113
|
generationId: context.generationId
|
|
18093
18114
|
});
|
|
18094
18115
|
} catch (error) {
|
|
18116
|
+
claimed.delete(command.id);
|
|
18095
18117
|
options.onError?.(error);
|
|
18096
18118
|
continue;
|
|
18097
18119
|
}
|
|
18098
|
-
claimed.add(command.id);
|
|
18099
18120
|
if (command.action === "stop") {
|
|
18100
18121
|
options.stop(command.turnRequestId);
|
|
18101
18122
|
await api.execute("acknowledgeAgentCommand", {
|
|
@@ -18133,14 +18154,11 @@ async function runServerCommandIntake(options) {
|
|
|
18133
18154
|
});
|
|
18134
18155
|
if (signal?.aborted)
|
|
18135
18156
|
break;
|
|
18136
|
-
if (reconcile)
|
|
18137
|
-
|
|
18138
|
-
if (page.commandProtocol !== 1)
|
|
18139
|
-
throw new Error("server command protocol changed; refusing intake");
|
|
18140
|
-
notify2(page.commands);
|
|
18141
|
-
}
|
|
18157
|
+
if (reconcile)
|
|
18158
|
+
requestReconciliation();
|
|
18142
18159
|
}
|
|
18143
18160
|
} finally {
|
|
18161
|
+
stopped = true;
|
|
18144
18162
|
off?.();
|
|
18145
18163
|
options.onWake?.(void 0);
|
|
18146
18164
|
if (context.current)
|