@ouro.bot/cli 0.1.0-alpha.1727 → 0.1.0-alpha.1728
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/changelog.json +7 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/session-events.js +11 -1
- package/dist/senses/bluebubbles/index.js +40 -18
- package/dist/senses/bluebubbles/latest-turn.js +5 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "Each pull request writes its own change note under changes/; the release job on main gives each landed change its version and adds the notes here (scripts/release-version.cjs). On main this file stops at the last version set by hand; the published package has every release. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1728",
|
|
6
|
+
"changes": [
|
|
7
|
+
"An iMessage that a newer one overtakes is no longer lost. When a link's preview fetch fails and recovery picks the message up after a newer one already has the chat, or when recovery after an outage works through a chat newest first, each older message is still saved to the conversation once the current turn ends, in the order it was sent. It doesn't start a turn of its own, so the agent sees it as unanswered at the next turn, and catching up after an outage spends no recovery budget on it.",
|
|
8
|
+
"A message is now told apart from its own saved copy by the record of that exact arrival rather than by its words. A retry after a timeout or restart no longer saves it twice, and \"call\" next to \"call me\", two \"ok\"s in a row, or an edit of a message already saved all reach the conversation. Conversation history now keeps that record's id on each message a friend sends, where the sense provides one."
|
|
9
|
+
]
|
|
10
|
+
},
|
|
4
11
|
{
|
|
5
12
|
"version": "0.1.0-alpha.1727",
|
|
6
13
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1728</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -957,6 +957,9 @@ function getIngressRelations(msg) {
|
|
|
957
957
|
replyToEventId: typeof relations.replyToEventId === "string" ? relations.replyToEventId : null,
|
|
958
958
|
threadRootEventId: typeof relations.threadRootEventId === "string" ? relations.threadRootEventId : null,
|
|
959
959
|
references: Array.isArray(relations.references) ? relations.references.filter((item) => typeof item === "string") : [],
|
|
960
|
+
...(typeof relations.inboundMessageId === "string" && relations.inboundMessageId.length > 0
|
|
961
|
+
? { inboundMessageId: relations.inboundMessageId }
|
|
962
|
+
: {}),
|
|
960
963
|
};
|
|
961
964
|
}
|
|
962
965
|
function createEventTime(role, recordedAt, captureKind, ingressAt) {
|
|
@@ -1015,6 +1018,7 @@ function buildEventFromMessage(message, sequence, recordedAt, captureKind, sourc
|
|
|
1015
1018
|
captureKind,
|
|
1016
1019
|
legacyVersion,
|
|
1017
1020
|
sourceMessageIndex,
|
|
1021
|
+
...(role === "user" && ingressRelations?.inboundMessageId ? { inbound: { messageId: ingressRelations.inboundMessageId } } : {}),
|
|
1018
1022
|
},
|
|
1019
1023
|
};
|
|
1020
1024
|
}
|
|
@@ -1177,6 +1181,8 @@ function normalizeSessionEvent(event, index, recordedAt) {
|
|
|
1177
1181
|
const time = event.time;
|
|
1178
1182
|
const relations = event.relations;
|
|
1179
1183
|
const provenance = event.provenance;
|
|
1184
|
+
const inbound = provenance?.inbound;
|
|
1185
|
+
const inboundMessageId = typeof inbound?.messageId === "string" && inbound.messageId.length > 0 ? inbound.messageId : null;
|
|
1180
1186
|
const content = sanitizeConversationContent(role, normalizeContent(event.content));
|
|
1181
1187
|
return {
|
|
1182
1188
|
id: typeof event.id === "string" ? event.id : makeEventId(index + 1),
|
|
@@ -1210,6 +1216,7 @@ function normalizeSessionEvent(event, index, recordedAt) {
|
|
|
1210
1216
|
...(isSessionEventOutbound(provenance?.outbound)
|
|
1211
1217
|
? { outbound: { origin: provenance.outbound.origin, deliveryId: provenance.outbound.deliveryId } }
|
|
1212
1218
|
: {}),
|
|
1219
|
+
...(inboundMessageId ? { inbound: { messageId: inboundMessageId } } : {}),
|
|
1213
1220
|
},
|
|
1214
1221
|
};
|
|
1215
1222
|
}
|
|
@@ -1257,7 +1264,10 @@ function exactRawEvent(value, index) {
|
|
|
1257
1264
|
return false;
|
|
1258
1265
|
}
|
|
1259
1266
|
const provenance = value.provenance;
|
|
1260
|
-
|
|
1267
|
+
const provenanceKeys = provenance && typeof provenance === "object" && "inbound" in provenance
|
|
1268
|
+
? ["captureKind", "legacyVersion", "sourceMessageIndex", "inbound"]
|
|
1269
|
+
: ["captureKind", "legacyVersion", "sourceMessageIndex"];
|
|
1270
|
+
if (!exactKeys(provenance, provenanceKeys)
|
|
1261
1271
|
|| typeof provenance.captureKind !== "string" || !["live", "synthetic", "migration"].includes(provenance.captureKind)
|
|
1262
1272
|
|| !(provenance.legacyVersion === null || Number.isSafeInteger(provenance.legacyVersion) && Number(provenance.legacyVersion) > 0)
|
|
1263
1273
|
|| !(provenance.sourceMessageIndex === null || Number.isSafeInteger(provenance.sourceMessageIndex) && Number(provenance.sourceMessageIndex) >= 0))
|
|
@@ -79,6 +79,7 @@ const runtime_1 = require("../../nerves/runtime");
|
|
|
79
79
|
const session_transaction_1 = require("../../mind/session-transaction");
|
|
80
80
|
const outbound_record_1 = require("../../mind/outbound-record");
|
|
81
81
|
const await_alert_1 = require("../../heart/awaiting/await-alert");
|
|
82
|
+
const session_events_1 = require("../../heart/session-events");
|
|
82
83
|
const orientation_frame_1 = require("../../heart/orientation-frame");
|
|
83
84
|
const proactive_content_guard_1 = require("../proactive-content-guard");
|
|
84
85
|
const bluebubbles_meta_guard_1 = require("../bluebubbles-meta-guard");
|
|
@@ -763,6 +764,21 @@ function sessionAlreadyAnsweredMessage(event, existingMessages) {
|
|
|
763
764
|
const index = sessionUserMessageIndex(event, existingMessages);
|
|
764
765
|
return index >= 0 && existingMessages.slice(index + 1).some((message) => (message.role === "assistant" && !(0, outbound_record_1.isRecordedOutboundText)(extractMessageText(message.content))));
|
|
765
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* A superseded message's own earlier attempt may have saved it before its turn timed out or was shut down. That copy
|
|
769
|
+
* carries its capture key, which is one per inbound event (an edit has its own, apart from the message it edits); the
|
|
770
|
+
* same words in another message ("ok", "ok") do not.
|
|
771
|
+
*/
|
|
772
|
+
function sessionHoldsCapture(captureKeyHash, events) {
|
|
773
|
+
return (events ?? []).some((saved) => saved.provenance.inbound?.messageId === captureKeyHash);
|
|
774
|
+
}
|
|
775
|
+
/** Puts an overtaken message before the newer messages still waiting after the last reply, so they keep the order they were sent in. */
|
|
776
|
+
function beforeUnansweredMessages(messages, message) {
|
|
777
|
+
let index = messages.length;
|
|
778
|
+
while (index > 0 && messages[index - 1].role === "user")
|
|
779
|
+
index--;
|
|
780
|
+
return [...messages.slice(0, index), message, ...messages.slice(index)];
|
|
781
|
+
}
|
|
766
782
|
/** Drop the unanswered copy a dead turn left at the tail, so the replay adds the message once. */
|
|
767
783
|
function withoutUnansweredTail(event, messages) {
|
|
768
784
|
return sessionUserMessageIndex(event, messages) === messages.length - 1
|
|
@@ -1790,7 +1806,8 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
1790
1806
|
const agentName = resolvedDeps.getAgentName();
|
|
1791
1807
|
(0, runtime_cwd_1.recoverRuntimeCwd)();
|
|
1792
1808
|
let activeTurnId = null;
|
|
1793
|
-
|
|
1809
|
+
// The budget holds back recovery turns. A message a newer one has overtaken only goes into its session, so it spends none.
|
|
1810
|
+
if (shouldUseBlueBubblesRecoveryBudget(source, options) && (0, latest_turn_1.isCurrent)(options.latestTurnCapability)) {
|
|
1794
1811
|
const decision = (0, autonomy_budget_1.reserveAutonomyBudget)((0, identity_1.getAgentRoot)(agentName), {
|
|
1795
1812
|
agent: agentName,
|
|
1796
1813
|
triggerType: "recovery",
|
|
@@ -1881,15 +1898,21 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
1881
1898
|
// Pre-load session inside the canonical turn lock so same-chat
|
|
1882
1899
|
// deliveries cannot race on stale trunk state.
|
|
1883
1900
|
const existing = resolvedDeps.loadSession(sessPath);
|
|
1884
|
-
|
|
1901
|
+
// A newer message in this chat took it before this one's turn, so this one only goes into the session. Matching it
|
|
1902
|
+
// by contained text would take it for a newer message that contains it ("call" in "call me"); it is matched exactly.
|
|
1903
|
+
const superseded = !(0, latest_turn_1.isCurrent)(options.latestTurnCapability);
|
|
1904
|
+
const replay = options.semanticRecovery === true || source !== "webhook";
|
|
1905
|
+
const replaying = replay && !superseded;
|
|
1885
1906
|
const sessionMessages = existing?.messages && existing.messages.length > 0
|
|
1886
1907
|
? structuredClone(replaying ? withoutUnansweredTail(event, existing.messages) : existing.messages)
|
|
1887
1908
|
: [{ role: "system", content: (0, prompt_1.flattenSystemPrompt)(await resolvedDeps.buildSystem("bluebubbles", {}, context)) }];
|
|
1888
1909
|
// Record EARLY for audit and crash recovery. This is capture truth, not
|
|
1889
1910
|
// a claim that the agent turn completed successfully.
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1911
|
+
// Only a replay can find its own earlier copy; a first arrival never has one.
|
|
1912
|
+
const alreadySaved = replay && (superseded
|
|
1913
|
+
? sessionHoldsCapture(options.currentIngressEvidence.captureKeyHash, existing?.events)
|
|
1914
|
+
: sessionAlreadyAnsweredMessage(event, existing?.messages ?? sessionMessages));
|
|
1915
|
+
const inboundSource = alreadySaved ? "recovery-bootstrap" : source;
|
|
1893
1916
|
(0, inbound_log_1.recordBlueBubblesInbound)(agentName, event, inboundSource);
|
|
1894
1917
|
if (inboundSource === "recovery-bootstrap") {
|
|
1895
1918
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -1912,7 +1935,10 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
1912
1935
|
role: "user",
|
|
1913
1936
|
content: buildInboundContent(event),
|
|
1914
1937
|
};
|
|
1915
|
-
|
|
1938
|
+
(0, session_events_1.stampIngressRelations)(userMessage, { replyToEventId: null, threadRootEventId: null, references: [], inboundMessageId: options.currentIngressEvidence.captureKeyHash });
|
|
1939
|
+
resolvedDeps.saveSession(sessPath, options.overtaken
|
|
1940
|
+
? beforeUnansweredMessages(structuredClone(sessionMessages), structuredClone(userMessage))
|
|
1941
|
+
: [...structuredClone(sessionMessages), structuredClone(userMessage)], existing?.lastUsage, existing?.state);
|
|
1916
1942
|
const liveTurnId = (0, active_turns_1.beginBlueBubblesActiveTurn)(agentName, event);
|
|
1917
1943
|
activeTurnId = liveTurnId;
|
|
1918
1944
|
// Waiting for permission to send is bounded by the turn deadline and shutdown.
|
|
@@ -3083,23 +3109,18 @@ async function handleCapturedBlueBubblesSemanticEvent(captured, resolvedDeps, so
|
|
|
3083
3109
|
}, {
|
|
3084
3110
|
allowSameGenerationRetry: semanticHandling.allowSameGenerationRetry,
|
|
3085
3111
|
});
|
|
3086
|
-
if (promotion.status
|
|
3087
|
-
if (!captureOnlyMutation
|
|
3112
|
+
if (promotion.status === "unresolved") {
|
|
3113
|
+
if (!captureOnlyMutation)
|
|
3088
3114
|
throw new Error("semantic_capture_routing_invalid");
|
|
3089
|
-
|
|
3090
|
-
const disposition = captureOnlyMutation
|
|
3091
|
-
? captureOnlyHandledDisposition()
|
|
3092
|
-
: { outcome: "message_observed", detailCode: null };
|
|
3115
|
+
const disposition = captureOnlyHandledDisposition();
|
|
3093
3116
|
publishTerminalReceipt(disposition.outcome, disposition.detailCode);
|
|
3094
3117
|
semanticHandlingCompleted = true;
|
|
3095
|
-
return {
|
|
3096
|
-
handled: true,
|
|
3097
|
-
notifiedAgent: false,
|
|
3098
|
-
kind: captured.normalized.kind,
|
|
3099
|
-
reason: captureOnlyMutation ? "mutation_state_only" : "superseded",
|
|
3100
|
-
};
|
|
3118
|
+
return { handled: true, notifiedAgent: false, kind: captured.normalized.kind, reason: "mutation_state_only" };
|
|
3101
3119
|
}
|
|
3120
|
+
// A newer message took the chat first (recovery runs newest first, and a parked capture keeps its old place).
|
|
3121
|
+
// A stale capability carries this message into its session in order, then leaves as superseded without a turn.
|
|
3102
3122
|
latestTurnCapability = promotion.capability;
|
|
3123
|
+
const overtaken = promotion.status === "stale";
|
|
3103
3124
|
if (captureOnlyMutation) {
|
|
3104
3125
|
const disposition = captureOnlyHandledDisposition();
|
|
3105
3126
|
publishTerminalReceipt(disposition.outcome, disposition.detailCode);
|
|
@@ -3133,6 +3154,7 @@ async function handleCapturedBlueBubblesSemanticEvent(captured, resolvedDeps, so
|
|
|
3133
3154
|
const capturedOptions = {
|
|
3134
3155
|
...options,
|
|
3135
3156
|
latestTurnCapability,
|
|
3157
|
+
...(overtaken ? { overtaken: true } : {}),
|
|
3136
3158
|
currentIngressEvidence: Object.freeze({
|
|
3137
3159
|
schemaVersion: 1,
|
|
3138
3160
|
provider: "bluebubbles",
|
|
@@ -210,10 +210,6 @@ function promote(reservation, input, options = {}) {
|
|
|
210
210
|
const sameGenerationRetry = reservation.ordinal === lane.highWater
|
|
211
211
|
&& options.allowSameGenerationRetry === true
|
|
212
212
|
&& lane.current === null;
|
|
213
|
-
if (reservation.ordinal < lane.highWater || (reservation.ordinal === lane.highWater && !sameGenerationRetry)) {
|
|
214
|
-
return { status: "stale" };
|
|
215
|
-
}
|
|
216
|
-
lane.current?.controller.abort(new Error("superseded"));
|
|
217
213
|
const controller = new AbortController();
|
|
218
214
|
const capability = Object.freeze({
|
|
219
215
|
ordinal: reservation.ordinal,
|
|
@@ -222,6 +218,11 @@ function promote(reservation, input, options = {}) {
|
|
|
222
218
|
signal: controller.signal,
|
|
223
219
|
controller,
|
|
224
220
|
});
|
|
221
|
+
if (reservation.ordinal < lane.highWater || (reservation.ordinal === lane.highWater && !sameGenerationRetry)) {
|
|
222
|
+
controller.abort(new Error("superseded"));
|
|
223
|
+
return { status: "stale", capability };
|
|
224
|
+
}
|
|
225
|
+
lane.current?.controller.abort(new Error("superseded"));
|
|
225
226
|
lane.highWater = reservation.ordinal;
|
|
226
227
|
lane.current = capability;
|
|
227
228
|
lanes.set(chatKey, lane);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1728",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1728",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1728",
|
|
4
4
|
"description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
|
|
5
5
|
"homepage": "https://ouroboros.bot/",
|
|
6
6
|
"engines": {
|