@primusclaw/personal-agent-runtime 0.10.4 → 0.12.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 +189 -2
- package/dist/sqlite/schema.sql +4 -0
- package/dist/types/claw/remote-agents.d.ts +2 -1
- package/dist/types/metrics/index.d.ts +1 -1
- package/dist/types/metrics/prometheus-metrics.d.ts +10 -0
- package/dist/types/sqlite/github-repository.d.ts +22 -2
- package/dist/worker.js +20 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -555,6 +555,18 @@ var HttpRemoteAgents = class {
|
|
|
555
555
|
async setApprovals(key2, enabled) {
|
|
556
556
|
return enabledOf(await this.#call("PUT", "/approvals", key2, { enabled }));
|
|
557
557
|
}
|
|
558
|
+
async muteTerminal(key2, item2, muted) {
|
|
559
|
+
const data = anyDataOf(await this.#call("PUT", "/approvals/mutes", key2, { item: item2, muted }), "a terminal mute");
|
|
560
|
+
const d = data !== null && typeof data === "object" ? data : {};
|
|
561
|
+
if (typeof d["muted"] !== "boolean" || typeof d["item"] !== "number")
|
|
562
|
+
throw new ClawAnswerInvalid4("a terminal mute has no item or muted");
|
|
563
|
+
return {
|
|
564
|
+
item: d["item"],
|
|
565
|
+
muted: d["muted"],
|
|
566
|
+
machine: typeof d["machine"] === "string" ? d["machine"] : "",
|
|
567
|
+
title: typeof d["title"] === "string" ? d["title"] : ""
|
|
568
|
+
};
|
|
569
|
+
}
|
|
558
570
|
async pair(key2) {
|
|
559
571
|
return read(
|
|
560
572
|
remotePairingSchema,
|
|
@@ -1595,6 +1607,28 @@ var HELP = {
|
|
|
1595
1607
|
"Files a user sent that did not reach Claw, by where they were dropped."
|
|
1596
1608
|
]
|
|
1597
1609
|
};
|
|
1610
|
+
var HELP_CURRENT_ONLY = {
|
|
1611
|
+
personal_agent_probe_total: [
|
|
1612
|
+
"counter",
|
|
1613
|
+
"Delivery probes the worker answered, by outcome: answered (the relay's ack came back) or unanswered."
|
|
1614
|
+
],
|
|
1615
|
+
personal_agent_probe_feedback_ms: [
|
|
1616
|
+
"gauge",
|
|
1617
|
+
"Milliseconds from the last probe's sending (by the ingress) to the worker's answer queued for the relay."
|
|
1618
|
+
],
|
|
1619
|
+
personal_agent_probe_reply_ms: [
|
|
1620
|
+
"gauge",
|
|
1621
|
+
"Milliseconds from the last answered probe's sending to the relay's ack of the answer reaching the worker."
|
|
1622
|
+
],
|
|
1623
|
+
personal_agent_probe_last_answered_seconds: [
|
|
1624
|
+
"gauge",
|
|
1625
|
+
"Unix time of the last answered probe (0: none since the worker started)."
|
|
1626
|
+
],
|
|
1627
|
+
personal_agent_inbound_rearmed_total: [
|
|
1628
|
+
"counter",
|
|
1629
|
+
"Times the inbound receivers' connection was re-opened because a call on the broker hung (once per connection)."
|
|
1630
|
+
]
|
|
1631
|
+
};
|
|
1598
1632
|
function compareTuples(a, b) {
|
|
1599
1633
|
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
1600
1634
|
const x = a[i] ?? "";
|
|
@@ -1624,6 +1658,8 @@ var PrometheusMetrics = class {
|
|
|
1624
1658
|
/** (when, lag): decreasing lags, the sliding-window maximum. */
|
|
1625
1659
|
lags = [];
|
|
1626
1660
|
/** Event type -> (receipt to sent, occurred to sent), each written from the start. */
|
|
1661
|
+
probes = { answered: 0, unanswered: 0, feedbackMs: 0, replyMs: 0, answeredAt: 0 };
|
|
1662
|
+
rearmed = 0;
|
|
1627
1663
|
eventTimes = new Map(
|
|
1628
1664
|
DELIVERED_EVENT_TYPES.map((t) => [t, [new Histogram(EVENT_BUCKETS), new Histogram(EVENT_BUCKETS)]])
|
|
1629
1665
|
);
|
|
@@ -1668,6 +1704,23 @@ var PrometheusMetrics = class {
|
|
|
1668
1704
|
if (current === void 0 || count <= 0) return;
|
|
1669
1705
|
this.dropped.set(path, current + Math.trunc(count));
|
|
1670
1706
|
}
|
|
1707
|
+
probed(feedbackMs, replyMs) {
|
|
1708
|
+
const feedback = Math.max(Math.trunc(feedbackMs), 0);
|
|
1709
|
+
if (replyMs === null) {
|
|
1710
|
+
this.probes = { ...this.probes, unanswered: this.probes.unanswered + 1, feedbackMs: feedback };
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
this.probes = {
|
|
1714
|
+
answered: this.probes.answered + 1,
|
|
1715
|
+
unanswered: this.probes.unanswered,
|
|
1716
|
+
feedbackMs: feedback,
|
|
1717
|
+
replyMs: Math.max(Math.trunc(replyMs), 0),
|
|
1718
|
+
answeredAt: Math.trunc(this.clock.epochMs() / 1e3)
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
inboundRearmed() {
|
|
1722
|
+
this.rearmed += 1;
|
|
1723
|
+
}
|
|
1671
1724
|
/** The longest wait of the messages handled in the window, in milliseconds (0: none). */
|
|
1672
1725
|
lagMaxMs() {
|
|
1673
1726
|
this.expire(this.clock.monotonicMs());
|
|
@@ -1682,7 +1735,28 @@ var PrometheusMetrics = class {
|
|
|
1682
1735
|
*/
|
|
1683
1736
|
render() {
|
|
1684
1737
|
const lagMaxMs = this.lagMaxMs();
|
|
1685
|
-
return this.renderAs(METRIC_PREFIX, lagMaxMs) + this.renderAs(LEGACY_METRIC_PREFIX, lagMaxMs);
|
|
1738
|
+
return this.renderAs(METRIC_PREFIX, lagMaxMs) + this.renderAs(LEGACY_METRIC_PREFIX, lagMaxMs) + this.renderCurrentOnly();
|
|
1739
|
+
}
|
|
1740
|
+
renderCurrentOnly() {
|
|
1741
|
+
const lines = [];
|
|
1742
|
+
const head2 = (name) => {
|
|
1743
|
+
const [kind, text3] = own2(HELP_CURRENT_ONLY, name) ?? ["untyped", ""];
|
|
1744
|
+
lines.push(`# HELP ${name} ${text3}`, `# TYPE ${name} ${kind}`);
|
|
1745
|
+
};
|
|
1746
|
+
head2("personal_agent_probe_total");
|
|
1747
|
+
lines.push(`personal_agent_probe_total{outcome="answered"} ${String(this.probes.answered)}`);
|
|
1748
|
+
lines.push(`personal_agent_probe_total{outcome="unanswered"} ${String(this.probes.unanswered)}`);
|
|
1749
|
+
const gauges = [
|
|
1750
|
+
["personal_agent_probe_feedback_ms", this.probes.feedbackMs],
|
|
1751
|
+
["personal_agent_probe_reply_ms", this.probes.replyMs],
|
|
1752
|
+
["personal_agent_probe_last_answered_seconds", this.probes.answeredAt],
|
|
1753
|
+
["personal_agent_inbound_rearmed_total", this.rearmed]
|
|
1754
|
+
];
|
|
1755
|
+
for (const [name, value] of gauges) {
|
|
1756
|
+
head2(name);
|
|
1757
|
+
lines.push(`${name} ${String(value)}`);
|
|
1758
|
+
}
|
|
1759
|
+
return lines.join("\n") + "\n";
|
|
1686
1760
|
}
|
|
1687
1761
|
renderAs(prefix, lagMaxMs) {
|
|
1688
1762
|
const lines = [];
|
|
@@ -3359,7 +3433,8 @@ var SqliteFeedbackRepository = class {
|
|
|
3359
3433
|
|
|
3360
3434
|
// packages/runtime/src/sqlite/github-repository.ts
|
|
3361
3435
|
import {
|
|
3362
|
-
ACTING_SESSION_KEEP_SECONDS
|
|
3436
|
+
ACTING_SESSION_KEEP_SECONDS,
|
|
3437
|
+
REVIEW_ONBOARDING_KEEP_SECONDS
|
|
3363
3438
|
} from "@primusclaw/personal-agent";
|
|
3364
3439
|
var CONFIRMATION_COLUMNS = "confirmation_id, session_id, actor_aad, requester_aad, repo, pr, reference_json, expires_at, state, created_at, kind, event";
|
|
3365
3440
|
function confirmation(row) {
|
|
@@ -3378,6 +3453,23 @@ function confirmation(row) {
|
|
|
3378
3453
|
event: col.str(row, "event")
|
|
3379
3454
|
};
|
|
3380
3455
|
}
|
|
3456
|
+
var ONBOARDING_DONE = 1;
|
|
3457
|
+
var ONBOARDING_DECLINED = 2;
|
|
3458
|
+
var ONBOARDING_DECLINED_TELLING = 3;
|
|
3459
|
+
var ONBOARDING_COLUMNS = "onboarding_id, actor_aad, requester_aad, pulls, request_json, told_rank, done, created_at";
|
|
3460
|
+
function onboarding(row) {
|
|
3461
|
+
return {
|
|
3462
|
+
onboardingId: col.str(row, "onboarding_id"),
|
|
3463
|
+
actorId: col.str(row, "actor_aad"),
|
|
3464
|
+
requesterId: col.str(row, "requester_aad"),
|
|
3465
|
+
pulls: col.str(row, "pulls"),
|
|
3466
|
+
request: storedObject(col.str(row, "request_json")) ?? {},
|
|
3467
|
+
toldRank: col.num(row, "told_rank"),
|
|
3468
|
+
done: col.num(row, "done") === ONBOARDING_DONE,
|
|
3469
|
+
declined: col.num(row, "done") >= ONBOARDING_DECLINED,
|
|
3470
|
+
createdAt: col.num(row, "created_at")
|
|
3471
|
+
};
|
|
3472
|
+
}
|
|
3381
3473
|
var SqliteGithubConfirmationRepository = class {
|
|
3382
3474
|
constructor(ctx) {
|
|
3383
3475
|
this.ctx = ctx;
|
|
@@ -3508,6 +3600,100 @@ var SqliteReviewDelegationRepository = class {
|
|
|
3508
3600
|
releaseGithubNotice(userId, kind) {
|
|
3509
3601
|
this.ctx.db.run("DELETE FROM github_notices WHERE aad_id = ? AND kind = ?", userId, kind);
|
|
3510
3602
|
}
|
|
3603
|
+
saveReviewOnboarding(o) {
|
|
3604
|
+
const { db } = this.ctx;
|
|
3605
|
+
const now = this.ctx.now();
|
|
3606
|
+
db.run("DELETE FROM review_onboarding WHERE created_at < ?", now - REVIEW_ONBOARDING_KEEP_SECONDS);
|
|
3607
|
+
db.run(
|
|
3608
|
+
"INSERT INTO review_onboarding (onboarding_id, actor_aad, requester_aad, pulls, request_json, told_rank, created_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (actor_aad, requester_aad, pulls) DO UPDATE SET onboarding_id = excluded.onboarding_id, request_json = excluded.request_json, told_rank = excluded.told_rank, done = 0, created_at = excluded.created_at",
|
|
3609
|
+
o.onboardingId,
|
|
3610
|
+
o.actorId,
|
|
3611
|
+
o.requesterId,
|
|
3612
|
+
o.pulls,
|
|
3613
|
+
pyJsonDumps(o.request),
|
|
3614
|
+
o.toldRank,
|
|
3615
|
+
now
|
|
3616
|
+
);
|
|
3617
|
+
const row = db.get(
|
|
3618
|
+
`SELECT ${ONBOARDING_COLUMNS} FROM review_onboarding WHERE actor_aad = ? AND requester_aad = ? AND pulls = ?`,
|
|
3619
|
+
o.actorId,
|
|
3620
|
+
o.requesterId,
|
|
3621
|
+
o.pulls
|
|
3622
|
+
);
|
|
3623
|
+
if (row === void 0) throw new Error("the review onboarding row was not kept");
|
|
3624
|
+
return onboarding(row);
|
|
3625
|
+
}
|
|
3626
|
+
getReviewOnboarding(onboardingId) {
|
|
3627
|
+
const row = this.ctx.db.get(
|
|
3628
|
+
`SELECT ${ONBOARDING_COLUMNS} FROM review_onboarding WHERE onboarding_id = ? AND created_at >= ?`,
|
|
3629
|
+
onboardingId,
|
|
3630
|
+
this.ctx.now() - REVIEW_ONBOARDING_KEEP_SECONDS
|
|
3631
|
+
);
|
|
3632
|
+
return row ? onboarding(row) : null;
|
|
3633
|
+
}
|
|
3634
|
+
openReviewOnboardings(actorId) {
|
|
3635
|
+
return this.ctx.db.all(
|
|
3636
|
+
`SELECT ${ONBOARDING_COLUMNS} FROM review_onboarding WHERE actor_aad = ? AND done = 0 AND created_at >= ? ORDER BY created_at, rowid`,
|
|
3637
|
+
actorId,
|
|
3638
|
+
this.ctx.now() - REVIEW_ONBOARDING_KEEP_SECONDS
|
|
3639
|
+
).map(onboarding);
|
|
3640
|
+
}
|
|
3641
|
+
onboardingReviewers() {
|
|
3642
|
+
return this.ctx.db.all(
|
|
3643
|
+
"SELECT DISTINCT actor_aad FROM review_onboarding WHERE done = 0 AND created_at >= ? ORDER BY actor_aad",
|
|
3644
|
+
this.ctx.now() - REVIEW_ONBOARDING_KEEP_SECONDS
|
|
3645
|
+
).map((r) => col.str(r, "actor_aad"));
|
|
3646
|
+
}
|
|
3647
|
+
claimOnboardingStep(actorId, rank) {
|
|
3648
|
+
return this.ctx.db.run(
|
|
3649
|
+
"UPDATE review_onboarding SET told_rank = ? WHERE actor_aad = ? AND done = 0 AND told_rank < ? AND created_at >= ?",
|
|
3650
|
+
rank,
|
|
3651
|
+
actorId,
|
|
3652
|
+
rank,
|
|
3653
|
+
this.ctx.now() - REVIEW_ONBOARDING_KEEP_SECONDS
|
|
3654
|
+
) > 0;
|
|
3655
|
+
}
|
|
3656
|
+
releaseOnboardingStep(onboardingId, from, to) {
|
|
3657
|
+
this.ctx.db.run(
|
|
3658
|
+
"UPDATE review_onboarding SET told_rank = ? WHERE onboarding_id = ? AND told_rank = ? AND done = 0",
|
|
3659
|
+
to,
|
|
3660
|
+
onboardingId,
|
|
3661
|
+
from
|
|
3662
|
+
);
|
|
3663
|
+
}
|
|
3664
|
+
finishReviewOnboarding(onboardingId) {
|
|
3665
|
+
return this.ctx.db.run("UPDATE review_onboarding SET done = 1 WHERE onboarding_id = ? AND done = 0", onboardingId) === 1;
|
|
3666
|
+
}
|
|
3667
|
+
dropReviewOnboarding(onboardingId) {
|
|
3668
|
+
this.ctx.db.run("DELETE FROM review_onboarding WHERE onboarding_id = ?", onboardingId);
|
|
3669
|
+
}
|
|
3670
|
+
declineReviewOnboarding(onboardingId) {
|
|
3671
|
+
return this.moveOnboarding(onboardingId, 0, ONBOARDING_DECLINED);
|
|
3672
|
+
}
|
|
3673
|
+
declinedReviewOnboardings(actorId) {
|
|
3674
|
+
const since = this.ctx.now() - REVIEW_ONBOARDING_KEEP_SECONDS;
|
|
3675
|
+
const where = actorId === void 0 ? "" : " AND actor_aad = ?";
|
|
3676
|
+
return this.ctx.db.all(
|
|
3677
|
+
`SELECT ${ONBOARDING_COLUMNS} FROM review_onboarding WHERE done = ? AND created_at >= ?${where} ORDER BY created_at, rowid`,
|
|
3678
|
+
ONBOARDING_DECLINED,
|
|
3679
|
+
since,
|
|
3680
|
+
...actorId === void 0 ? [] : [actorId]
|
|
3681
|
+
).map(onboarding);
|
|
3682
|
+
}
|
|
3683
|
+
claimDeclinedOnboarding(onboardingId) {
|
|
3684
|
+
return this.moveOnboarding(onboardingId, ONBOARDING_DECLINED, ONBOARDING_DECLINED_TELLING);
|
|
3685
|
+
}
|
|
3686
|
+
releaseDeclinedOnboarding(onboardingId) {
|
|
3687
|
+
this.moveOnboarding(onboardingId, ONBOARDING_DECLINED_TELLING, ONBOARDING_DECLINED);
|
|
3688
|
+
}
|
|
3689
|
+
moveOnboarding(onboardingId, from, to) {
|
|
3690
|
+
return this.ctx.db.run(
|
|
3691
|
+
"UPDATE review_onboarding SET done = ? WHERE onboarding_id = ? AND done = ?",
|
|
3692
|
+
to,
|
|
3693
|
+
onboardingId,
|
|
3694
|
+
from
|
|
3695
|
+
) === 1;
|
|
3696
|
+
}
|
|
3511
3697
|
};
|
|
3512
3698
|
|
|
3513
3699
|
// packages/runtime/src/sqlite/idempotency-repository.ts
|
|
@@ -6150,6 +6336,7 @@ export {
|
|
|
6150
6336
|
GithubDeviceFlow,
|
|
6151
6337
|
GithubIssueSink,
|
|
6152
6338
|
HELP,
|
|
6339
|
+
HELP_CURRENT_ONLY,
|
|
6153
6340
|
HttpIdentityLookup,
|
|
6154
6341
|
HttpKeyRevoker,
|
|
6155
6342
|
HttpTokenExchange,
|
package/dist/sqlite/schema.sql
CHANGED
|
@@ -129,3 +129,7 @@ CREATE TABLE IF NOT EXISTS group_language (
|
|
|
129
129
|
conversation_id TEXT PRIMARY KEY, lang TEXT NOT NULL, updated_at REAL NOT NULL);
|
|
130
130
|
CREATE TABLE IF NOT EXISTS bound_users (
|
|
131
131
|
aad_id TEXT PRIMARY KEY, claw_user_id TEXT NOT NULL, token_hash TEXT NOT NULL, updated_at REAL NOT NULL);
|
|
132
|
+
CREATE TABLE IF NOT EXISTS review_onboarding (
|
|
133
|
+
onboarding_id TEXT PRIMARY KEY, actor_aad TEXT NOT NULL, requester_aad TEXT NOT NULL, pulls TEXT NOT NULL,
|
|
134
|
+
request_json TEXT NOT NULL, told_rank INTEGER NOT NULL DEFAULT 0, done INTEGER NOT NULL DEFAULT 0, created_at REAL NOT NULL,
|
|
135
|
+
UNIQUE (actor_aad, requester_aad, pulls));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClawCredential, type ClawRemoteAgentsPort, type JsonObject, type NewRemoteSession, type RemoteConnector, type RemoteEventRow, type RemoteHidden, type RemotePairing, type RemoteSession, type RemoteSetup, type SseEvent } from "@primusclaw/personal-agent";
|
|
1
|
+
import { type ClawCredential, type ClawRemoteAgentsPort, type JsonObject, type NewRemoteSession, type RemoteConnector, type RemoteEventRow, type RemoteHidden, type RemotePairing, type RemoteSession, type RemoteSetup, type SseEvent, type TerminalMute } from "@primusclaw/personal-agent";
|
|
2
2
|
import { type ClawHttp } from "./http.js";
|
|
3
3
|
/** `ClawRemoteAgentsPort` over Claw's HTTP API; every call names this client (`X-Claw-Client`) in Claw's audit trail. */
|
|
4
4
|
export declare class HttpRemoteAgents implements ClawRemoteAgentsPort {
|
|
@@ -12,6 +12,7 @@ export declare class HttpRemoteAgents implements ClawRemoteAgentsPort {
|
|
|
12
12
|
}): Promise<RemoteConnector[]>;
|
|
13
13
|
approvals(key: ClawCredential): Promise<boolean>;
|
|
14
14
|
setApprovals(key: ClawCredential, enabled: boolean): Promise<boolean>;
|
|
15
|
+
muteTerminal(key: ClawCredential, item: number, muted: boolean): Promise<TerminalMute>;
|
|
15
16
|
pair(key: ClawCredential): Promise<RemotePairing>;
|
|
16
17
|
hide(key: ClawCredential, connectorId: string, refs: readonly string[], hidden: boolean): Promise<RemoteHidden>;
|
|
17
18
|
revoke(key: ClawCredential, connectorId: string): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { formatNumber, pyFloatRepr, round3 } from "./exposition.js";
|
|
2
|
-
export { ALERTED, CONTENT_TYPE, EVENT_BUCKETS, HELP, LAG_WINDOW_MS, LEGACY_METRIC_PREFIX, METRIC_PREFIX, PrometheusMetrics, } from "./prometheus-metrics.js";
|
|
2
|
+
export { ALERTED, CONTENT_TYPE, EVENT_BUCKETS, HELP, HELP_CURRENT_ONLY, LAG_WINDOW_MS, LEGACY_METRIC_PREFIX, METRIC_PREFIX, PrometheusMetrics, } from "./prometheus-metrics.js";
|
|
@@ -22,6 +22,11 @@ type Labels = ReadonlyArray<readonly [string, string]>;
|
|
|
22
22
|
export declare const ALERTED: ReadonlyArray<readonly [string, Labels]>;
|
|
23
23
|
/** Every metric (by its `personal_agent_` name): its type and help text. */
|
|
24
24
|
export declare const HELP: Readonly<Record<string, readonly [string, string]>>;
|
|
25
|
+
/**
|
|
26
|
+
* The series added after the names changed: written under their `personal_agent_` names only (no earlier release wrote
|
|
27
|
+
* them), after both halves above, so that the text an earlier release wrote stays as it was.
|
|
28
|
+
*/
|
|
29
|
+
export declare const HELP_CURRENT_ONLY: Readonly<Record<string, readonly [string, string]>>;
|
|
25
30
|
/** The MetricsPort of a worker, kept in memory and written in the Prometheus text format. */
|
|
26
31
|
export declare class PrometheusMetrics implements MetricsPort {
|
|
27
32
|
private readonly clock;
|
|
@@ -35,6 +40,8 @@ export declare class PrometheusMetrics implements MetricsPort {
|
|
|
35
40
|
/** (when, lag): decreasing lags, the sliding-window maximum. */
|
|
36
41
|
private readonly lags;
|
|
37
42
|
/** Event type -> (receipt to sent, occurred to sent), each written from the start. */
|
|
43
|
+
private probes;
|
|
44
|
+
private rearmed;
|
|
38
45
|
private readonly eventTimes;
|
|
39
46
|
constructor(clock: Clock, lagWindowMs?: number);
|
|
40
47
|
/** Inbound messages handled so far. */
|
|
@@ -44,6 +51,8 @@ export declare class PrometheusMetrics implements MetricsPort {
|
|
|
44
51
|
processed(lagMs: number | null, handleMs: number, ok: boolean): void;
|
|
45
52
|
limited(reason: string): void;
|
|
46
53
|
filesDropped(path: string, count?: number): void;
|
|
54
|
+
probed(feedbackMs: number, replyMs: number | null): void;
|
|
55
|
+
inboundRearmed(): void;
|
|
47
56
|
/** The longest wait of the messages handled in the window, in milliseconds (0: none). */
|
|
48
57
|
lagMaxMs(): number;
|
|
49
58
|
private expire;
|
|
@@ -52,6 +61,7 @@ export declare class PrometheusMetrics implements MetricsPort {
|
|
|
52
61
|
* help, under the deprecated names of an earlier release (that half is the text it wrote, byte for byte).
|
|
53
62
|
*/
|
|
54
63
|
render(): string;
|
|
64
|
+
private renderCurrentOnly;
|
|
55
65
|
private renderAs;
|
|
56
66
|
}
|
|
57
67
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** GitHub review delegation on SQLite (tables `github_confirmations`, `acting_sessions`, `review_notices`,
|
|
2
|
-
* `asker_follows`, `github_notices`). */
|
|
3
|
-
import { type AskerFollow, type ConfirmationState, type GithubConfirmation, type GithubConfirmationRepository, type JsonObject, type NewGithubConfirmation, type ReviewDelegationRepository, type ReviewNotice } from "@primusclaw/personal-agent";
|
|
2
|
+
* `asker_follows`, `github_notices`, `review_onboarding`). */
|
|
3
|
+
import { type AskerFollow, type ConfirmationState, type GithubConfirmation, type GithubConfirmationRepository, type JsonObject, type NewGithubConfirmation, type ReviewDelegationRepository, type ReviewNotice, type ReviewOnboarding } from "@primusclaw/personal-agent";
|
|
4
4
|
import type { StoreContext } from "./context.js";
|
|
5
5
|
export declare class SqliteGithubConfirmationRepository implements GithubConfirmationRepository {
|
|
6
6
|
private readonly ctx;
|
|
@@ -33,4 +33,24 @@ export declare class SqliteReviewDelegationRepository implements ReviewDelegatio
|
|
|
33
33
|
dropAskerFollow(itemId: string): void;
|
|
34
34
|
claimGithubNotice(userId: string, kind: string, interval: number): boolean;
|
|
35
35
|
releaseGithubNotice(userId: string, kind: string): void;
|
|
36
|
+
saveReviewOnboarding(o: {
|
|
37
|
+
readonly onboardingId: string;
|
|
38
|
+
readonly actorId: string;
|
|
39
|
+
readonly requesterId: string;
|
|
40
|
+
readonly pulls: string;
|
|
41
|
+
readonly request: JsonObject;
|
|
42
|
+
readonly toldRank: number;
|
|
43
|
+
}): ReviewOnboarding;
|
|
44
|
+
getReviewOnboarding(onboardingId: string): ReviewOnboarding | null;
|
|
45
|
+
openReviewOnboardings(actorId: string): ReviewOnboarding[];
|
|
46
|
+
onboardingReviewers(): string[];
|
|
47
|
+
claimOnboardingStep(actorId: string, rank: number): boolean;
|
|
48
|
+
releaseOnboardingStep(onboardingId: string, from: number, to: number): void;
|
|
49
|
+
finishReviewOnboarding(onboardingId: string): boolean;
|
|
50
|
+
dropReviewOnboarding(onboardingId: string): void;
|
|
51
|
+
declineReviewOnboarding(onboardingId: string): boolean;
|
|
52
|
+
declinedReviewOnboardings(actorId?: string): ReviewOnboarding[];
|
|
53
|
+
claimDeclinedOnboarding(onboardingId: string): boolean;
|
|
54
|
+
releaseDeclinedOnboarding(onboardingId: string): void;
|
|
55
|
+
private moveOnboarding;
|
|
36
56
|
}
|
package/dist/worker.js
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
Router,
|
|
56
56
|
reviewStop,
|
|
57
57
|
REVIEW_HANDOFF,
|
|
58
|
+
ONBOARDING_SWEEP_MS,
|
|
58
59
|
pendingOf,
|
|
59
60
|
UPGRADE_RETRY_SECONDS,
|
|
60
61
|
noModelRefusalPolicy,
|
|
@@ -98,6 +99,7 @@ import {
|
|
|
98
99
|
channelActions,
|
|
99
100
|
channelContext,
|
|
100
101
|
connectionsText,
|
|
102
|
+
forwardBlock,
|
|
101
103
|
limitsText,
|
|
102
104
|
MessageRateLimiter,
|
|
103
105
|
noteMessage,
|
|
@@ -117,7 +119,11 @@ function isGroup(message) {
|
|
|
117
119
|
var mask = (text) => redactText(text).text;
|
|
118
120
|
function messageTextFor(channelName) {
|
|
119
121
|
return {
|
|
120
|
-
|
|
122
|
+
// (what the person forwarded, then what they quoted: both stand before their own words)
|
|
123
|
+
quoteBlock: (message, group) => [
|
|
124
|
+
forwardBlock(message.forwards ?? [], { group, redact: mask }),
|
|
125
|
+
quoteBlock(message.quotes, { group, redact: mask })
|
|
126
|
+
].filter(Boolean).join("\n\n"),
|
|
121
127
|
withLinks: (text, message) => withLinks(text, message.links, { group: isGroup(message), redact: mask }),
|
|
122
128
|
withQuote,
|
|
123
129
|
unreadable(message) {
|
|
@@ -1136,6 +1142,13 @@ function featureTimers(base, built) {
|
|
|
1136
1142
|
runAtStart: true,
|
|
1137
1143
|
run: () => sweepOnce(review)
|
|
1138
1144
|
});
|
|
1145
|
+
timers.push({
|
|
1146
|
+
name: "review_onboarding",
|
|
1147
|
+
// (a reviewer who confirmed at the identity service is sent the next step)
|
|
1148
|
+
everyMs: ONBOARDING_SWEEP_MS,
|
|
1149
|
+
runAtStart: false,
|
|
1150
|
+
run: () => review.sweepOnboarding()
|
|
1151
|
+
});
|
|
1139
1152
|
}
|
|
1140
1153
|
return timers;
|
|
1141
1154
|
}
|
|
@@ -1526,6 +1539,12 @@ function withInboundStats(prometheus, stats) {
|
|
|
1526
1539
|
},
|
|
1527
1540
|
filesDropped: (path, count) => {
|
|
1528
1541
|
prometheus.filesDropped(path, count);
|
|
1542
|
+
},
|
|
1543
|
+
probed: (feedbackMs, replyMs) => {
|
|
1544
|
+
prometheus.probed(feedbackMs, replyMs);
|
|
1545
|
+
},
|
|
1546
|
+
inboundRearmed: () => {
|
|
1547
|
+
prometheus.inboundRearmed();
|
|
1529
1548
|
}
|
|
1530
1549
|
};
|
|
1531
1550
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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.12.0",
|
|
37
37
|
"fastify": "^5.12.8",
|
|
38
38
|
"zod": "^4.6.7"
|
|
39
39
|
}
|