@primusclaw/personal-agent-teams 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -13
- package/dist/main.js +76 -13
- package/dist/types/servicebus/consumer.d.ts +24 -1
- package/dist/types/stream/busy.d.ts +2 -1
- package/dist/types/stream/teams-stream.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -813,14 +813,29 @@ var TeamsStream = class {
|
|
|
813
813
|
}
|
|
814
814
|
finalOnce(activity) {
|
|
815
815
|
return this.lock.run(async () => {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
816
|
+
try {
|
|
817
|
+
await this.send(streamFinal(activity, this.parts.replyTo, this.streamId), true);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
if (refusedForGood(error)) {
|
|
820
|
+
this.logger.info("Teams refused the stream's final for good; the conversation can stream again");
|
|
821
|
+
this.close();
|
|
822
|
+
}
|
|
823
|
+
throw error;
|
|
820
824
|
}
|
|
825
|
+
this.close();
|
|
821
826
|
});
|
|
822
827
|
}
|
|
828
|
+
/** The stream is done with: it takes nothing more, and the conversation is free for the next one. */
|
|
829
|
+
close() {
|
|
830
|
+
this.closed = true;
|
|
831
|
+
if (this.parts.conversation && this.openedAt !== void 0) {
|
|
832
|
+
this.parts.busy.closed(this.parts.conversation, this.openedAt);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
823
835
|
};
|
|
836
|
+
function refusedForGood(error) {
|
|
837
|
+
return error instanceof StreamRefusedError && error.status === 403 && error.code === "ContentStreamNotAllowed";
|
|
838
|
+
}
|
|
824
839
|
|
|
825
840
|
// packages/teams/src/stream/live-stream.ts
|
|
826
841
|
function refused(reason, status = 0, code = "") {
|
|
@@ -2273,7 +2288,10 @@ function confirmWrite(model) {
|
|
|
2273
2288
|
const button = (title, op) => execute(title, `primusclaw.assistant_confirm_${op}`, { primusclaw: "assistant_confirm", op, card: model.cardId });
|
|
2274
2289
|
return message(
|
|
2275
2290
|
[header(t.confirmTitle, { tone: "warning", emoji: "needs_you" }), text(model.text)],
|
|
2276
|
-
buttons([
|
|
2291
|
+
buttons([
|
|
2292
|
+
button(model.allowLabel || t.confirm, "allow"),
|
|
2293
|
+
button(model.kind === "github_merge" ? t.denyMerge : t.deny, "deny")
|
|
2294
|
+
])
|
|
2277
2295
|
);
|
|
2278
2296
|
}
|
|
2279
2297
|
function choiceCard(model) {
|
|
@@ -3281,8 +3299,8 @@ var MODE_WHAT = {
|
|
|
3281
3299
|
"Approved and merged when nothing needs fixing and every check passes; a change the reviewing model judges high risk (security, credentials, CI/release, permissions, data migrations, ...) or one the repository asks to confirm waits for your own click on a card."
|
|
3282
3300
|
],
|
|
3283
3301
|
fully_auto: [
|
|
3284
|
-
"\u5BA1\u5B8C\u6CA1\u6709\u95EE\u9898\u3001\u68C0\u67E5\u5168\u90E8\u901A\u8FC7\u65F6\u76F4\u63A5\u6279\u51C6\u5E76\u5408\u5165\uFF0C\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\uFF1B\
|
|
3285
|
-
"Approved and merged when nothing needs fixing and every check passes, without asking you;
|
|
3302
|
+
"\u5BA1\u5B8C\u6CA1\u6709\u95EE\u9898\u3001\u68C0\u67E5\u5168\u90E8\u901A\u8FC7\u65F6\u76F4\u63A5\u6279\u51C6\u5E76\u5408\u5165\uFF0C\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\uFF0C\u4F60\u5728\u804A\u5929\u91CC\u8BA9\u6211\u5BA1\u5E76\u5408\u5165\u7684 PR \u4E5F\u4E00\u6837\uFF1B\u4ED3\u5E93\u81EA\u8EAB\u8981\u6C42\u7684\u68C0\u67E5\u4ECD\u7136\u751F\u6548\uFF1ACI \u6CA1\u8FC7\u6216\u8FD8\u6709\u6CA1\u89E3\u51B3\u7684\u8BC4\u5BA1\u8BA8\u8BBA\u4E0D\u4F1A\u5408\u5165\uFF0C\u4ED3\u5E93\u81EA\u5DF1\u8981\u6C42\u786E\u8BA4\u7684\u53D8\u66F4\uFF08.github/claw-review.yml \u7684 confirm_merge: always \u7B49\uFF09\u4ECD\u4F1A\u5148\u95EE\u4F60\u3002",
|
|
3303
|
+
"Approved and merged when nothing needs fixing and every check passes, without asking you, a pull request you ask me in the chat to review and merge included; the repository's own requirements still apply: nothing merges with CI failing or review threads open, and a change the repository itself requires a person for (confirm_merge: always in its review config, and the like) still waits for your click."
|
|
3286
3304
|
]
|
|
3287
3305
|
};
|
|
3288
3306
|
var MODE_BUTTON = { high_risk_confirm: "\u9AD8\u98CE\u9669\u518D\u95EE\u6211", fully_auto: "\u5168\u81EA\u52A8\u5408\u5165" };
|
|
@@ -6185,6 +6203,49 @@ function queueLagMs(message2, nowEpochMs, handleMs = 0) {
|
|
|
6185
6203
|
if (!message2.enqueuedAt) return void 0;
|
|
6186
6204
|
return Math.max(Math.trunc(nowEpochMs - message2.enqueuedAt.getTime()) - handleMs, 0);
|
|
6187
6205
|
}
|
|
6206
|
+
var MAX_CLIENT_LAG_MS = 24 * 60 * 6e4;
|
|
6207
|
+
var ISO_TIME = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/;
|
|
6208
|
+
var CLIENT_ID = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
6209
|
+
var CLIENT_ID_KEYS = ["clientActivityID", "clientActivityId", "clientmessageid", "clientMessageId"];
|
|
6210
|
+
var EPOCH_MS_ID = /^\d{13}$/;
|
|
6211
|
+
function isoEpochMs(value) {
|
|
6212
|
+
if (typeof value !== "string") return void 0;
|
|
6213
|
+
const match = ISO_TIME.exec(value);
|
|
6214
|
+
if (!match) return void 0;
|
|
6215
|
+
const [, base2, fraction = "", zone] = match;
|
|
6216
|
+
const ms = Date.parse(`${base2}.${fraction.padEnd(3, "0").slice(0, 3)}${zone}`);
|
|
6217
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
6218
|
+
}
|
|
6219
|
+
function clientTiming(activity) {
|
|
6220
|
+
const timing = {};
|
|
6221
|
+
const local = activity["localTimestamp"];
|
|
6222
|
+
const clientMs = isoEpochMs(local);
|
|
6223
|
+
if (clientMs !== void 0) timing.client_ts = local;
|
|
6224
|
+
const channelData = activity["channelData"];
|
|
6225
|
+
if (isObject(channelData)) {
|
|
6226
|
+
for (const key of CLIENT_ID_KEYS) {
|
|
6227
|
+
const id2 = channelData[key];
|
|
6228
|
+
if (typeof id2 === "string" && CLIENT_ID.test(id2)) {
|
|
6229
|
+
timing.client_msg_id = id2;
|
|
6230
|
+
break;
|
|
6231
|
+
}
|
|
6232
|
+
}
|
|
6233
|
+
}
|
|
6234
|
+
const stamp = activity["timestamp"];
|
|
6235
|
+
const id = activity["id"];
|
|
6236
|
+
let serverMs = isoEpochMs(stamp);
|
|
6237
|
+
if (serverMs !== void 0) timing.server_ts = stamp;
|
|
6238
|
+
else if (typeof id === "string" && EPOCH_MS_ID.test(id)) {
|
|
6239
|
+
serverMs = Number(id);
|
|
6240
|
+
timing.server_ts = new Date(serverMs).toISOString();
|
|
6241
|
+
}
|
|
6242
|
+
if (clientMs !== void 0 && serverMs !== void 0) {
|
|
6243
|
+
const lag = serverMs - clientMs;
|
|
6244
|
+
timing.client_lag_raw_ms = lag;
|
|
6245
|
+
if (lag >= 0 && lag <= MAX_CLIENT_LAG_MS) timing.client_lag_ms = lag;
|
|
6246
|
+
}
|
|
6247
|
+
return timing;
|
|
6248
|
+
}
|
|
6188
6249
|
function decode(body) {
|
|
6189
6250
|
const parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
6190
6251
|
if (!isObject(parsed)) throw new SyntaxError("body is not a JSON object");
|
|
@@ -6250,32 +6311,34 @@ var InboundConsumer = class {
|
|
|
6250
6311
|
await receiver.deadLetter(message2, "malformed", Array.from(why).slice(0, 200).join(""));
|
|
6251
6312
|
return;
|
|
6252
6313
|
}
|
|
6314
|
+
const timing = clientTiming(body);
|
|
6253
6315
|
const started = this.parts.clock.monotonicMs();
|
|
6254
6316
|
try {
|
|
6255
6317
|
await this.parts.handle(body);
|
|
6256
6318
|
} catch (error) {
|
|
6257
6319
|
this.logger.error("handler failed; abandoning for redelivery", { error: errorName5(error) });
|
|
6258
|
-
this.record(message2, started, false);
|
|
6320
|
+
this.record(message2, timing, started, false);
|
|
6259
6321
|
await receiver.abandon(message2);
|
|
6260
6322
|
return;
|
|
6261
6323
|
}
|
|
6262
|
-
this.record(message2, started, true);
|
|
6324
|
+
this.record(message2, timing, started, true);
|
|
6263
6325
|
await receiver.complete(message2);
|
|
6264
6326
|
}
|
|
6265
|
-
record(message2, started, ok5) {
|
|
6327
|
+
record(message2, timing, started, ok5) {
|
|
6266
6328
|
const handleMs = Math.trunc(this.parts.clock.monotonicMs() - started);
|
|
6267
6329
|
const lag = queueLagMs(message2, this.parts.clock.epochMs(), handleMs);
|
|
6268
|
-
this.logLine(message2, ok5 ? "completed" : "abandoned", lag, handleMs);
|
|
6330
|
+
this.logLine(message2, ok5 ? "completed" : "abandoned", lag, handleMs, timing);
|
|
6269
6331
|
this.parts.stats?.processed(lag, handleMs, ok5);
|
|
6270
6332
|
}
|
|
6271
6333
|
/** The one line for a message taken: ids, outcome and times only. */
|
|
6272
|
-
logLine(message2, outcome, lagMs, handleMs) {
|
|
6334
|
+
logLine(message2, outcome, lagMs, handleMs, timing = {}) {
|
|
6273
6335
|
this.logger.info("inbound message", {
|
|
6274
6336
|
id: message2.messageId,
|
|
6275
6337
|
delivery: message2.deliveryCount,
|
|
6276
6338
|
outcome,
|
|
6277
6339
|
lag_ms: lagMs,
|
|
6278
|
-
ms: handleMs
|
|
6340
|
+
ms: handleMs,
|
|
6341
|
+
...timing
|
|
6279
6342
|
});
|
|
6280
6343
|
}
|
|
6281
6344
|
};
|
package/dist/main.js
CHANGED
|
@@ -2547,6 +2547,49 @@ function queueLagMs(message2, nowEpochMs, handleMs = 0) {
|
|
|
2547
2547
|
if (!message2.enqueuedAt) return void 0;
|
|
2548
2548
|
return Math.max(Math.trunc(nowEpochMs - message2.enqueuedAt.getTime()) - handleMs, 0);
|
|
2549
2549
|
}
|
|
2550
|
+
var MAX_CLIENT_LAG_MS = 24 * 60 * 6e4;
|
|
2551
|
+
var ISO_TIME = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/;
|
|
2552
|
+
var CLIENT_ID = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
2553
|
+
var CLIENT_ID_KEYS = ["clientActivityID", "clientActivityId", "clientmessageid", "clientMessageId"];
|
|
2554
|
+
var EPOCH_MS_ID = /^\d{13}$/;
|
|
2555
|
+
function isoEpochMs(value) {
|
|
2556
|
+
if (typeof value !== "string") return void 0;
|
|
2557
|
+
const match = ISO_TIME.exec(value);
|
|
2558
|
+
if (!match) return void 0;
|
|
2559
|
+
const [, base2, fraction = "", zone] = match;
|
|
2560
|
+
const ms = Date.parse(`${base2}.${fraction.padEnd(3, "0").slice(0, 3)}${zone}`);
|
|
2561
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
2562
|
+
}
|
|
2563
|
+
function clientTiming(activity) {
|
|
2564
|
+
const timing = {};
|
|
2565
|
+
const local = activity["localTimestamp"];
|
|
2566
|
+
const clientMs = isoEpochMs(local);
|
|
2567
|
+
if (clientMs !== void 0) timing.client_ts = local;
|
|
2568
|
+
const channelData = activity["channelData"];
|
|
2569
|
+
if (isObject(channelData)) {
|
|
2570
|
+
for (const key of CLIENT_ID_KEYS) {
|
|
2571
|
+
const id2 = channelData[key];
|
|
2572
|
+
if (typeof id2 === "string" && CLIENT_ID.test(id2)) {
|
|
2573
|
+
timing.client_msg_id = id2;
|
|
2574
|
+
break;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
const stamp = activity["timestamp"];
|
|
2579
|
+
const id = activity["id"];
|
|
2580
|
+
let serverMs = isoEpochMs(stamp);
|
|
2581
|
+
if (serverMs !== void 0) timing.server_ts = stamp;
|
|
2582
|
+
else if (typeof id === "string" && EPOCH_MS_ID.test(id)) {
|
|
2583
|
+
serverMs = Number(id);
|
|
2584
|
+
timing.server_ts = new Date(serverMs).toISOString();
|
|
2585
|
+
}
|
|
2586
|
+
if (clientMs !== void 0 && serverMs !== void 0) {
|
|
2587
|
+
const lag = serverMs - clientMs;
|
|
2588
|
+
timing.client_lag_raw_ms = lag;
|
|
2589
|
+
if (lag >= 0 && lag <= MAX_CLIENT_LAG_MS) timing.client_lag_ms = lag;
|
|
2590
|
+
}
|
|
2591
|
+
return timing;
|
|
2592
|
+
}
|
|
2550
2593
|
function decode(body) {
|
|
2551
2594
|
const parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
2552
2595
|
if (!isObject(parsed)) throw new SyntaxError("body is not a JSON object");
|
|
@@ -2612,32 +2655,34 @@ var InboundConsumer = class {
|
|
|
2612
2655
|
await receiver.deadLetter(message2, "malformed", Array.from(why).slice(0, 200).join(""));
|
|
2613
2656
|
return;
|
|
2614
2657
|
}
|
|
2658
|
+
const timing = clientTiming(body);
|
|
2615
2659
|
const started = this.parts.clock.monotonicMs();
|
|
2616
2660
|
try {
|
|
2617
2661
|
await this.parts.handle(body);
|
|
2618
2662
|
} catch (error) {
|
|
2619
2663
|
this.logger.error("handler failed; abandoning for redelivery", { error: errorName3(error) });
|
|
2620
|
-
this.record(message2, started, false);
|
|
2664
|
+
this.record(message2, timing, started, false);
|
|
2621
2665
|
await receiver.abandon(message2);
|
|
2622
2666
|
return;
|
|
2623
2667
|
}
|
|
2624
|
-
this.record(message2, started, true);
|
|
2668
|
+
this.record(message2, timing, started, true);
|
|
2625
2669
|
await receiver.complete(message2);
|
|
2626
2670
|
}
|
|
2627
|
-
record(message2, started, ok5) {
|
|
2671
|
+
record(message2, timing, started, ok5) {
|
|
2628
2672
|
const handleMs = Math.trunc(this.parts.clock.monotonicMs() - started);
|
|
2629
2673
|
const lag = queueLagMs(message2, this.parts.clock.epochMs(), handleMs);
|
|
2630
|
-
this.logLine(message2, ok5 ? "completed" : "abandoned", lag, handleMs);
|
|
2674
|
+
this.logLine(message2, ok5 ? "completed" : "abandoned", lag, handleMs, timing);
|
|
2631
2675
|
this.parts.stats?.processed(lag, handleMs, ok5);
|
|
2632
2676
|
}
|
|
2633
2677
|
/** The one line for a message taken: ids, outcome and times only. */
|
|
2634
|
-
logLine(message2, outcome, lagMs, handleMs) {
|
|
2678
|
+
logLine(message2, outcome, lagMs, handleMs, timing = {}) {
|
|
2635
2679
|
this.logger.info("inbound message", {
|
|
2636
2680
|
id: message2.messageId,
|
|
2637
2681
|
delivery: message2.deliveryCount,
|
|
2638
2682
|
outcome,
|
|
2639
2683
|
lag_ms: lagMs,
|
|
2640
|
-
ms: handleMs
|
|
2684
|
+
ms: handleMs,
|
|
2685
|
+
...timing
|
|
2641
2686
|
});
|
|
2642
2687
|
}
|
|
2643
2688
|
};
|
|
@@ -3084,14 +3129,29 @@ var TeamsStream = class {
|
|
|
3084
3129
|
}
|
|
3085
3130
|
finalOnce(activity) {
|
|
3086
3131
|
return this.lock.run(async () => {
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3132
|
+
try {
|
|
3133
|
+
await this.send(streamFinal(activity, this.parts.replyTo, this.streamId), true);
|
|
3134
|
+
} catch (error) {
|
|
3135
|
+
if (refusedForGood(error)) {
|
|
3136
|
+
this.logger.info("Teams refused the stream's final for good; the conversation can stream again");
|
|
3137
|
+
this.close();
|
|
3138
|
+
}
|
|
3139
|
+
throw error;
|
|
3091
3140
|
}
|
|
3141
|
+
this.close();
|
|
3092
3142
|
});
|
|
3093
3143
|
}
|
|
3144
|
+
/** The stream is done with: it takes nothing more, and the conversation is free for the next one. */
|
|
3145
|
+
close() {
|
|
3146
|
+
this.closed = true;
|
|
3147
|
+
if (this.parts.conversation && this.openedAt !== void 0) {
|
|
3148
|
+
this.parts.busy.closed(this.parts.conversation, this.openedAt);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3094
3151
|
};
|
|
3152
|
+
function refusedForGood(error) {
|
|
3153
|
+
return error instanceof StreamRefusedError && error.status === 403 && error.code === "ContentStreamNotAllowed";
|
|
3154
|
+
}
|
|
3095
3155
|
|
|
3096
3156
|
// packages/teams/src/stream/live-stream.ts
|
|
3097
3157
|
function refused(reason, status = 0, code = "") {
|
|
@@ -4784,7 +4844,10 @@ function confirmWrite(model) {
|
|
|
4784
4844
|
const button = (title, op) => execute(title, `primusclaw.assistant_confirm_${op}`, { primusclaw: "assistant_confirm", op, card: model.cardId });
|
|
4785
4845
|
return message(
|
|
4786
4846
|
[header(t.confirmTitle, { tone: "warning", emoji: "needs_you" }), text2(model.text)],
|
|
4787
|
-
buttons([
|
|
4847
|
+
buttons([
|
|
4848
|
+
button(model.allowLabel || t.confirm, "allow"),
|
|
4849
|
+
button(model.kind === "github_merge" ? t.denyMerge : t.deny, "deny")
|
|
4850
|
+
])
|
|
4788
4851
|
);
|
|
4789
4852
|
}
|
|
4790
4853
|
function choiceCard(model) {
|
|
@@ -5792,8 +5855,8 @@ var MODE_WHAT = {
|
|
|
5792
5855
|
"Approved and merged when nothing needs fixing and every check passes; a change the reviewing model judges high risk (security, credentials, CI/release, permissions, data migrations, ...) or one the repository asks to confirm waits for your own click on a card."
|
|
5793
5856
|
],
|
|
5794
5857
|
fully_auto: [
|
|
5795
|
-
"\u5BA1\u5B8C\u6CA1\u6709\u95EE\u9898\u3001\u68C0\u67E5\u5168\u90E8\u901A\u8FC7\u65F6\u76F4\u63A5\u6279\u51C6\u5E76\u5408\u5165\uFF0C\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\uFF1B\
|
|
5796
|
-
"Approved and merged when nothing needs fixing and every check passes, without asking you;
|
|
5858
|
+
"\u5BA1\u5B8C\u6CA1\u6709\u95EE\u9898\u3001\u68C0\u67E5\u5168\u90E8\u901A\u8FC7\u65F6\u76F4\u63A5\u6279\u51C6\u5E76\u5408\u5165\uFF0C\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\uFF0C\u4F60\u5728\u804A\u5929\u91CC\u8BA9\u6211\u5BA1\u5E76\u5408\u5165\u7684 PR \u4E5F\u4E00\u6837\uFF1B\u4ED3\u5E93\u81EA\u8EAB\u8981\u6C42\u7684\u68C0\u67E5\u4ECD\u7136\u751F\u6548\uFF1ACI \u6CA1\u8FC7\u6216\u8FD8\u6709\u6CA1\u89E3\u51B3\u7684\u8BC4\u5BA1\u8BA8\u8BBA\u4E0D\u4F1A\u5408\u5165\uFF0C\u4ED3\u5E93\u81EA\u5DF1\u8981\u6C42\u786E\u8BA4\u7684\u53D8\u66F4\uFF08.github/claw-review.yml \u7684 confirm_merge: always \u7B49\uFF09\u4ECD\u4F1A\u5148\u95EE\u4F60\u3002",
|
|
5859
|
+
"Approved and merged when nothing needs fixing and every check passes, without asking you, a pull request you ask me in the chat to review and merge included; the repository's own requirements still apply: nothing merges with CI failing or review threads open, and a change the repository itself requires a person for (confirm_merge: always in its review config, and the like) still waits for your click."
|
|
5797
5860
|
]
|
|
5798
5861
|
};
|
|
5799
5862
|
var MODE_BUTTON = { high_risk_confirm: "\u9AD8\u98CE\u9669\u518D\u95EE\u6211", fully_auto: "\u5168\u81EA\u52A8\u5408\u5165" };
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* succeed); a handler failure abandons the message, so the broker redelivers it and, after its maximum delivery count,
|
|
5
5
|
* dead-letters it. Either way the session moves on: one poison message never blocks a conversation. Every message taken
|
|
6
6
|
* gets one line (`inbound message`): its id, what came of it (completed, abandoned, dead_lettered), how long it waited in
|
|
7
|
-
* the queue and how long it took; never its body.
|
|
7
|
+
* the queue and how long it took; never its body. For an activity that decodes, the line also says when the client sent it
|
|
8
|
+
* (`clientTiming`), so a message that reached Teams late can be told apart from one the person sent late.
|
|
8
9
|
*/
|
|
9
10
|
import type { Clock, Logger } from "@primusclaw/personal-agent";
|
|
10
11
|
import { type JsonObject } from "../cards/json.js";
|
|
@@ -26,6 +27,28 @@ export declare function isIdleTimeout(error: unknown): boolean;
|
|
|
26
27
|
* handling (now, less `handleMs`). undefined when the broker gave no enqueue time. A growing lag is the queue backing up.
|
|
27
28
|
*/
|
|
28
29
|
export declare function queueLagMs(message: Received, nowEpochMs: number, handleMs?: number): number | undefined;
|
|
30
|
+
/** A client lag beyond this is a wrong clock, not a held message: it is logged raw and not as `client_lag_ms`. */
|
|
31
|
+
export declare const MAX_CLIENT_LAG_MS: number;
|
|
32
|
+
/** When the client sent an activity and when the service took it, as the activity says; every field may be absent. */
|
|
33
|
+
export interface ClientTiming {
|
|
34
|
+
/** The activity's `localTimestamp`: the client's own clock when it sent the message, with its zone offset. */
|
|
35
|
+
readonly client_ts?: string;
|
|
36
|
+
/** The client's id of the message from `channelData`, when the client gave one. */
|
|
37
|
+
readonly client_msg_id?: string;
|
|
38
|
+
/** When the service took the message: the activity's `timestamp`, else the epoch milliseconds of a 1:1 message id. */
|
|
39
|
+
readonly server_ts?: string;
|
|
40
|
+
/** `server_ts` less `client_ts`, signed, as measured: negative when the client's clock runs ahead. */
|
|
41
|
+
readonly client_lag_raw_ms?: number;
|
|
42
|
+
/** The same lag when it can be one (0 to MAX_CLIENT_LAG_MS); absent when the clocks disagree beyond that. */
|
|
43
|
+
readonly client_lag_ms?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* When `activity` was sent by the client and taken by the service, for the `inbound message` line. Teams sets
|
|
47
|
+
* `timestamp` (the service's clock) and `localTimestamp` (the client's clock) on every message; the difference is how long
|
|
48
|
+
* the client held the message, plus the skew between the two clocks. A difference below zero or above
|
|
49
|
+
* MAX_CLIENT_LAG_MS is skew, so it is kept only as `client_lag_raw_ms`. Never reads the text or who sent it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clientTiming(activity: JsonObject): ClientTiming;
|
|
29
52
|
export interface ConsumerParts {
|
|
30
53
|
readonly client: BusClient;
|
|
31
54
|
readonly queue: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Teams allows one open stream per conversation. This remembers, per conversation, until when this process does not open
|
|
3
|
-
* another one there: one is open, or one whose final
|
|
3
|
+
* another one there: one is open, or one whose final did not get through may still be open on Teams' side until it times
|
|
4
|
+
* out. A final Teams refuses because the stream is already over (403 ContentStreamNotAllowed) frees the conversation at once.
|
|
4
5
|
*/
|
|
5
6
|
import type { Clock } from "@primusclaw/personal-agent";
|
|
6
7
|
/** Teams closes a stream 10 minutes after its first request. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-teams",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The personal agent on Microsoft Teams: activities, Adaptive Cards, streams, Bot Connector, inbound queue, and the worker's Teams surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@azure/core-auth": "^1.11.0",
|
|
37
37
|
"@azure/service-bus": "^7.10.0",
|
|
38
|
-
"@primusclaw/personal-agent": "0.
|
|
39
|
-
"@primusclaw/personal-agent-runtime": "0.
|
|
38
|
+
"@primusclaw/personal-agent": "0.11.0",
|
|
39
|
+
"@primusclaw/personal-agent-runtime": "0.11.0",
|
|
40
40
|
"zod": "^4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|