@primusclaw/personal-agent-teams 0.9.0 → 0.10.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 CHANGED
@@ -3270,7 +3270,7 @@ import {
3270
3270
  REVIEW_MODES,
3271
3271
  githubConfirmButtons
3272
3272
  } from "@primusclaw/personal-agent";
3273
- import { BOT_NAME, own as own7 } from "@primusclaw/personal-agent";
3273
+ import { own as own7 } from "@primusclaw/personal-agent";
3274
3274
  var MARKDOWN = /([\\`*_[\]<])/gu;
3275
3275
  function plain(value) {
3276
3276
  return value.replace(MARKDOWN, "\\$1");
@@ -3281,13 +3281,13 @@ var MODE_WHAT = {
3281
3281
  "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
3282
  ],
3283
3283
  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\u53EA\u6709\u4ED3\u5E93\u81EA\u5DF1\u8981\u6C42\u786E\u8BA4\u7684\u53D8\u66F4\uFF08.github/clawy.yml \u7684 confirm_merge: always \u7B49\uFF09\u4ECD\u4F1A\u5148\u95EE\u4F60\u3002",
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\u53EA\u6709\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",
3285
3285
  "Approved and merged when nothing needs fixing and every check passes, without asking you; only 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
3286
  ]
3287
3287
  };
3288
3288
  var MODE_BUTTON = { high_risk_confirm: "\u9AD8\u98CE\u9669\u518D\u95EE\u6211", fully_auto: "\u5168\u81EA\u52A8\u5408\u5165" };
3289
- function addAppButton(installUrl) {
3290
- return installUrl ? [openUrl(`\u6DFB\u52A0 ${BOT_NAME}`, installUrl)] : [];
3289
+ function addAppButton(installUrl, bot) {
3290
+ return installUrl ? [openUrl(`\u6DFB\u52A0 ${bot}`, installUrl)] : [];
3291
3291
  }
3292
3292
  function reviewModeCard(model) {
3293
3293
  const known = (mode) => Object.hasOwn(REVIEW_MODES, mode);
@@ -3313,12 +3313,12 @@ function reviewModeCard(model) {
3313
3313
  }
3314
3314
  body.push(
3315
3315
  note(
3316
- "\u8FD9\u4E2A\u8BBE\u7F6E\u5BF9\u4F60\u81EA\u5DF1\u8BA9 Clawy \u5BA1 PR\u3001\u4EE5\u53CA\u540C\u4E8B\u8BF7\u4F60\u4EE3\u5BA1\u90FD\u751F\u6548\u3002\u662F\u5426\u5141\u8BB8\u540C\u4E8B\u4EE5\u4F60\u7684\u540D\u4E49\u8BF7\u6211\u5BA1\u5E76\u5408\u5165\uFF0C\u662F\u53E6\u4E00\u4E2A\u5F00\u5173\uFF1A`/github auto-merge on|off`\u3002"
3316
+ `\u8FD9\u4E2A\u8BBE\u7F6E\u5BF9\u4F60\u81EA\u5DF1\u8BA9 ${model.bot} \u5BA1 PR\u3001\u4EE5\u53CA\u540C\u4E8B\u8BF7\u4F60\u4EE3\u5BA1\u90FD\u751F\u6548\u3002\u662F\u5426\u5141\u8BB8\u540C\u4E8B\u4EE5\u4F60\u7684\u540D\u4E49\u8BF7\u6211\u5BA1\u5E76\u5408\u5165\uFF0C\u662F\u53E6\u4E00\u4E2A\u5F00\u5173\uFF1A\`/github auto-merge on|off\`\u3002`
3317
3317
  )
3318
3318
  );
3319
3319
  english.push(
3320
3320
  text(
3321
- "This applies when you ask Clawy to review a pull request and when a colleague asks Clawy to review one as you. Whether colleagues may ask at all is the other switch, `/github auto-merge on|off`.",
3321
+ `This applies when you ask ${model.bot} to review a pull request and when a colleague asks ${model.bot} to review one as you. Whether colleagues may ask at all is the other switch, \`/github auto-merge on|off\`.`,
3322
3322
  { size: "Small" }
3323
3323
  )
3324
3324
  );
@@ -3327,7 +3327,7 @@ function reviewModeCard(model) {
3327
3327
  const choices = order.map(
3328
3328
  (m) => execute(own7(MODE_BUTTON, m) ?? m, "primusclaw.github_mode", { primusclaw: "github_mode", mode: m })
3329
3329
  );
3330
- return message(body, buttons([...choices, ...model.hint ? addAppButton(model.installUrl) : []]));
3330
+ return message(body, buttons([...choices, ...model.hint ? addAppButton(model.installUrl, model.bot) : []]));
3331
3331
  }
3332
3332
  function typedConfirmHint(number, lang) {
3333
3333
  const n = clip(String(number), 10);
@@ -3443,7 +3443,7 @@ function githubConfirmCard(m) {
3443
3443
  ];
3444
3444
  if (m.hint) body.push(note(typedConfirmHint(m.number, m.lang)));
3445
3445
  const actions = buttons(githubConfirmButtons(m.confirmationId, m.review !== void 0, m.lang).map(action));
3446
- return message(body, [...actions, ...m.hint ? addAppButton(m.installUrl) : []]);
3446
+ return message(body, [...actions, ...m.hint ? addAppButton(m.installUrl, m.bot) : []]);
3447
3447
  }
3448
3448
  function endedTone(ended) {
3449
3449
  const low = ended.toLowerCase();
@@ -4457,8 +4457,8 @@ function inboundLinksOf(activity) {
4457
4457
  }
4458
4458
 
4459
4459
  // packages/teams/src/activity/inbound/mentions.ts
4460
- import { cpLength as cpLength7, pyLstrip as pyLstrip2, pyStr as pyStr10, pyStrip as pyStrip7 } from "@primusclaw/personal-agent";
4461
- var DEFAULT_BOT_NAME = "Clawy";
4460
+ import { BOT_NAME, cpLength as cpLength7, pyLstrip as pyLstrip2, pyStr as pyStr10, pyStrip as pyStrip7 } from "@primusclaw/personal-agent";
4461
+ var DEFAULT_BOT_NAME = BOT_NAME;
4462
4462
  function isMention(entity) {
4463
4463
  return entity["type"] === "mention";
4464
4464
  }
@@ -7294,6 +7294,11 @@ import { SETTING_ALIASES, settingValue } from "@primusclaw/personal-agent-runtim
7294
7294
  var KEYVAULT_SCOPE = "https://vault.azure.net/.default";
7295
7295
  var KEYVAULT_API_VERSION = "7.4";
7296
7296
  var VAULT_NAMES = {
7297
+ TEAMS_ENCRYPTION_KEYS: "personal-agent-encryption-keys",
7298
+ TEAMS_EXCHANGE_CLIENT_SECRET: "personal-agent-exchange-client-secret",
7299
+ FEEDBACK_GITHUB_APP_KEY: "personal-agent-feedback-github-app-key"
7300
+ };
7301
+ var LEGACY_VAULT_NAMES = {
7297
7302
  TEAMS_ENCRYPTION_KEYS: "clawy-encryption-keys",
7298
7303
  TEAMS_EXCHANGE_CLIENT_SECRET: "clawy-exchange-client-secret",
7299
7304
  FEEDBACK_GITHUB_APP_KEY: "clawy-feedback-github-app-key"
@@ -7418,17 +7423,35 @@ var KeyVaultSecretSource = class {
7418
7423
  } finally {
7419
7424
  deadline.dispose();
7420
7425
  }
7426
+ const legacy = names.filter((name) => values.get(name)?.from === LEGACY_VAULT_NAMES[name]);
7427
+ if (legacy.length) {
7428
+ this.logger.warn(
7429
+ `secrets: deprecated Key Vault secret names: ${legacy.map((n) => `${LEGACY_VAULT_NAMES[n]} (now ${VAULT_NAMES[n]})`).join(", ")}; they are still read when the new name is missing; store the secrets under the new names`
7430
+ );
7431
+ }
7421
7432
  this.logger.info(
7422
- `secrets: ${String(values.size)} read from Key Vault ${vaultHost(this.url)} as client ${this.credential.clientId} (${names.map((name) => VAULT_NAMES[name]).join(", ")})`
7433
+ `secrets: ${String(values.size)} read from Key Vault ${vaultHost(this.url)} as client ${this.credential.clientId} (${[...values.values()].map((r) => r.from).join(", ")})`
7423
7434
  );
7424
- return values;
7435
+ return new Map([...values].map(([name, r]) => [name, r.value]));
7425
7436
  }
7426
7437
  async readAll(names, signal) {
7427
7438
  const token = await this.token(signal);
7428
7439
  const values = /* @__PURE__ */ new Map();
7429
- for (const name of names) values.set(name, await this.read(VAULT_NAMES[name], token, signal));
7440
+ for (const name of names) values.set(name, await this.readSecret(name, token, signal));
7430
7441
  return values;
7431
7442
  }
7443
+ /** A secret under its name, else (the vault has no such entry) under its deprecated name; never written under either. */
7444
+ async readSecret(name, token, signal) {
7445
+ const current = VAULT_NAMES[name];
7446
+ const legacy = LEGACY_VAULT_NAMES[name];
7447
+ const found = await this.read(current, token, signal);
7448
+ if (typeof found === "string") return { value: found, from: current };
7449
+ const old = await this.read(legacy, token, signal);
7450
+ if (typeof old === "string") return { value: old, from: legacy };
7451
+ throw new SecretsUnavailable2(
7452
+ `Key Vault secret ${current}: ${found.missing} (nor under its deprecated name ${legacy})`
7453
+ );
7454
+ }
7432
7455
  async token(signal) {
7433
7456
  for (let attempt2 = 1; ; attempt2++) {
7434
7457
  try {
@@ -7447,11 +7470,13 @@ var KeyVaultSecretSource = class {
7447
7470
  await this.sleep(BACKOFF_MS2 * 2 ** (attempt2 - 1), signal);
7448
7471
  }
7449
7472
  }
7473
+ /** `name`'s value, or why not when the vault has no such secret (it answered 404). */
7450
7474
  async read(name, token, signal) {
7451
7475
  const target = `${this.url}/secrets/${pyQuote(name, "")}?api-version=${KEYVAULT_API_VERSION}`;
7452
7476
  for (let attempt2 = 1; ; attempt2++) {
7453
7477
  const answer = await this.readOnce(target, name, token, signal);
7454
7478
  if ("value" in answer) return answer.value;
7479
+ if (answer.missing) return { missing: answer.reason };
7455
7480
  if (!answer.transient || attempt2 === ATTEMPTS) {
7456
7481
  throw new SecretsUnavailable2(`Key Vault secret ${name}: ${answer.reason}`);
7457
7482
  }
@@ -7474,14 +7499,15 @@ var KeyVaultSecretSource = class {
7474
7499
  status = response.status;
7475
7500
  text4 = await response.text();
7476
7501
  } catch (error) {
7477
- return { reason: `Key Vault unreachable (${errorName8(error)})`, transient: true };
7502
+ return { reason: `Key Vault unreachable (${errorName8(error)})`, transient: true, missing: false };
7478
7503
  } finally {
7479
7504
  timer.dispose();
7480
7505
  }
7481
7506
  if (status === 200) return { value: secretValue(name, text4) };
7482
7507
  return {
7483
7508
  reason: `Key Vault answered ${String(status)}${vaultErrorCode(text4)}`,
7484
- transient: status === 429 || status >= 500
7509
+ transient: status === 429 || status >= 500,
7510
+ missing: status === 404
7485
7511
  };
7486
7512
  }
7487
7513
  };
@@ -7518,7 +7544,6 @@ async function loadSecrets(env, deps) {
7518
7544
  }
7519
7545
 
7520
7546
  // packages/teams/src/assembly/worker.ts
7521
- var BOT_NAME2 = "Clawy";
7522
7547
  function conversationTypeOf(kind) {
7523
7548
  if (kind === "personal") return "personal";
7524
7549
  return kind === "group" ? "groupChat" : "channel";
@@ -7565,10 +7590,10 @@ function teamsShape(teams) {
7565
7590
  version: teamsVersion()
7566
7591
  };
7567
7592
  }
7568
- function teamsTypedEvent(logger) {
7593
+ function teamsTypedEvent(botName, logger) {
7569
7594
  return (conversation, messageId, text4) => {
7570
7595
  const activity = { ...activityOfReference(conversation.wire, messageId), text: text4 };
7571
- const read = toInboundEvent(activity, { botName: BOT_NAME2, logger });
7596
+ const read = toInboundEvent(activity, { botName, logger });
7572
7597
  return read.ok ? read.value : void 0;
7573
7598
  };
7574
7599
  }
@@ -7602,11 +7627,11 @@ function surfaceOf(teams, outbound, gate, deps) {
7602
7627
  return { acks, surface };
7603
7628
  }
7604
7629
  function connect(teams, parts, context) {
7605
- const { acks, inbound: inbound2, gate } = parts;
7630
+ const { botName, acks, inbound: inbound2, gate } = parts;
7606
7631
  const handle = inboundHandler({
7607
7632
  acks,
7608
7633
  route: context.route,
7609
- botName: BOT_NAME2,
7634
+ botName,
7610
7635
  logger: context.logger,
7611
7636
  groupContext: context.groupContext
7612
7637
  });
@@ -7636,13 +7661,13 @@ function connect(teams, parts, context) {
7636
7661
  });
7637
7662
  return { routes, source };
7638
7663
  }
7639
- function opened(teams, gate, deps) {
7664
+ function opened(teams, botName, gate, deps) {
7640
7665
  const { outbound, inbound: inbound2 } = transport(teams, gate, deps);
7641
7666
  const { acks, surface } = surfaceOf(teams, outbound, gate, deps);
7642
7667
  return {
7643
7668
  surface,
7644
- typedEvent: teamsTypedEvent(deps.logger),
7645
- connect: (context) => connect(teams, { acks, inbound: inbound2, gate }, context),
7669
+ typedEvent: teamsTypedEvent(botName, deps.logger),
7670
+ connect: (context) => connect(teams, { botName, acks, inbound: inbound2, gate }, context),
7646
7671
  closes: [() => outbound.close(), () => inbound2?.close()]
7647
7672
  };
7648
7673
  }
@@ -7653,12 +7678,12 @@ function teamsSurface() {
7653
7678
  const gate = gateEntryFromEnv(env);
7654
7679
  return {
7655
7680
  loadSecrets: (_names, deps) => loadSecrets(env, deps),
7656
- configure() {
7681
+ configure(settings) {
7657
7682
  const teams = teamsSettingsFromEnv(env, { queues: gate === void 0 });
7658
7683
  return {
7659
7684
  host: gate === void 0 ? "0.0.0.0" : LOOPBACK,
7660
7685
  shape: teamsShape(teams),
7661
- open: (deps) => opened(teams, gate, deps)
7686
+ open: (deps) => opened(teams, settings.botName, gate, deps)
7662
7687
  };
7663
7688
  }
7664
7689
  };
package/dist/main.js CHANGED
@@ -721,8 +721,8 @@ function inboundLinksOf(activity) {
721
721
  }
722
722
 
723
723
  // packages/teams/src/activity/inbound/mentions.ts
724
- import { cpLength as cpLength2, pyLstrip, pyStr as pyStr7, pyStrip as pyStrip4 } from "@primusclaw/personal-agent";
725
- var DEFAULT_BOT_NAME = "Clawy";
724
+ import { BOT_NAME, cpLength as cpLength2, pyLstrip, pyStr as pyStr7, pyStrip as pyStrip4 } from "@primusclaw/personal-agent";
725
+ var DEFAULT_BOT_NAME = BOT_NAME;
726
726
  function isMention(entity) {
727
727
  return entity["type"] === "mention";
728
728
  }
@@ -5781,7 +5781,7 @@ import {
5781
5781
  REVIEW_MODES,
5782
5782
  githubConfirmButtons
5783
5783
  } from "@primusclaw/personal-agent";
5784
- import { BOT_NAME, own as own11 } from "@primusclaw/personal-agent";
5784
+ import { own as own11 } from "@primusclaw/personal-agent";
5785
5785
  var MARKDOWN = /([\\`*_[\]<])/gu;
5786
5786
  function plain(value) {
5787
5787
  return value.replace(MARKDOWN, "\\$1");
@@ -5792,13 +5792,13 @@ var MODE_WHAT = {
5792
5792
  "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
5793
  ],
5794
5794
  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\u53EA\u6709\u4ED3\u5E93\u81EA\u5DF1\u8981\u6C42\u786E\u8BA4\u7684\u53D8\u66F4\uFF08.github/clawy.yml \u7684 confirm_merge: always \u7B49\uFF09\u4ECD\u4F1A\u5148\u95EE\u4F60\u3002",
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\u53EA\u6709\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",
5796
5796
  "Approved and merged when nothing needs fixing and every check passes, without asking you; only 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
5797
  ]
5798
5798
  };
5799
5799
  var MODE_BUTTON = { high_risk_confirm: "\u9AD8\u98CE\u9669\u518D\u95EE\u6211", fully_auto: "\u5168\u81EA\u52A8\u5408\u5165" };
5800
- function addAppButton(installUrl) {
5801
- return installUrl ? [openUrl(`\u6DFB\u52A0 ${BOT_NAME}`, installUrl)] : [];
5800
+ function addAppButton(installUrl, bot) {
5801
+ return installUrl ? [openUrl(`\u6DFB\u52A0 ${bot}`, installUrl)] : [];
5802
5802
  }
5803
5803
  function reviewModeCard(model) {
5804
5804
  const known = (mode) => Object.hasOwn(REVIEW_MODES, mode);
@@ -5824,12 +5824,12 @@ function reviewModeCard(model) {
5824
5824
  }
5825
5825
  body.push(
5826
5826
  note(
5827
- "\u8FD9\u4E2A\u8BBE\u7F6E\u5BF9\u4F60\u81EA\u5DF1\u8BA9 Clawy \u5BA1 PR\u3001\u4EE5\u53CA\u540C\u4E8B\u8BF7\u4F60\u4EE3\u5BA1\u90FD\u751F\u6548\u3002\u662F\u5426\u5141\u8BB8\u540C\u4E8B\u4EE5\u4F60\u7684\u540D\u4E49\u8BF7\u6211\u5BA1\u5E76\u5408\u5165\uFF0C\u662F\u53E6\u4E00\u4E2A\u5F00\u5173\uFF1A`/github auto-merge on|off`\u3002"
5827
+ `\u8FD9\u4E2A\u8BBE\u7F6E\u5BF9\u4F60\u81EA\u5DF1\u8BA9 ${model.bot} \u5BA1 PR\u3001\u4EE5\u53CA\u540C\u4E8B\u8BF7\u4F60\u4EE3\u5BA1\u90FD\u751F\u6548\u3002\u662F\u5426\u5141\u8BB8\u540C\u4E8B\u4EE5\u4F60\u7684\u540D\u4E49\u8BF7\u6211\u5BA1\u5E76\u5408\u5165\uFF0C\u662F\u53E6\u4E00\u4E2A\u5F00\u5173\uFF1A\`/github auto-merge on|off\`\u3002`
5828
5828
  )
5829
5829
  );
5830
5830
  english.push(
5831
5831
  text2(
5832
- "This applies when you ask Clawy to review a pull request and when a colleague asks Clawy to review one as you. Whether colleagues may ask at all is the other switch, `/github auto-merge on|off`.",
5832
+ `This applies when you ask ${model.bot} to review a pull request and when a colleague asks ${model.bot} to review one as you. Whether colleagues may ask at all is the other switch, \`/github auto-merge on|off\`.`,
5833
5833
  { size: "Small" }
5834
5834
  )
5835
5835
  );
@@ -5838,7 +5838,7 @@ function reviewModeCard(model) {
5838
5838
  const choices = order.map(
5839
5839
  (m) => execute(own11(MODE_BUTTON, m) ?? m, "primusclaw.github_mode", { primusclaw: "github_mode", mode: m })
5840
5840
  );
5841
- return message(body, buttons([...choices, ...model.hint ? addAppButton(model.installUrl) : []]));
5841
+ return message(body, buttons([...choices, ...model.hint ? addAppButton(model.installUrl, model.bot) : []]));
5842
5842
  }
5843
5843
  function typedConfirmHint(number, lang) {
5844
5844
  const n = clip(String(number), 10);
@@ -5954,7 +5954,7 @@ function githubConfirmCard(m) {
5954
5954
  ];
5955
5955
  if (m.hint) body.push(note(typedConfirmHint(m.number, m.lang)));
5956
5956
  const actions = buttons(githubConfirmButtons(m.confirmationId, m.review !== void 0, m.lang).map(action));
5957
- return message(body, [...actions, ...m.hint ? addAppButton(m.installUrl) : []]);
5957
+ return message(body, [...actions, ...m.hint ? addAppButton(m.installUrl, m.bot) : []]);
5958
5958
  }
5959
5959
  function endedTone(ended) {
5960
5960
  const low = ended.toLowerCase();
@@ -7263,6 +7263,11 @@ import { SETTING_ALIASES, settingValue } from "@primusclaw/personal-agent-runtim
7263
7263
  var KEYVAULT_SCOPE = "https://vault.azure.net/.default";
7264
7264
  var KEYVAULT_API_VERSION = "7.4";
7265
7265
  var VAULT_NAMES = {
7266
+ TEAMS_ENCRYPTION_KEYS: "personal-agent-encryption-keys",
7267
+ TEAMS_EXCHANGE_CLIENT_SECRET: "personal-agent-exchange-client-secret",
7268
+ FEEDBACK_GITHUB_APP_KEY: "personal-agent-feedback-github-app-key"
7269
+ };
7270
+ var LEGACY_VAULT_NAMES = {
7266
7271
  TEAMS_ENCRYPTION_KEYS: "clawy-encryption-keys",
7267
7272
  TEAMS_EXCHANGE_CLIENT_SECRET: "clawy-exchange-client-secret",
7268
7273
  FEEDBACK_GITHUB_APP_KEY: "clawy-feedback-github-app-key"
@@ -7387,17 +7392,35 @@ var KeyVaultSecretSource = class {
7387
7392
  } finally {
7388
7393
  deadline.dispose();
7389
7394
  }
7395
+ const legacy = names.filter((name) => values.get(name)?.from === LEGACY_VAULT_NAMES[name]);
7396
+ if (legacy.length) {
7397
+ this.logger.warn(
7398
+ `secrets: deprecated Key Vault secret names: ${legacy.map((n) => `${LEGACY_VAULT_NAMES[n]} (now ${VAULT_NAMES[n]})`).join(", ")}; they are still read when the new name is missing; store the secrets under the new names`
7399
+ );
7400
+ }
7390
7401
  this.logger.info(
7391
- `secrets: ${String(values.size)} read from Key Vault ${vaultHost(this.url)} as client ${this.credential.clientId} (${names.map((name) => VAULT_NAMES[name]).join(", ")})`
7402
+ `secrets: ${String(values.size)} read from Key Vault ${vaultHost(this.url)} as client ${this.credential.clientId} (${[...values.values()].map((r) => r.from).join(", ")})`
7392
7403
  );
7393
- return values;
7404
+ return new Map([...values].map(([name, r]) => [name, r.value]));
7394
7405
  }
7395
7406
  async readAll(names, signal) {
7396
7407
  const token = await this.token(signal);
7397
7408
  const values = /* @__PURE__ */ new Map();
7398
- for (const name of names) values.set(name, await this.read(VAULT_NAMES[name], token, signal));
7409
+ for (const name of names) values.set(name, await this.readSecret(name, token, signal));
7399
7410
  return values;
7400
7411
  }
7412
+ /** A secret under its name, else (the vault has no such entry) under its deprecated name; never written under either. */
7413
+ async readSecret(name, token, signal) {
7414
+ const current = VAULT_NAMES[name];
7415
+ const legacy = LEGACY_VAULT_NAMES[name];
7416
+ const found = await this.read(current, token, signal);
7417
+ if (typeof found === "string") return { value: found, from: current };
7418
+ const old = await this.read(legacy, token, signal);
7419
+ if (typeof old === "string") return { value: old, from: legacy };
7420
+ throw new SecretsUnavailable2(
7421
+ `Key Vault secret ${current}: ${found.missing} (nor under its deprecated name ${legacy})`
7422
+ );
7423
+ }
7401
7424
  async token(signal) {
7402
7425
  for (let attempt2 = 1; ; attempt2++) {
7403
7426
  try {
@@ -7416,11 +7439,13 @@ var KeyVaultSecretSource = class {
7416
7439
  await this.sleep(BACKOFF_MS2 * 2 ** (attempt2 - 1), signal);
7417
7440
  }
7418
7441
  }
7442
+ /** `name`'s value, or why not when the vault has no such secret (it answered 404). */
7419
7443
  async read(name, token, signal) {
7420
7444
  const target = `${this.url}/secrets/${pyQuote(name, "")}?api-version=${KEYVAULT_API_VERSION}`;
7421
7445
  for (let attempt2 = 1; ; attempt2++) {
7422
7446
  const answer = await this.readOnce(target, name, token, signal);
7423
7447
  if ("value" in answer) return answer.value;
7448
+ if (answer.missing) return { missing: answer.reason };
7424
7449
  if (!answer.transient || attempt2 === ATTEMPTS) {
7425
7450
  throw new SecretsUnavailable2(`Key Vault secret ${name}: ${answer.reason}`);
7426
7451
  }
@@ -7443,14 +7468,15 @@ var KeyVaultSecretSource = class {
7443
7468
  status = response.status;
7444
7469
  text4 = await response.text();
7445
7470
  } catch (error) {
7446
- return { reason: `Key Vault unreachable (${errorName8(error)})`, transient: true };
7471
+ return { reason: `Key Vault unreachable (${errorName8(error)})`, transient: true, missing: false };
7447
7472
  } finally {
7448
7473
  timer.dispose();
7449
7474
  }
7450
7475
  if (status === 200) return { value: secretValue(name, text4) };
7451
7476
  return {
7452
7477
  reason: `Key Vault answered ${String(status)}${vaultErrorCode(text4)}`,
7453
- transient: status === 429 || status >= 500
7478
+ transient: status === 429 || status >= 500,
7479
+ missing: status === 404
7454
7480
  };
7455
7481
  }
7456
7482
  };
@@ -7487,7 +7513,6 @@ async function loadSecrets(env, deps) {
7487
7513
  }
7488
7514
 
7489
7515
  // packages/teams/src/assembly/worker.ts
7490
- var BOT_NAME2 = "Clawy";
7491
7516
  function conversationTypeOf(kind) {
7492
7517
  if (kind === "personal") return "personal";
7493
7518
  return kind === "group" ? "groupChat" : "channel";
@@ -7534,10 +7559,10 @@ function teamsShape(teams) {
7534
7559
  version: teamsVersion()
7535
7560
  };
7536
7561
  }
7537
- function teamsTypedEvent(logger) {
7562
+ function teamsTypedEvent(botName, logger) {
7538
7563
  return (conversation, messageId, text4) => {
7539
7564
  const activity = { ...activityOfReference(conversation.wire, messageId), text: text4 };
7540
- const read = toInboundEvent(activity, { botName: BOT_NAME2, logger });
7565
+ const read = toInboundEvent(activity, { botName, logger });
7541
7566
  return read.ok ? read.value : void 0;
7542
7567
  };
7543
7568
  }
@@ -7571,11 +7596,11 @@ function surfaceOf(teams, outbound, gate, deps) {
7571
7596
  return { acks, surface };
7572
7597
  }
7573
7598
  function connect(teams, parts, context) {
7574
- const { acks, inbound: inbound2, gate } = parts;
7599
+ const { botName, acks, inbound: inbound2, gate } = parts;
7575
7600
  const handle = inboundHandler({
7576
7601
  acks,
7577
7602
  route: context.route,
7578
- botName: BOT_NAME2,
7603
+ botName,
7579
7604
  logger: context.logger,
7580
7605
  groupContext: context.groupContext
7581
7606
  });
@@ -7605,13 +7630,13 @@ function connect(teams, parts, context) {
7605
7630
  });
7606
7631
  return { routes, source };
7607
7632
  }
7608
- function opened(teams, gate, deps) {
7633
+ function opened(teams, botName, gate, deps) {
7609
7634
  const { outbound, inbound: inbound2 } = transport(teams, gate, deps);
7610
7635
  const { acks, surface } = surfaceOf(teams, outbound, gate, deps);
7611
7636
  return {
7612
7637
  surface,
7613
- typedEvent: teamsTypedEvent(deps.logger),
7614
- connect: (context) => connect(teams, { acks, inbound: inbound2, gate }, context),
7638
+ typedEvent: teamsTypedEvent(botName, deps.logger),
7639
+ connect: (context) => connect(teams, { botName, acks, inbound: inbound2, gate }, context),
7615
7640
  closes: [() => outbound.close(), () => inbound2?.close()]
7616
7641
  };
7617
7642
  }
@@ -7622,12 +7647,12 @@ function teamsSurface() {
7622
7647
  const gate = gateEntryFromEnv(env);
7623
7648
  return {
7624
7649
  loadSecrets: (_names, deps) => loadSecrets(env, deps),
7625
- configure() {
7650
+ configure(settings) {
7626
7651
  const teams = teamsSettingsFromEnv(env, { queues: gate === void 0 });
7627
7652
  return {
7628
7653
  host: gate === void 0 ? "0.0.0.0" : LOOPBACK,
7629
7654
  shape: teamsShape(teams),
7630
- open: (deps) => opened(teams, gate, deps)
7655
+ open: (deps) => opened(teams, settings.botName, gate, deps)
7631
7656
  };
7632
7657
  }
7633
7658
  };
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import type { InboundMention } from "@primusclaw/personal-agent";
8
8
  import { type Activity, type Fields } from "./schema.js";
9
- /** The bot's display name where the caller gives none (the Python worker's `branding.BOT_NAME`). */
10
- export declare const DEFAULT_BOT_NAME = "Clawy";
9
+ /** The bot's display name where the caller gives none: core's default (a deployment's own is `Settings.botName`). */
10
+ export declare const DEFAULT_BOT_NAME = "PrimusClaw Assistant";
11
11
  /** Whether `entity` is a mention of the bot (`botId` its id here; never when the id is unknown). */
12
12
  export declare function mentionsBot(entity: Fields, botId: string): boolean;
13
13
  /** True when the bot itself is @mentioned (a mention of another person does not count). */
@@ -18,7 +18,7 @@ export declare function isMentioned(activity: Activity): boolean;
18
18
  */
19
19
  export declare function isTargeted(activity: Activity): boolean;
20
20
  /**
21
- * True when the message starts by naming the bot ("@Clawy ..."): in a 1:1 chat attached to a remote session, the way
21
+ * True when the message starts by naming the bot ("@<name> ...", the deployment's name): in a 1:1 chat attached to a remote session, the way
22
22
  * the person says these words are for the bot and not for the session.
23
23
  */
24
24
  export declare function addressedToBot(activity: Activity, botName?: string): boolean;
@@ -7,7 +7,7 @@ export interface NoSender {
7
7
  readonly kind: "no_sender";
8
8
  }
9
9
  export interface ToEventOptions {
10
- /** The bot's display name, for "@<name> ..." (default "Clawy"). */
10
+ /** The bot's display name, for "@<name> ..." (the deployment's `Settings.botName`; default `BOT_NAME`). */
11
11
  readonly botName?: string;
12
12
  readonly logger?: Logger;
13
13
  }
@@ -22,7 +22,7 @@ export declare function teamsShape(teams: Pick<TeamsSettings, "style" | "install
22
22
  * `text` as the activity Teams would have sent for the person's own message `messageId` in a stored conversation, read as
23
23
  * core's event (what a plugin's `handleAsTyped` hands the router); undefined when it cannot be read.
24
24
  */
25
- export declare function teamsTypedEvent(logger: Logger): OpenedSurface["typedEvent"];
25
+ export declare function teamsTypedEvent(botName: string, logger: Logger): OpenedSurface["typedEvent"];
26
26
  /**
27
27
  * The Teams surface: the release gate's test entry is read first (TEAMS_GATE_ENTRY), the secrets come from where
28
28
  * SECRETS_SOURCE says (the environment or Azure Key Vault), and the Teams settings are read after core's.
@@ -9,6 +9,11 @@ export declare const KEYVAULT_SCOPE = "https://vault.azure.net/.default";
9
9
  export declare const KEYVAULT_API_VERSION = "7.4";
10
10
  /** The setting a secret replaces -> the name of the secret in the vault. */
11
11
  export declare const VAULT_NAMES: Readonly<Record<SecretName, string>>;
12
+ /**
13
+ * The name each secret was stored under before the bot's default name changed. Deprecated: it is read only when the vault
14
+ * holds no secret under the `VAULT_NAMES` name (with a warning at start), and never written.
15
+ */
16
+ export declare const LEGACY_VAULT_NAMES: Readonly<Record<SecretName, string>>;
12
17
  /**
13
18
  * What the environment holds for each secret with SECRETS_SOURCE=env (the GitHub App key is a mounted file); the older
14
19
  * `TEAMS_` name of a `PA_` one is read too.
@@ -37,7 +37,10 @@ export declare class KeyVaultSecretSource implements SecretSource {
37
37
  constructor(url: string, credential: VaultCredential, options: KeyVaultOptions);
38
38
  load(names: readonly SecretName[]): Promise<ReadonlyMap<SecretName, string>>;
39
39
  private readAll;
40
+ /** A secret under its name, else (the vault has no such entry) under its deprecated name; never written under either. */
41
+ private readSecret;
40
42
  private token;
43
+ /** `name`'s value, or why not when the vault has no such secret (it answered 404). */
41
44
  private read;
42
45
  private readOnce;
43
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primusclaw/personal-agent-teams",
3
- "version": "0.9.0",
3
+ "version": "0.10.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.9.0",
39
- "@primusclaw/personal-agent-runtime": "0.9.0",
38
+ "@primusclaw/personal-agent": "0.10.0",
39
+ "@primusclaw/personal-agent-runtime": "0.10.0",
40
40
  "zod": "^4.6.7"
41
41
  },
42
42
  "devDependencies": {