@primusclaw/personal-agent-runtime 0.15.2 → 0.15.4

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 CHANGED
@@ -1636,15 +1636,15 @@ var HELP = {
1636
1636
  var HELP_CURRENT_ONLY = {
1637
1637
  personal_agent_probe_total: [
1638
1638
  "counter",
1639
- "Delivery probes the worker answered, by outcome: answered (the relay's ack came back) or unanswered."
1639
+ "Delivery probes the worker answered, by outcome: answered (the relay's ack came back; with direct outbound the worker had the probe) or unanswered."
1640
1640
  ],
1641
1641
  personal_agent_probe_feedback_ms: [
1642
1642
  "gauge",
1643
- "Milliseconds from the last probe's sending (by the ingress) to the worker's answer queued for the relay."
1643
+ "Milliseconds from the last probe's sending (by the ingress) to the worker's answer queued for the relay (with direct outbound: to the worker having the probe)."
1644
1644
  ],
1645
1645
  personal_agent_probe_reply_ms: [
1646
1646
  "gauge",
1647
- "Milliseconds from the last answered probe's sending to the relay's ack of the answer reaching the worker."
1647
+ "Milliseconds from the last answered probe's sending to the relay's ack of the answer reaching the worker (with direct outbound: to the worker having the probe)."
1648
1648
  ],
1649
1649
  personal_agent_probe_last_answered_seconds: [
1650
1650
  "gauge",
@@ -1653,6 +1653,10 @@ var HELP_CURRENT_ONLY = {
1653
1653
  personal_agent_inbound_rearmed_total: [
1654
1654
  "counter",
1655
1655
  "Times the inbound receivers' connection was re-opened because a call on the broker hung (once per connection)."
1656
+ ],
1657
+ personal_agent_outbound_undelivered_total: [
1658
+ "counter",
1659
+ "Messages (sends, replies, updates) posted directly to the chat service that were not confirmed as delivered (the retries or the deadline used up, a refusal by the service, a token that could not be had, or an address the policy refuses, which fails before any request is made); each was thrown to its sender."
1656
1660
  ]
1657
1661
  };
1658
1662
  function compareTuples(a, b) {
@@ -1686,6 +1690,7 @@ var PrometheusMetrics = class {
1686
1690
  /** Event type -> (receipt to sent, occurred to sent), each written from the start. */
1687
1691
  probes = { answered: 0, unanswered: 0, feedbackMs: 0, replyMs: 0, answeredAt: 0 };
1688
1692
  rearmed = 0;
1693
+ undelivered = 0;
1689
1694
  eventTimes = new Map(
1690
1695
  DELIVERED_EVENT_TYPES.map((t) => [t, [new Histogram(EVENT_BUCKETS), new Histogram(EVENT_BUCKETS)]])
1691
1696
  );
@@ -1747,6 +1752,9 @@ var PrometheusMetrics = class {
1747
1752
  inboundRearmed() {
1748
1753
  this.rearmed += 1;
1749
1754
  }
1755
+ outboundUndelivered() {
1756
+ this.undelivered += 1;
1757
+ }
1750
1758
  /** The longest wait of the messages handled in the window, in milliseconds (0: none). */
1751
1759
  lagMaxMs() {
1752
1760
  this.expire(this.clock.monotonicMs());
@@ -1776,7 +1784,8 @@ var PrometheusMetrics = class {
1776
1784
  ["personal_agent_probe_feedback_ms", this.probes.feedbackMs],
1777
1785
  ["personal_agent_probe_reply_ms", this.probes.replyMs],
1778
1786
  ["personal_agent_probe_last_answered_seconds", this.probes.answeredAt],
1779
- ["personal_agent_inbound_rearmed_total", this.rearmed]
1787
+ ["personal_agent_inbound_rearmed_total", this.rearmed],
1788
+ ["personal_agent_outbound_undelivered_total", this.undelivered]
1780
1789
  ];
1781
1790
  for (const [name, value] of gauges) {
1782
1791
  head2(name);
@@ -2388,16 +2397,9 @@ function assistantSettings(read2) {
2388
2397
  throw new ConfigError2(`ASSISTANT_REPLY_WINDOW_SECONDS must be a positive number of seconds, not ${pyRepr(window)}`);
2389
2398
  }
2390
2399
  const enabled = read2.isOn("ASSISTANT_ENABLED");
2391
- const understanding = read2.switch("PA_ASSISTANT_UNDERSTANDING", false);
2392
2400
  const users = new Set(read2.list("ASSISTANT_USERS", true));
2393
- const listed = new Set(read2.list("PA_ASSISTANT_UNDERSTANDING_USERS", true));
2394
- const understandingUsers = understanding ? listed.size > 0 ? listed : users : /* @__PURE__ */ new Set();
2395
- if (understanding && understandingUsers.size === 0) {
2396
- throw new ConfigError2(
2397
- `${read2.source("PA_ASSISTANT_UNDERSTANDING")} is on but ${read2.source("PA_ASSISTANT_UNDERSTANDING_USERS")} names nobody (and ASSISTANT_USERS is empty)`
2398
- );
2399
- }
2400
- if (understandingUsers.size > 0 && !enabled) {
2401
+ const { everybody, understandingUsers } = understandingOf(read2, users);
2402
+ if ((everybody || understandingUsers.size > 0) && !enabled) {
2401
2403
  throw new ConfigError2(`${read2.source("PA_ASSISTANT_UNDERSTANDING")} needs ASSISTANT_ENABLED`);
2402
2404
  }
2403
2405
  if (users.size > 0 && [...understandingUsers].some((u) => !users.has(u))) {
@@ -2409,9 +2411,17 @@ function assistantSettings(read2) {
2409
2411
  enabled,
2410
2412
  users,
2411
2413
  replyWindowSeconds: seconds === void 0 ? ASSISTANT_REPLY_WINDOW_SECONDS : Number(seconds),
2414
+ understandingAll: everybody,
2412
2415
  understandingUsers
2413
2416
  };
2414
2417
  }
2418
+ function understandingOf(read2, users) {
2419
+ if (!read2.switch("PA_ASSISTANT_UNDERSTANDING", false)) return { everybody: false, understandingUsers: /* @__PURE__ */ new Set() };
2420
+ const listed = new Set(read2.list("PA_ASSISTANT_UNDERSTANDING_USERS", true));
2421
+ if (listed.has("*") || listed.size === 0 && users.size === 0)
2422
+ return { everybody: true, understandingUsers: /* @__PURE__ */ new Set() };
2423
+ return { everybody: false, understandingUsers: listed.size > 0 ? listed : users };
2424
+ }
2415
2425
  function directChat(read2) {
2416
2426
  return {
2417
2427
  enabled: read2.switch("PA_DIRECT_CHAT", false),
@@ -42,6 +42,7 @@ export declare class PrometheusMetrics implements MetricsPort {
42
42
  /** Event type -> (receipt to sent, occurred to sent), each written from the start. */
43
43
  private probes;
44
44
  private rearmed;
45
+ private undelivered;
45
46
  private readonly eventTimes;
46
47
  constructor(clock: Clock, lagWindowMs?: number);
47
48
  /** Inbound messages handled so far. */
@@ -53,6 +54,7 @@ export declare class PrometheusMetrics implements MetricsPort {
53
54
  filesDropped(path: string, count?: number): void;
54
55
  probed(feedbackMs: number, replyMs: number | null): void;
55
56
  inboundRearmed(): void;
57
+ outboundUndelivered(): void;
56
58
  /** The longest wait of the messages handled in the window, in milliseconds (0: none). */
57
59
  lagMaxMs(): number;
58
60
  private expire;
package/dist/worker.js CHANGED
@@ -252,7 +252,7 @@ function keeper(base, notifyUrl) {
252
252
  logger: base.logger,
253
253
  baseUrl: notifyUrl,
254
254
  assistant: assistant.enabled,
255
- understood: (aadId) => assistant.understandingUsers.has(aadId.toLowerCase()),
255
+ understood: (aadId) => assistant.understandingAll === true || assistant.understandingUsers.has(aadId.toLowerCase()),
256
256
  assistantFor: (aadId) => assistant.users.size === 0 || assistant.users.has(aadId.toLowerCase()),
257
257
  userIdOf: async (key) => pyStrip((await base.plugins.identityLookup.ownerOfKey(key))?.id ?? "") || void 0,
258
258
  // The surface Claw routes this person's assistant messages by (a reply goes back to the surface the message came from).
@@ -292,7 +292,9 @@ function assistantChat(base, integrations, style, parts, hooks) {
292
292
  style: () => ({ assistantProgress: style.assistantProgress, assistantStreamSay: style.assistantStreamSay }),
293
293
  enabled: settings2.assistant.enabled,
294
294
  users: settings2.assistant.users,
295
+ understandingAll: settings2.assistant.understandingAll === true,
295
296
  understanding: settings2.assistant.understandingUsers,
297
+ publicBaseUrl: settings2.publicBaseUrl,
296
298
  pluginId: settings2.claw.pluginId ?? void 0,
297
299
  assistantName: settings2.botName,
298
300
  legacyTurn: (aadId) => hooks.legacyTurn(aadId),
@@ -1546,6 +1548,9 @@ function withInboundStats(prometheus, stats) {
1546
1548
  },
1547
1549
  inboundRearmed: () => {
1548
1550
  prometheus.inboundRearmed();
1551
+ },
1552
+ outboundUndelivered: () => {
1553
+ prometheus.outboundUndelivered();
1549
1554
  }
1550
1555
  };
1551
1556
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primusclaw/personal-agent-runtime",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "Node adapters for the personal agent's ports (clock, randomness, logging, storage, Claw, metrics, HTTP), and, at @primusclaw/personal-agent-runtime/worker, the worker process on any chat surface.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@primusclaw/personal-agent": "0.15.2",
36
+ "@primusclaw/personal-agent": "0.15.4",
37
37
  "fastify": "^5.12.8",
38
38
  "zod": "^4.6.7"
39
39
  }