@ouro.bot/cli 0.1.0-alpha.1716 → 0.1.0-alpha.1718
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 +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/a2a/escalation-wiring.js +23 -3
- package/dist/heart/product/active.js +20 -0
- package/dist/products/butler.js +11 -0
- package/dist/senses/a2a-entry.js +3 -15
- package/dist/senses/bluebubbles/index.js +14 -0
- package/dist/senses/pipeline.js +18 -3
- package/dist/senses/proactive-content-guard.js +4 -2
- package/dist/senses/teams.js +63 -10
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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.1718",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Whether the Butler takes delegated commands and failure reports from other agents is now set in its product registration. Before, the A2A sense and the A2A server wiring each checked the Butler's name. On the Butler's image nothing changes: peers the operator granted can still send delegated commands, each one is still announced in the owner's own Telegram chat before it runs, and escalation peers can still file failure reports that are confirmed to the owner once the fix is live. The A2A sense now logs `senses.a2a_delegation_wired` when it turns delegation on. Agents with no product never get either, and that now includes a `butler` or `sanctuary` bundle run outside the Butler's image, which got both before. A notice that fails now also logs `daemon.product_hook_error`, and the command is still refused."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1717",
|
|
12
|
+
"changes": [
|
|
13
|
+
"The summary works on iMessage as well as Teams. Held notices are only cleared once the reply carrying the summary is confirmed delivered; a failed or unconfirmed send keeps them for the next message."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1716",
|
|
6
18
|
"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.1718</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -35,11 +35,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.RUNNING_HARNESS_VERSION = void 0;
|
|
37
37
|
exports.escalationOptionsFor = escalationOptionsFor;
|
|
38
|
+
exports.delegationOptionsFor = delegationOptionsFor;
|
|
38
39
|
exports.sendOwnerNoticeViaTelegram = sendOwnerNoticeViaTelegram;
|
|
39
40
|
const fs = __importStar(require("node:fs"));
|
|
40
41
|
const path = __importStar(require("node:path"));
|
|
41
42
|
const runtime_1 = require("../nerves/runtime");
|
|
42
|
-
const
|
|
43
|
+
const identity_1 = require("../heart/identity");
|
|
44
|
+
const active_1 = require("../heart/product/active");
|
|
45
|
+
const delegated_command_1 = require("./delegated-command");
|
|
43
46
|
/**
|
|
44
47
|
* The version of the harness that is running, read from its own package.json once when this module loads. A fix is
|
|
45
48
|
* "live" only when this process carries it, so the value must not follow whatever an upgrade later writes to disk.
|
|
@@ -47,14 +50,31 @@ const butler_agent_1 = require("../heart/butler-agent");
|
|
|
47
50
|
exports.RUNNING_HARNESS_VERSION = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../../package.json"), "utf8")).version;
|
|
48
51
|
/**
|
|
49
52
|
* What every A2A server entry point passes as `escalation`: confirm-when-live notices go to the owner through the same
|
|
50
|
-
* owner-notice path as delegated commands. Only
|
|
53
|
+
* owner-notice path as delegated commands. Only an agent whose product files and confirms failure reports gets it.
|
|
51
54
|
*/
|
|
52
55
|
function escalationOptionsFor(agentName, sendOwnerNotice) {
|
|
53
|
-
if (
|
|
56
|
+
if ((0, active_1.productFor)(agentName)?.a2a?.escalation !== true)
|
|
54
57
|
return {};
|
|
55
58
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.a2a_escalation_wired", message: "A2A server will confirm resolved failure reports to the owner", meta: { agentName, runningVersion: exports.RUNNING_HARNESS_VERSION } });
|
|
56
59
|
return { escalation: { runningVersion: exports.RUNNING_HARNESS_VERSION, notifyOwner: sendOwnerNotice } };
|
|
57
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* What the A2A server entry passes as `delegation`: an agent whose product accepts delegated commands takes them from
|
|
63
|
+
* granted peers on its owner's menu, and the product announces each one before it runs.
|
|
64
|
+
*/
|
|
65
|
+
function delegationOptionsFor(agentName) {
|
|
66
|
+
const notifyPrincipal = (0, active_1.productDelegationNotifier)(agentName);
|
|
67
|
+
if (!notifyPrincipal)
|
|
68
|
+
return {};
|
|
69
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.a2a_delegation_wired", message: "A2A server will accept delegated commands from granted peers", meta: { agentName } });
|
|
70
|
+
return {
|
|
71
|
+
delegation: {
|
|
72
|
+
principalProfileId: delegated_command_1.A2A_PRINCIPAL_PROFILE_ID,
|
|
73
|
+
agentRoot: (0, identity_1.getAgentRoot)(agentName),
|
|
74
|
+
notifyPrincipal,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
58
78
|
async function sendOwnerNoticeViaTelegram(agentName, notice) {
|
|
59
79
|
const { sendTelegramOwnerNotice } = await Promise.resolve().then(() => __importStar(require("../senses/telegram")));
|
|
60
80
|
await sendTelegramOwnerNotice(agentName, { ...notice, signal: AbortSignal.timeout(30_000) });
|
|
@@ -12,6 +12,7 @@ exports.productTools = productTools;
|
|
|
12
12
|
exports.productToolDefinitions = productToolDefinitions;
|
|
13
13
|
exports.productToolSelection = productToolSelection;
|
|
14
14
|
exports.productActiveWorkSections = productActiveWorkSections;
|
|
15
|
+
exports.productDelegationNotifier = productDelegationNotifier;
|
|
15
16
|
exports.productSense = productSense;
|
|
16
17
|
exports.productSenseRepairHint = productSenseRepairHint;
|
|
17
18
|
exports.productSenseReadiness = productSenseReadiness;
|
|
@@ -202,6 +203,25 @@ async function productActiveWorkSections(input) {
|
|
|
202
203
|
throw error;
|
|
203
204
|
}
|
|
204
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* How this agent's product announces a delegated command to its owner (J8), or null when the agent takes none. A rejection
|
|
208
|
+
* refuses the command, as the A2A server does for any failed notice, and is logged as the product's.
|
|
209
|
+
*/
|
|
210
|
+
function productDelegationNotifier(agentName) {
|
|
211
|
+
const product = productFor(agentName);
|
|
212
|
+
const delegation = product?.a2a?.delegation;
|
|
213
|
+
if (!delegation)
|
|
214
|
+
return null;
|
|
215
|
+
return async (notice) => {
|
|
216
|
+
try {
|
|
217
|
+
await delegation.notifyPrincipal(agentName, notice);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
hookFailed(product, "a2a.delegation.notifyPrincipal", agentName, error, "the product's delegated-command notice failed, so the command is refused");
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
205
225
|
/** How this agent's product runs one of core's senses (J6), or null when it runs it core's way. */
|
|
206
226
|
function productSense(agentName, sense) {
|
|
207
227
|
return productFor(agentName)?.senses?.[sense] ?? null;
|
package/dist/products/butler.js
CHANGED
|
@@ -172,6 +172,17 @@ exports.product = {
|
|
|
172
172
|
repairHint: () => "Agent-runnable: complete or recover the root authority migration; do not restore a resident Telegram token.",
|
|
173
173
|
},
|
|
174
174
|
},
|
|
175
|
+
// J8: the Butler takes delegated commands from peers the operator granted, each announced in the owner's own Telegram
|
|
176
|
+
// chat before it runs (never through the owner route, never held), and files and confirms failure reports.
|
|
177
|
+
a2a: {
|
|
178
|
+
delegation: {
|
|
179
|
+
notifyPrincipal: async (agentName, notice) => {
|
|
180
|
+
const { sendTelegramDelegatedAuditNotice } = await Promise.resolve().then(() => __importStar(require("../senses/telegram")));
|
|
181
|
+
await sendTelegramDelegatedAuditNotice(agentName, { ...notice, signal: AbortSignal.timeout(30_000) });
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
escalation: true,
|
|
185
|
+
},
|
|
175
186
|
// J5: the house check runs in the daemon, and only Supercronic may fire it on its cron schedule.
|
|
176
187
|
habits: {
|
|
177
188
|
"sanctuary-health": {
|
package/dist/senses/a2a-entry.js
CHANGED
|
@@ -47,9 +47,7 @@ function argValue(name) {
|
|
|
47
47
|
}
|
|
48
48
|
const runtime_logging_1 = require("../heart/daemon/runtime-logging");
|
|
49
49
|
const runtime_1 = require("../nerves/runtime");
|
|
50
|
-
const delegated_command_1 = require("../a2a/delegated-command");
|
|
51
50
|
const identity_1 = require("../heart/identity");
|
|
52
|
-
const butler_agent_1 = require("../heart/butler-agent");
|
|
53
51
|
(0, runtime_logging_1.configureDaemonRuntimeLogger)("a2a");
|
|
54
52
|
(0, runtime_1.emitNervesEvent)({
|
|
55
53
|
component: "senses",
|
|
@@ -67,7 +65,7 @@ Promise.all([
|
|
|
67
65
|
Promise.resolve().then(() => __importStar(require("../a2a/relay-config-vault"))),
|
|
68
66
|
Promise.resolve().then(() => __importStar(require("./sense-shutdown"))),
|
|
69
67
|
])
|
|
70
|
-
.then(async ([{ startA2AServer }, { loadOrMintA2AIdentity, readStoredA2ASeed, publishOwnA2ADid }, { waitForRuntimeCredentialBootstrap, readMachineRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, mergeMachineRuntimeCredentialConfig }, { loadOrCreateMachineIdentity }, { ready }, { escalationOptionsFor, sendOwnerNoticeViaTelegram }, { relayConfigFrom, vaultRelayConfigStore }, { installSenseShutdown },]) => {
|
|
68
|
+
.then(async ([{ startA2AServer }, { loadOrMintA2AIdentity, readStoredA2ASeed, publishOwnA2ADid }, { waitForRuntimeCredentialBootstrap, readMachineRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, mergeMachineRuntimeCredentialConfig }, { loadOrCreateMachineIdentity }, { ready }, { delegationOptionsFor, escalationOptionsFor, sendOwnerNoticeViaTelegram }, { relayConfigFrom, vaultRelayConfigStore }, { installSenseShutdown },]) => {
|
|
71
69
|
const os = await Promise.resolve().then(() => __importStar(require("node:os")));
|
|
72
70
|
// Wait for the daemon to deliver the machine-local runtime config (carrying the
|
|
73
71
|
// a2a identity seed) into the in-memory cache before we read or mint identity.
|
|
@@ -104,18 +102,8 @@ Promise.all([
|
|
|
104
102
|
const handle = await startA2AServer({
|
|
105
103
|
agentName,
|
|
106
104
|
identity,
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
...((0, butler_agent_1.isButlerAgent)(agentName) ? {
|
|
110
|
-
delegation: {
|
|
111
|
-
principalProfileId: delegated_command_1.A2A_PRINCIPAL_PROFILE_ID,
|
|
112
|
-
agentRoot: (0, identity_1.getAgentRoot)(agentName),
|
|
113
|
-
notifyPrincipal: async (notice) => {
|
|
114
|
-
const { sendTelegramDelegatedAuditNotice } = await Promise.resolve().then(() => __importStar(require("./telegram")));
|
|
115
|
-
await sendTelegramDelegatedAuditNotice(agentName, { ...notice, signal: AbortSignal.timeout(30_000) });
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
} : {}),
|
|
105
|
+
// An agent whose product accepts delegated commands takes them from explicitly granted peers, each announced before it runs.
|
|
106
|
+
...delegationOptionsFor(agentName),
|
|
119
107
|
...escalationOptionsFor(agentName, (notice) => sendOwnerNoticeViaTelegram(agentName, notice)),
|
|
120
108
|
notifyOwner: (notice) => sendOwnerNoticeViaTelegram(agentName, notice),
|
|
121
109
|
// A friends-relay inbox for messages sent while this agent is offline, when the operator set a2a.relay.url
|
|
@@ -2068,6 +2068,9 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
2068
2068
|
let resolveTimeout;
|
|
2069
2069
|
let recoveryTimedOut = false;
|
|
2070
2070
|
let activeRunTurn = null;
|
|
2071
|
+
// Held notices ride this turn's reply; they are settled only once the final send was accepted, else released.
|
|
2072
|
+
let heldNoticeDelivery;
|
|
2073
|
+
let heldNoticesConfirmed = false;
|
|
2071
2074
|
// BB-specific tool context wrappers
|
|
2072
2075
|
const summarize = (0, core_1.createSummarize)("human");
|
|
2073
2076
|
const bbCapabilities = (0, friends_1.getChannelCapabilities)("bluebubbles");
|
|
@@ -2195,6 +2198,8 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
2195
2198
|
enforceTrustGate: trust_gate_1.enforceTrustGate,
|
|
2196
2199
|
drainPending: pending_1.drainPending,
|
|
2197
2200
|
drainDeferredReturns: (deferredFriendId) => (0, pending_1.drainDeferredReturns)(resolvedDeps.getAgentName(), deferredFriendId),
|
|
2201
|
+
claimHeldNotices: (heldFriendId) => (0, pending_1.claimHeldNotices)(resolvedDeps.getAgentName(), heldFriendId),
|
|
2202
|
+
confirmHeldNoticeDelivery: true,
|
|
2198
2203
|
prepareRunAgentOptions: async ({ messages = [], currentUserMessages = [], runAgentOptions }) => {
|
|
2199
2204
|
preparedBlueBubblesContext = await buildBlueBubblesContextMessages({
|
|
2200
2205
|
agentName,
|
|
@@ -2316,6 +2321,7 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
2316
2321
|
/* v8 ignore stop */
|
|
2317
2322
|
const runTurn = (async () => {
|
|
2318
2323
|
const result = await turnPromise;
|
|
2324
|
+
heldNoticeDelivery = result.heldNoticeDelivery;
|
|
2319
2325
|
if (recoveryTimedOut && !finalTransportInvoked) {
|
|
2320
2326
|
(0, runtime_1.emitNervesEvent)({
|
|
2321
2327
|
level: "warn",
|
|
@@ -2411,6 +2417,12 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
2411
2417
|
: "no_visible_reply",
|
|
2412
2418
|
};
|
|
2413
2419
|
}
|
|
2420
|
+
const finalReply = result.messages?.findLast((message) => message.role === "assistant");
|
|
2421
|
+
const replyText = typeof finalReply?.content === "string" ? finalReply.content.trim() : "";
|
|
2422
|
+
if (heldNoticeDelivery && replyText.length > 0 && heldNoticeDelivery.includedIn(replyText)) {
|
|
2423
|
+
heldNoticeDelivery.confirm();
|
|
2424
|
+
heldNoticesConfirmed = true;
|
|
2425
|
+
}
|
|
2414
2426
|
// Acceptance is the visibility boundary. Publish the terminal dedupe
|
|
2415
2427
|
// receipt first, then project the private generated tail while this
|
|
2416
2428
|
// chat's canonical lock remains held. Even if receipt publication
|
|
@@ -2482,6 +2494,8 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
2482
2494
|
// the cross-process session lease until that work has actually quiesced.
|
|
2483
2495
|
if (activeRunTurn)
|
|
2484
2496
|
await activeRunTurn.catch(() => undefined);
|
|
2497
|
+
if (!heldNoticesConfirmed)
|
|
2498
|
+
heldNoticeDelivery?.release();
|
|
2485
2499
|
// If a terminal error was buffered and never replayed (e.g., handleInboundTurn threw),
|
|
2486
2500
|
// replay it now so the user still sees the error.
|
|
2487
2501
|
/* v8 ignore start -- error replay on throw: tested via BB error test @preserve */
|
package/dist/senses/pipeline.js
CHANGED
|
@@ -38,11 +38,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
};
|
|
39
39
|
})();
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.heldNoticesIncludedIn = heldNoticesIncludedIn;
|
|
41
42
|
exports.emitObligationTransitionEpisodes = emitObligationTransitionEpisodes;
|
|
42
43
|
exports.selectCheckpointCurrentAsk = selectCheckpointCurrentAsk;
|
|
43
44
|
exports.startPostTurnSync = startPostTurnSync;
|
|
44
45
|
exports.erroredTurnReply = erroredTurnReply;
|
|
45
46
|
exports.handleInboundTurn = handleInboundTurn;
|
|
47
|
+
const node_crypto_1 = require("node:crypto");
|
|
46
48
|
const fs = __importStar(require("fs"));
|
|
47
49
|
const path = __importStar(require("path"));
|
|
48
50
|
const runtime_1 = require("../nerves/runtime");
|
|
@@ -83,15 +85,28 @@ const friend_link_codes_1 = require("../mind/friend-link-codes");
|
|
|
83
85
|
const reply_gate_1 = require("./reply-gate");
|
|
84
86
|
const VOICE_PENDING_MAX_AGE_MS = 15 * 60 * 1_000;
|
|
85
87
|
const TELEGRAM_GENERIC_OUTREACH_PENDING_MAX_AGE_MS = 15 * 60 * 1_000;
|
|
88
|
+
function heldNoticeRef(notice) {
|
|
89
|
+
return `H-${(0, node_crypto_1.createHash)("sha1").update(`${notice.timestamp}\n${notice.content}`).digest("hex").slice(0, 6)}`;
|
|
90
|
+
}
|
|
91
|
+
// Inclusion is a contract with the model, not proof that its summary is accurate: the summary prompt gives every notice a
|
|
92
|
+
// reference and asks the reply to end with a "Held notices:" receipt line. Only that line is parsed, and it must name every
|
|
93
|
+
// notice. Anything else counts as not included and the notices are released.
|
|
94
|
+
function heldNoticesIncludedIn(held, reply) {
|
|
95
|
+
const receipt = reply.trimEnd().split("\n").pop().match(/^\s*Held notices:\s*(.*)$/i);
|
|
96
|
+
if (!receipt)
|
|
97
|
+
return held.length === 0;
|
|
98
|
+
const named = new Set(receipt[1].match(/H-[0-9a-f]{6}\b/g) ?? []);
|
|
99
|
+
return held.every((notice) => named.has(heldNoticeRef(notice)));
|
|
100
|
+
}
|
|
86
101
|
function renderHeldNoticeSummary(held) {
|
|
87
102
|
const lines = [...held]
|
|
88
103
|
.sort((a, b) => a.timestamp - b.timestamp)
|
|
89
|
-
.map((notice) => `- (${new Date(notice.timestamp).toISOString()}) ${notice.content}`);
|
|
104
|
+
.map((notice) => `- [${heldNoticeRef(notice)}] (${new Date(notice.timestamp).toISOString()}) ${notice.content}`);
|
|
90
105
|
return {
|
|
91
106
|
from: held[0].from,
|
|
92
107
|
friendId: held[0].friendId,
|
|
93
108
|
timestamp: Date.now(),
|
|
94
|
-
content: `Routine notices held while they were away, not sent to them. Give them one short summary of these, folded into your reply to this message; do not send them as separate messages, and do not send this summary on its own:\n${lines.join("\n")}`,
|
|
109
|
+
content: `Routine notices held while they were away, not sent to them. Give them one short summary of these, folded into your reply to this message; do not send them as separate messages, and do not send this summary on its own. End your reply with a final line "Held notices: " followed by every reference below, so delivery can be confirmed:\n${lines.join("\n")}`,
|
|
95
110
|
};
|
|
96
111
|
}
|
|
97
112
|
function pendingExpirationReason(channel, message, now, agentName) {
|
|
@@ -1427,7 +1442,7 @@ async function handleInboundTurnExclusive(input) {
|
|
|
1427
1442
|
messages: sessionMessages,
|
|
1428
1443
|
drainedPending: pending,
|
|
1429
1444
|
...(handedOffHeldNotices && heldClaimForDelivery ? {
|
|
1430
|
-
heldNoticeDelivery: { confirm: () => heldClaimForDelivery.settle(), release: () => heldClaimForDelivery.release() },
|
|
1445
|
+
heldNoticeDelivery: { confirm: () => heldClaimForDelivery.settle(), release: () => heldClaimForDelivery.release(), includedIn: (reply) => heldNoticesIncludedIn(heldClaimForDelivery.messages, reply) },
|
|
1431
1446
|
} : {}),
|
|
1432
1447
|
...(input.switchedProvider ? { switchedProvider: input.switchedProvider } : {}),
|
|
1433
1448
|
// Every chat sense answers an errored turn. The inner channel stays silent, and the CLI keeps showing its operator the raw error.
|
|
@@ -85,6 +85,8 @@ function getUntestedClaimReason(text) {
|
|
|
85
85
|
const NO_ACTION_NOW_PATTERN = /\b(?:nothing (?:to do|needed|for you to do)|no action (?:is )?(?:needed|required)|nothing is needed|fyi|just so you know)\b/i;
|
|
86
86
|
const FUTURE_GATE_PATTERN = /\b(?:nothing to do yet|nothing (?:is )?needed (?:from you )?yet|no action (?:is )?(?:needed|required) yet)\b/i;
|
|
87
87
|
const FUTURE_GATE_LATER_PATTERN = /\b(?:when|once|after|later)\b[^.]*\b(?:i'll|i will|will)\b[^.]*\b(?:send|ask|prompt|text|message)\b/i;
|
|
88
|
+
// Only the announced later request itself: "when it is ready I will send you a tap (to approve on your phone)". Whatever follows it is still checked.
|
|
89
|
+
const ANNOUNCED_REQUEST_PATTERN = /\b(?:when|once|after|later)\b[^.;!?]*?\b(?:i'll|i will|will)\s+(?:send|ask|prompt|text|message)\b(?:\s+(?:you|them))?(?:\s+(?:an?|the|one|single))?(?:\s+[a-z-]+){0,2}?(?:\s+(?:prompt|tap|request|message|text|notification|passkey|approval|link))+\b(?:\s+to approve(?:\s+on your phone)?)?/ig;
|
|
88
90
|
// Anything the person must know or act on now beats routine: a risk, a correction, a request, an update they asked for.
|
|
89
91
|
const MATERIAL_RISK_PATTERN = /\b(?:lost|lose|losing|data loss|outage|still (?:down|broken|failing)|is down|are down|went down|corrupt\w*|deleted|wiped|breach\w*|leak\w*|exposed|forced reboot|crash\w*|unrecoverable|at risk|urgent|failed to)\b/i;
|
|
90
92
|
const CORRECTION_PATTERN = /\b(?:correction|i was wrong|i got that wrong|that was wrong|ignore (?:my )?(?:last|earlier|previous)|disregard|retract\w*|mistake|my earlier (?:message|note))\b/i;
|
|
@@ -92,9 +94,9 @@ const PRESENT_ASK_PATTERN = /\b(?:please|can you|could you|would you|do you want
|
|
|
92
94
|
function getRoutineNoticeReason(text) {
|
|
93
95
|
if (REQUESTED_STATUS_PATTERN.test(text) || MATERIAL_RISK_PATTERN.test(text) || CORRECTION_PATTERN.test(text))
|
|
94
96
|
return null;
|
|
95
|
-
// The announced later request ("I'll send you a tap to approve") is not a present ask;
|
|
97
|
+
// The announced later request ("I'll send you a tap to approve") is not a present ask; an ask after a "but" or in another sentence is.
|
|
96
98
|
const futureGate = FUTURE_GATE_PATTERN.test(text) && FUTURE_GATE_LATER_PATTERN.test(text);
|
|
97
|
-
const withoutAnnouncedRequest = futureGate ? text.replace(
|
|
99
|
+
const withoutAnnouncedRequest = futureGate ? text.replace(ANNOUNCED_REQUEST_PATTERN, " ") : text;
|
|
98
100
|
if (PRESENT_ASK_PATTERN.test(withoutAnnouncedRequest))
|
|
99
101
|
return null;
|
|
100
102
|
if (futureGate)
|
package/dist/senses/teams.js
CHANGED
|
@@ -345,6 +345,19 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
345
345
|
// Handle the result of a stream call: if it returns a Promise (the Teams SDK
|
|
346
346
|
// does async HTTP under the hood even though the interface types it as void),
|
|
347
347
|
// catch its rejection so we detect a dead stream and abort the agent loop.
|
|
348
|
+
// Delivery ledger: only a transport acknowledgement counts as delivered.
|
|
349
|
+
let acked = 0;
|
|
350
|
+
let unacked = 0;
|
|
351
|
+
let lost = 0;
|
|
352
|
+
const inflight = [];
|
|
353
|
+
function track(result) {
|
|
354
|
+
if (result && typeof result.then === "function") {
|
|
355
|
+
inflight.push(result.then(() => { acked++; }, () => { lost++; }));
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
unacked++;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
348
361
|
function catchAsync(result) {
|
|
349
362
|
if (result && typeof result.catch === "function") {
|
|
350
363
|
result.catch((err) => markStopped("stream-async", err));
|
|
@@ -353,15 +366,19 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
353
366
|
// Safely emit a text delta to the stream with AI labels.
|
|
354
367
|
// On error (e.g. 403 from Teams stop button), abort the controller.
|
|
355
368
|
function safeEmit(text) {
|
|
356
|
-
|
|
357
|
-
|
|
369
|
+
if (stopped) {
|
|
370
|
+
lost++;
|
|
358
371
|
return;
|
|
372
|
+
}
|
|
359
373
|
try {
|
|
360
|
-
|
|
374
|
+
const emitted = stream.emit(streamChunk(text));
|
|
375
|
+
catchAsync(emitted);
|
|
376
|
+
track(emitted);
|
|
361
377
|
streamHasContent = true;
|
|
362
378
|
totalEmitted += text.length;
|
|
363
379
|
}
|
|
364
380
|
catch (err) {
|
|
381
|
+
lost++;
|
|
365
382
|
markStopped("safeEmit", err);
|
|
366
383
|
}
|
|
367
384
|
}
|
|
@@ -380,6 +397,10 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
380
397
|
if (result && typeof result.then === "function") {
|
|
381
398
|
awaitingTransport = true;
|
|
382
399
|
await result;
|
|
400
|
+
acked++;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
unacked++;
|
|
383
404
|
}
|
|
384
405
|
return true;
|
|
385
406
|
}
|
|
@@ -405,6 +426,10 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
405
426
|
if (result && typeof result.then === "function") {
|
|
406
427
|
awaitingTransport = true;
|
|
407
428
|
await result;
|
|
429
|
+
acked++;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
unacked++;
|
|
408
433
|
}
|
|
409
434
|
return true;
|
|
410
435
|
}
|
|
@@ -438,25 +463,41 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
438
463
|
let sendChain = Promise.resolve();
|
|
439
464
|
let sendChainBusy = false;
|
|
440
465
|
function safeSend(text) {
|
|
441
|
-
if (stopped || !sendMessage)
|
|
466
|
+
if (stopped || !sendMessage) {
|
|
467
|
+
lost++;
|
|
442
468
|
return;
|
|
469
|
+
}
|
|
443
470
|
if (!sendChainBusy) {
|
|
444
471
|
// Chain is idle -- start the send synchronously and mark busy
|
|
445
472
|
sendChainBusy = true;
|
|
446
473
|
try {
|
|
447
|
-
|
|
474
|
+
const sent = sendMessage(text);
|
|
475
|
+
track(sent);
|
|
476
|
+
sendChain = sent.catch((err) => markStopped("send", err)).finally(() => { sendChainBusy = false; });
|
|
448
477
|
}
|
|
449
478
|
catch (err) {
|
|
450
479
|
sendChainBusy = false;
|
|
480
|
+
lost++;
|
|
451
481
|
markStopped("send", err);
|
|
452
482
|
}
|
|
453
483
|
}
|
|
454
484
|
else {
|
|
455
485
|
// Chain is busy -- queue onto the existing chain
|
|
456
486
|
sendChain = sendChain.then(() => {
|
|
457
|
-
if (stopped)
|
|
487
|
+
if (stopped) {
|
|
488
|
+
lost++;
|
|
458
489
|
return;
|
|
459
|
-
|
|
490
|
+
}
|
|
491
|
+
let sent;
|
|
492
|
+
try {
|
|
493
|
+
sent = sendMessage(text);
|
|
494
|
+
}
|
|
495
|
+
catch (err) {
|
|
496
|
+
lost++;
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
track(sent);
|
|
500
|
+
return sent;
|
|
460
501
|
}).catch((err) => markStopped("send-queued", err));
|
|
461
502
|
}
|
|
462
503
|
}
|
|
@@ -590,6 +631,7 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
590
631
|
if (!delivered && sendMessage) {
|
|
591
632
|
try {
|
|
592
633
|
await sendMessage(trimmed);
|
|
634
|
+
acked++;
|
|
593
635
|
delivered = true;
|
|
594
636
|
lastError = null;
|
|
595
637
|
}
|
|
@@ -674,6 +716,7 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
674
716
|
safeSend(msg);
|
|
675
717
|
}
|
|
676
718
|
},
|
|
719
|
+
deliveryState: () => lost > 0 ? "failed" : unacked > 0 || acked === 0 ? "unconfirmed" : "confirmed",
|
|
677
720
|
flush: async () => {
|
|
678
721
|
stopFlushTimer();
|
|
679
722
|
stopPhraseRotation();
|
|
@@ -698,20 +741,28 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
698
741
|
// Stream is dead (not from finalization) — fall back to sendMessage; split on failure as recovery.
|
|
699
742
|
try {
|
|
700
743
|
await sendMessage(text);
|
|
744
|
+
acked++;
|
|
701
745
|
}
|
|
702
746
|
catch (error) {
|
|
703
747
|
// A lost acknowledgement is not a rejection. Only a definite size rejection permits a smaller retry.
|
|
704
748
|
if (!isTeamsSizeRejection(error) || text.length <= RECOVERY_CHUNK_SIZE)
|
|
705
749
|
throw error;
|
|
706
750
|
const chunks = splitMessage(text, RECOVERY_CHUNK_SIZE);
|
|
707
|
-
for (const chunk of chunks)
|
|
751
|
+
for (const chunk of chunks) {
|
|
708
752
|
await sendMessage(chunk);
|
|
753
|
+
acked++;
|
|
754
|
+
}
|
|
709
755
|
}
|
|
710
756
|
}
|
|
757
|
+
else if (stopped && !sendMessage) {
|
|
758
|
+
lost++;
|
|
759
|
+
}
|
|
711
760
|
}
|
|
712
761
|
else if (!streamHasContent && !options?.suppressEmptyStreamMessage) {
|
|
713
762
|
safeEmit("(completed with tool calls only — no text response)");
|
|
714
763
|
}
|
|
764
|
+
await sendChain;
|
|
765
|
+
await Promise.all(inflight);
|
|
715
766
|
(0, runtime_1.emitNervesEvent)({
|
|
716
767
|
component: "senses",
|
|
717
768
|
event: "teams.flush_done",
|
|
@@ -1228,12 +1279,14 @@ async function handleTeamsMessage(text, stream, conversationId, teamsContext, se
|
|
|
1228
1279
|
return;
|
|
1229
1280
|
}
|
|
1230
1281
|
// Flush any remaining accumulated text at end of turn. The held notices are settled only once this reached the
|
|
1231
|
-
// person with a reply
|
|
1282
|
+
// person with a reply that the transport acknowledged and that covers them; anything less puts them back.
|
|
1232
1283
|
let delivered = false;
|
|
1233
1284
|
try {
|
|
1234
1285
|
await callbacks.flush();
|
|
1235
1286
|
const finalReply = result.messages?.findLast((message) => message.role === "assistant");
|
|
1236
|
-
|
|
1287
|
+
const replyText = typeof finalReply?.content === "string" ? finalReply.content.trim() : "";
|
|
1288
|
+
delivered = callbacks.deliveryState() === "confirmed" && result.turnOutcome !== "superseded"
|
|
1289
|
+
&& replyText.length > 0 && (result.heldNoticeDelivery?.includedIn(replyText) ?? true);
|
|
1237
1290
|
}
|
|
1238
1291
|
finally {
|
|
1239
1292
|
if (delivered)
|
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.1718",
|
|
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.1718",
|
|
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.1718",
|
|
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": {
|