@ouro.bot/cli 0.1.0-alpha.1460 → 0.1.0-alpha.1462
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 +27 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/chat-interaction.js +31 -0
- package/dist/heart/core.js +26 -0
- package/dist/heart/sent-message-ledger.js +98 -0
- package/dist/heart/turn-summary.js +193 -0
- package/dist/senses/bluebubbles/index.js +23 -1
- package/dist/senses/bluebubbles/model.js +7 -2
- package/dist/senses/teams.js +29 -6
- package/dist/senses/telegram.js +8 -8
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
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.1462",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Every turn now logs one counts-only event, `engine.turn_summary`, when it ends, including a turn that ends by throwing. The event records:",
|
|
8
|
+
"the channel, how the turn ended and, for a turn that failed, the class of error (such as `auth-failure` or `rate-limit`);",
|
|
9
|
+
"the provider and model the turn ended on, and how many times it fell back to another provider;",
|
|
10
|
+
"the provider calls the main loop made and any step-budget stop;",
|
|
11
|
+
"the tool calls by name, the tool errors and any calls to a name the turn never offered;",
|
|
12
|
+
"how `find_tools` did: calls, calls that loaded a tool, and loaded tools called afterwards;",
|
|
13
|
+
"the tools offered up front and those held back;",
|
|
14
|
+
"the input, output and reasoning tokens summed over the main loop's provider calls.",
|
|
15
|
+
"It holds only numbers and values from fixed lists, never message text, tool arguments or results. An MCP tool is named only by its server, and a made-up tool name is counted as `unknown`. A failure to log the event never affects the turn. Side calls such as the kept-notes judge, and attempts that failed and were retried, aren't in the step or token counts."
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"version": "0.1.0-alpha.1461",
|
|
20
|
+
"changes": [
|
|
21
|
+
"When someone reacts to a message on iMessage, Telegram or Teams, the agent now reads what that message said (\"loved your message: \"are voice notes working?\"\") instead of a bare id. All three apps use one shared lookup: iMessage asks the BlueBubbles server for the message, Telegram reads the agent's own sent-message journal, and Teams reads a small new record of the agent's sent messages. When the message still can't be found, the agent is told so plainly and can ask."
|
|
22
|
+
]
|
|
23
|
+
},
|
|
4
24
|
{
|
|
5
25
|
"version": "0.1.0-alpha.1460",
|
|
26
|
+
"changes": [
|
|
27
|
+
"The container build compiles native dependencies against the Node headers already installed on the runner, so one timed-out download from nodejs.org no longer stops a release."
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"version": "0.1.0-alpha.1459",
|
|
6
32
|
"changes": [
|
|
7
33
|
"When a coding session the agent started finishes, fails, is stopped, stalls or waits for input, the agent is woken right away with a message saying which session it was, who it was for, what it ended with, and to tell that person now with `send_message` instead of waiting for a check-back. This works whatever chat started the session (iMessage, Telegram, Teams, the CLI or the agent's own private turn), and for Orca, local and Workbench sessions alike. Before, only sessions started from the CLI tried to wake the agent, and the private-runtime policy refused even those.",
|
|
8
34
|
"Orca and Workbench sessions are now checked every 30 seconds while any is still open, not only while someone is watching one, and a local session found dead after a restart is reported once.",
|
|
9
|
-
"Copilot app session replies and finished coding work now reach the agent through one shared path: a message queued for the private runtime, then a wake."
|
|
10
|
-
"The container build compiles native dependencies against the Node headers already installed on the runner, so one timed-out download from nodejs.org no longer stops a release."
|
|
35
|
+
"Copilot app session replies and finished coding work now reach the agent through one shared path: a message queued for the private runtime, then a wake."
|
|
11
36
|
]
|
|
12
37
|
},
|
|
13
38
|
{
|
|
@@ -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.1462</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveChatMessageRef = resolveChatMessageRef;
|
|
4
|
+
exports.resolveChatInteractionTarget = resolveChatInteractionTarget;
|
|
3
5
|
exports.renderChatInteraction = renderChatInteraction;
|
|
4
6
|
const runtime_1 = require("../nerves/runtime");
|
|
5
7
|
const EXCERPT_MAX_LENGTH = 80;
|
|
@@ -19,6 +21,35 @@ function targetPhrase(target, eventName) {
|
|
|
19
21
|
? `an unidentified message (target ${target.id}; its text could not be resolved)`
|
|
20
22
|
: `an unidentified message (the ${eventName} carried no target message reference)`;
|
|
21
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Fill in the message a reaction or edit points at, so the agent reads what was reacted to instead of a bare id.
|
|
26
|
+
* Every sense calls this with its own lookup; what the sense already knows wins over the lookup. A lookup that fails
|
|
27
|
+
* leaves the target as it was, and the renderer then says plainly that the message could not be found.
|
|
28
|
+
*/
|
|
29
|
+
async function resolveChatMessageRef(target, lookup,
|
|
30
|
+
/** The id to look up when it differs from the one shown to the agent (BlueBubbles shows "guid X"). */
|
|
31
|
+
lookupId = target.id) {
|
|
32
|
+
if (target.text?.trim() || !lookupId)
|
|
33
|
+
return target;
|
|
34
|
+
let found = null;
|
|
35
|
+
try {
|
|
36
|
+
found = await lookup(lookupId);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.chat_interaction_target_lookup_failed", message: "could not look up the message a reaction or edit points at", meta: { reason: error instanceof Error ? error.message : String(error) } });
|
|
40
|
+
}
|
|
41
|
+
const text = found?.text?.trim();
|
|
42
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.chat_interaction_target_resolved", message: "looked up the message a reaction or edit points at", meta: { found: Boolean(text) } });
|
|
43
|
+
if (!text)
|
|
44
|
+
return target;
|
|
45
|
+
const fromAgent = target.fromAgent ?? found?.fromAgent;
|
|
46
|
+
return { ...target, text, ...(typeof fromAgent === "boolean" ? { fromAgent } : {}) };
|
|
47
|
+
}
|
|
48
|
+
/** `resolveChatMessageRef` for a whole interaction; returns the same object when nothing was found. */
|
|
49
|
+
async function resolveChatInteractionTarget(interaction, lookup, lookupId) {
|
|
50
|
+
const target = await resolveChatMessageRef(interaction.target, lookup, lookupId ?? interaction.target.id);
|
|
51
|
+
return target === interaction.target ? interaction : { ...interaction, target };
|
|
52
|
+
}
|
|
22
53
|
/** The words the agent reads for an edit or a reaction. */
|
|
23
54
|
function renderChatInteraction(interaction) {
|
|
24
55
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.chat_interaction_rendered", message: "chat interaction rendered for the agent", meta: { kind: interaction.kind } });
|
package/dist/heart/core.js
CHANGED
|
@@ -84,6 +84,7 @@ const provider_fallback_1 = require("./provider-fallback");
|
|
|
84
84
|
const habit_session_1 = require("./habits/habit-session");
|
|
85
85
|
const provider_attempt_1 = require("./provider-attempt");
|
|
86
86
|
const openai_codex_token_1 = require("./providers/openai-codex-token");
|
|
87
|
+
const turn_summary_1 = require("./turn-summary");
|
|
87
88
|
// Cache only immutable provider construction inputs. ProviderRuntime owns
|
|
88
89
|
// mutable per-turn state (for example Responses nativeInput), so every caller
|
|
89
90
|
// must receive a fresh instance even when its binding fingerprint is unchanged.
|
|
@@ -1147,6 +1148,23 @@ function buildAuthFailureGuidance(provider, model, agentName, detail) {
|
|
|
1147
1148
|
return lines.join("\n");
|
|
1148
1149
|
}
|
|
1149
1150
|
async function runAgent(messages, callbacks, channel, signal, options) {
|
|
1151
|
+
// engine.turn_summary (counts only; see turn-summary.ts) is emitted once however the turn ends, a throw included.
|
|
1152
|
+
const turnTally = new turn_summary_1.TurnTally();
|
|
1153
|
+
let result;
|
|
1154
|
+
try {
|
|
1155
|
+
result = await runCountedTurn(turnTally, messages, (0, turn_summary_1.tallyToolEnds)(callbacks, turnTally), channel, signal, options);
|
|
1156
|
+
return result;
|
|
1157
|
+
}
|
|
1158
|
+
finally {
|
|
1159
|
+
(0, turn_summary_1.emitTurnSummary)(turnTally, {
|
|
1160
|
+
channel,
|
|
1161
|
+
outcome: result?.outcome ?? "errored",
|
|
1162
|
+
errorClass: result ? result.errorClassification ?? "none" : "unknown",
|
|
1163
|
+
traceId: options?.traceId,
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
async function runCountedTurn(turnTally, messages, callbacks, channel, signal, options) {
|
|
1150
1168
|
const generatedMessages = [];
|
|
1151
1169
|
let nextAttemptControls = [];
|
|
1152
1170
|
let rejectedAttempt = [];
|
|
@@ -1164,12 +1182,14 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1164
1182
|
: undefined;
|
|
1165
1183
|
// Automatic fallback (opt-in via agent.json providerFallback): start on the first chain entry not cooling down.
|
|
1166
1184
|
let providerRuntime = options?.providerRuntimeOverride ?? await getProviderRuntime(facing, owner);
|
|
1185
|
+
turnTally.route(providerRuntime.id, providerRuntime.model);
|
|
1167
1186
|
const fallbackChain = options?.providerRuntimeOverride ? [] : resolveTurnFallbackChain(facing, owner);
|
|
1168
1187
|
let chainIndex = 0;
|
|
1169
1188
|
const switchToChainEntry = async (from, firstCandidate, reason) => {
|
|
1170
1189
|
for (let candidate = firstCandidate; candidate !== null; candidate = (0, provider_fallback_1.nextReadyChainIndex)(fallbackChain, candidate)) {
|
|
1171
1190
|
try {
|
|
1172
1191
|
providerRuntime = await getChainEntryRuntime(fallbackChain[candidate], owner);
|
|
1192
|
+
turnTally.route(providerRuntime.id, providerRuntime.model);
|
|
1173
1193
|
chainIndex = candidate;
|
|
1174
1194
|
(0, runtime_1.emitNervesEvent)({
|
|
1175
1195
|
level: "warn",
|
|
@@ -1681,6 +1701,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1681
1701
|
})()
|
|
1682
1702
|
: ordinaryActiveTools;
|
|
1683
1703
|
const candidateToolNames = new Set(candidateActiveTools.map((tool) => tool.function.name));
|
|
1704
|
+
turnTally.offer(candidateActiveTools, deferralPool, ordinaryDefinitionsByName);
|
|
1684
1705
|
budgetNoteToolNames = candidateToolNames;
|
|
1685
1706
|
const unadvertisedRequiredTool = requiredToolCallNames.find((name) => !candidateToolNames.has(name));
|
|
1686
1707
|
if (unadvertisedRequiredTool) {
|
|
@@ -1882,6 +1903,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1882
1903
|
servedByProvider = true;
|
|
1883
1904
|
nextAttemptControls = [];
|
|
1884
1905
|
providerIterations += 1;
|
|
1906
|
+
turnTally.step(result.usage, providerRuntime.id, providerRuntime.model);
|
|
1885
1907
|
if (stepReportIteration !== null) {
|
|
1886
1908
|
// The progress-report call is the last one: it must settle (or rest), or the turn errors.
|
|
1887
1909
|
const settledReport = result.toolCalls.length === 1 && result.toolCalls[0].name === stepReportTool;
|
|
@@ -1967,6 +1989,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1967
1989
|
{ role: "user", content: wrapUpTool === "settle" ? STEP_BUDGET_REPORT_INSTRUCTION : STEP_BUDGET_REST_INSTRUCTION },
|
|
1968
1990
|
]);
|
|
1969
1991
|
callbacks.onClearText?.();
|
|
1992
|
+
turnTally.stepBudgetExhausted();
|
|
1970
1993
|
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "engine", event: "engine.step_budget_exhausted", message: `step budget used up; requesting a ${wrapUpTool}-only progress report`, meta: { stepBudget, providerIterations } });
|
|
1971
1994
|
continue;
|
|
1972
1995
|
}
|
|
@@ -2180,6 +2203,8 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
2180
2203
|
? (0, tools_base_1.withCode)(`rejected: ${entry.call.name} was not advertised for this channel; no handler was executed.`, "unknown-tool")
|
|
2181
2204
|
: (0, tools_base_1.withCode)(`invalid tool arguments: ${detail}`, "invalid-arguments");
|
|
2182
2205
|
rejections.push(rejection);
|
|
2206
|
+
// A rejected call never reaches onToolEnd; count it as a failed call (a name the turn never offered is "unknown").
|
|
2207
|
+
turnTally.rejected(entry.call.name);
|
|
2183
2208
|
options?.toolBoundaryObserver?.({
|
|
2184
2209
|
name: entry.call.name,
|
|
2185
2210
|
reason: callableToolNames.has(entry.call.name) ? "invalid_arguments" : "profile_excluded",
|
|
@@ -2716,6 +2741,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
2716
2741
|
for (const name of matchedNames)
|
|
2717
2742
|
if (!loadedDeferredTools.includes(name))
|
|
2718
2743
|
loadedDeferredTools.push(name);
|
|
2744
|
+
turnTally.findTools(matched.map((tool) => tool.function.name));
|
|
2719
2745
|
// A job a bundle does with a command its skill documents has no door to find; the skill's section answers.
|
|
2720
2746
|
const skills = (0, skill_search_1.findToolsSkillNote)(query, activeToolNames);
|
|
2721
2747
|
if (matched.length > 0 || skills.hits > 0)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SENT_MESSAGE_LEDGER_MAX_TEXT = exports.SENT_MESSAGE_LEDGER_MAX_ENTRIES = void 0;
|
|
37
|
+
exports.recordSentMessage = recordSentMessage;
|
|
38
|
+
exports.sentMessageLookup = sentMessageLookup;
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
|
+
const node_crypto_1 = require("node:crypto");
|
|
42
|
+
const runtime_1 = require("../nerves/runtime");
|
|
43
|
+
const atomic_file_1 = require("./atomic-file");
|
|
44
|
+
/**
|
|
45
|
+
* The messages the agent sent on a chat app that keeps no history the agent can read back, keyed by the id the app gave
|
|
46
|
+
* each one. When someone reacts to one of them the app sends only that id, and this is how the agent learns what it said.
|
|
47
|
+
* A sense whose app or journal already answers that (BlueBubbles' server, Telegram's effect journal) uses its own record
|
|
48
|
+
* instead, so no message is kept twice. Lives under the agent's ignored `state/`, newest entries kept, text excerpted.
|
|
49
|
+
*/
|
|
50
|
+
exports.SENT_MESSAGE_LEDGER_MAX_ENTRIES = 500;
|
|
51
|
+
exports.SENT_MESSAGE_LEDGER_MAX_TEXT = 500;
|
|
52
|
+
function ledgerPath(agentRoot, channel) {
|
|
53
|
+
return path.join(agentRoot, "state", "senses", "sent-messages", `${channel.replace(/[^\w.-]/g, "_")}.json`);
|
|
54
|
+
}
|
|
55
|
+
function entryKey(conversationId, messageId) {
|
|
56
|
+
return (0, node_crypto_1.createHash)("sha256").update(`${conversationId}\0${messageId}`).digest("hex");
|
|
57
|
+
}
|
|
58
|
+
function readLedger(file) {
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
61
|
+
return Array.isArray(parsed.entries)
|
|
62
|
+
? parsed.entries.filter((entry) => typeof entry?.key === "string" && typeof entry.text === "string")
|
|
63
|
+
: [];
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Note a message the agent sent. Never throws: losing one entry only means a later reaction to it reads as unidentified. */
|
|
70
|
+
function recordSentMessage(scope, messageId, text, now = new Date()) {
|
|
71
|
+
const trimmed = text.trim();
|
|
72
|
+
if (!messageId || !trimmed)
|
|
73
|
+
return;
|
|
74
|
+
let channel = "unknown";
|
|
75
|
+
try {
|
|
76
|
+
// A scope can be computed lazily (finding the agent root can fail), and that failure is caught here too.
|
|
77
|
+
const resolved = typeof scope === "function" ? scope() : scope;
|
|
78
|
+
channel = resolved.channel;
|
|
79
|
+
const file = ledgerPath(resolved.agentRoot, resolved.channel);
|
|
80
|
+
const key = entryKey(resolved.conversationId, messageId);
|
|
81
|
+
const entries = readLedger(file).filter((entry) => entry.key !== key);
|
|
82
|
+
entries.push({ key, text: trimmed.slice(0, exports.SENT_MESSAGE_LEDGER_MAX_TEXT), sentAt: now.toISOString() });
|
|
83
|
+
const body = { version: 1, entries: entries.slice(-exports.SENT_MESSAGE_LEDGER_MAX_ENTRIES) };
|
|
84
|
+
(0, atomic_file_1.writeFileAtomicSync)(file, `${JSON.stringify(body)}\n`);
|
|
85
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.sent_message_recorded", message: "noted a sent message for later reactions", meta: { channel } });
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.sent_message_record_failed", message: "could not note a sent message", meta: { channel, reason: String(error) } });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** A lookup for `resolveChatInteractionTarget` over this ledger: messages found here are always the agent's. */
|
|
92
|
+
function sentMessageLookup(scope) {
|
|
93
|
+
return (messageId) => {
|
|
94
|
+
const key = entryKey(scope.conversationId, messageId);
|
|
95
|
+
const entry = readLedger(ledgerPath(scope.agentRoot, scope.channel)).find((candidate) => candidate.key === key);
|
|
96
|
+
return entry ? { text: entry.text, fromAgent: true } : null;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TurnTally = exports.UNKNOWN_TOOL = exports.TURN_SUMMARY_CHANNELS = exports.ERROR_CLASSES_COVERED = exports.TURN_SUMMARY_ERROR_CLASSES = exports.RUN_AGENT_OUTCOMES_COVERED = exports.TURN_SUMMARY_OUTCOMES = void 0;
|
|
4
|
+
exports.tallyToolEnds = tallyToolEnds;
|
|
5
|
+
exports.emitTurnSummary = emitTurnSummary;
|
|
6
|
+
const runtime_1 = require("../nerves/runtime");
|
|
7
|
+
const tool_catalog_1 = require("../repertoire/tool-catalog");
|
|
8
|
+
/** Every value `runAgent` can end with; `RunAgentOutcome` in core.ts must stay a subset (a test pins it). */
|
|
9
|
+
exports.TURN_SUMMARY_OUTCOMES = ["settled", "suspended", "blocked", "superseded", "aborted", "errored", "observed", "rested"];
|
|
10
|
+
/** Fails to compile when `RunAgentOutcome` gains a value this list doesn't have. */
|
|
11
|
+
exports.RUN_AGENT_OUTCOMES_COVERED = true;
|
|
12
|
+
/** Why an errored turn failed: the provider error classes, or `none` when the turn didn't fail on an error. */
|
|
13
|
+
exports.TURN_SUMMARY_ERROR_CLASSES = ["auth-failure", "usage-limit", "rate-limit", "server-error", "network-error", "unknown", "none"];
|
|
14
|
+
/** Fails to compile when `ProviderErrorClassification` gains a value this list doesn't have. */
|
|
15
|
+
exports.ERROR_CLASSES_COVERED = true;
|
|
16
|
+
const CHANNEL_SET = {
|
|
17
|
+
cli: true, teams: true, bluebubbles: true, mail: true, voice: true, a2a: true, inner: true, mcp: true, telegram: true,
|
|
18
|
+
};
|
|
19
|
+
/** The channels a summary may name; anything else (or no channel) is `none`. */
|
|
20
|
+
exports.TURN_SUMMARY_CHANNELS = [...Object.keys(CHANNEL_SET), "none"];
|
|
21
|
+
/** The bucket for a tool name the turn never offered. */
|
|
22
|
+
exports.UNKNOWN_TOOL = "unknown";
|
|
23
|
+
/** The counters one `runAgent` call keeps. Every method is cheap and never throws on ordinary input. */
|
|
24
|
+
class TurnTally {
|
|
25
|
+
offered = new Map();
|
|
26
|
+
loaded = new Set();
|
|
27
|
+
calls = new Map();
|
|
28
|
+
provider = "unknown";
|
|
29
|
+
model = "unknown";
|
|
30
|
+
routed = false;
|
|
31
|
+
switches = 0;
|
|
32
|
+
emitted = false;
|
|
33
|
+
steps = 0;
|
|
34
|
+
budgetStops = 0;
|
|
35
|
+
errors = 0;
|
|
36
|
+
unknown = 0;
|
|
37
|
+
findCalls = 0;
|
|
38
|
+
findLoaded = 0;
|
|
39
|
+
loadedCalled = 0;
|
|
40
|
+
eager = 0;
|
|
41
|
+
deferred = 0;
|
|
42
|
+
input = 0;
|
|
43
|
+
output = 0;
|
|
44
|
+
reasoning = 0;
|
|
45
|
+
/** Records the doors a step offered (and those held back behind find_tools), so later calls can be named safely. */
|
|
46
|
+
offer(active, deferredPool, definitions) {
|
|
47
|
+
for (const tool of [...active, ...deferredPool]) {
|
|
48
|
+
const name = tool.function.name;
|
|
49
|
+
const server = definitions.get(name)?.mcpServer;
|
|
50
|
+
this.offered.set(name, server ? `mcp:${server}` : name);
|
|
51
|
+
}
|
|
52
|
+
const upFront = active.filter((tool) => tool.function.name !== tool_catalog_1.FIND_TOOLS_NAME && !this.loaded.has(tool.function.name));
|
|
53
|
+
this.eager = Math.max(this.eager, upFront.length);
|
|
54
|
+
this.deferred = Math.max(this.deferred, deferredPool.length);
|
|
55
|
+
}
|
|
56
|
+
/** The provider the turn is on; a change after the first counts as a fallback. */
|
|
57
|
+
route(provider, model) {
|
|
58
|
+
if (this.routed && (provider !== this.provider || model !== this.model))
|
|
59
|
+
this.switches += 1;
|
|
60
|
+
this.routed = true;
|
|
61
|
+
this.provider = provider;
|
|
62
|
+
this.model = model;
|
|
63
|
+
}
|
|
64
|
+
/** One provider call that returned, with the provider that served it and the usage it reported. */
|
|
65
|
+
step(usage, provider, model) {
|
|
66
|
+
this.route(provider, model);
|
|
67
|
+
this.steps += 1;
|
|
68
|
+
if (!usage)
|
|
69
|
+
return;
|
|
70
|
+
this.input += usage.input_tokens;
|
|
71
|
+
this.output += usage.output_tokens;
|
|
72
|
+
this.reasoning += usage.reasoning_tokens;
|
|
73
|
+
}
|
|
74
|
+
stepBudgetExhausted() {
|
|
75
|
+
this.budgetStops += 1;
|
|
76
|
+
}
|
|
77
|
+
/** A find_tools call and the door names it loaded. */
|
|
78
|
+
findTools(loadedNames) {
|
|
79
|
+
this.findCalls += 1;
|
|
80
|
+
if (loadedNames.length > 0)
|
|
81
|
+
this.findLoaded += 1;
|
|
82
|
+
for (const name of loadedNames)
|
|
83
|
+
this.loaded.add(name);
|
|
84
|
+
}
|
|
85
|
+
/** A tool call ended. find_tools is counted by `findTools`, so its own end is ignored here. */
|
|
86
|
+
toolEnd(name, success) {
|
|
87
|
+
if (name === tool_catalog_1.FIND_TOOLS_NAME)
|
|
88
|
+
return;
|
|
89
|
+
const label = this.offered.get(name);
|
|
90
|
+
if (label === undefined) {
|
|
91
|
+
this.unknown += 1;
|
|
92
|
+
this.calls.set(exports.UNKNOWN_TOOL, (this.calls.get(exports.UNKNOWN_TOOL) ?? 0) + 1);
|
|
93
|
+
if (!success)
|
|
94
|
+
this.errors += 1;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.calls.set(label, (this.calls.get(label) ?? 0) + 1);
|
|
98
|
+
if (!success)
|
|
99
|
+
this.errors += 1;
|
|
100
|
+
if (this.loaded.has(name))
|
|
101
|
+
this.loadedCalled += 1;
|
|
102
|
+
}
|
|
103
|
+
/** A call rejected before it ran (a name the turn didn't offer, or bad arguments): a failed call. */
|
|
104
|
+
rejected(name) {
|
|
105
|
+
if (name === tool_catalog_1.FIND_TOOLS_NAME) {
|
|
106
|
+
this.findCalls += 1;
|
|
107
|
+
this.errors += 1;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.toolEnd(name, false);
|
|
111
|
+
}
|
|
112
|
+
/** True the first time only, so a turn is summarized once. */
|
|
113
|
+
claimEmit() {
|
|
114
|
+
if (this.emitted)
|
|
115
|
+
return false;
|
|
116
|
+
this.emitted = true;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
summarize(input) {
|
|
120
|
+
const channel = input.channel !== undefined && Object.hasOwn(CHANNEL_SET, input.channel) ? input.channel : "none";
|
|
121
|
+
const outcome = exports.TURN_SUMMARY_OUTCOMES.includes(input.outcome) ? input.outcome : "errored";
|
|
122
|
+
const errorClass = exports.TURN_SUMMARY_ERROR_CLASSES.includes(input.errorClass) ? input.errorClass : "unknown";
|
|
123
|
+
return {
|
|
124
|
+
channel,
|
|
125
|
+
outcome,
|
|
126
|
+
errorClass,
|
|
127
|
+
provider: safeLabel(this.provider),
|
|
128
|
+
model: safeLabel(this.model),
|
|
129
|
+
providerSwitches: this.switches,
|
|
130
|
+
steps: this.steps,
|
|
131
|
+
stepBudgetExhausted: this.budgetStops,
|
|
132
|
+
toolCalls: Object.fromEntries([...this.calls.entries()].sort(([a], [b]) => a.localeCompare(b))),
|
|
133
|
+
toolErrors: this.errors,
|
|
134
|
+
unknownToolCalls: this.unknown,
|
|
135
|
+
findToolsCalls: this.findCalls,
|
|
136
|
+
findToolsLoaded: this.findLoaded,
|
|
137
|
+
loadedThenCalled: this.loadedCalled,
|
|
138
|
+
eagerDoors: this.eager,
|
|
139
|
+
deferredDoors: this.deferred,
|
|
140
|
+
inputTokens: this.input,
|
|
141
|
+
outputTokens: this.output,
|
|
142
|
+
reasoningTokens: this.reasoning,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.TurnTally = TurnTally;
|
|
147
|
+
/**
|
|
148
|
+
* The channel callbacks with every `onToolEnd` also counted in `tally`. Everything else passes through untouched,
|
|
149
|
+
* including methods' `this`, and the tally never stops the original callback from running.
|
|
150
|
+
*/
|
|
151
|
+
function tallyToolEnds(callbacks, tally) {
|
|
152
|
+
return new Proxy(callbacks, {
|
|
153
|
+
get(target, property, receiver) {
|
|
154
|
+
const value = Reflect.get(target, property, receiver);
|
|
155
|
+
if (property !== "onToolEnd" || typeof value !== "function")
|
|
156
|
+
return value;
|
|
157
|
+
// A proxy must return a frozen property as it is; such callbacks go uncounted rather than break the turn.
|
|
158
|
+
const own = Object.getOwnPropertyDescriptor(target, property);
|
|
159
|
+
if (own && !own.configurable && !own.writable)
|
|
160
|
+
return value;
|
|
161
|
+
return (name, summary, success) => {
|
|
162
|
+
try {
|
|
163
|
+
tally.toolEnd(name, success);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
// Counting must never change what the turn does.
|
|
167
|
+
}
|
|
168
|
+
return value.call(target, name, summary, success);
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/** Provider and model ids come from configuration; anything that doesn't look like an id is replaced. */
|
|
174
|
+
function safeLabel(value) {
|
|
175
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,79}$/.test(value) ? value : "other";
|
|
176
|
+
}
|
|
177
|
+
/** Emits `engine.turn_summary` for a finished turn. It never throws: a summary that fails is dropped. */
|
|
178
|
+
function emitTurnSummary(tally, input) {
|
|
179
|
+
try {
|
|
180
|
+
if (!tally.claimEmit())
|
|
181
|
+
return;
|
|
182
|
+
(0, runtime_1.emitNervesEvent)({
|
|
183
|
+
event: "engine.turn_summary",
|
|
184
|
+
trace_id: input.traceId,
|
|
185
|
+
component: "engine",
|
|
186
|
+
message: "turn summary (counts only)",
|
|
187
|
+
meta: tally.summarize(input),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// The turn already finished; a lost summary must not change its result.
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -48,6 +48,7 @@ exports.isAgentSelfHandle = isAgentSelfHandle;
|
|
|
48
48
|
exports.getDiscoveredOwnHandles = getDiscoveredOwnHandles;
|
|
49
49
|
exports.clearDiscoveredOwnHandles = clearDiscoveredOwnHandles;
|
|
50
50
|
exports.recordDiscoveredOwnHandle = recordDiscoveredOwnHandle;
|
|
51
|
+
exports.nameBlueBubblesReactionTarget = nameBlueBubblesReactionTarget;
|
|
51
52
|
exports.seedBlueBubblesStartupSemanticObservations = seedBlueBubblesStartupSemanticObservations;
|
|
52
53
|
exports.handleBlueBubblesEvent = handleBlueBubblesEvent;
|
|
53
54
|
exports.recoverQueuedBlueBubblesMessages = recoverQueuedBlueBubblesMessages;
|
|
@@ -83,6 +84,7 @@ const proactive_content_guard_1 = require("../proactive-content-guard");
|
|
|
83
84
|
const bluebubbles_meta_guard_1 = require("../bluebubbles-meta-guard");
|
|
84
85
|
const model_1 = require("./model");
|
|
85
86
|
const client_1 = require("./client");
|
|
87
|
+
const chat_interaction_1 = require("../../heart/chat-interaction");
|
|
86
88
|
const reactions_1 = require("./reactions");
|
|
87
89
|
const send_file_1 = require("./send-file");
|
|
88
90
|
const tools_chat_1 = require("../../repertoire/tools-chat");
|
|
@@ -2630,6 +2632,24 @@ function isCaptureOnlyBlueBubblesMutation(capture) {
|
|
|
2630
2632
|
return capture.event.kind === "unsend";
|
|
2631
2633
|
}
|
|
2632
2634
|
/** A reaction or an edit is speech to the agent: it arrives as a message carrying the shared rendering, aimed at the message it changes. */
|
|
2635
|
+
/**
|
|
2636
|
+
* A tapback names only the guid it points at. Ask the BlueBubbles server for that message (the agent's own sent
|
|
2637
|
+
* history and the person's), through the reaction resolver every sense shares, so the agent reads what was reacted to.
|
|
2638
|
+
*/
|
|
2639
|
+
async function nameBlueBubblesReactionTarget(event, client) {
|
|
2640
|
+
if (event.mutationType !== "reaction" || !event.reaction || !event.targetMessageGuid)
|
|
2641
|
+
return event;
|
|
2642
|
+
const interaction = (0, model_1.blueBubblesReactionInteraction)(event.reaction, { guid: event.targetMessageGuid });
|
|
2643
|
+
const named = await (0, chat_interaction_1.resolveChatInteractionTarget)(interaction, async (guid) => {
|
|
2644
|
+
if (client.getRepliedMessage) {
|
|
2645
|
+
const replied = await client.getRepliedMessage(guid);
|
|
2646
|
+
return replied ? { text: replied.text, fromAgent: replied.fromMe } : null;
|
|
2647
|
+
}
|
|
2648
|
+
const text = await client.getMessageText(guid);
|
|
2649
|
+
return text ? { text } : null;
|
|
2650
|
+
}, event.targetMessageGuid);
|
|
2651
|
+
return named === interaction ? event : { ...event, textForAgent: (0, chat_interaction_1.renderChatInteraction)(named) };
|
|
2652
|
+
}
|
|
2633
2653
|
function blueBubblesInteractionAsMessage(event) {
|
|
2634
2654
|
return {
|
|
2635
2655
|
kind: "message",
|
|
@@ -3018,7 +3038,9 @@ async function handleCapturedBlueBubblesSemanticEvent(captured, resolvedDeps, so
|
|
|
3018
3038
|
&& (identityGroundedRepaired.mutationType === "reaction" || identityGroundedRepaired.mutationType === "edit")
|
|
3019
3039
|
? identityGroundedRepaired
|
|
3020
3040
|
: null;
|
|
3021
|
-
const turnEvent = interaction
|
|
3041
|
+
const turnEvent = interaction
|
|
3042
|
+
? blueBubblesInteractionAsMessage(await nameBlueBubblesReactionTarget(interaction, resolvedDeps.createClient()))
|
|
3043
|
+
: identityGroundedRepaired;
|
|
3022
3044
|
if (turnEvent.kind === "mutation") {
|
|
3023
3045
|
const outcome = auditOnlyHandledOutcome(turnEvent.mutationType);
|
|
3024
3046
|
publishTerminalReceipt(outcome);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BlueBubblesIgnoredEventError = void 0;
|
|
4
4
|
exports.describeBlueBubblesReaction = describeBlueBubblesReaction;
|
|
5
5
|
exports.renderBlueBubblesReactionText = renderBlueBubblesReactionText;
|
|
6
|
+
exports.blueBubblesReactionInteraction = blueBubblesReactionInteraction;
|
|
6
7
|
exports.renderBlueBubblesEditText = renderBlueBubblesEditText;
|
|
7
8
|
exports.normalizeBlueBubblesEvent = normalizeBlueBubblesEvent;
|
|
8
9
|
const chat_interaction_1 = require("../../heart/chat-interaction");
|
|
@@ -203,13 +204,17 @@ function describeBlueBubblesReaction(raw, rawTransportValue = raw) {
|
|
|
203
204
|
* it was added or removed, and which message it points at.
|
|
204
205
|
*/
|
|
205
206
|
function renderBlueBubblesReactionText(reaction, target) {
|
|
206
|
-
return (0, chat_interaction_1.renderChatInteraction)(
|
|
207
|
+
return (0, chat_interaction_1.renderChatInteraction)(blueBubblesReactionInteraction(reaction, target));
|
|
208
|
+
}
|
|
209
|
+
/** A tapback as the shared reaction every sense speaks; BlueBubbles only maps its wire values. */
|
|
210
|
+
function blueBubblesReactionInteraction(reaction, target) {
|
|
211
|
+
return {
|
|
207
212
|
kind: "reaction",
|
|
208
213
|
label: reaction.action === "remove" ? reaction.noun ?? reaction.raw.replace(/^-/, "") : reaction.raw,
|
|
209
214
|
...(reaction.verb ? { verb: reaction.verb } : {}),
|
|
210
215
|
removed: reaction.action === "remove",
|
|
211
216
|
target: { ...(target.guid ? { id: `guid ${target.guid}` } : {}), ...(target.text ? { text: target.text } : {}), ...(typeof target.fromMe === "boolean" ? { fromAgent: target.fromMe } : {}) },
|
|
212
|
-
}
|
|
217
|
+
};
|
|
213
218
|
}
|
|
214
219
|
function stripPartPrefix(guid) {
|
|
215
220
|
if (!guid)
|
package/dist/senses/teams.js
CHANGED
|
@@ -38,8 +38,10 @@ exports.aiLabelEntities = aiLabelEntities;
|
|
|
38
38
|
exports.stripMentions = stripMentions;
|
|
39
39
|
exports.splitMessage = splitMessage;
|
|
40
40
|
exports.sanitizeFeedbackComment = sanitizeFeedbackComment;
|
|
41
|
+
exports.noteTeamsSentMessage = noteTeamsSentMessage;
|
|
41
42
|
exports.buildFeedbackSyntheticText = buildFeedbackSyntheticText;
|
|
42
43
|
exports.buildReactionSyntheticText = buildReactionSyntheticText;
|
|
44
|
+
exports.resolveTeamsReactionText = resolveTeamsReactionText;
|
|
43
45
|
exports.buildEditSyntheticText = buildEditSyntheticText;
|
|
44
46
|
exports.buildWelcomeCard = buildWelcomeCard;
|
|
45
47
|
exports.createTeamsCallbacks = createTeamsCallbacks;
|
|
@@ -73,6 +75,7 @@ const commands_1 = require("./commands");
|
|
|
73
75
|
const nerves_1 = require("../nerves");
|
|
74
76
|
const runtime_1 = require("../nerves/runtime");
|
|
75
77
|
const chat_interaction_1 = require("../heart/chat-interaction");
|
|
78
|
+
const sent_message_ledger_1 = require("../heart/sent-message-ledger");
|
|
76
79
|
const proactive_content_guard_1 = require("./proactive-content-guard");
|
|
77
80
|
const turn_coordinator_1 = require("../heart/turn-coordinator");
|
|
78
81
|
const identity_1 = require("../heart/identity");
|
|
@@ -171,8 +174,18 @@ function sanitizeFeedbackComment(comment) {
|
|
|
171
174
|
}
|
|
172
175
|
// Teams names its reactions; the agent reads the emoji the person tapped.
|
|
173
176
|
const TEAMS_REACTION_EMOJI = { like: "👍", dislike: "👎", heart: "❤️", laugh: "😆", surprised: "😮", sad: "😢", angry: "😠" };
|
|
174
|
-
function teamsReaction(type, removed) {
|
|
175
|
-
return (0, chat_interaction_1.renderChatInteraction)({ kind: "reaction", label: TEAMS_REACTION_EMOJI[type] ?? type, removed, target
|
|
177
|
+
function teamsReaction(type, removed, target = { fromAgent: true }) {
|
|
178
|
+
return (0, chat_interaction_1.renderChatInteraction)({ kind: "reaction", label: TEAMS_REACTION_EMOJI[type] ?? type, removed, target });
|
|
179
|
+
}
|
|
180
|
+
/** Where the agent's Teams messages are noted, so a reaction (which carries only the message id) can say what was reacted to. */
|
|
181
|
+
function teamsSentScope(conversationId) {
|
|
182
|
+
return { agentRoot: (0, identity_1.getAgentRoot)(), channel: "teams", conversationId };
|
|
183
|
+
}
|
|
184
|
+
/** Note a Teams message the agent sent, from the receipt Teams returned for it. */
|
|
185
|
+
function noteTeamsSentMessage(conversationId, receipt, text) {
|
|
186
|
+
const id = receipt && typeof receipt === "object" && "id" in receipt && typeof receipt.id === "string" ? receipt.id : undefined;
|
|
187
|
+
if (id)
|
|
188
|
+
(0, sent_message_ledger_1.recordSentMessage)(() => teamsSentScope(conversationId), id, text);
|
|
176
189
|
}
|
|
177
190
|
// Build synthetic message text from a Teams feedback reaction (the thumbs on an AI-labeled reply).
|
|
178
191
|
function buildFeedbackSyntheticText(reaction, comment) {
|
|
@@ -180,9 +193,17 @@ function buildFeedbackSyntheticText(reaction, comment) {
|
|
|
180
193
|
return `[${teamsReaction(reaction === "like" ? "like" : "dislike", false)}${said}]`;
|
|
181
194
|
}
|
|
182
195
|
// Teams only tells a bot about reactions on the bot's own messages, so the target is always the agent's.
|
|
183
|
-
function buildReactionSyntheticText(added, removed) {
|
|
196
|
+
function buildReactionSyntheticText(added, removed, target) {
|
|
184
197
|
const change = added?.[0] ? { type: added[0].type, removed: false } : removed?.[0] ? { type: removed[0].type, removed: true } : null;
|
|
185
|
-
return change ? `[${teamsReaction(change.type, change.removed)}]` : null;
|
|
198
|
+
return change ? `[${teamsReaction(change.type, change.removed, target)}]` : null;
|
|
199
|
+
}
|
|
200
|
+
/** A Teams reaction names the message by id (`replyToId`); the shared resolver finds what the agent said in it. */
|
|
201
|
+
async function resolveTeamsReactionText(activity) {
|
|
202
|
+
const conversationId = activity.conversation?.id;
|
|
203
|
+
if (!activity.replyToId || !conversationId)
|
|
204
|
+
return buildReactionSyntheticText(activity.reactionsAdded, activity.reactionsRemoved);
|
|
205
|
+
const target = await (0, chat_interaction_1.resolveChatMessageRef)({ fromAgent: true }, (0, sent_message_ledger_1.sentMessageLookup)(teamsSentScope(conversationId)), activity.replyToId);
|
|
206
|
+
return buildReactionSyntheticText(activity.reactionsAdded, activity.reactionsRemoved, target);
|
|
186
207
|
}
|
|
187
208
|
function buildEditSyntheticText(newText) {
|
|
188
209
|
return `[${(0, chat_interaction_1.renderChatInteraction)({ kind: "edit", newText, target: { fromAgent: false } })}]`;
|
|
@@ -1413,7 +1434,7 @@ function registerBotHandlers(app, label) {
|
|
|
1413
1434
|
}
|
|
1414
1435
|
};
|
|
1415
1436
|
const ctxSend = (t) => {
|
|
1416
|
-
const sending = noted(t, () => ctx.send({ type: "message", text: t, replyToId: activity.replyToId, entities: aiLabelEntities(), channelData: { feedbackLoopEnabled: true } }));
|
|
1437
|
+
const sending = noted(t, async () => noteTeamsSentMessage(convId, await ctx.send({ type: "message", text: t, replyToId: activity.replyToId, entities: aiLabelEntities(), channelData: { feedbackLoopEnabled: true } }), t));
|
|
1417
1438
|
inbound.track(sending);
|
|
1418
1439
|
return sending;
|
|
1419
1440
|
};
|
|
@@ -1451,7 +1472,7 @@ function registerBotHandlers(app, label) {
|
|
|
1451
1472
|
return undefined;
|
|
1452
1473
|
});
|
|
1453
1474
|
app.on("messageReaction", async (ctx) => {
|
|
1454
|
-
const text =
|
|
1475
|
+
const text = await resolveTeamsReactionText(ctx.activity);
|
|
1455
1476
|
if (text)
|
|
1456
1477
|
await runInteractionTurn(ctx, text, true);
|
|
1457
1478
|
return undefined;
|
|
@@ -1502,6 +1523,7 @@ function registerBotHandlers(app, label) {
|
|
|
1502
1523
|
try {
|
|
1503
1524
|
const receipt = await send({ type: "message", text, replyToId: inboundActivityId, entities: aiLabelEntities(), channelData: { feedbackLoopEnabled: true } });
|
|
1504
1525
|
inbound().noteSent(true);
|
|
1526
|
+
noteTeamsSentMessage(convId, receipt, text);
|
|
1505
1527
|
const messageId = receipt && typeof receipt === "object" && "id" in receipt && typeof receipt.id === "string" ? receipt.id : undefined;
|
|
1506
1528
|
reportTeamsRequest(messageId ? "replied" : "reply_emitted", convId, requestContext, { delivery: messageId ? "accepted" : "unconfirmed", ...(messageId ? { outboundActivityId: messageId } : {}) });
|
|
1507
1529
|
}
|
|
@@ -1963,6 +1985,7 @@ async function sendProactiveTeamsMessageToSession(params, deps) {
|
|
|
1963
1985
|
meta: { friendId: params.friendId, aadObjectId: aadInfo.aadObjectId, sessionKey: params.sessionKey },
|
|
1964
1986
|
});
|
|
1965
1987
|
const messageId = activity && typeof activity === "object" && "id" in activity && typeof activity.id === "string" ? activity.id : undefined;
|
|
1988
|
+
noteTeamsSentMessage(conversation.id, activity, params.text);
|
|
1966
1989
|
// Saved into the conversation it was sent into, so the friend's reply there carries it.
|
|
1967
1990
|
const origin = params.origin ?? "proactive";
|
|
1968
1991
|
// Recording never changes the result of a send that already went out.
|
package/dist/senses/telegram.js
CHANGED
|
@@ -1894,15 +1894,15 @@ function createTelegramSenseApp(options) {
|
|
|
1894
1894
|
}
|
|
1895
1895
|
};
|
|
1896
1896
|
// Telegram tells the bot which message was reacted to, not what it said. The journal knows the agent's own messages.
|
|
1897
|
-
const nameReactionTarget = (message) => {
|
|
1897
|
+
const nameReactionTarget = async (message) => {
|
|
1898
1898
|
const interaction = message.interaction;
|
|
1899
|
-
if (interaction?.kind !== "reaction"
|
|
1899
|
+
if (interaction?.kind !== "reaction")
|
|
1900
1900
|
return message;
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
return
|
|
1904
|
-
|
|
1905
|
-
return { ...message, interaction: named, text: (0, chat_interaction_1.renderChatInteraction)(named) };
|
|
1901
|
+
const named = await (0, chat_interaction_1.resolveChatInteractionTarget)(interaction, (id) => {
|
|
1902
|
+
const sent = (0, telegram_effect_adapter_1.resolveTelegramReply)(getEffectJournal(), { messageId: Number(id), friendId: configuredOwnerFriendId, sessionKey: configuredOwnerSessionKey });
|
|
1903
|
+
return sent?.text ? { text: sent.text, fromAgent: true } : null;
|
|
1904
|
+
});
|
|
1905
|
+
return named === interaction ? message : { ...message, interaction: named, text: (0, chat_interaction_1.renderChatInteraction)(named) };
|
|
1906
1906
|
};
|
|
1907
1907
|
/** Write a message's entry before its turn, or null when it must not run: it has an outcome, or a stopped turn left it unsafe to run again. */
|
|
1908
1908
|
const beginInbound = (id) => {
|
|
@@ -2023,7 +2023,7 @@ function createTelegramSenseApp(options) {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
};
|
|
2025
2025
|
const onMessage = (inbound) => runWithAcceptanceAuditOwner(async () => {
|
|
2026
|
-
const message = nameReactionTarget(inbound);
|
|
2026
|
+
const message = await nameReactionTarget(inbound);
|
|
2027
2027
|
const turn = beginInbound(inboundIdFor(message.updateId));
|
|
2028
2028
|
if (!turn)
|
|
2029
2029
|
return;
|
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.1462",
|
|
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.1462",
|
|
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.1462",
|
|
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": {
|