@primusclaw/personal-agent-runtime 0.8.0 → 0.8.1

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
@@ -1820,8 +1820,87 @@ var HttpTokenExchange = class {
1820
1820
  }
1821
1821
  };
1822
1822
 
1823
+ // packages/runtime/src/config/aliases.ts
1824
+ import { own as own3, pyStrip as pyStrip4 } from "@primusclaw/personal-agent";
1825
+ var SETTING_PREFIX = "PA_";
1826
+ var LEGACY_SETTING_PREFIX = "TEAMS_";
1827
+ var ALIASED_SETTINGS = [
1828
+ "DB_PATH",
1829
+ "ENCRYPTION_KEYS",
1830
+ "CLAW_EVENTS_GONE",
1831
+ "ON_BEHALF_USERS",
1832
+ "OBSERVE_USERS",
1833
+ "DIRECT_CHAT",
1834
+ "DIRECT_CHAT_USERS",
1835
+ "ASSISTANT_UNDERSTANDING",
1836
+ "ASSISTANT_UNDERSTANDING_USERS",
1837
+ "GROUP_CONTEXT_MESSAGES",
1838
+ "GROUP_CONTEXT_HOURS",
1839
+ "GROUP_CONTEXT_CHARS",
1840
+ "GROUP_CONTEXT_GRANTED",
1841
+ "EXCHANGE_ENABLED",
1842
+ "EXCHANGE_CLIENT_ID",
1843
+ "EXCHANGE_CLIENT_SECRET",
1844
+ "EXCHANGE_TOKEN_URL",
1845
+ "EXCHANGE_BINDING_REQUEST_URL",
1846
+ "EXCHANGE_ISSUER",
1847
+ "EXCHANGE_AUDIENCE",
1848
+ "EXCHANGE_SCOPE",
1849
+ "EXCHANGE_FOR_CHAT",
1850
+ "GITHUB_REVIEW_ENABLED",
1851
+ "GITHUB_REVIEW_OWNERS",
1852
+ "REVIEW_INTENT_MODEL",
1853
+ "GITHUB_CREDENTIAL_URL",
1854
+ "GITHUB_CLIENT_ID",
1855
+ "USER_MESSAGE_LIMIT",
1856
+ "USER_MESSAGE_WINDOW_SECONDS",
1857
+ "USER_MAX_CONCURRENT_TASKS",
1858
+ "LINK_MAX_FAILURES_PER_USER",
1859
+ "LINK_MAX_FAILURES_GLOBAL",
1860
+ "LINK_ATTEMPT_WINDOW_SECONDS",
1861
+ "LIMIT_PR_REVIEW",
1862
+ "LIMIT_PR_MERGE",
1863
+ "LIMIT_APPROVAL",
1864
+ "LIMIT_REMOTE_AGENT"
1865
+ ];
1866
+ var SETTING_ALIASES = new Map(
1867
+ ALIASED_SETTINGS.map((stem) => [SETTING_PREFIX + stem, LEGACY_SETTING_PREFIX + stem])
1868
+ );
1869
+ var NEUTRAL_OF = new Map([...SETTING_ALIASES].map(([neutral, old]) => [old, neutral]));
1870
+ var isSet = (env, name) => pyStrip4(own3(env, name) ?? "") !== "";
1871
+ function settingSource(env, name) {
1872
+ const neutral = NEUTRAL_OF.get(name) ?? name;
1873
+ const legacy = SETTING_ALIASES.get(neutral);
1874
+ if (legacy === void 0) return name;
1875
+ if (isSet(env, neutral)) return neutral;
1876
+ return own3(env, legacy) !== void 0 ? legacy : neutral;
1877
+ }
1878
+ function settingValue(env, name) {
1879
+ return own3(env, settingSource(env, name));
1880
+ }
1881
+ function legacySettings(env) {
1882
+ const out = [];
1883
+ for (const [neutral, legacy] of SETTING_ALIASES) {
1884
+ if (isSet(env, legacy)) out.push({ legacy, neutral, ignored: isSet(env, neutral) });
1885
+ }
1886
+ return out;
1887
+ }
1888
+ function warnLegacySettings(env, logger) {
1889
+ const used = legacySettings(env);
1890
+ const read2 = used.filter((s) => !s.ignored);
1891
+ if (read2.length > 0) {
1892
+ logger.warn(
1893
+ `deprecated setting names: ${read2.map((s) => `${s.legacy} (now ${s.neutral})`).join(", ")}; they still work, the ${SETTING_PREFIX} names take precedence`,
1894
+ { settings: read2.map((s) => s.legacy).join(",") }
1895
+ );
1896
+ }
1897
+ for (const s of used.filter((u) => u.ignored)) {
1898
+ logger.warn(`${s.legacy} is ignored: ${s.neutral} is set`, { setting: s.legacy });
1899
+ }
1900
+ }
1901
+
1823
1902
  // packages/runtime/src/config/env.ts
1824
- import { ConfigError, decimalBigInt, own as own3, pyStrip as pyStrip4 } from "@primusclaw/personal-agent";
1903
+ import { ConfigError, decimalBigInt, pyStrip as pyStrip5 } from "@primusclaw/personal-agent";
1825
1904
  var ON = ["1", "true", "yes", "on"];
1826
1905
  var OFF = ["0", "false", "no", "off"];
1827
1906
  var EnvReader = class {
@@ -1829,18 +1908,22 @@ var EnvReader = class {
1829
1908
  this.env = env;
1830
1909
  }
1831
1910
  env;
1911
+ /** The variable `name` is read from (the `PA_` or the `TEAMS_` name of a pair; any other name as it is). */
1912
+ source(name) {
1913
+ return settingSource(this.env, name);
1914
+ }
1832
1915
  /** The raw value ("" unset). */
1833
1916
  raw(name, fallback = "") {
1834
- return own3(this.env, name) ?? fallback;
1917
+ return settingValue(this.env, name) ?? fallback;
1835
1918
  }
1836
1919
  /** The value without surrounding white space ("" unset). */
1837
1920
  text(name, fallback = "") {
1838
- return pyStrip4(this.raw(name, fallback));
1921
+ return pyStrip5(this.raw(name, fallback));
1839
1922
  }
1840
1923
  /** A value that must be set and not blank. */
1841
1924
  required(name) {
1842
1925
  const value = this.text(name);
1843
- if (value === "") throw new ConfigError(`environment variable ${name} is required`);
1926
+ if (value === "") throw new ConfigError(`environment variable ${this.source(name)} is required`);
1844
1927
  return value;
1845
1928
  }
1846
1929
  /** On or off; `fallback` when unset or empty; anything else stops the worker. */
@@ -1848,7 +1931,7 @@ var EnvReader = class {
1848
1931
  const value = this.text(name).toLowerCase();
1849
1932
  if (value === "") return fallback;
1850
1933
  if (!ON.includes(value) && !OFF.includes(value)) {
1851
- throw new ConfigError(`${name} must be on or off, not ${pyRepr(value)}`);
1934
+ throw new ConfigError(`${this.source(name)} must be on or off, not ${pyRepr(value)}`);
1852
1935
  }
1853
1936
  return ON.includes(value);
1854
1937
  }
@@ -1862,17 +1945,17 @@ var EnvReader = class {
1862
1945
  if (value === "") return fallback;
1863
1946
  const number = decimalBigInt(value);
1864
1947
  if (number === void 0 || number <= 0n) {
1865
- throw new ConfigError(`${name} must be a positive whole number, not ${pyRepr(value)}`);
1948
+ throw new ConfigError(`${this.source(name)} must be a positive whole number, not ${pyRepr(value)}`);
1866
1949
  }
1867
1950
  return Number(number);
1868
1951
  }
1869
1952
  /** A whole number (Python's `int()` of the value: a sign, surrounding space and `_` between digits allowed). */
1870
1953
  int(name, fallback) {
1871
- const value = pyStrip4(this.raw(name, fallback));
1954
+ const value = pyStrip5(this.raw(name, fallback));
1872
1955
  const match = new RegExp("^([+-]?)(\\p{Nd}+(?:_\\p{Nd}+)*)$", "u").exec(value);
1873
1956
  const digits = match === null ? void 0 : decimalBigInt((match[2] ?? "").replaceAll("_", ""));
1874
1957
  if (match === null || digits === void 0) {
1875
- throw new ConfigError(`${name} must be a whole number, not ${pyRepr(value)}`);
1958
+ throw new ConfigError(`${this.source(name)} must be a whole number, not ${pyRepr(value)}`);
1876
1959
  }
1877
1960
  return Number(match[1] === "-" ? -digits : digits);
1878
1961
  }
@@ -1882,7 +1965,7 @@ var EnvReader = class {
1882
1965
  }
1883
1966
  /** A comma separated list, blank entries dropped; `lower` lower-cases each entry. */
1884
1967
  list(name, lower = false) {
1885
- return this.raw(name).split(",").map((entry) => pyStrip4(entry)).filter((entry) => entry !== "").map((entry) => lower ? entry.toLowerCase() : entry);
1968
+ return this.raw(name).split(",").map((entry) => pyStrip5(entry)).filter((entry) => entry !== "").map((entry) => lower ? entry.toLowerCase() : entry);
1886
1969
  }
1887
1970
  };
1888
1971
  function pyRepr(value) {
@@ -1901,15 +1984,20 @@ import { readFileSync } from "node:fs";
1901
1984
  import {
1902
1985
  SECRETS_SOURCES,
1903
1986
  SecretsUnavailable,
1904
- pyStrip as pyStrip5
1987
+ pyStrip as pyStrip6
1905
1988
  } from "@primusclaw/personal-agent";
1989
+ var SECRET_SETTING_NAMES = {
1990
+ TEAMS_ENCRYPTION_KEYS: "PA_ENCRYPTION_KEYS",
1991
+ TEAMS_EXCHANGE_CLIENT_SECRET: "PA_EXCHANGE_CLIENT_SECRET",
1992
+ FEEDBACK_GITHUB_APP_KEY: "FEEDBACK_GITHUB_KEY_FILE"
1993
+ };
1906
1994
  var ENV_NAMES = {
1907
1995
  TEAMS_ENCRYPTION_KEYS: "TEAMS_ENCRYPTION_KEYS",
1908
1996
  TEAMS_EXCHANGE_CLIENT_SECRET: "TEAMS_EXCHANGE_CLIENT_SECRET",
1909
1997
  FEEDBACK_GITHUB_APP_KEY: "FEEDBACK_GITHUB_KEY_FILE"
1910
1998
  };
1911
1999
  function secretsSourceOf(env) {
1912
- const value = pyStrip5(env["SECRETS_SOURCE"] ?? "").toLowerCase() || "env";
2000
+ const value = pyStrip6(env["SECRETS_SOURCE"] ?? "").toLowerCase() || "env";
1913
2001
  const known = SECRETS_SOURCES.find((name) => name === value);
1914
2002
  if (known === void 0) {
1915
2003
  throw new SecretsUnavailable(`SECRETS_SOURCE must be one of ${SECRETS_SOURCES.join(", ")}, not ${pyRepr(value)}`);
@@ -1920,7 +2008,7 @@ function wantedSecrets(env) {
1920
2008
  const read2 = new EnvReader(env);
1921
2009
  return [
1922
2010
  "TEAMS_ENCRYPTION_KEYS",
1923
- ...read2.isOn("TEAMS_EXCHANGE_ENABLED") ? ["TEAMS_EXCHANGE_CLIENT_SECRET"] : [],
2011
+ ...read2.isOn("PA_EXCHANGE_ENABLED") ? ["TEAMS_EXCHANGE_CLIENT_SECRET"] : [],
1924
2012
  ...read2.text("FEEDBACK_GITHUB_APP_ID") !== "" && read2.text("FEEDBACK_GITHUB_INSTALLATION_ID") !== "" ? ["FEEDBACK_GITHUB_APP_KEY"] : []
1925
2013
  ];
1926
2014
  }
@@ -1941,9 +2029,9 @@ var EnvSecretSource = class {
1941
2029
  const values = /* @__PURE__ */ new Map();
1942
2030
  const read2 = new EnvReader(this.env);
1943
2031
  for (const name of names) {
1944
- const variable = ENV_NAMES[name];
2032
+ const variable = SECRET_SETTING_NAMES[name];
1945
2033
  const value = read2.text(variable);
1946
- if (value === "") throw new SecretsUnavailable(`environment variable ${variable} is required`);
2034
+ if (value === "") throw new SecretsUnavailable(`environment variable ${read2.source(variable)} is required`);
1947
2035
  values.set(name, name === "FEEDBACK_GITHUB_APP_KEY" ? this.keyFile(value) : value);
1948
2036
  }
1949
2037
  return values;
@@ -1951,7 +2039,7 @@ var EnvSecretSource = class {
1951
2039
  keyFile(path) {
1952
2040
  let text3;
1953
2041
  try {
1954
- text3 = pyStrip5(this.readFile(path));
2042
+ text3 = pyStrip6(this.readFile(path));
1955
2043
  } catch {
1956
2044
  throw new SecretsUnavailable(`FEEDBACK_GITHUB_KEY_FILE ${path} cannot be read`);
1957
2045
  }
@@ -1968,6 +2056,7 @@ import {
1968
2056
  DEFAULT_MESSAGE_WINDOW_SECONDS,
1969
2057
  DEFAULT_GROUP_CONTEXT,
1970
2058
  decimalBigInt as decimalBigInt2,
2059
+ LIMIT_ENV_PREFIX,
1971
2060
  parseLimits
1972
2061
  } from "@primusclaw/personal-agent";
1973
2062
  var GITHUB_CLI_CLIENT_ID = "178c6fc778ccc68e1d6a";
@@ -1984,7 +2073,7 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
1984
2073
  throw new ConfigError2(`METRICS_PORT must differ from PORT (${String(listenPort)})`);
1985
2074
  }
1986
2075
  return {
1987
- dbPath: read2.raw("TEAMS_DB_PATH", "/data/state.db"),
2076
+ dbPath: read2.raw("PA_DB_PATH", "/data/state.db"),
1988
2077
  encryptionKeys: secret(read2, store, "TEAMS_ENCRYPTION_KEYS").split(",").map((k) => k.trim()).filter((k) => k !== ""),
1989
2078
  clawApiUrl: withoutTrailingSlash(read2.required("CLAW_API_URL")),
1990
2079
  safeApiUrl: withoutTrailingSlash(read2.required("SAFE_API_URL")),
@@ -2004,37 +2093,37 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
2004
2093
  },
2005
2094
  githubReview: githubReviewSettings(read2, publicBaseUrl),
2006
2095
  assistant: assistantSettings(read2),
2007
- clawEventsGone: read2.isOn("TEAMS_CLAW_EVENTS_GONE"),
2096
+ clawEventsGone: read2.isOn("PA_CLAW_EVENTS_GONE"),
2008
2097
  directChat: directChat(read2),
2009
- onBehalfUsers: new Set(read2.list("TEAMS_ON_BEHALF_USERS")),
2010
- observeUsers: new Set(read2.list("TEAMS_OBSERVE_USERS", true)),
2098
+ onBehalfUsers: new Set(read2.list("PA_ON_BEHALF_USERS")),
2099
+ observeUsers: new Set(read2.list("PA_OBSERVE_USERS", true)),
2011
2100
  groupContext: groupContextSettings(read2),
2012
2101
  sensitiveLimits: limitsOf(read2),
2013
2102
  linkLimits: {
2014
- perUser: read2.positiveInt("TEAMS_LINK_MAX_FAILURES_PER_USER", 5),
2015
- global: read2.positiveInt("TEAMS_LINK_MAX_FAILURES_GLOBAL", 100),
2016
- windowSeconds: read2.positiveInt("TEAMS_LINK_ATTEMPT_WINDOW_SECONDS", 600)
2103
+ perUser: read2.positiveInt("PA_LINK_MAX_FAILURES_PER_USER", 5),
2104
+ global: read2.positiveInt("PA_LINK_MAX_FAILURES_GLOBAL", 100),
2105
+ windowSeconds: read2.positiveInt("PA_LINK_ATTEMPT_WINDOW_SECONDS", 600)
2017
2106
  },
2018
2107
  userLimits: {
2019
- messageLimit: read2.positiveInt("TEAMS_USER_MESSAGE_LIMIT", DEFAULT_MESSAGE_LIMIT),
2020
- messageWindowSeconds: read2.positiveInt("TEAMS_USER_MESSAGE_WINDOW_SECONDS", DEFAULT_MESSAGE_WINDOW_SECONDS),
2021
- maxConcurrentTasks: read2.positiveInt("TEAMS_USER_MAX_CONCURRENT_TASKS", DEFAULT_MAX_CONCURRENT_TASKS)
2108
+ messageLimit: read2.positiveInt("PA_USER_MESSAGE_LIMIT", DEFAULT_MESSAGE_LIMIT),
2109
+ messageWindowSeconds: read2.positiveInt("PA_USER_MESSAGE_WINDOW_SECONDS", DEFAULT_MESSAGE_WINDOW_SECONDS),
2110
+ maxConcurrentTasks: read2.positiveInt("PA_USER_MAX_CONCURRENT_TASKS", DEFAULT_MAX_CONCURRENT_TASKS)
2022
2111
  },
2023
2112
  secretsSource: store.source
2024
2113
  };
2025
2114
  }
2026
2115
  function groupContextSettings(read2) {
2027
- const messages = read2.int("TEAMS_GROUP_CONTEXT_MESSAGES", String(DEFAULT_GROUP_CONTEXT.messages));
2116
+ const messages = read2.int("PA_GROUP_CONTEXT_MESSAGES", String(DEFAULT_GROUP_CONTEXT.messages));
2028
2117
  if (messages < 0 || messages > MAX_GROUP_CONTEXT_MESSAGES) {
2029
2118
  throw new ConfigError2(
2030
- `TEAMS_GROUP_CONTEXT_MESSAGES must be between 0 and ${String(MAX_GROUP_CONTEXT_MESSAGES)}, not ${String(messages)}`
2119
+ `${read2.source("PA_GROUP_CONTEXT_MESSAGES")} must be between 0 and ${String(MAX_GROUP_CONTEXT_MESSAGES)}, not ${String(messages)}`
2031
2120
  );
2032
2121
  }
2033
2122
  return {
2034
2123
  messages,
2035
- maxAgeSeconds: read2.positiveInt("TEAMS_GROUP_CONTEXT_HOURS", DEFAULT_GROUP_CONTEXT.maxAgeSeconds / 3600) * 3600,
2036
- messageChars: read2.positiveInt("TEAMS_GROUP_CONTEXT_CHARS", DEFAULT_GROUP_CONTEXT.messageChars),
2037
- granted: read2.raw("TEAMS_GROUP_CONTEXT_GRANTED") === "1"
2124
+ maxAgeSeconds: read2.positiveInt("PA_GROUP_CONTEXT_HOURS", DEFAULT_GROUP_CONTEXT.maxAgeSeconds / 3600) * 3600,
2125
+ messageChars: read2.positiveInt("PA_GROUP_CONTEXT_CHARS", DEFAULT_GROUP_CONTEXT.messageChars),
2126
+ granted: read2.raw("PA_GROUP_CONTEXT_GRANTED") === "1"
2038
2127
  };
2039
2128
  }
2040
2129
  function secret(read2, store, name) {
@@ -2043,41 +2132,43 @@ function secret(read2, store, name) {
2043
2132
  if (store.source === "keyvault") {
2044
2133
  throw new ConfigError2(`SECRETS_SOURCE=keyvault but ${name} was not read from the vault`);
2045
2134
  }
2046
- return read2.required(name);
2135
+ return read2.required(SECRET_SETTING_NAMES[name]);
2047
2136
  }
2048
2137
  function exchangeSettings(read2, store, publicBaseUrl) {
2049
- const enabled = read2.isOn("TEAMS_EXCHANGE_ENABLED");
2050
- const forChat = read2.isOn("TEAMS_EXCHANGE_FOR_CHAT");
2051
- if (read2.isOn("TEAMS_GITHUB_REVIEW_ENABLED") && !enabled) {
2052
- throw new ConfigError2("TEAMS_GITHUB_REVIEW_ENABLED needs TEAMS_EXCHANGE_ENABLED");
2138
+ const enabled = read2.isOn("PA_EXCHANGE_ENABLED");
2139
+ const forChat = read2.isOn("PA_EXCHANGE_FOR_CHAT");
2140
+ if (read2.isOn("PA_GITHUB_REVIEW_ENABLED") && !enabled) {
2141
+ throw new ConfigError2(`${read2.source("PA_GITHUB_REVIEW_ENABLED")} needs ${read2.source("PA_EXCHANGE_ENABLED")}`);
2142
+ }
2143
+ if (forChat && !enabled) {
2144
+ throw new ConfigError2(`${read2.source("PA_EXCHANGE_FOR_CHAT")} needs ${read2.source("PA_EXCHANGE_ENABLED")}`);
2053
2145
  }
2054
- if (forChat && !enabled) throw new ConfigError2("TEAMS_EXCHANGE_FOR_CHAT needs TEAMS_EXCHANGE_ENABLED");
2055
2146
  return {
2056
2147
  enabled,
2057
- tokenUrl: enabled ? read2.raw("TEAMS_EXCHANGE_TOKEN_URL", `${publicBaseUrl}/oauth/token`) : "",
2058
- clientId: enabled ? read2.required("TEAMS_EXCHANGE_CLIENT_ID") : "",
2148
+ tokenUrl: enabled ? read2.raw("PA_EXCHANGE_TOKEN_URL", `${publicBaseUrl}/oauth/token`) : "",
2149
+ clientId: enabled ? read2.required("PA_EXCHANGE_CLIENT_ID") : "",
2059
2150
  clientSecret: enabled ? secret(read2, store, "TEAMS_EXCHANGE_CLIENT_SECRET") : "",
2060
- issuer: read2.raw("TEAMS_EXCHANGE_ISSUER", "teams.microsoft.com"),
2061
- audience: read2.raw("TEAMS_EXCHANGE_AUDIENCE", "claw-api"),
2062
- scope: read2.raw("TEAMS_EXCHANGE_SCOPE", "claw.api"),
2063
- bindingRequestUrl: enabled ? read2.raw("TEAMS_EXCHANGE_BINDING_REQUEST_URL", `${publicBaseUrl}/oauth/binding-requests`) : "",
2151
+ issuer: read2.raw("PA_EXCHANGE_ISSUER", "teams.microsoft.com"),
2152
+ audience: read2.raw("PA_EXCHANGE_AUDIENCE", "claw-api"),
2153
+ scope: read2.raw("PA_EXCHANGE_SCOPE", "claw.api"),
2154
+ bindingRequestUrl: enabled ? read2.raw("PA_EXCHANGE_BINDING_REQUEST_URL", `${publicBaseUrl}/oauth/binding-requests`) : "",
2064
2155
  forChat
2065
2156
  };
2066
2157
  }
2067
2158
  function githubReviewSettings(read2, publicBaseUrl) {
2068
- const enabled = read2.isOn("TEAMS_GITHUB_REVIEW_ENABLED");
2069
- const owners = read2.list("TEAMS_GITHUB_REVIEW_OWNERS");
2159
+ const enabled = read2.isOn("PA_GITHUB_REVIEW_ENABLED");
2160
+ const owners = read2.list("PA_GITHUB_REVIEW_OWNERS");
2070
2161
  if (enabled && owners.length === 0) {
2071
2162
  throw new ConfigError2(
2072
- "TEAMS_GITHUB_REVIEW_ENABLED needs TEAMS_GITHUB_REVIEW_OWNERS (the GitHub owners whose pull requests are taken)"
2163
+ `${read2.source("PA_GITHUB_REVIEW_ENABLED")} needs ${read2.source("PA_GITHUB_REVIEW_OWNERS")} (the GitHub owners whose pull requests are taken)`
2073
2164
  );
2074
2165
  }
2075
2166
  return {
2076
2167
  enabled,
2077
2168
  owners,
2078
- intentModel: enabled ? read2.text("TEAMS_REVIEW_INTENT_MODEL") || read2.text("CLAWY_MODEL") : "",
2079
- credentialUrl: enabled ? withoutTrailingSlash(read2.raw("TEAMS_GITHUB_CREDENTIAL_URL", `${publicBaseUrl}/oauth/external-credentials`)) : "",
2080
- clientId: read2.text("TEAMS_GITHUB_CLIENT_ID", GITHUB_CLI_CLIENT_ID) || GITHUB_CLI_CLIENT_ID
2169
+ intentModel: enabled ? read2.text("PA_REVIEW_INTENT_MODEL") || read2.text("CLAWY_MODEL") : "",
2170
+ credentialUrl: enabled ? withoutTrailingSlash(read2.raw("PA_GITHUB_CREDENTIAL_URL", `${publicBaseUrl}/oauth/external-credentials`)) : "",
2171
+ clientId: read2.text("PA_GITHUB_CLIENT_ID", GITHUB_CLI_CLIENT_ID) || GITHUB_CLI_CLIENT_ID
2081
2172
  };
2082
2173
  }
2083
2174
  function assistantSettings(read2) {
@@ -2087,20 +2178,22 @@ function assistantSettings(read2) {
2087
2178
  throw new ConfigError2(`ASSISTANT_REPLY_WINDOW_SECONDS must be a positive number of seconds, not ${pyRepr(window)}`);
2088
2179
  }
2089
2180
  const enabled = read2.isOn("ASSISTANT_ENABLED");
2090
- const understanding = read2.switch("TEAMS_ASSISTANT_UNDERSTANDING", false);
2181
+ const understanding = read2.switch("PA_ASSISTANT_UNDERSTANDING", false);
2091
2182
  const users = new Set(read2.list("ASSISTANT_USERS", true));
2092
- const listed = new Set(read2.list("TEAMS_ASSISTANT_UNDERSTANDING_USERS", true));
2183
+ const listed = new Set(read2.list("PA_ASSISTANT_UNDERSTANDING_USERS", true));
2093
2184
  const understandingUsers = understanding ? listed.size > 0 ? listed : users : /* @__PURE__ */ new Set();
2094
2185
  if (understanding && understandingUsers.size === 0) {
2095
2186
  throw new ConfigError2(
2096
- "TEAMS_ASSISTANT_UNDERSTANDING is on but TEAMS_ASSISTANT_UNDERSTANDING_USERS names nobody (and ASSISTANT_USERS is empty)"
2187
+ `${read2.source("PA_ASSISTANT_UNDERSTANDING")} is on but ${read2.source("PA_ASSISTANT_UNDERSTANDING_USERS")} names nobody (and ASSISTANT_USERS is empty)`
2097
2188
  );
2098
2189
  }
2099
2190
  if (understandingUsers.size > 0 && !enabled) {
2100
- throw new ConfigError2("TEAMS_ASSISTANT_UNDERSTANDING needs ASSISTANT_ENABLED");
2191
+ throw new ConfigError2(`${read2.source("PA_ASSISTANT_UNDERSTANDING")} needs ASSISTANT_ENABLED`);
2101
2192
  }
2102
2193
  if (users.size > 0 && [...understandingUsers].some((u) => !users.has(u))) {
2103
- throw new ConfigError2("TEAMS_ASSISTANT_UNDERSTANDING_USERS names people who are not in ASSISTANT_USERS");
2194
+ throw new ConfigError2(
2195
+ `${read2.source("PA_ASSISTANT_UNDERSTANDING_USERS")} names people who are not in ASSISTANT_USERS`
2196
+ );
2104
2197
  }
2105
2198
  return {
2106
2199
  enabled,
@@ -2111,13 +2204,16 @@ function assistantSettings(read2) {
2111
2204
  }
2112
2205
  function directChat(read2) {
2113
2206
  return {
2114
- enabled: read2.switch("TEAMS_DIRECT_CHAT", false),
2115
- users: new Set(read2.list("TEAMS_DIRECT_CHAT_USERS", true))
2207
+ enabled: read2.switch("PA_DIRECT_CHAT", false),
2208
+ users: new Set(read2.list("PA_DIRECT_CHAT_USERS", true))
2116
2209
  };
2117
2210
  }
2118
2211
  function limitsOf(read2) {
2119
2212
  try {
2120
- return parseLimits((name) => read2.raw(name));
2213
+ return parseLimits((name) => read2.raw(name), {
2214
+ prefix: LIMIT_ENV_PREFIX,
2215
+ source: (name) => read2.source(name)
2216
+ });
2121
2217
  } catch (err5) {
2122
2218
  if (err5 instanceof ConfigError2) throw err5;
2123
2219
  throw new ConfigError2(err5 instanceof Error ? err5.message : String(err5));
@@ -2394,6 +2490,20 @@ var Database = class {
2394
2490
  constructor(path) {
2395
2491
  this.#db = new DatabaseSync(path, { timeout: 5e3 });
2396
2492
  this.#db.exec("PRAGMA journal_mode=WAL");
2493
+ this.#db.exec("PRAGMA synchronous=NORMAL");
2494
+ }
2495
+ /**
2496
+ * `write` with each commit synced to disk (`synchronous=FULL`): for what is acknowledged as kept before it is used. Inside an
2497
+ * open transaction SQLite refuses to change the setting, so there `write` just runs and its commit is the transaction's.
2498
+ */
2499
+ durably(write) {
2500
+ if (this.#db.isTransaction) return write();
2501
+ this.#db.exec("PRAGMA synchronous=FULL");
2502
+ try {
2503
+ return write();
2504
+ } finally {
2505
+ this.#db.exec("PRAGMA synchronous=NORMAL");
2506
+ }
2397
2507
  }
2398
2508
  /** Several statements, no parameters (DDL). */
2399
2509
  exec(sql) {
@@ -4192,12 +4302,14 @@ var SqliteHeldEventRepository = class {
4192
4302
  const { db } = this.ctx;
4193
4303
  const now = this.ctx.now();
4194
4304
  db.run("DELETE FROM held_events WHERE held_at < ?", now - HELD_TTL_SECONDS);
4195
- db.run(
4196
- "INSERT OR IGNORE INTO held_events (event_id, aad_id, event_json, held_at) VALUES (?, ?, ?, ?)",
4197
- pyStr4(event["event_id"]),
4198
- userId,
4199
- pyJsonDumps(event),
4200
- now
4305
+ db.durably(
4306
+ () => db.run(
4307
+ "INSERT OR IGNORE INTO held_events (event_id, aad_id, event_json, held_at) VALUES (?, ?, ?, ?)",
4308
+ pyStr4(event["event_id"]),
4309
+ userId,
4310
+ pyJsonDumps(event),
4311
+ now
4312
+ )
4201
4313
  );
4202
4314
  db.run(
4203
4315
  "DELETE FROM held_events WHERE aad_id = ? AND event_id NOT IN (SELECT event_id FROM held_events WHERE aad_id = ? ORDER BY held_at DESC, rowid DESC LIMIT ?)",
@@ -5805,7 +5917,7 @@ function feedbackSink(config, options) {
5805
5917
 
5806
5918
  // packages/runtime/src/github/feedback-worker.ts
5807
5919
  import { readFileSync as readFileSync3 } from "node:fs";
5808
- import { pyStrip as pyStrip6 } from "@primusclaw/personal-agent";
5920
+ import { pyStrip as pyStrip7 } from "@primusclaw/personal-agent";
5809
5921
  function packageVersion(packageJson) {
5810
5922
  try {
5811
5923
  const parsed = JSON.parse(readFileSync3(packageJson, "utf8"));
@@ -5816,7 +5928,7 @@ function packageVersion(packageJson) {
5816
5928
  }
5817
5929
  }
5818
5930
  function workerInfoFromEnv(env, worker) {
5819
- const tag = (name) => pyStrip6(env[name] ?? "");
5931
+ const tag = (name) => pyStrip7(env[name] ?? "");
5820
5932
  return {
5821
5933
  pluginId: worker.pluginId,
5822
5934
  version: worker.version,
@@ -5891,6 +6003,7 @@ var ChatLog = class {
5891
6003
  export {
5892
6004
  ACCESS_TOKEN,
5893
6005
  ALERTED,
6006
+ ALIASED_SETTINGS,
5894
6007
  ASSISTANT_REPLY_WINDOW_SECONDS,
5895
6008
  AppTokenSource,
5896
6009
  BUSY_POLL_MS,
@@ -5926,6 +6039,7 @@ export {
5926
6039
  IdentityCredentialClient,
5927
6040
  InvalidToken,
5928
6041
  LAG_WINDOW_MS,
6042
+ LEGACY_SETTING_PREFIX,
5929
6043
  LINK_HASH_LABEL,
5930
6044
  MAX_BODY_BYTES,
5931
6045
  MAX_DEVICE_WAIT_SECONDS,
@@ -5938,6 +6052,9 @@ export {
5938
6052
  PublicPullReader,
5939
6053
  REFRESH_MARGIN_SECONDS,
5940
6054
  REQUEST_MARGIN_SECONDS,
6055
+ SECRET_SETTING_NAMES,
6056
+ SETTING_ALIASES,
6057
+ SETTING_PREFIX,
5941
6058
  SqliteStore,
5942
6059
  StoreSecrets,
5943
6060
  UNMATCHED_ROUTE,
@@ -5959,6 +6076,7 @@ export {
5959
6076
  hashLinkCode,
5960
6077
  healthzRoute,
5961
6078
  json,
6079
+ legacySettings,
5962
6080
  lineLogger,
5963
6081
  linkHashKey,
5964
6082
  linkRoute,
@@ -5974,6 +6092,8 @@ export {
5974
6092
  round3,
5975
6093
  ruleText,
5976
6094
  secretsSourceOf,
6095
+ settingSource,
6096
+ settingValue,
5977
6097
  sign,
5978
6098
  sinceOccurred,
5979
6099
  systemClock,
@@ -5982,6 +6102,7 @@ export {
5982
6102
  urlsafeB64Decode,
5983
6103
  urlsafeB64Encode,
5984
6104
  wantedSecrets,
6105
+ warnLegacySettings,
5985
6106
  withoutTrailingSlash,
5986
6107
  workerInfoFromEnv
5987
6108
  };
@@ -14,7 +14,7 @@ export interface IdentityLookupOptions {
14
14
  /**
15
15
  * Who a credential belongs to. A person's own key (`ak-...`) is asked of the platform's `/users/self` with the key itself
16
16
  * (the Python worker's `safe.whoami`, `safe.safe_user` and `safe.user_id_of`, which read the same answer). An identity
17
- * token exchanged for them (TEAMS_EXCHANGE_FOR_CHAT) is asked of Claw's `/v1/me` with the token, when Claw's URL is
17
+ * token exchanged for them (PA_EXCHANGE_FOR_CHAT) is asked of Claw's `/v1/me` with the token, when Claw's URL is
18
18
  * given: the platform does not take such a token on its data routes, and Claw answers with the platform's id, name and
19
19
  * email of the token's subject (it has no account type: ""). Any failure is no owner: an answer other than 200, a timeout
20
20
  * or a broken connection, a body that is not JSON or not an object. The caller says so, or tries again later (the
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The worker's own settings carry the `PA_` prefix (personal agent): the store, the encryption keys, the token exchange,
3
+ * the review for a colleague, the per-person limits and the other settings every surface shares. They were first
4
+ * written with the `TEAMS_` prefix, when Teams was the only surface; those names are still read, as aliases, so a
5
+ * deployment that sets them keeps working unchanged. `PA_` and not a word such as `WORKER_`: the Teams surface already
6
+ * uses `WORKER_IDENTITY_*` for its own Azure identity, and a surface's own settings keep the surface's prefix
7
+ * (`TEAMS_STREAMING`, `TEAMS_AI_LABEL`), so the prefix says whose a setting is.
8
+ *
9
+ * The rule, for every pair: the `PA_` name when it is set and not blank; else the `TEAMS_` name when it is set; else the
10
+ * `PA_` name (unset or blank). A message about a value names the variable it was read from.
11
+ */
12
+ import { type Logger } from "@primusclaw/personal-agent";
13
+ /** The prefix of the worker's own settings. */
14
+ export declare const SETTING_PREFIX = "PA_";
15
+ /** The prefix the same settings were first written with, still read as an alias. */
16
+ export declare const LEGACY_SETTING_PREFIX = "TEAMS_";
17
+ /** The settings read under both prefixes, by their name after the prefix. */
18
+ export declare const ALIASED_SETTINGS: readonly ["DB_PATH", "ENCRYPTION_KEYS", "CLAW_EVENTS_GONE", "ON_BEHALF_USERS", "OBSERVE_USERS", "DIRECT_CHAT", "DIRECT_CHAT_USERS", "ASSISTANT_UNDERSTANDING", "ASSISTANT_UNDERSTANDING_USERS", "GROUP_CONTEXT_MESSAGES", "GROUP_CONTEXT_HOURS", "GROUP_CONTEXT_CHARS", "GROUP_CONTEXT_GRANTED", "EXCHANGE_ENABLED", "EXCHANGE_CLIENT_ID", "EXCHANGE_CLIENT_SECRET", "EXCHANGE_TOKEN_URL", "EXCHANGE_BINDING_REQUEST_URL", "EXCHANGE_ISSUER", "EXCHANGE_AUDIENCE", "EXCHANGE_SCOPE", "EXCHANGE_FOR_CHAT", "GITHUB_REVIEW_ENABLED", "GITHUB_REVIEW_OWNERS", "REVIEW_INTENT_MODEL", "GITHUB_CREDENTIAL_URL", "GITHUB_CLIENT_ID", "USER_MESSAGE_LIMIT", "USER_MESSAGE_WINDOW_SECONDS", "USER_MAX_CONCURRENT_TASKS", "LINK_MAX_FAILURES_PER_USER", "LINK_MAX_FAILURES_GLOBAL", "LINK_ATTEMPT_WINDOW_SECONDS", "LIMIT_PR_REVIEW", "LIMIT_PR_MERGE", "LIMIT_APPROVAL", "LIMIT_REMOTE_AGENT"];
19
+ /** The pairs: `PA_` name -> the `TEAMS_` name still read when it is not set. */
20
+ export declare const SETTING_ALIASES: ReadonlyMap<string, string>;
21
+ type Env = Readonly<Record<string, string | undefined>>;
22
+ /**
23
+ * The variable a setting is read from: `name` may be either name of a pair (or any other setting, read as it is). The
24
+ * `PA_` name when it is set and not blank, else the `TEAMS_` name when it is present, else the `PA_` name.
25
+ */
26
+ export declare function settingSource(env: Env, name: string): string;
27
+ /** The value of a setting under the alias rule (undefined: neither name is present). */
28
+ export declare function settingValue(env: Env, name: string): string | undefined;
29
+ /** A legacy name in use: the one read, or one set beside its `PA_` name and ignored. */
30
+ export interface LegacySetting {
31
+ readonly legacy: string;
32
+ readonly neutral: string;
33
+ /** The `PA_` name is set too, so the `TEAMS_` value is not read. */
34
+ readonly ignored: boolean;
35
+ }
36
+ /** The `TEAMS_` names this environment sets (not blank) of the settings that now carry `PA_`. */
37
+ export declare function legacySettings(env: Env): LegacySetting[];
38
+ /**
39
+ * One warning at start for the `TEAMS_` names in use, naming the `PA_` name of each (never a value: some are secrets);
40
+ * and one for each `TEAMS_` name that is set beside its `PA_` name and so not read. Nothing when none is in use.
41
+ */
42
+ export declare function warnLegacySettings(env: Env, logger: Logger): void;
43
+ export {};
@@ -1,9 +1,15 @@
1
1
  /** The process environment, or a test's. */
2
2
  export type Env = Readonly<Record<string, string | undefined>>;
3
- /** Reads settings out of an environment, with the worker's rules: a typo stops the worker, it never picks a value. */
3
+ /**
4
+ * Reads settings out of an environment, with the worker's rules: a typo stops the worker, it never picks a value. A
5
+ * setting that has a `PA_` name and an older `TEAMS_` name is read under either (`settingSource`), and a message about
6
+ * its value names the variable it was read from.
7
+ */
4
8
  export declare class EnvReader {
5
9
  readonly env: Env;
6
10
  constructor(env: Env);
11
+ /** The variable `name` is read from (the `PA_` or the `TEAMS_` name of a pair; any other name as it is). */
12
+ source(name: string): string;
7
13
  /** The raw value ("" unset). */
8
14
  raw(name: string, fallback?: string): string;
9
15
  /** The value without surrounding white space ("" unset). */
@@ -1,3 +1,4 @@
1
+ export { ALIASED_SETTINGS, LEGACY_SETTING_PREFIX, SETTING_ALIASES, SETTING_PREFIX, legacySettings, settingSource, settingValue, warnLegacySettings, type LegacySetting, } from "./aliases.js";
1
2
  export { EnvReader, pyRepr, withoutTrailingSlash, type Env } from "./env.js";
2
- export { ENV_NAMES, EnvSecretSource, secretsSourceOf, wantedSecrets } from "./secrets.js";
3
+ export { ENV_NAMES, EnvSecretSource, SECRET_SETTING_NAMES, secretsSourceOf, wantedSecrets } from "./secrets.js";
3
4
  export { ASSISTANT_REPLY_WINDOW_SECONDS, GITHUB_CLI_CLIENT_ID, readSettings } from "./settings.js";
@@ -1,6 +1,16 @@
1
1
  import { type SecretName, type SecretSource, type SecretsSourceName } from "@primusclaw/personal-agent";
2
2
  import { type Env } from "./env.js";
3
- /** Where SECRETS_SOURCE=env finds each secret: an environment variable, or (the GitHub App's key) the file it names. */
3
+ /**
4
+ * Where SECRETS_SOURCE=env finds each secret: an environment variable (its `PA_` name, or the older `TEAMS_` one, as
5
+ * `settingSource` reads them), or (the GitHub App's key) the file it names.
6
+ */
7
+ export declare const SECRET_SETTING_NAMES: Readonly<Record<SecretName, string>>;
8
+ /**
9
+ * The environment variable of each secret as 0.8.0 and earlier named it.
10
+ *
11
+ * @deprecated The worker reads `SECRET_SETTING_NAMES` (the `PA_` names, with these `TEAMS_` ones as their older
12
+ * aliases). Kept, with its values, for callers of 0.8.0 and earlier.
13
+ */
4
14
  export declare const ENV_NAMES: Readonly<Record<SecretName, string>>;
5
15
  /** SECRETS_SOURCE: env (the default) or keyvault; a typo stops the worker. */
6
16
  export declare function secretsSourceOf(env: Env): SecretsSourceName;
@@ -4,7 +4,7 @@ import { type Env } from "./env.js";
4
4
  export declare const GITHUB_CLI_CLIENT_ID = "178c6fc778ccc68e1d6a";
5
5
  /** The default of ASSISTANT_REPLY_WINDOW_SECONDS. */
6
6
  export declare const ASSISTANT_REPLY_WINDOW_SECONDS: number;
7
- /** The most messages TEAMS_GROUP_CONTEXT_MESSAGES may keep per group chat. */
7
+ /** The most messages PA_GROUP_CONTEXT_MESSAGES may keep per group chat. */
8
8
  export declare const MAX_GROUP_CONTEXT_MESSAGES = 200;
9
9
  /**
10
10
  * The worker's channel-neutral settings from the environment (the Python worker's `Settings.from_env`, without the
@@ -1,6 +1,6 @@
1
1
  /** The label the key is derived under. A new label is a new key: every pending code is void. */
2
2
  export declare const LINK_HASH_LABEL = "primusclaw-teams/link-code-hmac/v1";
3
- /** The HMAC key link codes are hashed under, derived from one Fernet key of TEAMS_ENCRYPTION_KEYS. */
3
+ /** The HMAC key link codes are hashed under, derived from one Fernet key of PA_ENCRYPTION_KEYS. */
4
4
  export declare function linkHashKey(fernetKey: string): Uint8Array;
5
5
  /** A link code as it is stored (hex). */
6
6
  export declare function hashLinkCode(code: string, key: Uint8Array): string;
@@ -15,7 +15,7 @@ export interface ClawEventsDeps {
15
15
  readonly claims: Pick<IdempotencyRepository, "claimEvent" | "finishEvent" | "releaseEvent">;
16
16
  readonly deliver: EventSink;
17
17
  readonly clock: Clock;
18
- /** TEAMS_CLAW_EVENTS_GONE: an event for a person with no chat here is answered 410 (else 200 "dropped", for an older Claw). */
18
+ /** PA_CLAW_EVENTS_GONE: an event for a person with no chat here is answered 410 (else 200 "dropped", for an older Claw). */
19
19
  readonly gone: boolean;
20
20
  readonly metrics?: Pick<MetricsPort, "eventDelivered">;
21
21
  readonly logger?: Logger;
@@ -6,7 +6,7 @@ import type { Database } from "./database.js";
6
6
  export type SecurityEventFields = Readonly<Record<string, string | number | undefined>>;
7
7
  export type SecurityEventSink = (event: "link_attempt" | "link_lockout", fields: SecurityEventFields) => void;
8
8
  /**
9
- * The keys of TEAMS_ENCRYPTION_KEYS: the first encrypts and hashes new link codes, every one decrypts and finds a code
9
+ * The keys of PA_ENCRYPTION_KEYS: the first encrypts and hashes new link codes, every one decrypts and finds a code
10
10
  * (adding a key at the head does not void the codes of the last 10 minutes).
11
11
  */
12
12
  export declare class StoreSecrets {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The one SQLite connection a store works on, with typed statement helpers. Opened as the Python worker opens it:
3
- * autocommit (`isolation_level=None`), WAL, and a 5 s busy timeout (`sqlite3.connect`'s default).
3
+ * autocommit (`isolation_level=None`), WAL, and a 5 s busy timeout (`sqlite3.connect`'s default). Unlike it, a commit is not
4
+ * fsynced on its own (`synchronous=NORMAL`, below).
4
5
  */
5
6
  import { type SQLInputValue } from "node:sqlite";
6
7
  export type SqlValue = SQLInputValue;
@@ -9,6 +10,11 @@ export type Row = Readonly<Record<string, SqlValue>>;
9
10
  export declare class Database {
10
11
  #private;
11
12
  constructor(path: string);
13
+ /**
14
+ * `write` with each commit synced to disk (`synchronous=FULL`): for what is acknowledged as kept before it is used. Inside an
15
+ * open transaction SQLite refuses to change the setting, so there `write` just runs and its commit is the transaction's.
16
+ */
17
+ durably<T>(write: () => T): T;
12
18
  /** Several statements, no parameters (DDL). */
13
19
  exec(sql: string): void;
14
20
  /** Rows changed. */
@@ -5,8 +5,8 @@
5
5
  import type { Clock, LinkLimits, Logger, Random } from "@primusclaw/personal-agent";
6
6
  import type { SecurityEventSink } from "./context.js";
7
7
  import { SqliteStore } from "./store.js";
8
- /** The settings the store is opened with; the configuration's own fields (TEAMS_DB_PATH, TEAMS_ENCRYPTION_KEYS, the
9
- * TEAMS_LINK_* limits), so a worker's settings object is passed as it is. */
8
+ /** The settings the store is opened with; the configuration's own fields (PA_DB_PATH, PA_ENCRYPTION_KEYS, the
9
+ * PA_LINK_* limits), so a worker's settings object is passed as it is. */
10
10
  export interface WorkerStoreSettings {
11
11
  readonly dbPath: string;
12
12
  readonly encryptionKeys: readonly string[];
@@ -24,9 +24,9 @@ import { SqliteRepoHistoryRepository, SqliteSessionRepository } from "./session-
24
24
  import { SqliteTurnAnswerRepository } from "./turn-repository.js";
25
25
  export declare const DEFAULT_LINK_LIMITS: LinkLimits;
26
26
  export interface SqliteStoreOptions {
27
- /** The database file (`TEAMS_DB_PATH`), or ":memory:". */
27
+ /** The database file (`PA_DB_PATH`), or ":memory:". */
28
28
  readonly path: string;
29
- /** TEAMS_ENCRYPTION_KEYS: the first encrypts, all decrypt. At least one. */
29
+ /** PA_ENCRYPTION_KEYS: the first encrypts, all decrypt. At least one. */
30
30
  readonly encryptionKeys: readonly string[];
31
31
  readonly clock?: Clock;
32
32
  readonly random?: Random;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The review delegation (TEAMS_GITHUB_REVIEW_ENABLED), as the Python worker's `main.run` builds `GithubReview` and
2
+ * The review delegation (PA_GITHUB_REVIEW_ENABLED), as the Python worker's `main.run` builds `GithubReview` and
3
3
  * `Agent.__init__` attaches it: the identity service's GitHub credentials, the device flow `/github` connects with, the
4
- * public pull request reader, the request reader on the platform's model gateway (TEAMS_REVIEW_INTENT_MODEL), and the chat
4
+ * public pull request reader, the request reader on the platform's model gateway (PA_REVIEW_INTENT_MODEL), and the chat
5
5
  * it runs in (its turns start on the router, its onboarding and connect cards are the router's). What it gives back: the
6
6
  * router's GitHub part, its handlers, the handoff the assistant can send back, the follows it takes up again at start, the
7
7
  * open review cards it sweeps, and the stopped items it hears of.
@@ -27,5 +27,5 @@ export interface ReviewParts {
27
27
  readonly service: GithubReview;
28
28
  readonly handoff: ReviewHandoffAction;
29
29
  }
30
- /** The review service and the handoff the assistant sends back; undefined with TEAMS_GITHUB_REVIEW_ENABLED off. */
30
+ /** The review service and the handoff the assistant sends back; undefined with PA_GITHUB_REVIEW_ENABLED off. */
31
31
  export declare function reviewParts(base: AssemblyBase, inputs: ReviewInputs, assistant: Pick<AssistantParts, "receipts" | "chat">): ReviewParts | undefined;
@@ -9,7 +9,7 @@ import type { PendingEntry, ChannelContextBuilder, Clock, ConnectionsText, Fetch
9
9
  * the surface people know as `channelName` (what an unreadable file's line says did not give it).
10
10
  */
11
11
  export declare function messageTextFor(channelName: string): MessageText;
12
- /** TEAMS_USER_*: messages per window, tasks at once (Python `limits.UserLimits` and `MessageRateLimiter`). */
12
+ /** PA_USER_* (or the older TEAMS_USER_*): messages per window, tasks at once (Python `limits.UserLimits` and `MessageRateLimiter`). */
13
13
  export declare function routerLimits(limits: UserLimits, clock: Clock): RouterLimits;
14
14
  /** Python `understanding.channel_context` as `Agent._understood` builds it (the people named, the chat's actions). */
15
15
  export declare function channelContextBuilder(store: ContextStore,
@@ -2,7 +2,7 @@
2
2
  * The features behind the router, built and wired as the Python worker's `main.build_agent`, `Agent.__init__` and
3
3
  * `main.build_worker_app` wire them: the router with every feature it hands messages to, what carries Claw's events into the
4
4
  * chat (`/claw-events`), the background loops of `main.run`, what runs once at start, and what the release gate's test entry
5
- * reads. The review service (TEAMS_GITHUB_REVIEW_ENABLED) is built in `features-review.ts`.
5
+ * reads. The review service (PA_GITHUB_REVIEW_ENABLED) is built in `features-review.ts`.
6
6
  */
7
7
  import type { GroupContext, JsonObject, GithubReview } from "@primusclaw/personal-agent";
8
8
  import { Router } from "@primusclaw/personal-agent";
@@ -35,7 +35,7 @@ export interface Features {
35
35
  start(): Promise<void>;
36
36
  /** The worker stops: the assistant's open receipts are dropped, so their close timers do not keep the process up. */
37
37
  stop(): void;
38
- /** The review service (TEAMS_GITHUB_REVIEW_ENABLED; undefined off), for the gate's review scenarios and the tests. */
38
+ /** The review service (PA_GITHUB_REVIEW_ENABLED; undefined off), for the gate's review scenarios and the tests. */
39
39
  readonly review: GithubReview | undefined;
40
40
  /** The recent messages of group chats (kept in memory): the inbound handler drops a chat the bot was removed from. */
41
41
  readonly groupContext: GroupContext;
@@ -45,6 +45,6 @@ export interface Features {
45
45
  readonly madeSessions: () => readonly string[];
46
46
  };
47
47
  }
48
- /** The route the Python worker serves for TEAMS_ON_BEHALF_USERS (link_api.py); a deployment's plugin adds it here. */
48
+ /** The route the Python worker serves for PA_ON_BEHALF_USERS (link_api.py); a deployment's plugin adds it here. */
49
49
  export declare const ON_BEHALF_PATH = "/primus-claw-agent/on-behalf";
50
50
  export declare function buildFeatures(given: AssemblyBase): Features;
@@ -14,7 +14,7 @@ export interface WorkerRoutesParts {
14
14
  readonly plugins: Plugins;
15
15
  /** PROACTIVE_ENABLED: Claw's notifications are taken at /claw-events. */
16
16
  readonly proactive: boolean;
17
- /** TEAMS_CLAW_EVENTS_GONE. */
17
+ /** PA_CLAW_EVENTS_GONE. */
18
18
  readonly gone: boolean;
19
19
  readonly deliverEvent: (userId: string, reference: JsonObject, event: JsonObject) => Promise<string>;
20
20
  }
package/dist/worker.js CHANGED
@@ -22,7 +22,8 @@ import {
22
22
  readSettings,
23
23
  secretsSourceOf,
24
24
  systemClock,
25
- wantedSecrets
25
+ wantedSecrets,
26
+ warnLegacySettings
26
27
  } from "@primusclaw/personal-agent-runtime";
27
28
 
28
29
  // packages/runtime/src/worker/build-info.ts
@@ -60,6 +61,7 @@ import {
60
61
  noModelRefusalPolicy,
61
62
  TerminalApprovalsCommand
62
63
  } from "@primusclaw/personal-agent";
64
+ import { settingSource } from "@primusclaw/personal-agent-runtime";
63
65
 
64
66
  // packages/runtime/src/worker/startup-error.ts
65
67
  var StartupError = class extends Error {
@@ -148,9 +150,6 @@ function routerLimits(limits, clock) {
148
150
  }
149
151
  function channelContextBuilder(store, pending = () => []) {
150
152
  return (request) => {
151
- const mentions = request.message.mentions.map((m) => ({
152
- mentioned: { id: m.channelUserId, name: m.name, aadObjectId: m.userId }
153
- }));
154
153
  const known = store.members.knownMembers().map((m) => ({
155
154
  id: m.id,
156
155
  name: m.name,
@@ -158,10 +157,10 @@ function channelContextBuilder(store, pending = () => []) {
158
157
  ...m.email ? { email: m.email } : {}
159
158
  }));
160
159
  const people = peopleOf(
161
- mentions,
160
+ request.message.mentions,
162
161
  request.message.text,
163
162
  known,
164
- (aad) => store.links.clawUserIdOf(aad),
163
+ (directoryId) => store.links.clawUserIdOf(directoryId),
165
164
  (channelId) => store.members.userForChannelId(channelId)
166
165
  );
167
166
  const actions = channelActions(request.parts);
@@ -971,7 +970,7 @@ function refuseMissing(base) {
971
970
  );
972
971
  if (settings2.onBehalfUsers.size > 0 && !plugins.routeExtensions.some((route) => route.method === "POST" && route.path === ON_BEHALF_PATH))
973
972
  throw new StartupError(
974
- `TEAMS_ON_BEHALF_USERS is set, but no plugin serves ${ON_BEHALF_PATH}: unset it or run with the plugin that does`
973
+ `${settingSource(base.env, "PA_ON_BEHALF_USERS")} is set, but no plugin serves ${ON_BEHALF_PATH}: unset it or run with the plugin that does`
975
974
  );
976
975
  }
977
976
  function listenForStops(router, service) {
@@ -1515,6 +1514,7 @@ async function envSecrets(env, names) {
1515
1514
  return new EnvSecretSource(env).load([...names]);
1516
1515
  }
1517
1516
  async function assemblyBase(env, prepared, deps) {
1517
+ warnLegacySettings(env, deps.logger);
1518
1518
  const names = wantedSecrets(env);
1519
1519
  const secrets = await (prepared.loadSecrets ? prepared.loadSecrets(names, deps) : envSecrets(env, names));
1520
1520
  const settings2 = readSettings(env, secrets);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primusclaw/personal-agent-runtime",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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.8.0",
36
+ "@primusclaw/personal-agent": "0.8.1",
37
37
  "fastify": "^5.12.8",
38
38
  "zod": "^4.6.7"
39
39
  }