@primusclaw/personal-agent-runtime 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +183 -59
- package/dist/types/claw/client.d.ts +2 -2
- package/dist/types/claw/sessions.d.ts +1 -1
- package/dist/types/claw/skills.d.ts +16 -0
- package/dist/types/config/aliases.d.ts +18 -9
- package/dist/types/config/index.d.ts +1 -1
- package/dist/types/github/feedback-config.d.ts +2 -0
- package/dist/types/github/feedback-issues.d.ts +7 -1
- package/dist/types/github/intent-reader.d.ts +2 -0
- package/dist/types/metrics/index.d.ts +1 -1
- package/dist/types/metrics/prometheus-metrics.d.ts +15 -4
- package/dist/types/worker/features-w8.d.ts +3 -1
- package/dist/worker.js +35 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1225,8 +1225,101 @@ 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
|
-
var DEFAULT_CLIENT_LABEL = "
|
|
1322
|
+
var DEFAULT_CLIENT_LABEL = "personal-agent";
|
|
1230
1323
|
function createClawClient(options) {
|
|
1231
1324
|
const http = new ClawHttp(options.baseUrl, options.fetch ?? ((url, init) => fetch(url, init)));
|
|
1232
1325
|
const toolId = options.ruleToolId ?? null;
|
|
@@ -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
|
|
|
@@ -1451,6 +1545,8 @@ import {
|
|
|
1451
1545
|
own as own2
|
|
1452
1546
|
} from "@primusclaw/personal-agent";
|
|
1453
1547
|
var CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
|
|
1548
|
+
var METRIC_PREFIX = "personal_agent_";
|
|
1549
|
+
var LEGACY_METRIC_PREFIX = "clawy_";
|
|
1454
1550
|
var LAG_WINDOW_MS = 6e4;
|
|
1455
1551
|
var EVENT_BUCKETS = [0.5, 1, 2, 3, 5, 10, 30, 60];
|
|
1456
1552
|
var ALERTED = [
|
|
@@ -1474,27 +1570,30 @@ var ALERTED = [
|
|
|
1474
1570
|
["key_unlinked", [["reason", "rejected"]]]
|
|
1475
1571
|
];
|
|
1476
1572
|
var HELP = {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1573
|
+
personal_agent_security_events_total: ["counter", "Security events logged by the worker, by event and category."],
|
|
1574
|
+
personal_agent_inbound_handled_total: ["counter", "Inbound messages handled (completed or abandoned)."],
|
|
1575
|
+
personal_agent_inbound_failed_total: [
|
|
1480
1576
|
"counter",
|
|
1481
1577
|
"Inbound messages whose handler failed and that were abandoned for redelivery."
|
|
1482
1578
|
],
|
|
1483
|
-
|
|
1484
|
-
|
|
1579
|
+
personal_agent_inbound_handle_ms_total: ["counter", "Milliseconds spent handling inbound messages, summed."],
|
|
1580
|
+
personal_agent_inbound_lag_max_ms: [
|
|
1485
1581
|
"gauge",
|
|
1486
1582
|
"Longest time a message handled in the last 60 seconds waited in the inbound queue."
|
|
1487
1583
|
],
|
|
1488
|
-
|
|
1489
|
-
|
|
1584
|
+
personal_agent_inbound_limited_total: ["counter", "Messages and tasks refused by a per-user limit, by reason."],
|
|
1585
|
+
personal_agent_event_handle_seconds: [
|
|
1490
1586
|
"histogram",
|
|
1491
1587
|
"Seconds from receiving a Claw event to having sent it to the chat, by event type."
|
|
1492
1588
|
],
|
|
1493
|
-
|
|
1589
|
+
personal_agent_event_to_chat_seconds: [
|
|
1494
1590
|
"histogram",
|
|
1495
1591
|
"Seconds from when Claw says an event happened to having sent it to the chat, by event type."
|
|
1496
1592
|
],
|
|
1497
|
-
|
|
1593
|
+
personal_agent_files_dropped_total: [
|
|
1594
|
+
"counter",
|
|
1595
|
+
"Files a user sent that did not reach Claw, by where they were dropped."
|
|
1596
|
+
]
|
|
1498
1597
|
};
|
|
1499
1598
|
function compareTuples(a, b) {
|
|
1500
1599
|
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
@@ -1577,49 +1676,54 @@ var PrometheusMetrics = class {
|
|
|
1577
1676
|
expire(now) {
|
|
1578
1677
|
while ((this.lags[0]?.[0] ?? Infinity) <= now - this.lagWindowMs) this.lags.shift();
|
|
1579
1678
|
}
|
|
1580
|
-
/**
|
|
1679
|
+
/**
|
|
1680
|
+
* All series in the Prometheus text exposition format (version 0.0.4): under their names, then, with the same values and
|
|
1681
|
+
* help, under the deprecated names of an earlier release (that half is the text it wrote, byte for byte).
|
|
1682
|
+
*/
|
|
1581
1683
|
render() {
|
|
1684
|
+
const lagMaxMs = this.lagMaxMs();
|
|
1685
|
+
return this.renderAs(METRIC_PREFIX, lagMaxMs) + this.renderAs(LEGACY_METRIC_PREFIX, lagMaxMs);
|
|
1686
|
+
}
|
|
1687
|
+
renderAs(prefix, lagMaxMs) {
|
|
1582
1688
|
const lines = [];
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1689
|
+
const named = (stem) => prefix + stem;
|
|
1690
|
+
const head2 = (stem) => {
|
|
1691
|
+
const [kind, text3] = own2(HELP, METRIC_PREFIX + stem) ?? ["untyped", ""];
|
|
1692
|
+
lines.push(`# HELP ${named(stem)} ${text3}`, `# TYPE ${named(stem)} ${kind}`);
|
|
1586
1693
|
};
|
|
1587
|
-
head2("
|
|
1694
|
+
head2("security_events_total");
|
|
1588
1695
|
const events = [...this.events.values()].sort(
|
|
1589
1696
|
(a, b) => compareTuples([a.event, ...a.labels.flat()], [b.event, ...b.labels.flat()])
|
|
1590
1697
|
);
|
|
1591
1698
|
for (const { event, labels, value } of events) {
|
|
1592
1699
|
const pairs = [["event", event], ...labels].map(([k, v]) => `${k}="${v}"`).join(",");
|
|
1593
|
-
lines.push(
|
|
1700
|
+
lines.push(`${named("security_events_total")}{${pairs}} ${String(value)}`);
|
|
1594
1701
|
}
|
|
1595
1702
|
const plain = [
|
|
1596
|
-
["
|
|
1597
|
-
["
|
|
1598
|
-
["
|
|
1599
|
-
["
|
|
1703
|
+
["inbound_handled_total", this.handledCount],
|
|
1704
|
+
["inbound_failed_total", this.failedCount],
|
|
1705
|
+
["inbound_handle_ms_total", this.handleMsTotal],
|
|
1706
|
+
["inbound_lag_max_ms", lagMaxMs]
|
|
1600
1707
|
];
|
|
1601
|
-
for (const [
|
|
1602
|
-
head2(
|
|
1603
|
-
lines.push(`${
|
|
1708
|
+
for (const [stem, value] of plain) {
|
|
1709
|
+
head2(stem);
|
|
1710
|
+
lines.push(`${named(stem)} ${String(value)}`);
|
|
1604
1711
|
}
|
|
1605
|
-
head2("
|
|
1712
|
+
head2("inbound_limited_total");
|
|
1606
1713
|
for (const [reason, value] of [...this.limits].sort(([a], [b]) => compareTuples([a], [b]))) {
|
|
1607
|
-
lines.push(
|
|
1608
|
-
}
|
|
1609
|
-
this.renderHistograms(lines, head2);
|
|
1610
|
-
head2("clawy_files_dropped_total");
|
|
1611
|
-
for (const [path, value] of [...this.dropped].sort(([a], [b]) => compareTuples([a], [b]))) {
|
|
1612
|
-
lines.push(`clawy_files_dropped_total{path="${path}"} ${String(value)}`);
|
|
1714
|
+
lines.push(`${named("inbound_limited_total")}{reason="${reason}"} ${String(value)}`);
|
|
1613
1715
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
renderHistograms(lines, head2) {
|
|
1617
|
-
["clawy_event_handle_seconds", "clawy_event_to_chat_seconds"].forEach((name, position) => {
|
|
1618
|
-
head2(name);
|
|
1716
|
+
["event_handle_seconds", "event_to_chat_seconds"].forEach((stem, position) => {
|
|
1717
|
+
head2(stem);
|
|
1619
1718
|
for (const type of DELIVERED_EVENT_TYPES) {
|
|
1620
|
-
lines.push(...this.eventTimes.get(type)?.[position]?.lines(
|
|
1719
|
+
lines.push(...this.eventTimes.get(type)?.[position]?.lines(named(stem), `type="${type}"`) ?? []);
|
|
1621
1720
|
}
|
|
1622
1721
|
});
|
|
1722
|
+
head2("files_dropped_total");
|
|
1723
|
+
for (const [path, value] of [...this.dropped].sort(([a], [b]) => compareTuples([a], [b]))) {
|
|
1724
|
+
lines.push(`${named("files_dropped_total")}{path="${path}"} ${String(value)}`);
|
|
1725
|
+
}
|
|
1726
|
+
return lines.join("\n") + "\n";
|
|
1623
1727
|
}
|
|
1624
1728
|
};
|
|
1625
1729
|
|
|
@@ -1863,9 +1967,13 @@ var ALIASED_SETTINGS = [
|
|
|
1863
1967
|
"LIMIT_APPROVAL",
|
|
1864
1968
|
"LIMIT_REMOTE_AGENT"
|
|
1865
1969
|
];
|
|
1866
|
-
var
|
|
1867
|
-
|
|
1868
|
-
|
|
1970
|
+
var MODEL_SETTING_PREFIX = "PERSONAL_AGENT_";
|
|
1971
|
+
var LEGACY_MODEL_SETTING_PREFIX = "CLAWY_";
|
|
1972
|
+
var MODEL_SETTINGS = ["MODEL", "FALLBACK_MODEL", "REVIEW_MODEL"];
|
|
1973
|
+
var SETTING_ALIASES = new Map([
|
|
1974
|
+
...ALIASED_SETTINGS.map((stem) => [SETTING_PREFIX + stem, LEGACY_SETTING_PREFIX + stem]),
|
|
1975
|
+
...MODEL_SETTINGS.map((stem) => [MODEL_SETTING_PREFIX + stem, LEGACY_MODEL_SETTING_PREFIX + stem])
|
|
1976
|
+
]);
|
|
1869
1977
|
var NEUTRAL_OF = new Map([...SETTING_ALIASES].map(([neutral, old]) => [old, neutral]));
|
|
1870
1978
|
var isSet = (env, name) => pyStrip4(own3(env, name) ?? "") !== "";
|
|
1871
1979
|
function settingSource(env, name) {
|
|
@@ -1890,7 +1998,7 @@ function warnLegacySettings(env, logger) {
|
|
|
1890
1998
|
const read2 = used.filter((s) => !s.ignored);
|
|
1891
1999
|
if (read2.length > 0) {
|
|
1892
2000
|
logger.warn(
|
|
1893
|
-
`deprecated setting names: ${read2.map((s) => `${s.legacy} (now ${s.neutral})`).join(", ")}; they still work, the
|
|
2001
|
+
`deprecated setting names: ${read2.map((s) => `${s.legacy} (now ${s.neutral})`).join(", ")}; they still work, the new names take precedence`,
|
|
1894
2002
|
{ settings: read2.map((s) => s.legacy).join(",") }
|
|
1895
2003
|
);
|
|
1896
2004
|
}
|
|
@@ -2050,6 +2158,7 @@ var EnvSecretSource = class {
|
|
|
2050
2158
|
|
|
2051
2159
|
// packages/runtime/src/config/settings.ts
|
|
2052
2160
|
import {
|
|
2161
|
+
BOT_NAME,
|
|
2053
2162
|
ConfigError as ConfigError2,
|
|
2054
2163
|
DEFAULT_MAX_CONCURRENT_TASKS,
|
|
2055
2164
|
DEFAULT_MESSAGE_LIMIT,
|
|
@@ -2080,6 +2189,7 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
|
|
|
2080
2189
|
publicBaseUrl,
|
|
2081
2190
|
listenPort,
|
|
2082
2191
|
metricsPort,
|
|
2192
|
+
botName: read2.text("PERSONAL_AGENT_BOT_NAME") || BOT_NAME,
|
|
2083
2193
|
claw: {
|
|
2084
2194
|
pluginId: read2.optionalInt("CLAW_PLUGIN_ID"),
|
|
2085
2195
|
ruleToolId: read2.optionalInt("CLAW_RULE_TOOL_ID"),
|
|
@@ -2087,9 +2197,9 @@ function readSettings(env, secrets = /* @__PURE__ */ new Map()) {
|
|
|
2087
2197
|
},
|
|
2088
2198
|
exchange,
|
|
2089
2199
|
models: {
|
|
2090
|
-
chat: read2.text("
|
|
2091
|
-
fallback: read2.text("
|
|
2092
|
-
review: read2.text("
|
|
2200
|
+
chat: read2.text("PERSONAL_AGENT_MODEL"),
|
|
2201
|
+
fallback: read2.text("PERSONAL_AGENT_FALLBACK_MODEL"),
|
|
2202
|
+
review: read2.text("PERSONAL_AGENT_REVIEW_MODEL")
|
|
2093
2203
|
},
|
|
2094
2204
|
githubReview: githubReviewSettings(read2, publicBaseUrl),
|
|
2095
2205
|
assistant: assistantSettings(read2),
|
|
@@ -2166,7 +2276,7 @@ function githubReviewSettings(read2, publicBaseUrl) {
|
|
|
2166
2276
|
return {
|
|
2167
2277
|
enabled,
|
|
2168
2278
|
owners,
|
|
2169
|
-
intentModel: enabled ? read2.text("PA_REVIEW_INTENT_MODEL") || read2.text("
|
|
2279
|
+
intentModel: enabled ? read2.text("PA_REVIEW_INTENT_MODEL") || read2.text("PERSONAL_AGENT_MODEL") : "",
|
|
2170
2280
|
credentialUrl: enabled ? withoutTrailingSlash(read2.raw("PA_GITHUB_CREDENTIAL_URL", `${publicBaseUrl}/oauth/external-credentials`)) : "",
|
|
2171
2281
|
clientId: read2.text("PA_GITHUB_CLIENT_ID", GITHUB_CLI_CLIENT_ID) || GITHUB_CLI_CLIENT_ID
|
|
2172
2282
|
};
|
|
@@ -4305,7 +4415,7 @@ var SqliteHeldEventRepository = class {
|
|
|
4305
4415
|
db.durably(
|
|
4306
4416
|
() => db.run(
|
|
4307
4417
|
"INSERT OR IGNORE INTO held_events (event_id, aad_id, event_json, held_at) VALUES (?, ?, ?, ?)",
|
|
4308
|
-
|
|
4418
|
+
pyStr5(event["event_id"]),
|
|
4309
4419
|
userId,
|
|
4310
4420
|
pyJsonDumps(event),
|
|
4311
4421
|
now
|
|
@@ -4330,7 +4440,7 @@ var SqliteHeldEventRepository = class {
|
|
|
4330
4440
|
return rows.map((r) => storedObject(col.str(r, "event_json"))).filter((e) => e !== null);
|
|
4331
4441
|
}
|
|
4332
4442
|
};
|
|
4333
|
-
function
|
|
4443
|
+
function pyStr5(value) {
|
|
4334
4444
|
if (typeof value === "string") return value;
|
|
4335
4445
|
if (value === void 0) throw new RangeError("a held event needs an event_id");
|
|
4336
4446
|
if (value === null) return "None";
|
|
@@ -5479,13 +5589,13 @@ var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
|
5479
5589
|
var DEVICE_PAGE_HOST = "github.com";
|
|
5480
5590
|
var SLOW_DOWN_SECONDS = 5;
|
|
5481
5591
|
var MAX_DEVICE_WAIT_SECONDS = 15 * 60;
|
|
5482
|
-
var
|
|
5592
|
+
var int2 = z6.number().int().positive();
|
|
5483
5593
|
var started = z6.object({
|
|
5484
5594
|
device_code: z6.string().min(1),
|
|
5485
5595
|
user_code: z6.string().min(1),
|
|
5486
5596
|
verification_uri: z6.string(),
|
|
5487
|
-
expires_in:
|
|
5488
|
-
interval:
|
|
5597
|
+
expires_in: int2,
|
|
5598
|
+
interval: int2.optional().default(5)
|
|
5489
5599
|
});
|
|
5490
5600
|
var polled = z6.object({
|
|
5491
5601
|
error: z6.unknown().optional(),
|
|
@@ -5629,13 +5739,16 @@ var GatewayIntentReader = class {
|
|
|
5629
5739
|
url;
|
|
5630
5740
|
fetchImpl;
|
|
5631
5741
|
read(key2, text3, mentions, channel) {
|
|
5632
|
-
return this.complete(key2, intentPrompt(channel), { message: text3, mentions });
|
|
5742
|
+
return this.complete(key2, intentPrompt(channel, this.options.botName), { message: text3, mentions });
|
|
5633
5743
|
}
|
|
5634
5744
|
readMode(key2, text3, channel) {
|
|
5635
|
-
return this.complete(key2, modePrompt(channel), { message: text3 });
|
|
5745
|
+
return this.complete(key2, modePrompt(channel, this.options.botName), { message: text3 });
|
|
5636
5746
|
}
|
|
5637
5747
|
readAnswer(key2, text3, pending, channel) {
|
|
5638
|
-
return this.complete(key2, answerPrompt(channel), {
|
|
5748
|
+
return this.complete(key2, answerPrompt(channel, this.options.botName), {
|
|
5749
|
+
message: text3,
|
|
5750
|
+
waiting_for_this_person: pending
|
|
5751
|
+
});
|
|
5639
5752
|
}
|
|
5640
5753
|
async complete(key2, system, payload) {
|
|
5641
5754
|
const body = {
|
|
@@ -5744,11 +5857,14 @@ import { ConfigError as ConfigError3 } from "@primusclaw/personal-agent";
|
|
|
5744
5857
|
// packages/runtime/src/github/feedback-issues.ts
|
|
5745
5858
|
import {
|
|
5746
5859
|
err as err4,
|
|
5747
|
-
ok as ok4
|
|
5860
|
+
ok as ok4,
|
|
5861
|
+
PERSISTED_FEEDBACK_LABEL
|
|
5748
5862
|
} from "@primusclaw/personal-agent";
|
|
5749
|
-
var FEEDBACK_LABEL =
|
|
5863
|
+
var FEEDBACK_LABEL = PERSISTED_FEEDBACK_LABEL;
|
|
5750
5864
|
var LABEL_COLOR = "d93f0b";
|
|
5751
|
-
|
|
5865
|
+
function labelDescription(botName) {
|
|
5866
|
+
return `Reported by a user from Teams through ${botName}`;
|
|
5867
|
+
}
|
|
5752
5868
|
function isoSeconds(epochMs) {
|
|
5753
5869
|
return `${new Date(Math.floor(epochMs / 1e3) * 1e3).toISOString().slice(0, 19)}Z`;
|
|
5754
5870
|
}
|
|
@@ -5777,14 +5893,16 @@ function bodyOf(value) {
|
|
|
5777
5893
|
return typeof body === "string" ? body : "";
|
|
5778
5894
|
}
|
|
5779
5895
|
var GithubIssueSink = class {
|
|
5780
|
-
constructor(api, repo, log) {
|
|
5896
|
+
constructor(api, repo, log, botName) {
|
|
5781
5897
|
this.api = api;
|
|
5782
5898
|
this.log = log;
|
|
5899
|
+
this.botName = botName;
|
|
5783
5900
|
const [owner = "", name = ""] = repo.split("/");
|
|
5784
5901
|
this.repoPath = `/repos/${segment2(owner)}/${segment2(name)}`;
|
|
5785
5902
|
}
|
|
5786
5903
|
api;
|
|
5787
5904
|
log;
|
|
5905
|
+
botName;
|
|
5788
5906
|
labelReady = false;
|
|
5789
5907
|
repoPath;
|
|
5790
5908
|
async createIssue(title, body, labels) {
|
|
@@ -5857,7 +5975,7 @@ var GithubIssueSink = class {
|
|
|
5857
5975
|
const made = await this.api.request({
|
|
5858
5976
|
method: "POST",
|
|
5859
5977
|
path: `${this.repoPath}/labels`,
|
|
5860
|
-
body: { name: FEEDBACK_LABEL, color: LABEL_COLOR, description:
|
|
5978
|
+
body: { name: FEEDBACK_LABEL, color: LABEL_COLOR, description: labelDescription(this.botName) }
|
|
5861
5979
|
});
|
|
5862
5980
|
if (made.status === 201 || made.status === 422)
|
|
5863
5981
|
this.labelReady = true;
|
|
@@ -5912,7 +6030,7 @@ function feedbackSink(config, options) {
|
|
|
5912
6030
|
options.log.warn("feedback: GitHub App token failed; falling back to the token file", { code });
|
|
5913
6031
|
});
|
|
5914
6032
|
const api = new GithubApi({ apiUrl: config.apiUrl, tokens, ...options.fetch ? { fetch: options.fetch } : {} });
|
|
5915
|
-
return new GithubIssueSink(api, config.repo, options.log);
|
|
6033
|
+
return new GithubIssueSink(api, config.repo, options.log, options.botName);
|
|
5916
6034
|
}
|
|
5917
6035
|
|
|
5918
6036
|
// packages/runtime/src/github/feedback-worker.ts
|
|
@@ -6039,11 +6157,16 @@ export {
|
|
|
6039
6157
|
IdentityCredentialClient,
|
|
6040
6158
|
InvalidToken,
|
|
6041
6159
|
LAG_WINDOW_MS,
|
|
6160
|
+
LEGACY_METRIC_PREFIX,
|
|
6161
|
+
LEGACY_MODEL_SETTING_PREFIX,
|
|
6042
6162
|
LEGACY_SETTING_PREFIX,
|
|
6043
6163
|
LINK_HASH_LABEL,
|
|
6044
6164
|
MAX_BODY_BYTES,
|
|
6045
6165
|
MAX_DEVICE_WAIT_SECONDS,
|
|
6046
6166
|
MAX_SKEW_SECONDS,
|
|
6167
|
+
METRIC_PREFIX,
|
|
6168
|
+
MODEL_SETTINGS,
|
|
6169
|
+
MODEL_SETTING_PREFIX,
|
|
6047
6170
|
MultiFernet,
|
|
6048
6171
|
NOT_BOUND_TTL_SECONDS,
|
|
6049
6172
|
PREFIX,
|
|
@@ -6076,6 +6199,7 @@ export {
|
|
|
6076
6199
|
hashLinkCode,
|
|
6077
6200
|
healthzRoute,
|
|
6078
6201
|
json,
|
|
6202
|
+
labelDescription,
|
|
6079
6203
|
legacySettings,
|
|
6080
6204
|
lineLogger,
|
|
6081
6205
|
linkHashKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ClawPort, type Clock, type Logger } from "@primusclaw/personal-agent";
|
|
2
2
|
import { type Fetch } from "./http.js";
|
|
3
3
|
/** What Claw's audit trail calls this client by default (`X-Claw-Client`). */
|
|
4
|
-
export declare const DEFAULT_CLIENT_LABEL = "
|
|
4
|
+
export declare const DEFAULT_CLIENT_LABEL = "personal-agent";
|
|
5
5
|
/** How the Claw client is made (from the worker's settings). */
|
|
6
6
|
export interface ClawClientOptions {
|
|
7
7
|
/** CLAW_API_URL, without a trailing slash. */
|
|
@@ -10,7 +10,7 @@ export interface ClawClientOptions {
|
|
|
10
10
|
readonly logger?: Logger;
|
|
11
11
|
/** CLAW_PLUGIN_ID (null: plain sessions). */
|
|
12
12
|
readonly pluginId?: number | null;
|
|
13
|
-
/**
|
|
13
|
+
/** PERSONAL_AGENT_MODEL ("" sends none). */
|
|
14
14
|
readonly model?: string;
|
|
15
15
|
/** CLAW_RULE_TOOL_ID (null: no rule rides on a message). */
|
|
16
16
|
readonly ruleToolId?: number | null;
|
|
@@ -11,7 +11,7 @@ export declare const CHANGES_MAX_BYTES = 1048576;
|
|
|
11
11
|
export interface MessageDefaults {
|
|
12
12
|
/** CLAW_PLUGIN_ID, named as the web client names it (`pluginId`); null none. */
|
|
13
13
|
readonly pluginId: number | null;
|
|
14
|
-
/**
|
|
14
|
+
/** PERSONAL_AGENT_MODEL: what a new session asks for when its caller names none ("" none). */
|
|
15
15
|
readonly model: string;
|
|
16
16
|
/** The reply-style rule, when a rule tool is configured. */
|
|
17
17
|
readonly rule: StyleRule | null;
|
|
@@ -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
|
+
}
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* uses `WORKER_IDENTITY_*` for its own Azure identity, and a surface's own settings keep the surface's prefix
|
|
7
7
|
* (`TEAMS_STREAMING`, `TEAMS_AI_LABEL`), so the prefix says whose a setting is.
|
|
8
8
|
*
|
|
9
|
-
* The
|
|
10
|
-
*
|
|
9
|
+
* The model settings were first named after the bot's earlier default name; they now carry `PERSONAL_AGENT_`, and the
|
|
10
|
+
* earlier names are read as aliases the same way.
|
|
11
|
+
*
|
|
12
|
+
* The rule, for every pair: the new name when it is set and not blank; else the old name when it is set; else the new
|
|
13
|
+
* name (unset or blank). A message about a value names the variable it was read from. An old name is only ever read.
|
|
11
14
|
*/
|
|
12
15
|
import { type Logger } from "@primusclaw/personal-agent";
|
|
13
16
|
/** The prefix of the worker's own settings. */
|
|
@@ -16,28 +19,34 @@ export declare const SETTING_PREFIX = "PA_";
|
|
|
16
19
|
export declare const LEGACY_SETTING_PREFIX = "TEAMS_";
|
|
17
20
|
/** The settings read under both prefixes, by their name after the prefix. */
|
|
18
21
|
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
|
|
22
|
+
/** The prefix of the model settings. */
|
|
23
|
+
export declare const MODEL_SETTING_PREFIX = "PERSONAL_AGENT_";
|
|
24
|
+
/** The prefix the model settings were first written with, still read as an alias. */
|
|
25
|
+
export declare const LEGACY_MODEL_SETTING_PREFIX = "CLAWY_";
|
|
26
|
+
/** The model settings, by their name after the prefix. */
|
|
27
|
+
export declare const MODEL_SETTINGS: readonly ["MODEL", "FALLBACK_MODEL", "REVIEW_MODEL"];
|
|
28
|
+
/** The pairs: new name -> the old name still read when it is not set. */
|
|
20
29
|
export declare const SETTING_ALIASES: ReadonlyMap<string, string>;
|
|
21
30
|
type Env = Readonly<Record<string, string | undefined>>;
|
|
22
31
|
/**
|
|
23
32
|
* 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
|
-
*
|
|
33
|
+
* new name when it is set and not blank, else the old name when it is present, else the new name.
|
|
25
34
|
*/
|
|
26
35
|
export declare function settingSource(env: Env, name: string): string;
|
|
27
36
|
/** The value of a setting under the alias rule (undefined: neither name is present). */
|
|
28
37
|
export declare function settingValue(env: Env, name: string): string | undefined;
|
|
29
|
-
/** A legacy name in use: the one read, or one set beside its
|
|
38
|
+
/** A legacy name in use: the one read, or one set beside its new name and ignored. */
|
|
30
39
|
export interface LegacySetting {
|
|
31
40
|
readonly legacy: string;
|
|
32
41
|
readonly neutral: string;
|
|
33
|
-
/** The
|
|
42
|
+
/** The new name is set too, so the old value is not read. */
|
|
34
43
|
readonly ignored: boolean;
|
|
35
44
|
}
|
|
36
|
-
/** The
|
|
45
|
+
/** The old names this environment sets (not blank) of the settings that now carry a new name. */
|
|
37
46
|
export declare function legacySettings(env: Env): LegacySetting[];
|
|
38
47
|
/**
|
|
39
|
-
* One warning at start for the
|
|
40
|
-
*
|
|
48
|
+
* One warning at start for the old names in use, naming the new name of each (never a value: some are secrets); and one
|
|
49
|
+
* for each old name that is set beside its new name and so not read. Nothing when none is in use.
|
|
41
50
|
*/
|
|
42
51
|
export declare function warnLegacySettings(env: Env, logger: Logger): void;
|
|
43
52
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ALIASED_SETTINGS, LEGACY_SETTING_PREFIX, SETTING_ALIASES, SETTING_PREFIX, legacySettings, settingSource, settingValue, warnLegacySettings, type LegacySetting, } from "./aliases.js";
|
|
1
|
+
export { ALIASED_SETTINGS, LEGACY_MODEL_SETTING_PREFIX, LEGACY_SETTING_PREFIX, MODEL_SETTING_PREFIX, MODEL_SETTINGS, SETTING_ALIASES, SETTING_PREFIX, legacySettings, settingSource, settingValue, warnLegacySettings, type LegacySetting, } from "./aliases.js";
|
|
2
2
|
export { EnvReader, pyRepr, withoutTrailingSlash, type Env } from "./env.js";
|
|
3
3
|
export { ENV_NAMES, EnvSecretSource, SECRET_SETTING_NAMES, secretsSourceOf, wantedSecrets } from "./secrets.js";
|
|
4
4
|
export { ASSISTANT_REPLY_WINDOW_SECONDS, GITHUB_CLI_CLIENT_ID, readSettings } from "./settings.js";
|
|
@@ -21,6 +21,8 @@ export interface FeedbackSinkOptions {
|
|
|
21
21
|
/** Seconds since the epoch. */
|
|
22
22
|
readonly clock?: () => number;
|
|
23
23
|
readonly log: Logger;
|
|
24
|
+
/** The bot's name in this deployment (`Settings.botName`). */
|
|
25
|
+
readonly botName: string;
|
|
24
26
|
}
|
|
25
27
|
/** The sink feedback delivers to, or undefined when nothing is configured (reports are then only recorded). */
|
|
26
28
|
export declare function feedbackSink(config: FeedbackConfig, options: FeedbackSinkOptions): FeedbackSink | undefined;
|
|
@@ -6,14 +6,20 @@
|
|
|
6
6
|
import { type FeedbackSink, type IssueRef, type Logger, type Result, type SinkError } from "@primusclaw/personal-agent";
|
|
7
7
|
import { GithubApi } from "./api.js";
|
|
8
8
|
export declare const FEEDBACK_LABEL = "clawy-feedback";
|
|
9
|
+
/** The feedback label's description, naming the bot by the deployment's name. */
|
|
10
|
+
export declare function labelDescription(botName: string): string;
|
|
9
11
|
export declare class GithubIssueSink implements FeedbackSink {
|
|
10
12
|
private readonly api;
|
|
11
13
|
private readonly log;
|
|
14
|
+
/** The bot's name in this deployment (`Settings.botName`), for the label's description. */
|
|
15
|
+
private readonly botName;
|
|
12
16
|
private labelReady;
|
|
13
17
|
private readonly repoPath;
|
|
14
18
|
constructor(api: GithubApi,
|
|
15
19
|
/** `owner/name`. */
|
|
16
|
-
repo: string, log: Logger
|
|
20
|
+
repo: string, log: Logger,
|
|
21
|
+
/** The bot's name in this deployment (`Settings.botName`), for the label's description. */
|
|
22
|
+
botName: string);
|
|
17
23
|
createIssue(title: string, body: string, labels: readonly string[]): Promise<Result<IssueRef, SinkError>>;
|
|
18
24
|
findIssue(marker: string, sinceEpochMs: number): Promise<Result<IssueRef | undefined, SinkError>>;
|
|
19
25
|
hasComment(issue: number, marker: string, sinceEpochMs: number): Promise<Result<boolean, SinkError>>;
|
|
@@ -10,6 +10,8 @@ export declare const INTENT_MS = 10000;
|
|
|
10
10
|
export interface IntentReaderOptions {
|
|
11
11
|
readonly baseUrl: string;
|
|
12
12
|
readonly model: string;
|
|
13
|
+
/** The bot's name in this deployment (`Settings.botName`): the prompts say who the message was sent to. */
|
|
14
|
+
readonly botName: string;
|
|
13
15
|
readonly logger: Logger;
|
|
14
16
|
readonly fetch?: FetchLike;
|
|
15
17
|
readonly timeoutMs?: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { formatNumber, pyFloatRepr, round3 } from "./exposition.js";
|
|
2
|
-
export { ALERTED, CONTENT_TYPE, EVENT_BUCKETS, HELP, LAG_WINDOW_MS, PrometheusMetrics } from "./prometheus-metrics.js";
|
|
2
|
+
export { ALERTED, CONTENT_TYPE, EVENT_BUCKETS, HELP, LAG_WINDOW_MS, LEGACY_METRIC_PREFIX, METRIC_PREFIX, PrometheusMetrics, } from "./prometheus-metrics.js";
|
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
* The worker's counters for the operator's alerts, in memory (they start from zero when the worker restarts), written in
|
|
3
3
|
* the Prometheus text format for `GET /metrics` on its own port (the listener is the channel's assembly). The text is
|
|
4
4
|
* the Python worker's, line for line: the alert queries and dashboards read these names and labels.
|
|
5
|
+
*
|
|
6
|
+
* Every series is written twice for one release: under its `personal_agent_` name, then under the name an earlier release used
|
|
7
|
+
* (`LEGACY_METRIC_PREFIX`), so that alert rules and dashboards can move to the new names after the new build is live. The old
|
|
8
|
+
* names are deprecated and go away in the next minor release.
|
|
5
9
|
*/
|
|
6
10
|
import { type Clock, type MetricsPort, type SecurityEventRecord } from "@primusclaw/personal-agent";
|
|
7
11
|
export declare const CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
|
|
8
|
-
/**
|
|
12
|
+
/** The prefix of every metric's name. */
|
|
13
|
+
export declare const METRIC_PREFIX = "personal_agent_";
|
|
14
|
+
/** The prefix an earlier release wrote the same metrics under, still written beside the new names for one release. */
|
|
15
|
+
export declare const LEGACY_METRIC_PREFIX = "clawy_";
|
|
16
|
+
/** `personal_agent_inbound_lag_max_ms`: the longest wait of the messages handled in this many milliseconds. */
|
|
9
17
|
export declare const LAG_WINDOW_MS = 60000;
|
|
10
18
|
/** Seconds; the 5 s bucket is the "card within 5 s" line. */
|
|
11
19
|
export declare const EVENT_BUCKETS: readonly [0.5, 1, 2, 3, 5, 10, 30, 60];
|
|
12
20
|
type Labels = ReadonlyArray<readonly [string, string]>;
|
|
13
21
|
/** Series written as 0 from the start, so that each one an alert reads exists before its first event. */
|
|
14
22
|
export declare const ALERTED: ReadonlyArray<readonly [string, Labels]>;
|
|
15
|
-
/** Every metric: its type and help text. */
|
|
23
|
+
/** Every metric (by its `personal_agent_` name): its type and help text. */
|
|
16
24
|
export declare const HELP: Readonly<Record<string, readonly [string, string]>>;
|
|
17
25
|
/** The MetricsPort of a worker, kept in memory and written in the Prometheus text format. */
|
|
18
26
|
export declare class PrometheusMetrics implements MetricsPort {
|
|
@@ -39,8 +47,11 @@ export declare class PrometheusMetrics implements MetricsPort {
|
|
|
39
47
|
/** The longest wait of the messages handled in the window, in milliseconds (0: none). */
|
|
40
48
|
lagMaxMs(): number;
|
|
41
49
|
private expire;
|
|
42
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* All series in the Prometheus text exposition format (version 0.0.4): under their names, then, with the same values and
|
|
52
|
+
* help, under the deprecated names of an earlier release (that half is the text it wrote, byte for byte).
|
|
53
|
+
*/
|
|
43
54
|
render(): string;
|
|
44
|
-
private
|
|
55
|
+
private renderAs;
|
|
45
56
|
}
|
|
46
57
|
export {};
|
|
@@ -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
|
}
|
package/dist/worker.js
CHANGED
|
@@ -48,7 +48,6 @@ function withBuildInfo(render, info) {
|
|
|
48
48
|
|
|
49
49
|
// packages/runtime/src/worker/features.ts
|
|
50
50
|
import {
|
|
51
|
-
BOT_NAME,
|
|
52
51
|
chatTurnKey,
|
|
53
52
|
contextInterceptor,
|
|
54
53
|
Guardrails as Guardrails2,
|
|
@@ -90,6 +89,7 @@ import {
|
|
|
90
89
|
turn as turn2,
|
|
91
90
|
WatchClicks,
|
|
92
91
|
WorkCardClicks,
|
|
92
|
+
SkillCardClicks,
|
|
93
93
|
WorkClicks
|
|
94
94
|
} from "@primusclaw/personal-agent";
|
|
95
95
|
|
|
@@ -288,6 +288,7 @@ function assistantChat(base, integrations, style, parts, hooks) {
|
|
|
288
288
|
users: settings2.assistant.users,
|
|
289
289
|
understanding: settings2.assistant.understandingUsers,
|
|
290
290
|
pluginId: settings2.claw.pluginId ?? void 0,
|
|
291
|
+
assistantName: settings2.botName,
|
|
291
292
|
legacyTurn: (aadId) => hooks.legacyTurn(aadId),
|
|
292
293
|
files: messageFiles(base.surface),
|
|
293
294
|
onFilesDropped: (path, count) => {
|
|
@@ -315,7 +316,11 @@ function assistantParts(base, inputs) {
|
|
|
315
316
|
const { store, claw, logger, exchange } = base;
|
|
316
317
|
const subs = keeper(base, notifyUrl);
|
|
317
318
|
const receipts = new Receipts(base.clock, logger, () => style.assistantReceipt);
|
|
318
|
-
const directChat = new DirectChat(
|
|
319
|
+
const directChat = new DirectChat(
|
|
320
|
+
base.settings.directChat.enabled,
|
|
321
|
+
base.settings.directChat.users,
|
|
322
|
+
base.settings.botName
|
|
323
|
+
);
|
|
319
324
|
const late = {};
|
|
320
325
|
const board = new Board({
|
|
321
326
|
store,
|
|
@@ -351,7 +356,13 @@ function assistantParts(base, inputs) {
|
|
|
351
356
|
const watch = new WatchClicks({ store, claw: claw.workItems, exchange, logger });
|
|
352
357
|
const linked = (userId) => store.links.getKey(userId) !== null;
|
|
353
358
|
const choices = new AssistantChoiceClicks({ store, deliver: (message) => hooks.typed(message), logger });
|
|
354
|
-
const
|
|
359
|
+
const skillCards = new SkillCardClicks({ store, skills: claw.skills, logger });
|
|
360
|
+
const clicks = [
|
|
361
|
+
new WorkCardClicks(work, watch, exchange, linked, logger),
|
|
362
|
+
actionClicks(actions),
|
|
363
|
+
choices,
|
|
364
|
+
skillCards
|
|
365
|
+
];
|
|
355
366
|
return { subs, chat: assistant, board, receipts, directChat, actions, clicks };
|
|
356
367
|
}
|
|
357
368
|
|
|
@@ -424,7 +435,7 @@ function proactiveParts(base, style, assistant, errors, router) {
|
|
|
424
435
|
clock: base.clock,
|
|
425
436
|
logger: base.logger,
|
|
426
437
|
publicEvent: (event) => publicRunEvent(event, errors, (text) => looksLikeServiceError(text) || looksInternal(text)),
|
|
427
|
-
botName:
|
|
438
|
+
botName: settings2.botName,
|
|
428
439
|
...router === void 0 ? {} : { identityAfterRefusal: identityAfterRefusal(base, router) }
|
|
429
440
|
};
|
|
430
441
|
const proactive = new Proactive(deps);
|
|
@@ -506,7 +517,7 @@ function remoteAgents(base, inputs) {
|
|
|
506
517
|
windowDefault: switches.remoteWindow,
|
|
507
518
|
timings: REMOTE_FOLLOW_TIMINGS,
|
|
508
519
|
watchTimings: REMOTE_WATCH_TIMINGS,
|
|
509
|
-
botName:
|
|
520
|
+
botName: settings2.botName,
|
|
510
521
|
streaming: base.surface.caps.streaming
|
|
511
522
|
},
|
|
512
523
|
claw: claw.remoteAgents,
|
|
@@ -628,6 +639,7 @@ function reviewDeps(base, inputs, host) {
|
|
|
628
639
|
intent: review.intentModel ? new GatewayIntentReader({
|
|
629
640
|
baseUrl: `${settings2.safeApiUrl}/llm-proxy/v1`,
|
|
630
641
|
model: review.intentModel,
|
|
642
|
+
botName: settings2.botName,
|
|
631
643
|
logger,
|
|
632
644
|
fetch
|
|
633
645
|
}) : void 0,
|
|
@@ -646,7 +658,8 @@ function reviewDeps(base, inputs, host) {
|
|
|
646
658
|
restoreRef: (stored) => shape.restoreRef(stored),
|
|
647
659
|
owners: review.owners,
|
|
648
660
|
installUrl: shape.installHintUrl,
|
|
649
|
-
defaultModel: settings2.models.review
|
|
661
|
+
defaultModel: settings2.models.review,
|
|
662
|
+
botName: settings2.botName
|
|
650
663
|
};
|
|
651
664
|
}
|
|
652
665
|
function reviewParts(base, inputs, assistant) {
|
|
@@ -806,6 +819,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
806
819
|
import {
|
|
807
820
|
chatCredentialOf,
|
|
808
821
|
DailyBrief,
|
|
822
|
+
SkillsCommand,
|
|
809
823
|
FeedbackFlow,
|
|
810
824
|
FeedbackReporting,
|
|
811
825
|
FeedbackService,
|
|
@@ -863,7 +877,7 @@ function feedbackService(base, mask2) {
|
|
|
863
877
|
return pyStrip3(state.answer);
|
|
864
878
|
}
|
|
865
879
|
},
|
|
866
|
-
wording: { botName:
|
|
880
|
+
wording: { botName: settings2.botName, channelName: base.shape.channelName },
|
|
867
881
|
publicBaseUrl: settings2.publicBaseUrl,
|
|
868
882
|
worker: workerInfoFromEnv(env, {
|
|
869
883
|
pluginId: settings2.claw.pluginId === null ? "" : String(settings2.claw.pluginId),
|
|
@@ -906,7 +920,8 @@ function w8Parts(base, options) {
|
|
|
906
920
|
users: [...settings2.observeUsers],
|
|
907
921
|
conversationOf: conversationFor(base),
|
|
908
922
|
pluginId: settings2.claw.pluginId ?? void 0,
|
|
909
|
-
log: logger
|
|
923
|
+
log: logger,
|
|
924
|
+
botName: settings2.botName
|
|
910
925
|
});
|
|
911
926
|
const groupContext = new GroupContext({
|
|
912
927
|
settings: settings2.groupContext,
|
|
@@ -927,11 +942,12 @@ function w8Parts(base, options) {
|
|
|
927
942
|
});
|
|
928
943
|
return {
|
|
929
944
|
service,
|
|
930
|
-
flow: new FeedbackFlow({ reports: store.feedback, reporting, service, log: logger }),
|
|
945
|
+
flow: new FeedbackFlow({ reports: store.feedback, reporting, service, log: logger, botName: settings2.botName }),
|
|
931
946
|
thumbs,
|
|
932
947
|
observer,
|
|
933
948
|
groupContext,
|
|
934
949
|
brief,
|
|
950
|
+
commands: [brief, new SkillsCommand({ store, skills: claw.skills, logger })],
|
|
935
951
|
reportView: (userId, scope) => {
|
|
936
952
|
const view = service.reportView(userId, scope);
|
|
937
953
|
return reportMessage(view.promptId, view.group);
|
|
@@ -966,7 +982,7 @@ function refuseMissing(base) {
|
|
|
966
982
|
const { settings: settings2, plugins } = base;
|
|
967
983
|
if (settings2.models.fallback !== "" && plugins.modelRefusalPolicy === noModelRefusalPolicy)
|
|
968
984
|
throw new StartupError(
|
|
969
|
-
"
|
|
985
|
+
"PERSONAL_AGENT_FALLBACK_MODEL is set, but no plugin says when a model refused (modelRefusalPolicy): the fallback would never be used"
|
|
970
986
|
);
|
|
971
987
|
if (settings2.onBehalfUsers.size > 0 && !plugins.routeExtensions.some((route) => route.method === "POST" && route.path === ON_BEHALF_PATH))
|
|
972
988
|
throw new StartupError(
|
|
@@ -1006,7 +1022,7 @@ function routerDeps(base, built, errors) {
|
|
|
1006
1022
|
return {
|
|
1007
1023
|
config: {
|
|
1008
1024
|
publicBaseUrl: settings2.publicBaseUrl,
|
|
1009
|
-
botName:
|
|
1025
|
+
botName: settings2.botName,
|
|
1010
1026
|
pluginId: settings2.claw.pluginId === null ? "" : String(settings2.claw.pluginId),
|
|
1011
1027
|
model: settings2.models.chat,
|
|
1012
1028
|
reviewModel: settings2.models.review,
|
|
@@ -1187,7 +1203,7 @@ function buildFeatures(given) {
|
|
|
1187
1203
|
lateReview.handoff = review?.handoff;
|
|
1188
1204
|
const reviewHandlers = review?.service.routeHandlers();
|
|
1189
1205
|
const groupInterceptors = [
|
|
1190
|
-
contextInterceptor(w8.groupContext),
|
|
1206
|
+
contextInterceptor(w8.groupContext, base.settings.botName),
|
|
1191
1207
|
w8.observer.interceptor,
|
|
1192
1208
|
w8.flow.interceptor
|
|
1193
1209
|
];
|
|
@@ -1196,7 +1212,7 @@ function buildFeatures(given) {
|
|
|
1196
1212
|
personalInterceptors: [...reviewHandlers?.personalInterceptors ?? [], w8.flow.interceptor],
|
|
1197
1213
|
groupInterceptors,
|
|
1198
1214
|
commands: [
|
|
1199
|
-
w8.
|
|
1215
|
+
...w8.commands,
|
|
1200
1216
|
...switches.remoteAgents ? [new TerminalApprovalsCommand(base.claw.remoteAgents)] : [],
|
|
1201
1217
|
...reviewHandlers?.commands ?? []
|
|
1202
1218
|
],
|
|
@@ -1320,7 +1336,12 @@ function platformPlugins(plugins, deps) {
|
|
|
1320
1336
|
}) : plugins.identityLookup;
|
|
1321
1337
|
const keyRevoker = plugins.keyRevoker === noKeyRevoker ? new HttpKeyRevoker(settings2.safeApiUrl, (url, init) => deps.fetch(url, init)) : plugins.keyRevoker;
|
|
1322
1338
|
const config = feedbackConfigFromEnv(env, secrets.get("FEEDBACK_GITHUB_APP_KEY") ?? "");
|
|
1323
|
-
const sink = plugins.feedbackSink === noFeedbackSink2 ? feedbackSink(config, {
|
|
1339
|
+
const sink = plugins.feedbackSink === noFeedbackSink2 ? feedbackSink(config, {
|
|
1340
|
+
fetch: (url, init) => deps.fetch(url, init),
|
|
1341
|
+
clock: deps.now,
|
|
1342
|
+
log: logger,
|
|
1343
|
+
botName: settings2.botName
|
|
1344
|
+
}) ?? noFeedbackSink2 : plugins.feedbackSink;
|
|
1324
1345
|
if (sink === noFeedbackSink2) logger.info("feedback: not configured; reports are stored only");
|
|
1325
1346
|
else if (plugins.feedbackSink === noFeedbackSink2)
|
|
1326
1347
|
logger.info("feedback: issues go to the configured repository", { repo: config.repo });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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.10.0",
|
|
37
37
|
"fastify": "^5.12.8",
|
|
38
38
|
"zod": "^4.6.7"
|
|
39
39
|
}
|