@ouro.bot/cli 0.1.0-alpha.1087 → 0.1.0-alpha.1089
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/mind/where-am-i.js +4 -3
- package/dist/repertoire/ado-semantic.js +3 -2
- package/dist/repertoire/auth-required.js +21 -0
- package/dist/repertoire/tools-github.js +2 -1
- package/dist/repertoire/tools-teams.js +7 -6
- package/dist/senses/teams.js +86 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1089",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Where-i-am names the machine its one-machine senses run on (\"that run here, on aris-mac-mini: teams, habits\" and \"run on a peer, not here\"), and lists machine-scoped senses agent.json turns off, so the agent never answers \"one machine at a time\" without saying which, or leaves out a sense that is off."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1088",
|
|
12
|
+
"changes": [
|
|
13
|
+
"Teams says exactly why OAuth sign-in can't start; typing stays visible during long tools"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1087",
|
|
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.1089</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
package/dist/mind/where-am-i.js
CHANGED
|
@@ -100,12 +100,12 @@ function renderWhereAmI(presence, self, nowMs = Date.now()) {
|
|
|
100
100
|
const holder = presence.peers.find((peer) => peer.machineId !== self.machineId && (0, presence_1.isRosterMember)(presence, peer.machineId) && peer.owns?.includes(sense) && !peer.failover?.includes(sense));
|
|
101
101
|
return holder ? `${sense} (not yet: waiting for ${machineName(holder.machineId)} to let go)` : sense;
|
|
102
102
|
});
|
|
103
|
-
lines.push(`shared senses that run here: ${here.length > 0 ? here.join(", ") : "none"}.`);
|
|
103
|
+
lines.push(`shared senses (each runs on exactly one machine) that run here, on ${self.name}: ${here.length > 0 ? here.join(", ") : "none"}.`);
|
|
104
104
|
for (const lease of standIn) {
|
|
105
105
|
lines.push(`i am running ${lease.sense} here in place of ${machineName(lease.from)} since ${ago(lease.since, nowMs)}, because ${lease.reason || "it stopped answering"}; ${machineName(lease.from)} takes it back as soon as it runs again.`);
|
|
106
106
|
}
|
|
107
107
|
if (elsewhere.length > 0) {
|
|
108
|
-
lines.push(`shared senses that run on a peer: ${elsewhere.map((sense) => {
|
|
108
|
+
lines.push(`shared senses that run on a peer, not here: ${elsewhere.map((sense) => {
|
|
109
109
|
const owner = (0, presence_1.effectiveOwner)(presence, sense);
|
|
110
110
|
const record = presence.peers.find((peer) => peer.machineId === owner);
|
|
111
111
|
const shown = record?.owns?.includes(sense) ? `its record from ${ago(record.seenAt, nowMs)} says it runs it` : "its last record does not show it running";
|
|
@@ -116,7 +116,8 @@ function renderWhereAmI(presence, self, nowMs = Date.now()) {
|
|
|
116
116
|
if (off.length > 0)
|
|
117
117
|
lines.push(`turned off in agent.json, so running on no machine: ${off.join(", ")}.`);
|
|
118
118
|
const local = MACHINE_SENSES.filter((sense) => (0, presence_1.senseEnabled)(presence, sense));
|
|
119
|
-
|
|
119
|
+
const localOff = MACHINE_SENSES.filter((sense) => !(0, presence_1.senseEnabled)(presence, sense));
|
|
120
|
+
lines.push(`machine-scoped senses that run on every presence and see only their own machine: ${local.length > 0 ? local.join(", ") : "none"}${localOff.length > 0 ? `; turned off in agent.json: ${localOff.join(", ")}` : ""}.`);
|
|
120
121
|
if (presence.legacy.length > 0) {
|
|
121
122
|
lines.push(`until ${presence.legacy.map((id) => machineName(id)).join(", ")} publish${presence.legacy.length === 1 ? "es" : ""} a current presence record, every shared sense stays with home.`);
|
|
122
123
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.adoSemanticToolDefinitions = void 0;
|
|
6
6
|
const runtime_1 = require("../nerves/runtime");
|
|
7
|
+
const auth_required_1 = require("./auth-required");
|
|
7
8
|
const ado_client_1 = require("./ado-client");
|
|
8
9
|
const ado_context_1 = require("./ado-context");
|
|
9
10
|
const ado_templates_1 = require("./ado-templates");
|
|
@@ -85,7 +86,7 @@ function buildReparentPatch(newParentId) {
|
|
|
85
86
|
}
|
|
86
87
|
async function checkAuth(ctx) {
|
|
87
88
|
if (!ctx?.adoToken) {
|
|
88
|
-
return "
|
|
89
|
+
return (0, auth_required_1.authRequired)(ctx, "ado", "I need access to Azure DevOps.");
|
|
89
90
|
}
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
@@ -238,7 +239,7 @@ exports.adoSemanticToolDefinitions = [
|
|
|
238
239
|
},
|
|
239
240
|
handler: async (args, ctx) => {
|
|
240
241
|
if (!ctx?.adoToken) {
|
|
241
|
-
return "
|
|
242
|
+
return (0, auth_required_1.authRequired)(ctx, "ado", "I need access to Azure DevOps.");
|
|
242
243
|
}
|
|
243
244
|
(0, runtime_1.emitNervesEvent)({
|
|
244
245
|
component: "repertoire",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authRequired = authRequired;
|
|
4
|
+
const runtime_1 = require("../nerves/runtime");
|
|
5
|
+
/**
|
|
6
|
+
* The result a tool returns when it has no token for an OAuth connection. When the sense already knows sign-in
|
|
7
|
+
* cannot start for that connection (for example the bot has no such OAuth connection), the result says exactly
|
|
8
|
+
* that instead of promising a sign-in prompt that will never appear.
|
|
9
|
+
*/
|
|
10
|
+
function authRequired(ctx, connection, need) {
|
|
11
|
+
const unavailable = ctx?.oauthUnavailable?.[connection];
|
|
12
|
+
(0, runtime_1.emitNervesEvent)({
|
|
13
|
+
component: "repertoire",
|
|
14
|
+
event: "repertoire.auth_required",
|
|
15
|
+
message: "tool needs an OAuth token it does not have",
|
|
16
|
+
meta: { connection, signinAvailable: !unavailable },
|
|
17
|
+
});
|
|
18
|
+
return unavailable
|
|
19
|
+
? `AUTH_UNAVAILABLE:${connection} -- ${need} Sign-in can't start here: ${unavailable}`
|
|
20
|
+
: `AUTH_REQUIRED:${connection} -- ${need} Please sign in when prompted.`;
|
|
21
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.githubToolDefinitions = void 0;
|
|
4
|
+
const auth_required_1 = require("./auth-required");
|
|
4
5
|
const github_client_1 = require("./github-client");
|
|
5
6
|
const runtime_1 = require("../nerves/runtime");
|
|
6
7
|
exports.githubToolDefinitions = [
|
|
@@ -29,7 +30,7 @@ exports.githubToolDefinitions = [
|
|
|
29
30
|
meta: {},
|
|
30
31
|
});
|
|
31
32
|
if (!ctx?.githubToken) {
|
|
32
|
-
return "
|
|
33
|
+
return (0, auth_required_1.authRequired)(ctx, "github", "I need access to GitHub.");
|
|
33
34
|
}
|
|
34
35
|
const owner = "ourostack";
|
|
35
36
|
const repo = "ouroboros";
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.teamsToolDefinitions = void 0;
|
|
7
|
+
const auth_required_1 = require("./auth-required");
|
|
7
8
|
const graph_client_1 = require("./graph-client");
|
|
8
9
|
const ado_client_1 = require("./ado-client");
|
|
9
10
|
const graph_endpoints_json_1 = __importDefault(require("./data/graph-endpoints.json"));
|
|
@@ -31,7 +32,7 @@ exports.teamsToolDefinitions = [
|
|
|
31
32
|
},
|
|
32
33
|
handler: async (args, ctx) => {
|
|
33
34
|
if (!ctx?.graphToken) {
|
|
34
|
-
return "
|
|
35
|
+
return (0, auth_required_1.authRequired)(ctx, "graph", "I need access to Microsoft Graph.");
|
|
35
36
|
}
|
|
36
37
|
return (0, graph_client_1.graphRequest)(ctx.graphToken, "GET", args.path);
|
|
37
38
|
},
|
|
@@ -57,7 +58,7 @@ exports.teamsToolDefinitions = [
|
|
|
57
58
|
},
|
|
58
59
|
handler: async (args, ctx) => {
|
|
59
60
|
if (!ctx?.graphToken) {
|
|
60
|
-
return "
|
|
61
|
+
return (0, auth_required_1.authRequired)(ctx, "graph", "I need access to Microsoft Graph.");
|
|
61
62
|
}
|
|
62
63
|
if (!MUTATE_METHODS.includes(args.method)) {
|
|
63
64
|
return `Invalid method "${args.method}". Must be one of: ${MUTATE_METHODS.join(", ")}`;
|
|
@@ -90,7 +91,7 @@ exports.teamsToolDefinitions = [
|
|
|
90
91
|
},
|
|
91
92
|
handler: async (args, ctx) => {
|
|
92
93
|
if (!ctx?.adoToken) {
|
|
93
|
-
return "
|
|
94
|
+
return (0, auth_required_1.authRequired)(ctx, "ado", "I need access to Azure DevOps.");
|
|
94
95
|
}
|
|
95
96
|
const method = args.method || "GET";
|
|
96
97
|
return (0, ado_client_1.adoRequest)(ctx.adoToken, method, args.organization, args.path, args.body, args.host);
|
|
@@ -119,7 +120,7 @@ exports.teamsToolDefinitions = [
|
|
|
119
120
|
},
|
|
120
121
|
handler: async (args, ctx) => {
|
|
121
122
|
if (!ctx?.adoToken) {
|
|
122
|
-
return "
|
|
123
|
+
return (0, auth_required_1.authRequired)(ctx, "ado", "I need access to Azure DevOps.");
|
|
123
124
|
}
|
|
124
125
|
if (!MUTATE_METHODS.includes(args.method)) {
|
|
125
126
|
return `Invalid method "${args.method}". Must be one of: ${MUTATE_METHODS.join(", ")}`;
|
|
@@ -142,7 +143,7 @@ exports.teamsToolDefinitions = [
|
|
|
142
143
|
},
|
|
143
144
|
handler: async (_args, ctx) => {
|
|
144
145
|
if (!ctx?.graphToken) {
|
|
145
|
-
return "
|
|
146
|
+
return (0, auth_required_1.authRequired)(ctx, "graph", "I need access to your Microsoft 365 profile.");
|
|
146
147
|
}
|
|
147
148
|
return (0, graph_client_1.getProfile)(ctx.graphToken);
|
|
148
149
|
},
|
|
@@ -166,7 +167,7 @@ exports.teamsToolDefinitions = [
|
|
|
166
167
|
},
|
|
167
168
|
handler: async (args, ctx) => {
|
|
168
169
|
if (!ctx?.adoToken) {
|
|
169
|
-
return "
|
|
170
|
+
return (0, auth_required_1.authRequired)(ctx, "ado", "I need access to your Azure DevOps account.");
|
|
170
171
|
}
|
|
171
172
|
let org = args.organization;
|
|
172
173
|
if (!org) {
|
package/dist/senses/teams.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DEFAULT_FLUSH_INTERVAL_MS = void 0;
|
|
36
|
+
exports.TYPING_KEEPALIVE_MS = exports.DEFAULT_FLUSH_INTERVAL_MS = void 0;
|
|
37
37
|
exports.aiLabelEntities = aiLabelEntities;
|
|
38
38
|
exports.stripMentions = stripMentions;
|
|
39
39
|
exports.splitMessage = splitMessage;
|
|
@@ -44,6 +44,10 @@ exports.createTeamsCallbacks = createTeamsCallbacks;
|
|
|
44
44
|
exports.reasoningStatus = reasoningStatus;
|
|
45
45
|
exports.withConversationLock = withConversationLock;
|
|
46
46
|
exports.parseTeamsQuotedReply = parseTeamsQuotedReply;
|
|
47
|
+
exports.oauthSigninUnavailableReason = oauthSigninUnavailableReason;
|
|
48
|
+
exports.recordOAuthSigninFailure = recordOAuthSigninFailure;
|
|
49
|
+
exports.oauthSigninUnavailableNotice = oauthSigninUnavailableNotice;
|
|
50
|
+
exports.resetOAuthSigninFailures = resetOAuthSigninFailures;
|
|
47
51
|
exports.handleTeamsMessage = handleTeamsMessage;
|
|
48
52
|
exports.createTeamsSdkLogger = createTeamsSdkLogger;
|
|
49
53
|
exports.sendProactiveTeamsMessageToSession = sendProactiveTeamsMessageToSession;
|
|
@@ -121,6 +125,9 @@ const RECOVERY_CHUNK_SIZE = 4000;
|
|
|
121
125
|
// At 1000ms (1 req/sec), we stay at the Teams throttle floor while keeping the
|
|
122
126
|
// stream alive well within the 15s Copilot timeout. Tune up if 429s observed.
|
|
123
127
|
exports.DEFAULT_FLUSH_INTERVAL_MS = 1_000;
|
|
128
|
+
// Teams shows a typing indicator for only a few seconds. While a tool runs nothing else refreshes it, so a long
|
|
129
|
+
// shell or session call looked like silence; this repeats the current status until the tool ends.
|
|
130
|
+
exports.TYPING_KEEPALIVE_MS = 3_000;
|
|
124
131
|
// Split text into chunks that fit within maxLen, breaking at paragraph
|
|
125
132
|
// boundaries (\n\n), then line boundaries (\n), then word boundaries.
|
|
126
133
|
// Never loses content — all text is preserved across chunks.
|
|
@@ -219,6 +226,22 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
219
226
|
let lastPhrase = "";
|
|
220
227
|
let flushTimer = null;
|
|
221
228
|
const flushInterval = options?.flushIntervalMs ?? exports.DEFAULT_FLUSH_INTERVAL_MS;
|
|
229
|
+
let keepaliveTimer = null;
|
|
230
|
+
let toolsRunning = 0;
|
|
231
|
+
let toolStatus = "";
|
|
232
|
+
const keepaliveInterval = options?.typingKeepaliveMs ?? exports.TYPING_KEEPALIVE_MS;
|
|
233
|
+
function startTypingKeepalive() {
|
|
234
|
+
if (keepaliveTimer)
|
|
235
|
+
return;
|
|
236
|
+
keepaliveTimer = setInterval(() => safeUpdate(toolStatus || "working..."), keepaliveInterval);
|
|
237
|
+
}
|
|
238
|
+
function stopTypingKeepalive() {
|
|
239
|
+
toolsRunning = 0;
|
|
240
|
+
if (keepaliveTimer) {
|
|
241
|
+
clearInterval(keepaliveTimer);
|
|
242
|
+
keepaliveTimer = null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
222
245
|
// The SDK merges every chunk's entities into the final message, and Teams rejects a final
|
|
223
246
|
// message with more than one root message entity (400 BadSyntax), so only the first chunk
|
|
224
247
|
// carries the AI label.
|
|
@@ -271,12 +294,14 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
271
294
|
stopped = true;
|
|
272
295
|
stopPhraseRotation();
|
|
273
296
|
stopFlushTimer();
|
|
297
|
+
stopTypingKeepalive();
|
|
274
298
|
controller.abort();
|
|
275
299
|
}
|
|
276
300
|
// Clean up timers when the controller is aborted externally
|
|
277
301
|
controller.signal.addEventListener("abort", () => {
|
|
278
302
|
stopPhraseRotation();
|
|
279
303
|
stopFlushTimer();
|
|
304
|
+
stopTypingKeepalive();
|
|
280
305
|
});
|
|
281
306
|
// Handle the result of a stream call: if it returns a Promise (the Teams SDK
|
|
282
307
|
// does async HTTP under the hood even though the interface types it as void),
|
|
@@ -545,7 +570,7 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
545
570
|
},
|
|
546
571
|
...(() => {
|
|
547
572
|
const toolCbs = (0, tool_activity_callbacks_1.createToolActivityCallbacks)({
|
|
548
|
-
onDescription: (text) => safeUpdate(text),
|
|
573
|
+
onDescription: (text) => { toolStatus = text; safeUpdate(text); },
|
|
549
574
|
/* v8 ignore next -- onResult only called in debug mode; tested via tool-activity-callbacks.test.ts @preserve */
|
|
550
575
|
onResult: (text) => safeUpdate(text),
|
|
551
576
|
/* v8 ignore next -- onFailure tested via onToolEnd failure test @preserve */
|
|
@@ -567,6 +592,8 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
567
592
|
flushTextBuffer();
|
|
568
593
|
toolCbs.onToolStart(name, args);
|
|
569
594
|
hadToolRun = true;
|
|
595
|
+
toolsRunning++;
|
|
596
|
+
startTypingKeepalive();
|
|
570
597
|
},
|
|
571
598
|
onToolEnd: (name, summary, success) => {
|
|
572
599
|
// speak is flow-control: skip phrase-rotation stop and tool-activity end
|
|
@@ -577,6 +604,9 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
577
604
|
return;
|
|
578
605
|
stopPhraseRotation();
|
|
579
606
|
toolCbs.onToolEnd(name, summary, success);
|
|
607
|
+
toolsRunning = Math.max(0, toolsRunning - 1);
|
|
608
|
+
if (toolsRunning === 0)
|
|
609
|
+
stopTypingKeepalive();
|
|
580
610
|
},
|
|
581
611
|
};
|
|
582
612
|
})(),
|
|
@@ -604,6 +634,7 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
|
|
|
604
634
|
flush: async () => {
|
|
605
635
|
stopFlushTimer();
|
|
606
636
|
stopPhraseRotation();
|
|
637
|
+
stopTypingKeepalive();
|
|
607
638
|
if (textBuffer) {
|
|
608
639
|
// Bypass MIN_INITIAL_CHARS threshold — flush delivers all remaining content
|
|
609
640
|
firstContentEmitted = true;
|
|
@@ -785,6 +816,44 @@ function parseTeamsQuotedReply(attachments, ids) {
|
|
|
785
816
|
}
|
|
786
817
|
return undefined;
|
|
787
818
|
}
|
|
819
|
+
const OAUTH_SERVICE_LABELS = { graph: "Microsoft Graph", ado: "Azure DevOps", github: "GitHub" };
|
|
820
|
+
const OAUTH_UNAVAILABLE_TTL_MS = 60 * 60 * 1000;
|
|
821
|
+
// Sign-ins that could not start, by OAuth connection name. Kept for an hour so every turn in between can say why
|
|
822
|
+
// instead of promising a prompt, and so the person hears about it once, not on every turn.
|
|
823
|
+
const oauthSigninUnavailable = new Map();
|
|
824
|
+
/** Why sign-in for this connection can't start, when a recent attempt showed it; undefined when it may work. */
|
|
825
|
+
function oauthSigninUnavailableReason(connectionName, now = Date.now()) {
|
|
826
|
+
const entry = oauthSigninUnavailable.get(connectionName);
|
|
827
|
+
if (!entry)
|
|
828
|
+
return undefined;
|
|
829
|
+
if (entry.until <= now) {
|
|
830
|
+
oauthSigninUnavailable.delete(connectionName);
|
|
831
|
+
return undefined;
|
|
832
|
+
}
|
|
833
|
+
return entry.reason;
|
|
834
|
+
}
|
|
835
|
+
/** Records a sign-in that failed to start and returns the reason in words the person can act on. */
|
|
836
|
+
function recordOAuthSigninFailure(connectionName, error, now = Date.now()) {
|
|
837
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
838
|
+
const reason = /status code 400\b/.test(message)
|
|
839
|
+
? `Bot Service rejected the sign-in request (HTTP 400). The usual cause is that this bot registration has no OAuth connection named "${connectionName}"; it has to be added on the Azure Bot before sign-in can work.`
|
|
840
|
+
: `the sign-in request failed (${message.slice(0, 160)}).`;
|
|
841
|
+
oauthSigninUnavailable.set(connectionName, { reason, until: now + OAUTH_UNAVAILABLE_TTL_MS });
|
|
842
|
+
(0, runtime_1.emitNervesEvent)({
|
|
843
|
+
level: "warn", component: "channels", event: "channel.oauth_signin_unavailable",
|
|
844
|
+
message: "OAuth sign-in cannot start for this connection", meta: { connectionName, reason },
|
|
845
|
+
});
|
|
846
|
+
return reason;
|
|
847
|
+
}
|
|
848
|
+
/** The one-line notice the person gets when a sign-in they needed could not start. */
|
|
849
|
+
function oauthSigninUnavailableNotice(service, reason) {
|
|
850
|
+
const label = OAUTH_SERVICE_LABELS[service] ?? service;
|
|
851
|
+
return `I couldn't start the ${label} sign-in, so I can't use ${label} here: ${reason}`;
|
|
852
|
+
}
|
|
853
|
+
/** For tests: forget every recorded sign-in failure. */
|
|
854
|
+
function resetOAuthSigninFailures() {
|
|
855
|
+
oauthSigninUnavailable.clear();
|
|
856
|
+
}
|
|
788
857
|
function reportTeamsRequest(stage, conversationId, context, details = {}) {
|
|
789
858
|
if (!context?.inboundActivityId)
|
|
790
859
|
return;
|
|
@@ -892,6 +961,7 @@ async function handleTeamsMessage(text, stream, conversationId, teamsContext, se
|
|
|
892
961
|
graphToken: teamsContext.graphToken,
|
|
893
962
|
adoToken: teamsContext.adoToken,
|
|
894
963
|
githubToken: teamsContext.githubToken,
|
|
964
|
+
...(teamsContext.oauthUnavailable ? { oauthUnavailable: teamsContext.oauthUnavailable } : {}),
|
|
895
965
|
signin: teamsContext.signin,
|
|
896
966
|
summarize: (0, core_1.createSummarize)("human"),
|
|
897
967
|
tenantId: teamsContext.tenantId,
|
|
@@ -1420,6 +1490,10 @@ function registerBotHandlers(app, label) {
|
|
|
1420
1490
|
}
|
|
1421
1491
|
catch { /* no token yet — tool handler will trigger signin */ }
|
|
1422
1492
|
(0, runtime_1.emitNervesEvent)({ level: "info", event: "channel.token_status", component: "channels", message: "oauth token availability", meta: { graph: !!graphToken, ado: !!adoToken, github: !!githubToken, tenantId } });
|
|
1493
|
+
const unavailableEntries = [["graph", tenantOAuth.graphConnectionName], ["ado", tenantOAuth.adoConnectionName], ["github", tenantOAuth.githubConnectionName]]
|
|
1494
|
+
.map(([service, cn]) => [service, oauthSigninUnavailableReason(cn)])
|
|
1495
|
+
.filter((entry) => entry[1] !== undefined);
|
|
1496
|
+
const oauthUnavailable = unavailableEntries.length > 0 ? Object.fromEntries(unavailableEntries) : undefined;
|
|
1423
1497
|
const teamsContext = {
|
|
1424
1498
|
inboundActivityId: activity.id,
|
|
1425
1499
|
replyToId: activity.replyToId,
|
|
@@ -1427,7 +1501,11 @@ function registerBotHandlers(app, label) {
|
|
|
1427
1501
|
graphToken,
|
|
1428
1502
|
adoToken,
|
|
1429
1503
|
githubToken,
|
|
1504
|
+
...(oauthUnavailable ? { oauthUnavailable } : {}),
|
|
1430
1505
|
signin: async (cn) => {
|
|
1506
|
+
// Already known not to start: don't send the person another card that can't appear.
|
|
1507
|
+
if (oauthSigninUnavailableReason(cn))
|
|
1508
|
+
return undefined;
|
|
1431
1509
|
try {
|
|
1432
1510
|
const result = await signin({ connectionName: cn });
|
|
1433
1511
|
(0, runtime_1.emitNervesEvent)({ level: "info", event: "channel.signin_result", component: "channels", message: `signin(${cn}): ${result ? "token received" : "no token"}`, meta: { connectionName: cn, hasToken: !!result } });
|
|
@@ -1436,6 +1514,12 @@ function registerBotHandlers(app, label) {
|
|
|
1436
1514
|
catch (e) {
|
|
1437
1515
|
const msg = e instanceof Error ? e.message : String(e);
|
|
1438
1516
|
(0, runtime_1.emitNervesEvent)({ level: "error", event: "channel.signin_error", component: "channels", message: `signin(${cn}) failed`, meta: { connectionName: cn, reason: msg.slice(0, 100) } });
|
|
1517
|
+
const reason = recordOAuthSigninFailure(cn, e);
|
|
1518
|
+
const service = Object.entries(tenantOAuth).find(([, name]) => name === cn)?.[0]?.replace(/ConnectionName$/, "") ?? cn;
|
|
1519
|
+
try {
|
|
1520
|
+
await sendText(oauthSigninUnavailableNotice(service, reason));
|
|
1521
|
+
}
|
|
1522
|
+
catch { /* the failure is already logged */ }
|
|
1439
1523
|
return undefined;
|
|
1440
1524
|
}
|
|
1441
1525
|
},
|
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.1089",
|
|
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.1089",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|