@primusclaw/personal-agent-runtime 0.8.0 → 0.9.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 +284 -69
- package/dist/types/claw/identity-lookup.d.ts +1 -1
- package/dist/types/claw/skills.d.ts +16 -0
- package/dist/types/config/aliases.d.ts +43 -0
- package/dist/types/config/env.d.ts +7 -1
- package/dist/types/config/index.d.ts +2 -1
- package/dist/types/config/secrets.d.ts +11 -1
- package/dist/types/config/settings.d.ts +1 -1
- package/dist/types/crypto/link-code.d.ts +1 -1
- package/dist/types/http/claw-events.d.ts +1 -1
- package/dist/types/sqlite/context.d.ts +1 -1
- package/dist/types/sqlite/database.d.ts +7 -1
- package/dist/types/sqlite/open.d.ts +2 -2
- package/dist/types/sqlite/store.d.ts +2 -2
- package/dist/types/worker/features-review.d.ts +3 -3
- package/dist/types/worker/features-text.d.ts +1 -1
- package/dist/types/worker/features-w8.d.ts +3 -1
- package/dist/types/worker/features.d.ts +3 -3
- package/dist/types/worker/http.d.ts +1 -1
- package/dist/worker.js +18 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1225,6 +1225,99 @@ function isObject4(value) {
|
|
|
1225
1225
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
1228
|
+
// packages/runtime/src/claw/skills.ts
|
|
1229
|
+
import {
|
|
1230
|
+
ClawAnswerInvalid as ClawAnswerInvalid9,
|
|
1231
|
+
pyStr as pyStr4
|
|
1232
|
+
} from "@primusclaw/personal-agent";
|
|
1233
|
+
function int(value) {
|
|
1234
|
+
return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
|
|
1235
|
+
}
|
|
1236
|
+
function entryOf(row) {
|
|
1237
|
+
const name = pyStr4(row["name"]);
|
|
1238
|
+
if (!name) throw new ClawAnswerInvalid9("a skill without its name");
|
|
1239
|
+
return {
|
|
1240
|
+
name,
|
|
1241
|
+
version: int(row["version"]) ?? 0,
|
|
1242
|
+
description: pyStr4(row["description"]),
|
|
1243
|
+
enabled: row["enabled"] !== false,
|
|
1244
|
+
invocation: row["invocation"] === "manual" ? "manual" : "auto",
|
|
1245
|
+
imported: row["origin"] === "import",
|
|
1246
|
+
lastUsedAt: pyStr4(row["last_used_at"]),
|
|
1247
|
+
files: int(row["files"]) ?? 0
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
function changeOf(answer2, what) {
|
|
1251
|
+
const out = objectOf(answer2, what);
|
|
1252
|
+
return {
|
|
1253
|
+
version: int(out["version"]),
|
|
1254
|
+
changed: out["changed"] !== false,
|
|
1255
|
+
changeId: pyStr4(out["change_id"]),
|
|
1256
|
+
undoExpiresAt: pyStr4(out["undo_expires_at"])
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
var HttpSkills = class {
|
|
1260
|
+
constructor(http) {
|
|
1261
|
+
this.http = http;
|
|
1262
|
+
}
|
|
1263
|
+
http;
|
|
1264
|
+
async list(key2) {
|
|
1265
|
+
const answer2 = await this.http.json({ method: "GET", path: "/v1/users/me/skills?view=current", key: key2 });
|
|
1266
|
+
return rowsOf(answer2, "the skills").map(entryOf);
|
|
1267
|
+
}
|
|
1268
|
+
async show(key2, name) {
|
|
1269
|
+
const answer2 = await this.http.json({
|
|
1270
|
+
method: "GET",
|
|
1271
|
+
path: `/v1/users/me/skills/${segment(name)}?view=current`,
|
|
1272
|
+
key: key2
|
|
1273
|
+
});
|
|
1274
|
+
const data = dataOf(answer2, "a skill");
|
|
1275
|
+
const files = Array.isArray(data["file_list"]) ? data["file_list"] : [];
|
|
1276
|
+
return {
|
|
1277
|
+
...entryOf(data),
|
|
1278
|
+
content: pyStr4(data["content"]),
|
|
1279
|
+
fileList: files.flatMap(
|
|
1280
|
+
(f) => typeof f === "object" && f !== null && typeof f["path"] === "string" ? [
|
|
1281
|
+
{
|
|
1282
|
+
path: pyStr4(f["path"]),
|
|
1283
|
+
sizeBytes: int(f["size_bytes"]) ?? 0
|
|
1284
|
+
}
|
|
1285
|
+
] : []
|
|
1286
|
+
)
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
async setEnabled(key2, name, enabled) {
|
|
1290
|
+
const verb = enabled ? "enable" : "disable";
|
|
1291
|
+
return changeOf(
|
|
1292
|
+
await this.http.json({ method: "POST", path: `/v1/users/me/skills/${segment(name)}/${verb}`, key: key2, body: {} }),
|
|
1293
|
+
"a switch"
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
async remove(key2, name) {
|
|
1297
|
+
return changeOf(
|
|
1298
|
+
await this.http.json({ method: "DELETE", path: `/v1/users/me/skills/${segment(name)}`, key: key2 }),
|
|
1299
|
+
"a delete"
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
async update(key2, name, skill) {
|
|
1303
|
+
const body = { content: skill.content, description: skill.description };
|
|
1304
|
+
return changeOf(
|
|
1305
|
+
await this.http.json({ method: "PUT", path: `/v1/users/me/skills/${segment(name)}`, key: key2, body }),
|
|
1306
|
+
"an edit"
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
async undo(key2, changeId) {
|
|
1310
|
+
const answer2 = await this.http.json({
|
|
1311
|
+
method: "POST",
|
|
1312
|
+
path: `/v1/users/me/skill-changes/${segment(changeId)}/undo`,
|
|
1313
|
+
key: key2,
|
|
1314
|
+
body: {}
|
|
1315
|
+
});
|
|
1316
|
+
const data = dataOf(answer2, "an undo");
|
|
1317
|
+
return { undone: pyStr4(data["undone"]), name: pyStr4(data["name"]), version: int(data["version"]) };
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1228
1321
|
// packages/runtime/src/claw/client.ts
|
|
1229
1322
|
var DEFAULT_CLIENT_LABEL = "clawy";
|
|
1230
1323
|
function createClawClient(options) {
|
|
@@ -1240,7 +1333,8 @@ function createClawClient(options) {
|
|
|
1240
1333
|
notifications: new HttpNotifications(http),
|
|
1241
1334
|
triggers: new HttpTriggers(http),
|
|
1242
1335
|
mergeConfirmations: new HttpMergeConfirmations(http),
|
|
1243
|
-
remoteAgents: new HttpRemoteAgents(http, options.clientLabel ?? DEFAULT_CLIENT_LABEL)
|
|
1336
|
+
remoteAgents: new HttpRemoteAgents(http, options.clientLabel ?? DEFAULT_CLIENT_LABEL),
|
|
1337
|
+
skills: new HttpSkills(http)
|
|
1244
1338
|
};
|
|
1245
1339
|
}
|
|
1246
1340
|
|
|
@@ -1820,8 +1914,87 @@ var HttpTokenExchange = class {
|
|
|
1820
1914
|
}
|
|
1821
1915
|
};
|
|
1822
1916
|
|
|
1917
|
+
// packages/runtime/src/config/aliases.ts
|
|
1918
|
+
import { own as own3, pyStrip as pyStrip4 } from "@primusclaw/personal-agent";
|
|
1919
|
+
var SETTING_PREFIX = "PA_";
|
|
1920
|
+
var LEGACY_SETTING_PREFIX = "TEAMS_";
|
|
1921
|
+
var ALIASED_SETTINGS = [
|
|
1922
|
+
"DB_PATH",
|
|
1923
|
+
"ENCRYPTION_KEYS",
|
|
1924
|
+
"CLAW_EVENTS_GONE",
|
|
1925
|
+
"ON_BEHALF_USERS",
|
|
1926
|
+
"OBSERVE_USERS",
|
|
1927
|
+
"DIRECT_CHAT",
|
|
1928
|
+
"DIRECT_CHAT_USERS",
|
|
1929
|
+
"ASSISTANT_UNDERSTANDING",
|
|
1930
|
+
"ASSISTANT_UNDERSTANDING_USERS",
|
|
1931
|
+
"GROUP_CONTEXT_MESSAGES",
|
|
1932
|
+
"GROUP_CONTEXT_HOURS",
|
|
1933
|
+
"GROUP_CONTEXT_CHARS",
|
|
1934
|
+
"GROUP_CONTEXT_GRANTED",
|
|
1935
|
+
"EXCHANGE_ENABLED",
|
|
1936
|
+
"EXCHANGE_CLIENT_ID",
|
|
1937
|
+
"EXCHANGE_CLIENT_SECRET",
|
|
1938
|
+
"EXCHANGE_TOKEN_URL",
|
|
1939
|
+
"EXCHANGE_BINDING_REQUEST_URL",
|
|
1940
|
+
"EXCHANGE_ISSUER",
|
|
1941
|
+
"EXCHANGE_AUDIENCE",
|
|
1942
|
+
"EXCHANGE_SCOPE",
|
|
1943
|
+
"EXCHANGE_FOR_CHAT",
|
|
1944
|
+
"GITHUB_REVIEW_ENABLED",
|
|
1945
|
+
"GITHUB_REVIEW_OWNERS",
|
|
1946
|
+
"REVIEW_INTENT_MODEL",
|
|
1947
|
+
"GITHUB_CREDENTIAL_URL",
|
|
1948
|
+
"GITHUB_CLIENT_ID",
|
|
1949
|
+
"USER_MESSAGE_LIMIT",
|
|
1950
|
+
"USER_MESSAGE_WINDOW_SECONDS",
|
|
1951
|
+
"USER_MAX_CONCURRENT_TASKS",
|
|
1952
|
+
"LINK_MAX_FAILURES_PER_USER",
|
|
1953
|
+
"LINK_MAX_FAILURES_GLOBAL",
|
|
1954
|
+
"LINK_ATTEMPT_WINDOW_SECONDS",
|
|
1955
|
+
"LIMIT_PR_REVIEW",
|
|
1956
|
+
"LIMIT_PR_MERGE",
|
|
1957
|
+
"LIMIT_APPROVAL",
|
|
1958
|
+
"LIMIT_REMOTE_AGENT"
|
|
1959
|
+
];
|
|
1960
|
+
var SETTING_ALIASES = new Map(
|
|
1961
|
+
ALIASED_SETTINGS.map((stem) => [SETTING_PREFIX + stem, LEGACY_SETTING_PREFIX + stem])
|
|
1962
|
+
);
|
|
1963
|
+
var NEUTRAL_OF = new Map([...SETTING_ALIASES].map(([neutral, old]) => [old, neutral]));
|
|
1964
|
+
var isSet = (env, name) => pyStrip4(own3(env, name) ?? "") !== "";
|
|
1965
|
+
function settingSource(env, name) {
|
|
1966
|
+
const neutral = NEUTRAL_OF.get(name) ?? name;
|
|
1967
|
+
const legacy = SETTING_ALIASES.get(neutral);
|
|
1968
|
+
if (legacy === void 0) return name;
|
|
1969
|
+
if (isSet(env, neutral)) return neutral;
|
|
1970
|
+
return own3(env, legacy) !== void 0 ? legacy : neutral;
|
|
1971
|
+
}
|
|
1972
|
+
function settingValue(env, name) {
|
|
1973
|
+
return own3(env, settingSource(env, name));
|
|
1974
|
+
}
|
|
1975
|
+
function legacySettings(env) {
|
|
1976
|
+
const out = [];
|
|
1977
|
+
for (const [neutral, legacy] of SETTING_ALIASES) {
|
|
1978
|
+
if (isSet(env, legacy)) out.push({ legacy, neutral, ignored: isSet(env, neutral) });
|
|
1979
|
+
}
|
|
1980
|
+
return out;
|
|
1981
|
+
}
|
|
1982
|
+
function warnLegacySettings(env, logger) {
|
|
1983
|
+
const used = legacySettings(env);
|
|
1984
|
+
const read2 = used.filter((s) => !s.ignored);
|
|
1985
|
+
if (read2.length > 0) {
|
|
1986
|
+
logger.warn(
|
|
1987
|
+
`deprecated setting names: ${read2.map((s) => `${s.legacy} (now ${s.neutral})`).join(", ")}; they still work, the ${SETTING_PREFIX} names take precedence`,
|
|
1988
|
+
{ settings: read2.map((s) => s.legacy).join(",") }
|
|
1989
|
+
);
|
|
1990
|
+
}
|
|
1991
|
+
for (const s of used.filter((u) => u.ignored)) {
|
|
1992
|
+
logger.warn(`${s.legacy} is ignored: ${s.neutral} is set`, { setting: s.legacy });
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1823
1996
|
// packages/runtime/src/config/env.ts
|
|
1824
|
-
import { ConfigError, decimalBigInt,
|
|
1997
|
+
import { ConfigError, decimalBigInt, pyStrip as pyStrip5 } from "@primusclaw/personal-agent";
|
|
1825
1998
|
var ON = ["1", "true", "yes", "on"];
|
|
1826
1999
|
var OFF = ["0", "false", "no", "off"];
|
|
1827
2000
|
var EnvReader = class {
|
|
@@ -1829,18 +2002,22 @@ var EnvReader = class {
|
|
|
1829
2002
|
this.env = env;
|
|
1830
2003
|
}
|
|
1831
2004
|
env;
|
|
2005
|
+
/** The variable `name` is read from (the `PA_` or the `TEAMS_` name of a pair; any other name as it is). */
|
|
2006
|
+
source(name) {
|
|
2007
|
+
return settingSource(this.env, name);
|
|
2008
|
+
}
|
|
1832
2009
|
/** The raw value ("" unset). */
|
|
1833
2010
|
raw(name, fallback = "") {
|
|
1834
|
-
return
|
|
2011
|
+
return settingValue(this.env, name) ?? fallback;
|
|
1835
2012
|
}
|
|
1836
2013
|
/** The value without surrounding white space ("" unset). */
|
|
1837
2014
|
text(name, fallback = "") {
|
|
1838
|
-
return
|
|
2015
|
+
return pyStrip5(this.raw(name, fallback));
|
|
1839
2016
|
}
|
|
1840
2017
|
/** A value that must be set and not blank. */
|
|
1841
2018
|
required(name) {
|
|
1842
2019
|
const value = this.text(name);
|
|
1843
|
-
if (value === "") throw new ConfigError(`environment variable ${name} is required`);
|
|
2020
|
+
if (value === "") throw new ConfigError(`environment variable ${this.source(name)} is required`);
|
|
1844
2021
|
return value;
|
|
1845
2022
|
}
|
|
1846
2023
|
/** On or off; `fallback` when unset or empty; anything else stops the worker. */
|
|
@@ -1848,7 +2025,7 @@ var EnvReader = class {
|
|
|
1848
2025
|
const value = this.text(name).toLowerCase();
|
|
1849
2026
|
if (value === "") return fallback;
|
|
1850
2027
|
if (!ON.includes(value) && !OFF.includes(value)) {
|
|
1851
|
-
throw new ConfigError(`${name} must be on or off, not ${pyRepr(value)}`);
|
|
2028
|
+
throw new ConfigError(`${this.source(name)} must be on or off, not ${pyRepr(value)}`);
|
|
1852
2029
|
}
|
|
1853
2030
|
return ON.includes(value);
|
|
1854
2031
|
}
|
|
@@ -1862,17 +2039,17 @@ var EnvReader = class {
|
|
|
1862
2039
|
if (value === "") return fallback;
|
|
1863
2040
|
const number = decimalBigInt(value);
|
|
1864
2041
|
if (number === void 0 || number <= 0n) {
|
|
1865
|
-
throw new ConfigError(`${name} must be a positive whole number, not ${pyRepr(value)}`);
|
|
2042
|
+
throw new ConfigError(`${this.source(name)} must be a positive whole number, not ${pyRepr(value)}`);
|
|
1866
2043
|
}
|
|
1867
2044
|
return Number(number);
|
|
1868
2045
|
}
|
|
1869
2046
|
/** A whole number (Python's `int()` of the value: a sign, surrounding space and `_` between digits allowed). */
|
|
1870
2047
|
int(name, fallback) {
|
|
1871
|
-
const value =
|
|
2048
|
+
const value = pyStrip5(this.raw(name, fallback));
|
|
1872
2049
|
const match = new RegExp("^([+-]?)(\\p{Nd}+(?:_\\p{Nd}+)*)$", "u").exec(value);
|
|
1873
2050
|
const digits = match === null ? void 0 : decimalBigInt((match[2] ?? "").replaceAll("_", ""));
|
|
1874
2051
|
if (match === null || digits === void 0) {
|
|
1875
|
-
throw new ConfigError(`${name} must be a whole number, not ${pyRepr(value)}`);
|
|
2052
|
+
throw new ConfigError(`${this.source(name)} must be a whole number, not ${pyRepr(value)}`);
|
|
1876
2053
|
}
|
|
1877
2054
|
return Number(match[1] === "-" ? -digits : digits);
|
|
1878
2055
|
}
|
|
@@ -1882,7 +2059,7 @@ var EnvReader = class {
|
|
|
1882
2059
|
}
|
|
1883
2060
|
/** A comma separated list, blank entries dropped; `lower` lower-cases each entry. */
|
|
1884
2061
|
list(name, lower = false) {
|
|
1885
|
-
return this.raw(name).split(",").map((entry) =>
|
|
2062
|
+
return this.raw(name).split(",").map((entry) => pyStrip5(entry)).filter((entry) => entry !== "").map((entry) => lower ? entry.toLowerCase() : entry);
|
|
1886
2063
|
}
|
|
1887
2064
|
};
|
|
1888
2065
|
function pyRepr(value) {
|
|
@@ -1901,15 +2078,20 @@ import { readFileSync } from "node:fs";
|
|
|
1901
2078
|
import {
|
|
1902
2079
|
SECRETS_SOURCES,
|
|
1903
2080
|
SecretsUnavailable,
|
|
1904
|
-
pyStrip as
|
|
2081
|
+
pyStrip as pyStrip6
|
|
1905
2082
|
} from "@primusclaw/personal-agent";
|
|
2083
|
+
var SECRET_SETTING_NAMES = {
|
|
2084
|
+
TEAMS_ENCRYPTION_KEYS: "PA_ENCRYPTION_KEYS",
|
|
2085
|
+
TEAMS_EXCHANGE_CLIENT_SECRET: "PA_EXCHANGE_CLIENT_SECRET",
|
|
2086
|
+
FEEDBACK_GITHUB_APP_KEY: "FEEDBACK_GITHUB_KEY_FILE"
|
|
2087
|
+
};
|
|
1906
2088
|
var ENV_NAMES = {
|
|
1907
2089
|
TEAMS_ENCRYPTION_KEYS: "TEAMS_ENCRYPTION_KEYS",
|
|
1908
2090
|
TEAMS_EXCHANGE_CLIENT_SECRET: "TEAMS_EXCHANGE_CLIENT_SECRET",
|
|
1909
2091
|
FEEDBACK_GITHUB_APP_KEY: "FEEDBACK_GITHUB_KEY_FILE"
|
|
1910
2092
|
};
|
|
1911
2093
|
function secretsSourceOf(env) {
|
|
1912
|
-
const value =
|
|
2094
|
+
const value = pyStrip6(env["SECRETS_SOURCE"] ?? "").toLowerCase() || "env";
|
|
1913
2095
|
const known = SECRETS_SOURCES.find((name) => name === value);
|
|
1914
2096
|
if (known === void 0) {
|
|
1915
2097
|
throw new SecretsUnavailable(`SECRETS_SOURCE must be one of ${SECRETS_SOURCES.join(", ")}, not ${pyRepr(value)}`);
|
|
@@ -1920,7 +2102,7 @@ function wantedSecrets(env) {
|
|
|
1920
2102
|
const read2 = new EnvReader(env);
|
|
1921
2103
|
return [
|
|
1922
2104
|
"TEAMS_ENCRYPTION_KEYS",
|
|
1923
|
-
...read2.isOn("
|
|
2105
|
+
...read2.isOn("PA_EXCHANGE_ENABLED") ? ["TEAMS_EXCHANGE_CLIENT_SECRET"] : [],
|
|
1924
2106
|
...read2.text("FEEDBACK_GITHUB_APP_ID") !== "" && read2.text("FEEDBACK_GITHUB_INSTALLATION_ID") !== "" ? ["FEEDBACK_GITHUB_APP_KEY"] : []
|
|
1925
2107
|
];
|
|
1926
2108
|
}
|
|
@@ -1941,9 +2123,9 @@ var EnvSecretSource = class {
|
|
|
1941
2123
|
const values = /* @__PURE__ */ new Map();
|
|
1942
2124
|
const read2 = new EnvReader(this.env);
|
|
1943
2125
|
for (const name of names) {
|
|
1944
|
-
const variable =
|
|
2126
|
+
const variable = SECRET_SETTING_NAMES[name];
|
|
1945
2127
|
const value = read2.text(variable);
|
|
1946
|
-
if (value === "") throw new SecretsUnavailable(`environment variable ${variable} is required`);
|
|
2128
|
+
if (value === "") throw new SecretsUnavailable(`environment variable ${read2.source(variable)} is required`);
|
|
1947
2129
|
values.set(name, name === "FEEDBACK_GITHUB_APP_KEY" ? this.keyFile(value) : value);
|
|
1948
2130
|
}
|
|
1949
2131
|
return values;
|
|
@@ -1951,7 +2133,7 @@ var EnvSecretSource = class {
|
|
|
1951
2133
|
keyFile(path) {
|
|
1952
2134
|
let text3;
|
|
1953
2135
|
try {
|
|
1954
|
-
text3 =
|
|
2136
|
+
text3 = pyStrip6(this.readFile(path));
|
|
1955
2137
|
} catch {
|
|
1956
2138
|
throw new SecretsUnavailable(`FEEDBACK_GITHUB_KEY_FILE ${path} cannot be read`);
|
|
1957
2139
|
}
|
|
@@ -1968,6 +2150,7 @@ import {
|
|
|
1968
2150
|
DEFAULT_MESSAGE_WINDOW_SECONDS,
|
|
1969
2151
|
DEFAULT_GROUP_CONTEXT,
|
|
1970
2152
|
decimalBigInt as decimalBigInt2,
|
|
2153
|
+
LIMIT_ENV_PREFIX,
|
|
1971
2154
|
parseLimits
|
|
1972
2155
|
} from "@primusclaw/personal-agent";
|
|
1973
2156
|
var GITHUB_CLI_CLIENT_ID = "178c6fc778ccc68e1d6a";
|
|
@@ -1984,7 +2167,7 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
|
|
|
1984
2167
|
throw new ConfigError2(`METRICS_PORT must differ from PORT (${String(listenPort)})`);
|
|
1985
2168
|
}
|
|
1986
2169
|
return {
|
|
1987
|
-
dbPath: read2.raw("
|
|
2170
|
+
dbPath: read2.raw("PA_DB_PATH", "/data/state.db"),
|
|
1988
2171
|
encryptionKeys: secret(read2, store, "TEAMS_ENCRYPTION_KEYS").split(",").map((k) => k.trim()).filter((k) => k !== ""),
|
|
1989
2172
|
clawApiUrl: withoutTrailingSlash(read2.required("CLAW_API_URL")),
|
|
1990
2173
|
safeApiUrl: withoutTrailingSlash(read2.required("SAFE_API_URL")),
|
|
@@ -2004,37 +2187,37 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
|
|
|
2004
2187
|
},
|
|
2005
2188
|
githubReview: githubReviewSettings(read2, publicBaseUrl),
|
|
2006
2189
|
assistant: assistantSettings(read2),
|
|
2007
|
-
clawEventsGone: read2.isOn("
|
|
2190
|
+
clawEventsGone: read2.isOn("PA_CLAW_EVENTS_GONE"),
|
|
2008
2191
|
directChat: directChat(read2),
|
|
2009
|
-
onBehalfUsers: new Set(read2.list("
|
|
2010
|
-
observeUsers: new Set(read2.list("
|
|
2192
|
+
onBehalfUsers: new Set(read2.list("PA_ON_BEHALF_USERS")),
|
|
2193
|
+
observeUsers: new Set(read2.list("PA_OBSERVE_USERS", true)),
|
|
2011
2194
|
groupContext: groupContextSettings(read2),
|
|
2012
2195
|
sensitiveLimits: limitsOf(read2),
|
|
2013
2196
|
linkLimits: {
|
|
2014
|
-
perUser: read2.positiveInt("
|
|
2015
|
-
global: read2.positiveInt("
|
|
2016
|
-
windowSeconds: read2.positiveInt("
|
|
2197
|
+
perUser: read2.positiveInt("PA_LINK_MAX_FAILURES_PER_USER", 5),
|
|
2198
|
+
global: read2.positiveInt("PA_LINK_MAX_FAILURES_GLOBAL", 100),
|
|
2199
|
+
windowSeconds: read2.positiveInt("PA_LINK_ATTEMPT_WINDOW_SECONDS", 600)
|
|
2017
2200
|
},
|
|
2018
2201
|
userLimits: {
|
|
2019
|
-
messageLimit: read2.positiveInt("
|
|
2020
|
-
messageWindowSeconds: read2.positiveInt("
|
|
2021
|
-
maxConcurrentTasks: read2.positiveInt("
|
|
2202
|
+
messageLimit: read2.positiveInt("PA_USER_MESSAGE_LIMIT", DEFAULT_MESSAGE_LIMIT),
|
|
2203
|
+
messageWindowSeconds: read2.positiveInt("PA_USER_MESSAGE_WINDOW_SECONDS", DEFAULT_MESSAGE_WINDOW_SECONDS),
|
|
2204
|
+
maxConcurrentTasks: read2.positiveInt("PA_USER_MAX_CONCURRENT_TASKS", DEFAULT_MAX_CONCURRENT_TASKS)
|
|
2022
2205
|
},
|
|
2023
2206
|
secretsSource: store.source
|
|
2024
2207
|
};
|
|
2025
2208
|
}
|
|
2026
2209
|
function groupContextSettings(read2) {
|
|
2027
|
-
const messages = read2.int("
|
|
2210
|
+
const messages = read2.int("PA_GROUP_CONTEXT_MESSAGES", String(DEFAULT_GROUP_CONTEXT.messages));
|
|
2028
2211
|
if (messages < 0 || messages > MAX_GROUP_CONTEXT_MESSAGES) {
|
|
2029
2212
|
throw new ConfigError2(
|
|
2030
|
-
|
|
2213
|
+
`${read2.source("PA_GROUP_CONTEXT_MESSAGES")} must be between 0 and ${String(MAX_GROUP_CONTEXT_MESSAGES)}, not ${String(messages)}`
|
|
2031
2214
|
);
|
|
2032
2215
|
}
|
|
2033
2216
|
return {
|
|
2034
2217
|
messages,
|
|
2035
|
-
maxAgeSeconds: read2.positiveInt("
|
|
2036
|
-
messageChars: read2.positiveInt("
|
|
2037
|
-
granted: read2.raw("
|
|
2218
|
+
maxAgeSeconds: read2.positiveInt("PA_GROUP_CONTEXT_HOURS", DEFAULT_GROUP_CONTEXT.maxAgeSeconds / 3600) * 3600,
|
|
2219
|
+
messageChars: read2.positiveInt("PA_GROUP_CONTEXT_CHARS", DEFAULT_GROUP_CONTEXT.messageChars),
|
|
2220
|
+
granted: read2.raw("PA_GROUP_CONTEXT_GRANTED") === "1"
|
|
2038
2221
|
};
|
|
2039
2222
|
}
|
|
2040
2223
|
function secret(read2, store, name) {
|
|
@@ -2043,41 +2226,43 @@ function secret(read2, store, name) {
|
|
|
2043
2226
|
if (store.source === "keyvault") {
|
|
2044
2227
|
throw new ConfigError2(`SECRETS_SOURCE=keyvault but ${name} was not read from the vault`);
|
|
2045
2228
|
}
|
|
2046
|
-
return read2.required(name);
|
|
2229
|
+
return read2.required(SECRET_SETTING_NAMES[name]);
|
|
2047
2230
|
}
|
|
2048
2231
|
function exchangeSettings(read2, store, publicBaseUrl) {
|
|
2049
|
-
const enabled = read2.isOn("
|
|
2050
|
-
const forChat = read2.isOn("
|
|
2051
|
-
if (read2.isOn("
|
|
2052
|
-
throw new ConfigError2("
|
|
2232
|
+
const enabled = read2.isOn("PA_EXCHANGE_ENABLED");
|
|
2233
|
+
const forChat = read2.isOn("PA_EXCHANGE_FOR_CHAT");
|
|
2234
|
+
if (read2.isOn("PA_GITHUB_REVIEW_ENABLED") && !enabled) {
|
|
2235
|
+
throw new ConfigError2(`${read2.source("PA_GITHUB_REVIEW_ENABLED")} needs ${read2.source("PA_EXCHANGE_ENABLED")}`);
|
|
2236
|
+
}
|
|
2237
|
+
if (forChat && !enabled) {
|
|
2238
|
+
throw new ConfigError2(`${read2.source("PA_EXCHANGE_FOR_CHAT")} needs ${read2.source("PA_EXCHANGE_ENABLED")}`);
|
|
2053
2239
|
}
|
|
2054
|
-
if (forChat && !enabled) throw new ConfigError2("TEAMS_EXCHANGE_FOR_CHAT needs TEAMS_EXCHANGE_ENABLED");
|
|
2055
2240
|
return {
|
|
2056
2241
|
enabled,
|
|
2057
|
-
tokenUrl: enabled ? read2.raw("
|
|
2058
|
-
clientId: enabled ? read2.required("
|
|
2242
|
+
tokenUrl: enabled ? read2.raw("PA_EXCHANGE_TOKEN_URL", `${publicBaseUrl}/oauth/token`) : "",
|
|
2243
|
+
clientId: enabled ? read2.required("PA_EXCHANGE_CLIENT_ID") : "",
|
|
2059
2244
|
clientSecret: enabled ? secret(read2, store, "TEAMS_EXCHANGE_CLIENT_SECRET") : "",
|
|
2060
|
-
issuer: read2.raw("
|
|
2061
|
-
audience: read2.raw("
|
|
2062
|
-
scope: read2.raw("
|
|
2063
|
-
bindingRequestUrl: enabled ? read2.raw("
|
|
2245
|
+
issuer: read2.raw("PA_EXCHANGE_ISSUER", "teams.microsoft.com"),
|
|
2246
|
+
audience: read2.raw("PA_EXCHANGE_AUDIENCE", "claw-api"),
|
|
2247
|
+
scope: read2.raw("PA_EXCHANGE_SCOPE", "claw.api"),
|
|
2248
|
+
bindingRequestUrl: enabled ? read2.raw("PA_EXCHANGE_BINDING_REQUEST_URL", `${publicBaseUrl}/oauth/binding-requests`) : "",
|
|
2064
2249
|
forChat
|
|
2065
2250
|
};
|
|
2066
2251
|
}
|
|
2067
2252
|
function githubReviewSettings(read2, publicBaseUrl) {
|
|
2068
|
-
const enabled = read2.isOn("
|
|
2069
|
-
const owners = read2.list("
|
|
2253
|
+
const enabled = read2.isOn("PA_GITHUB_REVIEW_ENABLED");
|
|
2254
|
+
const owners = read2.list("PA_GITHUB_REVIEW_OWNERS");
|
|
2070
2255
|
if (enabled && owners.length === 0) {
|
|
2071
2256
|
throw new ConfigError2(
|
|
2072
|
-
"
|
|
2257
|
+
`${read2.source("PA_GITHUB_REVIEW_ENABLED")} needs ${read2.source("PA_GITHUB_REVIEW_OWNERS")} (the GitHub owners whose pull requests are taken)`
|
|
2073
2258
|
);
|
|
2074
2259
|
}
|
|
2075
2260
|
return {
|
|
2076
2261
|
enabled,
|
|
2077
2262
|
owners,
|
|
2078
|
-
intentModel: enabled ? read2.text("
|
|
2079
|
-
credentialUrl: enabled ? withoutTrailingSlash(read2.raw("
|
|
2080
|
-
clientId: read2.text("
|
|
2263
|
+
intentModel: enabled ? read2.text("PA_REVIEW_INTENT_MODEL") || read2.text("CLAWY_MODEL") : "",
|
|
2264
|
+
credentialUrl: enabled ? withoutTrailingSlash(read2.raw("PA_GITHUB_CREDENTIAL_URL", `${publicBaseUrl}/oauth/external-credentials`)) : "",
|
|
2265
|
+
clientId: read2.text("PA_GITHUB_CLIENT_ID", GITHUB_CLI_CLIENT_ID) || GITHUB_CLI_CLIENT_ID
|
|
2081
2266
|
};
|
|
2082
2267
|
}
|
|
2083
2268
|
function assistantSettings(read2) {
|
|
@@ -2087,20 +2272,22 @@ function assistantSettings(read2) {
|
|
|
2087
2272
|
throw new ConfigError2(`ASSISTANT_REPLY_WINDOW_SECONDS must be a positive number of seconds, not ${pyRepr(window)}`);
|
|
2088
2273
|
}
|
|
2089
2274
|
const enabled = read2.isOn("ASSISTANT_ENABLED");
|
|
2090
|
-
const understanding = read2.switch("
|
|
2275
|
+
const understanding = read2.switch("PA_ASSISTANT_UNDERSTANDING", false);
|
|
2091
2276
|
const users = new Set(read2.list("ASSISTANT_USERS", true));
|
|
2092
|
-
const listed = new Set(read2.list("
|
|
2277
|
+
const listed = new Set(read2.list("PA_ASSISTANT_UNDERSTANDING_USERS", true));
|
|
2093
2278
|
const understandingUsers = understanding ? listed.size > 0 ? listed : users : /* @__PURE__ */ new Set();
|
|
2094
2279
|
if (understanding && understandingUsers.size === 0) {
|
|
2095
2280
|
throw new ConfigError2(
|
|
2096
|
-
"
|
|
2281
|
+
`${read2.source("PA_ASSISTANT_UNDERSTANDING")} is on but ${read2.source("PA_ASSISTANT_UNDERSTANDING_USERS")} names nobody (and ASSISTANT_USERS is empty)`
|
|
2097
2282
|
);
|
|
2098
2283
|
}
|
|
2099
2284
|
if (understandingUsers.size > 0 && !enabled) {
|
|
2100
|
-
throw new ConfigError2("
|
|
2285
|
+
throw new ConfigError2(`${read2.source("PA_ASSISTANT_UNDERSTANDING")} needs ASSISTANT_ENABLED`);
|
|
2101
2286
|
}
|
|
2102
2287
|
if (users.size > 0 && [...understandingUsers].some((u) => !users.has(u))) {
|
|
2103
|
-
throw new ConfigError2(
|
|
2288
|
+
throw new ConfigError2(
|
|
2289
|
+
`${read2.source("PA_ASSISTANT_UNDERSTANDING_USERS")} names people who are not in ASSISTANT_USERS`
|
|
2290
|
+
);
|
|
2104
2291
|
}
|
|
2105
2292
|
return {
|
|
2106
2293
|
enabled,
|
|
@@ -2111,13 +2298,16 @@ function assistantSettings(read2) {
|
|
|
2111
2298
|
}
|
|
2112
2299
|
function directChat(read2) {
|
|
2113
2300
|
return {
|
|
2114
|
-
enabled: read2.switch("
|
|
2115
|
-
users: new Set(read2.list("
|
|
2301
|
+
enabled: read2.switch("PA_DIRECT_CHAT", false),
|
|
2302
|
+
users: new Set(read2.list("PA_DIRECT_CHAT_USERS", true))
|
|
2116
2303
|
};
|
|
2117
2304
|
}
|
|
2118
2305
|
function limitsOf(read2) {
|
|
2119
2306
|
try {
|
|
2120
|
-
return parseLimits((name) => read2.raw(name)
|
|
2307
|
+
return parseLimits((name) => read2.raw(name), {
|
|
2308
|
+
prefix: LIMIT_ENV_PREFIX,
|
|
2309
|
+
source: (name) => read2.source(name)
|
|
2310
|
+
});
|
|
2121
2311
|
} catch (err5) {
|
|
2122
2312
|
if (err5 instanceof ConfigError2) throw err5;
|
|
2123
2313
|
throw new ConfigError2(err5 instanceof Error ? err5.message : String(err5));
|
|
@@ -2394,6 +2584,20 @@ var Database = class {
|
|
|
2394
2584
|
constructor(path) {
|
|
2395
2585
|
this.#db = new DatabaseSync(path, { timeout: 5e3 });
|
|
2396
2586
|
this.#db.exec("PRAGMA journal_mode=WAL");
|
|
2587
|
+
this.#db.exec("PRAGMA synchronous=NORMAL");
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* `write` with each commit synced to disk (`synchronous=FULL`): for what is acknowledged as kept before it is used. Inside an
|
|
2591
|
+
* open transaction SQLite refuses to change the setting, so there `write` just runs and its commit is the transaction's.
|
|
2592
|
+
*/
|
|
2593
|
+
durably(write) {
|
|
2594
|
+
if (this.#db.isTransaction) return write();
|
|
2595
|
+
this.#db.exec("PRAGMA synchronous=FULL");
|
|
2596
|
+
try {
|
|
2597
|
+
return write();
|
|
2598
|
+
} finally {
|
|
2599
|
+
this.#db.exec("PRAGMA synchronous=NORMAL");
|
|
2600
|
+
}
|
|
2397
2601
|
}
|
|
2398
2602
|
/** Several statements, no parameters (DDL). */
|
|
2399
2603
|
exec(sql) {
|
|
@@ -4192,12 +4396,14 @@ var SqliteHeldEventRepository = class {
|
|
|
4192
4396
|
const { db } = this.ctx;
|
|
4193
4397
|
const now = this.ctx.now();
|
|
4194
4398
|
db.run("DELETE FROM held_events WHERE held_at < ?", now - HELD_TTL_SECONDS);
|
|
4195
|
-
db.
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4399
|
+
db.durably(
|
|
4400
|
+
() => db.run(
|
|
4401
|
+
"INSERT OR IGNORE INTO held_events (event_id, aad_id, event_json, held_at) VALUES (?, ?, ?, ?)",
|
|
4402
|
+
pyStr5(event["event_id"]),
|
|
4403
|
+
userId,
|
|
4404
|
+
pyJsonDumps(event),
|
|
4405
|
+
now
|
|
4406
|
+
)
|
|
4201
4407
|
);
|
|
4202
4408
|
db.run(
|
|
4203
4409
|
"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 ?)",
|
|
@@ -4218,7 +4424,7 @@ var SqliteHeldEventRepository = class {
|
|
|
4218
4424
|
return rows.map((r) => storedObject(col.str(r, "event_json"))).filter((e) => e !== null);
|
|
4219
4425
|
}
|
|
4220
4426
|
};
|
|
4221
|
-
function
|
|
4427
|
+
function pyStr5(value) {
|
|
4222
4428
|
if (typeof value === "string") return value;
|
|
4223
4429
|
if (value === void 0) throw new RangeError("a held event needs an event_id");
|
|
4224
4430
|
if (value === null) return "None";
|
|
@@ -5367,13 +5573,13 @@ var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
|
5367
5573
|
var DEVICE_PAGE_HOST = "github.com";
|
|
5368
5574
|
var SLOW_DOWN_SECONDS = 5;
|
|
5369
5575
|
var MAX_DEVICE_WAIT_SECONDS = 15 * 60;
|
|
5370
|
-
var
|
|
5576
|
+
var int2 = z6.number().int().positive();
|
|
5371
5577
|
var started = z6.object({
|
|
5372
5578
|
device_code: z6.string().min(1),
|
|
5373
5579
|
user_code: z6.string().min(1),
|
|
5374
5580
|
verification_uri: z6.string(),
|
|
5375
|
-
expires_in:
|
|
5376
|
-
interval:
|
|
5581
|
+
expires_in: int2,
|
|
5582
|
+
interval: int2.optional().default(5)
|
|
5377
5583
|
});
|
|
5378
5584
|
var polled = z6.object({
|
|
5379
5585
|
error: z6.unknown().optional(),
|
|
@@ -5805,7 +6011,7 @@ function feedbackSink(config, options) {
|
|
|
5805
6011
|
|
|
5806
6012
|
// packages/runtime/src/github/feedback-worker.ts
|
|
5807
6013
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
5808
|
-
import { pyStrip as
|
|
6014
|
+
import { pyStrip as pyStrip7 } from "@primusclaw/personal-agent";
|
|
5809
6015
|
function packageVersion(packageJson) {
|
|
5810
6016
|
try {
|
|
5811
6017
|
const parsed = JSON.parse(readFileSync3(packageJson, "utf8"));
|
|
@@ -5816,7 +6022,7 @@ function packageVersion(packageJson) {
|
|
|
5816
6022
|
}
|
|
5817
6023
|
}
|
|
5818
6024
|
function workerInfoFromEnv(env, worker) {
|
|
5819
|
-
const tag = (name) =>
|
|
6025
|
+
const tag = (name) => pyStrip7(env[name] ?? "");
|
|
5820
6026
|
return {
|
|
5821
6027
|
pluginId: worker.pluginId,
|
|
5822
6028
|
version: worker.version,
|
|
@@ -5891,6 +6097,7 @@ var ChatLog = class {
|
|
|
5891
6097
|
export {
|
|
5892
6098
|
ACCESS_TOKEN,
|
|
5893
6099
|
ALERTED,
|
|
6100
|
+
ALIASED_SETTINGS,
|
|
5894
6101
|
ASSISTANT_REPLY_WINDOW_SECONDS,
|
|
5895
6102
|
AppTokenSource,
|
|
5896
6103
|
BUSY_POLL_MS,
|
|
@@ -5926,6 +6133,7 @@ export {
|
|
|
5926
6133
|
IdentityCredentialClient,
|
|
5927
6134
|
InvalidToken,
|
|
5928
6135
|
LAG_WINDOW_MS,
|
|
6136
|
+
LEGACY_SETTING_PREFIX,
|
|
5929
6137
|
LINK_HASH_LABEL,
|
|
5930
6138
|
MAX_BODY_BYTES,
|
|
5931
6139
|
MAX_DEVICE_WAIT_SECONDS,
|
|
@@ -5938,6 +6146,9 @@ export {
|
|
|
5938
6146
|
PublicPullReader,
|
|
5939
6147
|
REFRESH_MARGIN_SECONDS,
|
|
5940
6148
|
REQUEST_MARGIN_SECONDS,
|
|
6149
|
+
SECRET_SETTING_NAMES,
|
|
6150
|
+
SETTING_ALIASES,
|
|
6151
|
+
SETTING_PREFIX,
|
|
5941
6152
|
SqliteStore,
|
|
5942
6153
|
StoreSecrets,
|
|
5943
6154
|
UNMATCHED_ROUTE,
|
|
@@ -5959,6 +6170,7 @@ export {
|
|
|
5959
6170
|
hashLinkCode,
|
|
5960
6171
|
healthzRoute,
|
|
5961
6172
|
json,
|
|
6173
|
+
legacySettings,
|
|
5962
6174
|
lineLogger,
|
|
5963
6175
|
linkHashKey,
|
|
5964
6176
|
linkRoute,
|
|
@@ -5974,6 +6186,8 @@ export {
|
|
|
5974
6186
|
round3,
|
|
5975
6187
|
ruleText,
|
|
5976
6188
|
secretsSourceOf,
|
|
6189
|
+
settingSource,
|
|
6190
|
+
settingValue,
|
|
5977
6191
|
sign,
|
|
5978
6192
|
sinceOccurred,
|
|
5979
6193
|
systemClock,
|
|
@@ -5982,6 +6196,7 @@ export {
|
|
|
5982
6196
|
urlsafeB64Decode,
|
|
5983
6197
|
urlsafeB64Encode,
|
|
5984
6198
|
wantedSecrets,
|
|
6199
|
+
warnLegacySettings,
|
|
5985
6200
|
withoutTrailingSlash,
|
|
5986
6201
|
workerInfoFromEnv
|
|
5987
6202
|
};
|
|
@@ -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 (
|
|
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,16 @@
|
|
|
1
|
+
import { type ClawCredential, type ClawSkill, type ClawSkillChange, type ClawSkillEntry, type ClawSkillsPort, type ClawSkillUndone } from "@primusclaw/personal-agent";
|
|
2
|
+
import { type ClawHttp } from "./http.js";
|
|
3
|
+
/** `ClawSkillsPort` over Claw's HTTP API: the person's own skills, always as them. */
|
|
4
|
+
export declare class HttpSkills implements ClawSkillsPort {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: ClawHttp);
|
|
7
|
+
list(key: ClawCredential): Promise<ClawSkillEntry[]>;
|
|
8
|
+
show(key: ClawCredential, name: string): Promise<ClawSkill>;
|
|
9
|
+
setEnabled(key: ClawCredential, name: string, enabled: boolean): Promise<ClawSkillChange>;
|
|
10
|
+
remove(key: ClawCredential, name: string): Promise<ClawSkillChange>;
|
|
11
|
+
update(key: ClawCredential, name: string, skill: {
|
|
12
|
+
readonly content: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
}): Promise<ClawSkillChange>;
|
|
15
|
+
undo(key: ClawCredential, changeId: string): Promise<ClawSkillUndone>;
|
|
16
|
+
}
|
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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 (
|
|
9
|
-
*
|
|
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 (`
|
|
27
|
+
/** The database file (`PA_DB_PATH`), or ":memory:". */
|
|
28
28
|
readonly path: string;
|
|
29
|
-
/**
|
|
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 (
|
|
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 (
|
|
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
|
|
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_
|
|
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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonObject, OutMessage } from "@primusclaw/personal-agent";
|
|
2
|
-
import { DailyBrief, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
2
|
+
import { DailyBrief, SkillsCommand, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
3
3
|
import type { AssemblyBase } from "./features-base.js";
|
|
4
4
|
/** The brief Claw put together, as a message (Python `render.brief_markdown`). */
|
|
5
5
|
export declare function briefMarkdown(brief: JsonObject): string;
|
|
@@ -11,6 +11,8 @@ export interface W8Parts {
|
|
|
11
11
|
/** The recent messages of group chats, in memory, as background for an @mention. */
|
|
12
12
|
readonly groupContext: GroupContext;
|
|
13
13
|
readonly brief: DailyBrief;
|
|
14
|
+
/** Its commands: `/brief`, and `/skills` (the person's own skills, in their own chat). */
|
|
15
|
+
readonly commands: readonly [DailyBrief, SkillsCommand];
|
|
14
16
|
/** The Report a problem card under a message of the person's that went wrong. */
|
|
15
17
|
reportView(userId: string, scope: string): OutMessage;
|
|
16
18
|
}
|
|
@@ -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 (
|
|
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 (
|
|
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
|
|
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
|
-
/**
|
|
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 {
|
|
@@ -88,6 +90,7 @@ import {
|
|
|
88
90
|
turn as turn2,
|
|
89
91
|
WatchClicks,
|
|
90
92
|
WorkCardClicks,
|
|
93
|
+
SkillCardClicks,
|
|
91
94
|
WorkClicks
|
|
92
95
|
} from "@primusclaw/personal-agent";
|
|
93
96
|
|
|
@@ -148,9 +151,6 @@ function routerLimits(limits, clock) {
|
|
|
148
151
|
}
|
|
149
152
|
function channelContextBuilder(store, pending = () => []) {
|
|
150
153
|
return (request) => {
|
|
151
|
-
const mentions = request.message.mentions.map((m) => ({
|
|
152
|
-
mentioned: { id: m.channelUserId, name: m.name, aadObjectId: m.userId }
|
|
153
|
-
}));
|
|
154
154
|
const known = store.members.knownMembers().map((m) => ({
|
|
155
155
|
id: m.id,
|
|
156
156
|
name: m.name,
|
|
@@ -158,10 +158,10 @@ function channelContextBuilder(store, pending = () => []) {
|
|
|
158
158
|
...m.email ? { email: m.email } : {}
|
|
159
159
|
}));
|
|
160
160
|
const people = peopleOf(
|
|
161
|
-
mentions,
|
|
161
|
+
request.message.mentions,
|
|
162
162
|
request.message.text,
|
|
163
163
|
known,
|
|
164
|
-
(
|
|
164
|
+
(directoryId) => store.links.clawUserIdOf(directoryId),
|
|
165
165
|
(channelId) => store.members.userForChannelId(channelId)
|
|
166
166
|
);
|
|
167
167
|
const actions = channelActions(request.parts);
|
|
@@ -352,7 +352,13 @@ function assistantParts(base, inputs) {
|
|
|
352
352
|
const watch = new WatchClicks({ store, claw: claw.workItems, exchange, logger });
|
|
353
353
|
const linked = (userId) => store.links.getKey(userId) !== null;
|
|
354
354
|
const choices = new AssistantChoiceClicks({ store, deliver: (message) => hooks.typed(message), logger });
|
|
355
|
-
const
|
|
355
|
+
const skillCards = new SkillCardClicks({ store, skills: claw.skills, logger });
|
|
356
|
+
const clicks = [
|
|
357
|
+
new WorkCardClicks(work, watch, exchange, linked, logger),
|
|
358
|
+
actionClicks(actions),
|
|
359
|
+
choices,
|
|
360
|
+
skillCards
|
|
361
|
+
];
|
|
356
362
|
return { subs, chat: assistant, board, receipts, directChat, actions, clicks };
|
|
357
363
|
}
|
|
358
364
|
|
|
@@ -807,6 +813,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
807
813
|
import {
|
|
808
814
|
chatCredentialOf,
|
|
809
815
|
DailyBrief,
|
|
816
|
+
SkillsCommand,
|
|
810
817
|
FeedbackFlow,
|
|
811
818
|
FeedbackReporting,
|
|
812
819
|
FeedbackService,
|
|
@@ -933,6 +940,7 @@ function w8Parts(base, options) {
|
|
|
933
940
|
observer,
|
|
934
941
|
groupContext,
|
|
935
942
|
brief,
|
|
943
|
+
commands: [brief, new SkillsCommand({ store, skills: claw.skills, logger })],
|
|
936
944
|
reportView: (userId, scope) => {
|
|
937
945
|
const view = service.reportView(userId, scope);
|
|
938
946
|
return reportMessage(view.promptId, view.group);
|
|
@@ -971,7 +979,7 @@ function refuseMissing(base) {
|
|
|
971
979
|
);
|
|
972
980
|
if (settings2.onBehalfUsers.size > 0 && !plugins.routeExtensions.some((route) => route.method === "POST" && route.path === ON_BEHALF_PATH))
|
|
973
981
|
throw new StartupError(
|
|
974
|
-
|
|
982
|
+
`${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
983
|
);
|
|
976
984
|
}
|
|
977
985
|
function listenForStops(router, service) {
|
|
@@ -1197,7 +1205,7 @@ function buildFeatures(given) {
|
|
|
1197
1205
|
personalInterceptors: [...reviewHandlers?.personalInterceptors ?? [], w8.flow.interceptor],
|
|
1198
1206
|
groupInterceptors,
|
|
1199
1207
|
commands: [
|
|
1200
|
-
w8.
|
|
1208
|
+
...w8.commands,
|
|
1201
1209
|
...switches.remoteAgents ? [new TerminalApprovalsCommand(base.claw.remoteAgents)] : [],
|
|
1202
1210
|
...reviewHandlers?.commands ?? []
|
|
1203
1211
|
],
|
|
@@ -1515,6 +1523,7 @@ async function envSecrets(env, names) {
|
|
|
1515
1523
|
return new EnvSecretSource(env).load([...names]);
|
|
1516
1524
|
}
|
|
1517
1525
|
async function assemblyBase(env, prepared, deps) {
|
|
1526
|
+
warnLegacySettings(env, deps.logger);
|
|
1518
1527
|
const names = wantedSecrets(env);
|
|
1519
1528
|
const secrets = await (prepared.loadSecrets ? prepared.loadSecrets(names, deps) : envSecrets(env, names));
|
|
1520
1529
|
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.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
36
|
+
"@primusclaw/personal-agent": "0.9.0",
|
|
37
37
|
"fastify": "^5.12.8",
|
|
38
38
|
"zod": "^4.6.7"
|
|
39
39
|
}
|