@primusclaw/personal-agent 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.
Files changed (34) hide show
  1. package/dist/index.js +1471 -509
  2. package/dist/types/assistant/views.d.ts +2 -0
  3. package/dist/types/claw/model.d.ts +1 -1
  4. package/dist/types/inbound-text/forward-block.d.ts +24 -0
  5. package/dist/types/inbound-text/index.d.ts +1 -0
  6. package/dist/types/locales/assistant-cards.d.ts +1 -0
  7. package/dist/types/locales/remote-agents.d.ts +1 -0
  8. package/dist/types/locales/review-onboarding.d.ts +48 -0
  9. package/dist/types/locales/review-start.d.ts +0 -2
  10. package/dist/types/locales/terminal-approvals.d.ts +14 -0
  11. package/dist/types/ports/claw/remote-agents.d.ts +12 -0
  12. package/dist/types/ports/metrics.d.ts +8 -0
  13. package/dist/types/ports/store/github.d.ts +58 -2
  14. package/dist/types/ports/store/policy.d.ts +2 -0
  15. package/dist/types/ports/surface.d.ts +22 -0
  16. package/dist/types/protocol/claw-api/reviews.d.ts +5 -1
  17. package/dist/types/protocol/remote-agents.d.ts +69 -0
  18. package/dist/types/remote/agents.d.ts +2 -0
  19. package/dist/types/remote/approvals-command.d.ts +2 -1
  20. package/dist/types/remote/prompt.d.ts +11 -1
  21. package/dist/types/remote/remote-agents.d.ts +2 -0
  22. package/dist/types/review/index.d.ts +1 -0
  23. package/dist/types/review/refusals.d.ts +5 -3
  24. package/dist/types/review/service/account.d.ts +5 -0
  25. package/dist/types/review/service/context.d.ts +12 -0
  26. package/dist/types/review/service/github-review.d.ts +3 -0
  27. package/dist/types/review/service/notices.d.ts +7 -0
  28. package/dist/types/review/service/onboarding.d.ts +85 -0
  29. package/dist/types/review/service/start.d.ts +9 -13
  30. package/dist/types/routing/features.d.ts +8 -1
  31. package/dist/types/routing/group-remote.d.ts +1 -1
  32. package/dist/types/routing/personal-text.d.ts +11 -1
  33. package/dist/types/routing/session-files.d.ts +57 -0
  34. package/package.json +1 -1
@@ -66,6 +66,8 @@ export interface ConfirmWriteModel {
66
66
  readonly cardId: string;
67
67
  /** Claw's word for letting it through ("" for "Confirm"). */
68
68
  readonly allowLabel: string;
69
+ /** What is held (`github_merge`, `trigger_create`, ...): a merge's other button says "Don't merge". Absent: "Don't". */
70
+ readonly kind?: string;
69
71
  readonly lang: string;
70
72
  }
71
73
  /** A choice the assistant put to the person: its options as radio buttons (or check boxes) and Send. */
@@ -92,7 +92,7 @@ export interface ReviewStart {
92
92
  readonly mergeNeedsConfirmation: boolean | null;
93
93
  /** The item limit that was full when Claw queued it ("" it started). */
94
94
  readonly queued: string;
95
- /** Claw merges it with the asker's own account once approved and green. */
95
+ /** The reviewer's account merges it; when the reviewer cannot merge, Claw asks the asker whether their own account merges it. */
96
96
  readonly mergeByRequester: boolean;
97
97
  }
98
98
  /** Which GitHub token Claw's GitHub tools use for the token's own user now (never the token). */
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The messages a person forwarded, as text for the model: a line that says the person forwarded them, then each one
3
+ * with who wrote it and when, its text after "> " so nothing it says can pass for a line of its own (as a quote's is).
4
+ * A forward is the person handing over what others said for the model to work on, so it gets a budget of its own,
5
+ * larger than the quotes' (several messages at once, each whole where it can be). In a group the names and the texts
6
+ * are masked as a quote's are.
7
+ */
8
+ import { type Logger } from "../ports/logger.js";
9
+ import type { InboundForward } from "../ports/surface.js";
10
+ import { type Redact } from "./redact.js";
11
+ /** The most forwarded text, over all the messages of one forward, that is sent on (code points). */
12
+ export declare const FORWARD_CHARS = 24000;
13
+ /** The most forwarded messages that are shown. */
14
+ export declare const FORWARD_COUNT = 20;
15
+ export interface ForwardBlockOptions {
16
+ /** A group conversation: names and texts are masked. */
17
+ readonly group?: boolean;
18
+ readonly redact?: Redact;
19
+ readonly logger?: Logger;
20
+ }
21
+ /** How the forwarded text is to be taken: as what others said, to read and use; an instruction in it is not the person's. */
22
+ export declare const MATERIAL: string;
23
+ /** The forwarded messages as text for the model, "" when there are none. */
24
+ export declare function forwardBlock(forwards: readonly InboundForward[], options?: ForwardBlockOptions): string;
@@ -2,6 +2,7 @@
2
2
  * The texts the model is sent for an inbound message, built from core's inbound types alone: the quote block, the
3
3
  * text with the addresses behind its links, and the text with its mentions marked.
4
4
  */
5
+ export * from "./forward-block.js";
5
6
  export * from "./marked-text.js";
6
7
  export * from "./quote-block.js";
7
8
  export * from "./redact.js";
@@ -24,6 +24,7 @@ export declare const assistantCardText: import("./catalog.js").Catalog<{
24
24
  confirmTitle: string;
25
25
  confirm: string;
26
26
  deny: string;
27
+ denyMerge: string;
27
28
  boardTitle: string;
28
29
  boardWaiting: (p: {
29
30
  n: number;
@@ -72,6 +72,7 @@ export declare const remoteAgentText: import("./catalog.js").Catalog<{
72
72
  notAttachedDetach: string;
73
73
  attachHow: string;
74
74
  lostTrack: string;
75
+ filesNotTaken: string;
75
76
  noAnswerableOption: string;
76
77
  notReported: string;
77
78
  reconnecting: (p: {
@@ -0,0 +1,48 @@
1
+ /**
2
+ * What a reviewer who cannot be acted as yet is told, step by step, and what the asker is told about them: which step is
3
+ * missing, and once all are done that the review can start. The reviewer's lines are in English and Chinese, as the
4
+ * review service's other notices to a reviewer are; the asker's are in Chinese, as its other answers to the asker are.
5
+ */
6
+ /** The steps that let a colleague have a review done as this person, in the order they can be done. */
7
+ export declare const ONBOARDING_STEPS: readonly ["identity", "bind", "auto_merge", "link"];
8
+ export type OnboardingStep = (typeof ONBOARDING_STEPS)[number];
9
+ /** The steps this person is shown: the three every reviewer needs, and their own key when it is missing. */
10
+ export declare function stepsShown(withLink: boolean): readonly OnboardingStep[];
11
+ export interface StepsAsked {
12
+ /** Who asked ("" not known). */
13
+ readonly asker: string;
14
+ readonly group: boolean;
15
+ readonly pulls: string;
16
+ readonly merge: boolean;
17
+ }
18
+ export declare const onboardingText: {
19
+ /** The reviewer's first message: what was asked of them, and every step with the one to do now marked. */
20
+ readonly first: (asked: StepsAsked, steps: readonly OnboardingStep[], current: OnboardingStep) => string;
21
+ /** A step (or more) was done: the next one, with every step marked. */
22
+ readonly next: (askers: string, steps: readonly OnboardingStep[], current: OnboardingStep) => string;
23
+ /** Every step is done. */
24
+ readonly allDone: (askers: string) => string;
25
+ /** The buttons' card under a step. */
26
+ readonly bindPrompt: "Connect GitHub now? / 现在连接 GitHub?";
27
+ readonly bindButton: "Connect GitHub / 连接 GitHub";
28
+ readonly autoMergePrompt: "Allow reviews as you now? You can turn it off at any time with `/github auto-merge off`. / 现在开启代审授权?随时可以用 `/github auto-merge off` 关闭。";
29
+ readonly autoMergeButton: "Allow / 开启代审授权";
30
+ readonly declineButton: "Not now / 暂不开启";
31
+ readonly binding: "Connecting GitHub: the code follows. / 正在连接 GitHub,验证码见下一条。";
32
+ readonly allowed: "Done. / 已处理。";
33
+ readonly declined: "Understood: reviews as you stay off, and the colleague is told. / 好的,不开启代审授权,我会告诉同事。";
34
+ readonly notYours: "This button is for someone else. / 这个按钮不是给你的。";
35
+ readonly inactive: "This button is no longer active. / 这个按钮已失效。";
36
+ readonly oneToOne: "Please do this in your 1:1 chat with me. / 请在和我的 1:1 聊天里操作。";
37
+ /** The asker, where they asked: which step the reviewer has left, and what happens next. */
38
+ readonly missing: (who: string, steps: readonly OnboardingStep[], current: OnboardingStep, sent: boolean, group: boolean) => string;
39
+ /** The asker, where they asked, once every step is done. */
40
+ readonly ready: (who: string, pulls: string, merge: boolean) => string;
41
+ readonly readyTitle: "可以开始代审了";
42
+ readonly retryButton: "重新发起代审";
43
+ readonly retried: (pulls: string) => string;
44
+ readonly onlyAsker: "只有发起这次代审的人可以重新发起。";
45
+ readonly retryGone: "这个按钮已失效(已用过或已过期),需要的话请再发一次请求。";
46
+ /** The asker, where they asked, when the reviewer said no. */
47
+ readonly refused: (who: string, pulls: string) => string;
48
+ };
@@ -13,8 +13,6 @@ export declare const reviewStartText: {
13
13
  readonly unsureWho: (bot: string) => string;
14
14
  readonly unsureWhoFull: (bot: string) => string;
15
15
  readonly githubUnknown: (who: string) => string;
16
- readonly notAuthorized: (who: string, merge: boolean) => string;
17
- readonly reviewerNotLinked: (who: string, bot: string) => string;
18
16
  readonly reviewerNotConnected: (who: string, bot: string) => string;
19
17
  readonly reviewerPlatformDown: (who: string) => string;
20
18
  readonly modelsUnknown: (whose: string, model: string) => string;
@@ -45,5 +45,19 @@ export declare const terminalApprovalText: import("./catalog.js").Catalog<{
45
45
  approvalsTurnedOn: string;
46
46
  approvalsTurnedOff: string;
47
47
  approvalsUsage: string;
48
+ muted: (p: {
49
+ item: string;
50
+ where: string;
51
+ }) => string;
52
+ unmuted: (p: {
53
+ item: string;
54
+ where: string;
55
+ }) => string;
56
+ muteNotFound: (p: {
57
+ item: string;
58
+ }) => string;
59
+ muteNotTerminal: (p: {
60
+ item: string;
61
+ }) => string;
48
62
  approvalsUnavailable: string;
49
63
  }>;
@@ -3,6 +3,13 @@ import type { RemoteHidden } from "../../protocol.js";
3
3
  import type { ClawCredential } from "../../claw/credential.js";
4
4
  import type { SseEvent } from "../../claw/model.js";
5
5
  import type { RemoteConnector, RemoteEventRow, RemotePairing, RemoteSession, RemoteSetup } from "../../claw/remote.js";
6
+ /** What Claw stored for a muted (or unmuted) terminal conversation (`PUT /v1/remote-agents/approvals/mutes`). */
7
+ export interface TerminalMute {
8
+ readonly item: number;
9
+ readonly muted: boolean;
10
+ readonly machine: string;
11
+ readonly title: string;
12
+ }
6
13
  /** What a remote session starts with. */
7
14
  export interface NewRemoteSession {
8
15
  readonly connectorId: string;
@@ -43,6 +50,11 @@ export interface ClawRemoteAgentsPort {
43
50
  approvals(key: ClawCredential): Promise<boolean>;
44
51
  /** Turn them on or off (`PUT /approvals`); answers the setting as Claw stored it. */
45
52
  setApprovals(key: ClawCredential, enabled: boolean): Promise<boolean>;
53
+ /**
54
+ * Mute (or unmute) one conversation open in a terminal, named by its work item (`#<item>`): nothing it asks, waits for or finishes
55
+ * is pushed while muted (`PUT /approvals/mutes`). Answers what Claw stored, and the machine and conversation it names.
56
+ */
57
+ muteTerminal(key: ClawCredential, item: number, muted: boolean): Promise<TerminalMute>;
46
58
  createSession(key: ClawCredential, session: NewRemoteSession): Promise<RemoteSession>;
47
59
  sessions(key: ClawCredential): Promise<RemoteSession[]>;
48
60
  session(key: ClawCredential, sessionId: string): Promise<RemoteSession>;
@@ -16,6 +16,14 @@ export interface MetricsPort {
16
16
  limited(reason: string): void;
17
17
  /** `count` files a person sent did not reach Claw on `path` (assistant | session | remote_agent | review | unreadable). */
18
18
  filesDropped(path: string, count?: number): void;
19
+ /**
20
+ * One delivery probe (a surface's synthetic message through its own queues): milliseconds from its sending to the
21
+ * worker's answer queued, and to that answer's round trip back (null: it did not come back in time). Optional: a
22
+ * port of one's own without it does not count them.
23
+ */
24
+ probed?(feedbackMs: number, replyMs: number | null): void;
25
+ /** A receiver of the surface's inbound queue whose call on the broker hung was dropped and taken again (optional). */
26
+ inboundRearmed?(): void;
19
27
  }
20
28
  /** Metrics that go nowhere: the default where a caller passes none. */
21
29
  export declare const noMetrics: MetricsPort;
@@ -1,5 +1,6 @@
1
- /** GitHub review delegation: held writes, sessions that act as someone, followed reviews and rationed notices
2
- * (tables `github_confirmations`, `acting_sessions`, `review_notices`, `asker_follows`, `github_notices`). */
1
+ /** GitHub review delegation: held writes, sessions that act as someone, followed reviews, rationed notices and the
2
+ * reviewers a request waits for (tables `github_confirmations`, `acting_sessions`, `review_notices`, `asker_follows`,
3
+ * `github_notices`, `review_onboarding`). */
3
4
  import type { JsonObject } from "./json.js";
4
5
  export type ConfirmationState = "pending" | "sending" | "done" | (string & {});
5
6
  /** A write that waits for the person the review acts for. A click is checked against this row, never the card. */
@@ -55,6 +56,27 @@ export interface AskerFollow {
55
56
  readonly reviewerTold: boolean;
56
57
  readonly deadline: number;
57
58
  }
59
+ /**
60
+ * A review asked of someone who cannot be acted as yet (their Primus account, GitHub or standing authorization is
61
+ * missing): kept so that each step they complete is followed by the next, and the asker is told once all are done.
62
+ */
63
+ export interface ReviewOnboarding {
64
+ readonly onboardingId: string;
65
+ /** The reviewer. */
66
+ readonly actorId: string;
67
+ readonly requesterId: string;
68
+ /** The pull requests, "owner/repo#n" joined by spaces in the order asked. */
69
+ readonly pulls: string;
70
+ /** What the request is started again from (who, where, the merge flag, the note). */
71
+ readonly request: JsonObject;
72
+ /** The rank of the last step the reviewer was told about (0: none). */
73
+ readonly toldRank: number;
74
+ /** The asker was told the reviewer is ready. */
75
+ readonly done: boolean;
76
+ /** The reviewer said no: the asker is owed (or is being told) that, and nothing waits for the reviewer. */
77
+ readonly declined: boolean;
78
+ readonly createdAt: number;
79
+ }
58
80
  export interface ReviewDelegationRepository {
59
81
  /** A session that acts as another person (a review for a colleague). */
60
82
  noteActingSession(sessionId: string, requesterId: string, actorId: string): void;
@@ -78,4 +100,38 @@ export interface ReviewDelegationRepository {
78
100
  /** One notice of this kind per person per `interval` seconds. */
79
101
  claimGithubNotice(userId: string, kind: string, interval: number): boolean;
80
102
  releaseGithubNotice(userId: string, kind: string): void;
103
+ /**
104
+ * Keeps (or refreshes) what waits for `actorId` to finish their steps, one per reviewer, asker and pull requests: an
105
+ * earlier one of the same three takes this id (a button sent for the earlier request no longer answers), this request
106
+ * and told rank, and is owed to the asker again. Drops
107
+ * those older than REVIEW_ONBOARDING_KEEP_SECONDS. The kept row.
108
+ */
109
+ saveReviewOnboarding(onboarding: {
110
+ readonly onboardingId: string;
111
+ readonly actorId: string;
112
+ readonly requesterId: string;
113
+ readonly pulls: string;
114
+ readonly request: JsonObject;
115
+ readonly toldRank: number;
116
+ }): ReviewOnboarding;
117
+ getReviewOnboarding(onboardingId: string): ReviewOnboarding | null;
118
+ /** What still waits for this reviewer (the asker not yet told), oldest first. */
119
+ openReviewOnboardings(actorId: string): ReviewOnboarding[];
120
+ /** Every reviewer something still waits for. */
121
+ onboardingReviewers(): string[];
122
+ /** Raises the told rank of every open one of `actorId` below `rank`; true for the one caller that raised any. */
123
+ claimOnboardingStep(actorId: string, rank: number): boolean;
124
+ /** Undoes a claim whose step could not be said: this one back to `to` while it is open and still at `from`. */
125
+ releaseOnboardingStep(onboardingId: string, from: number, to: number): void;
126
+ /** Marks it done (the asker is to be told); true for the one caller that marked it. */
127
+ finishReviewOnboarding(onboardingId: string): boolean;
128
+ dropReviewOnboarding(onboardingId: string): void;
129
+ /** Marks an open one declined (the asker is owed that); true for the one caller that marked it. */
130
+ declineReviewOnboarding(onboardingId: string): boolean;
131
+ /** The declined ones whose asker is not yet told (of `actorId`, or of everyone), oldest first. */
132
+ declinedReviewOnboardings(actorId?: string): ReviewOnboarding[];
133
+ /** Takes a declined one to tell its asker; true for the one caller that took it. */
134
+ claimDeclinedOnboarding(onboardingId: string): boolean;
135
+ /** Gives back a declined one whose asker could not be told, for the next sweep. */
136
+ releaseDeclinedOnboarding(onboardingId: string): void;
81
137
  }
@@ -48,6 +48,8 @@ export declare const HELD_TTL_SECONDS: number;
48
48
  export declare const APPROVAL_TTL_SECONDS: number;
49
49
  /** How long a review session is remembered as one that acts as a user. */
50
50
  export declare const ACTING_SESSION_KEEP_SECONDS: number;
51
+ /** How long a review asked of someone who has steps left waits for them to finish (and its retry button works). */
52
+ export declare const REVIEW_ONBOARDING_KEEP_SECONDS: number;
51
53
  /** The repositories /repo remembers per user (and lists). */
52
54
  export declare const RECENT_REPOS = 5;
53
55
  /** "My next message is for this repository" is forgotten after this. */
@@ -81,6 +81,25 @@ export interface InboundQuote {
81
81
  */
82
82
  readonly source: "entity" | "html" | "placeholder";
83
83
  }
84
+ /**
85
+ * A message someone else wrote that the person forwarded into this chat (Teams' Forward), or one of several they
86
+ * forwarded at once. What it says is never part of the person's own words.
87
+ */
88
+ export interface InboundForward {
89
+ /** The channel's id of the original message ("" when not said). */
90
+ readonly messageId: string;
91
+ /** Who wrote it ("" when the channel did not say). */
92
+ readonly author: string;
93
+ /**
94
+ * What it says. An image it showed stands where it stood: `[image-<n>]` when it is file n of the message's files (the
95
+ * name it is passed on under starts so), `[image not passed on]` when it could not be.
96
+ */
97
+ readonly text: string;
98
+ /** When it was written, as the channel said it ("" when not said). */
99
+ readonly sentAt: string;
100
+ /** Where the adapter read it (for a log line, never the text): the message's HTML, or a forward reference. */
101
+ readonly source: "html" | "reference";
102
+ }
84
103
  /** Someone the message @mentions (never the bot itself: the adapter removes its own mention). */
85
104
  export interface InboundMention {
86
105
  /** The channel's id of the person (Teams: "29:..."). */
@@ -127,6 +146,9 @@ export interface InboundMessage extends InboundBase {
127
146
  readonly mentions: readonly InboundMention[];
128
147
  readonly links: readonly InboundLink[];
129
148
  readonly quotes: readonly InboundQuote[];
149
+ /** The messages the person forwarded with this one, in the order the channel gave them (absent: none). */
150
+ readonly forwards?: readonly InboundForward[];
151
+ /** Includes the images of the forwarded messages that the channel gave a way to fetch. */
130
152
  readonly files: readonly InboundFile[];
131
153
  /**
132
154
  * The names of attachments the channel gave no way to fetch (a file shared as a link), told back to the person
@@ -26,7 +26,11 @@ export interface StartedReview {
26
26
  review_only: boolean;
27
27
  /** Present when every merge of this review waits for the acting user's own confirmation, whatever their review mode. */
28
28
  merge_needs_confirmation?: true;
29
- /** Present on a review asked of someone else that may merge: the requester's own account merges it once it is approved and green. */
29
+ /**
30
+ * Present on a review asked of someone else that may merge. The reviewer's account merges it once they approve (at once under their
31
+ * fully automatic setting, else on their own confirmation); only when the reviewer cannot merge it (no permission) is the requester
32
+ * asked, with a card, whether their own account merges it. Nothing is merged with the requester's account unasked.
33
+ */
30
34
  merge_by_requester?: true;
31
35
  /** With model choice on: the model the review runs on (null: the deployment's default). Absent with model choice off. */
32
36
  model?: string | null;
@@ -13,6 +13,10 @@ export declare const REMOTE_AGENT_LIMITS: {
13
13
  readonly maxCapabilitiesBytes: number;
14
14
  /** Bytes of one prompt. */
15
15
  readonly maxPromptBytes: number;
16
+ /** Files one prompt may carry (`prompt.files`). */
17
+ readonly maxPromptFiles: 10;
18
+ /** Bytes of all the files of one prompt together, decoded (base64 makes them a third larger on the wire). */
19
+ readonly maxPromptFileBytes: number;
16
20
  /** Commands one user may issue per minute, across all connectors. */
17
21
  readonly commandsPerMinute: 60;
18
22
  };
@@ -66,6 +70,15 @@ export declare function connectorVersionStatus(version: string | null | undefine
66
70
  export declare const REMOTE_EVENT_PERMISSION_REQUEST = "permissionRequest";
67
71
  export declare const REMOTE_EVENT_PERMISSION_RESOLVED = "permission_resolved";
68
72
  export declare const REMOTE_EVENT_SESSION_CLOSED = "session_closed";
73
+ /**
74
+ * A turn of a conversation open in a terminal ended while nobody was at that terminal, posted on the conversation's terminal-hook
75
+ * session (`origin` "terminal_hook") by its connector: `{ref, outcome: "done" | "error", error?, message, agent, cwd, ended_at,
76
+ * away_ms}`. `message` is the end of what the agent last said (untrusted text); `error` names why a turn that failed did
77
+ * (Claude Code's `StopFailure` reason, such as `rate_limit`). The connector posts it only once the terminal has had no input for a
78
+ * minute after the turn ended, and never while a chat follows the conversation; Claw tells the owner, unless they turned the
79
+ * terminal pushes off or muted that conversation.
80
+ */
81
+ export declare const REMOTE_EVENT_TERMINAL_TURN_END = "terminal_turn_end";
69
82
  /**
70
83
  * What the person sent a session (a `prompt` command), written by Claw itself when it queues the prompt: `{text, cmd_id, cmd_seq,
71
84
  * client, by: "claw"}` with a negative `seq`. An agent's events carry only its own side, so without it a window opened on the
@@ -99,7 +112,43 @@ export interface RemoteHeartbeat {
99
112
  agents: RemoteAgentDescriptor[];
100
113
  /** Highest `cmd_seq` the connector has fully handled; the server may forget up to it. */
101
114
  cmdCursor: number | null;
115
+ /** What the connector holds that Claw has not acknowledged yet (`outbox` on the wire); absent from an older connector. */
116
+ outbox?: RemoteOutboxReport | null;
102
117
  }
118
+ /** Sessions an outbox report names at most, the longest waiting first. */
119
+ export declare const REMOTE_OUTBOX_REPORT_MAX_SESSIONS = 20;
120
+ /** One session's part of an outbox report. */
121
+ export interface RemoteOutboxSession {
122
+ sessionId: string;
123
+ /** Its events not acknowledged yet. */
124
+ pending: number;
125
+ /** How long the oldest of them has waited, in milliseconds. */
126
+ oldestAgeMs: number;
127
+ }
128
+ /**
129
+ * The connector's own account of its event outbox, sent with every heartbeat (`outbox`, snake_case on the wire): how many
130
+ * events wait, how long the oldest has, and how many posts in a row failed and for how long. It is what tells Claw that a
131
+ * machine's replies are not getting through when the reason is on Claw's side (a batch Claw keeps refusing with a 5xx) as
132
+ * well as when it is not (a proxy, a network). Only ever a report: a malformed one is ignored, never a reason to refuse the
133
+ * heartbeat that carries it.
134
+ */
135
+ export interface RemoteOutboxReport {
136
+ pending: number;
137
+ oldestAgeMs: number;
138
+ /** Consecutive failed posts; 0 once a post succeeded. */
139
+ failures: number;
140
+ /** How long ago the first of those failures was, in milliseconds; 0 with no failure. */
141
+ failingMs: number;
142
+ /** What the last failure was: `http_<status>`, `network` or `error`; null with no failure. */
143
+ lastError: string | null;
144
+ /** The sessions with events waiting, the longest waiting first, at most {@link REMOTE_OUTBOX_REPORT_MAX_SESSIONS}. */
145
+ sessions: RemoteOutboxSession[];
146
+ }
147
+ /**
148
+ * The heartbeat's `outbox`, or null when it is absent or malformed. Total, like every parser here, and lenient by design: a
149
+ * report is advice about delivery, and a heartbeat refused over it would take the machine offline.
150
+ */
151
+ export declare function parseOutboxReport(raw: unknown): RemoteOutboxReport | null;
103
152
  export declare function parseConnectorRegistration(body: unknown): Parsed<{
104
153
  name: string;
105
154
  version: string | null;
@@ -189,6 +238,11 @@ export declare function parseTerminalSessionOpen(body: unknown): Parsed<RemoteTe
189
238
  export declare function parseApprovalsSetting(body: unknown): Parsed<{
190
239
  enabled: boolean;
191
240
  }>;
241
+ /** `PUT /v1/remote-agents/approvals/mutes`: mute (or unmute) the conversation behind work item `#item`, one open in a terminal. */
242
+ export declare function parseTerminalMute(body: unknown): Parsed<{
243
+ item: number;
244
+ muted: boolean;
245
+ }>;
192
246
  /**
193
247
  * Hiding conversations of a machine from its owner's lists (`POST /v1/remote-agents/connectors/:cid/hidden`), and the
194
248
  * listing that leaves them out (`GET /v1/remote-agents/connectors`, `?hidden=include` to list them too). Nothing on the
@@ -256,6 +310,21 @@ export interface RemoteCommandSpec {
256
310
  /** What the audit trail keeps. Never the text a user typed. */
257
311
  audit(payload: Record<string, unknown>): Record<string, unknown>;
258
312
  }
313
+ /** A file a prompt carries, as the connector receives it. */
314
+ export interface RemotePromptFile {
315
+ /** One safe path component: letters, digits, `._ -`, no leading dot, at most 100 characters. */
316
+ name: string;
317
+ media_type: string;
318
+ /** The bytes, base64. */
319
+ data: string;
320
+ }
321
+ /**
322
+ * The files a prompt carries (`files`, optional): at most {@link REMOTE_AGENT_LIMITS.maxPromptFiles}, each a safe name, a
323
+ * media type and its bytes in base64, all together at most {@link REMOTE_AGENT_LIMITS.maxPromptFileBytes} decoded, no two
324
+ * with one name (compared without case). A connector that says it can (the agent capability `prompt_files`) saves them on its machine and names
325
+ * where in the prompt; Claw keeps them only while the command waits to be delivered, never in the session's events.
326
+ */
327
+ export declare function parsePromptFiles(raw: unknown): Parsed<RemotePromptFile[]>;
259
328
  export declare const REMOTE_COMMANDS: Record<RemoteCommandType, RemoteCommandSpec>;
260
329
  export declare function isRemoteCommandType(v: unknown): v is RemoteCommandType;
261
330
  /** One server-sent-events frame. `id` is omitted for frames a client must not resume from. */
@@ -13,6 +13,8 @@ export declare function agentRef(connector: Pick<Connector, "name">, agent: Pick
13
13
  export declare function agentRoots(agent: Agent): string[];
14
14
  /** The connector can take back a message that waits for its terminal without stopping anything (`withdraw`). */
15
15
  export declare function withdraws(agent: Agent | null | undefined): boolean;
16
+ /** The connector saves the files a prompt carries on its machine and names them in the prompt (`prompt_files`). */
17
+ export declare function takesFiles(agent: Agent | null | undefined): boolean;
16
18
  /** The connector can open a conversation that is open in a terminal read-only (`watch_live`). */
17
19
  export declare function watchesLive(agent: Agent): boolean;
18
20
  /** The connector types messages into the terminal that has this conversation open (a tmux pane of its user's). */
@@ -3,6 +3,7 @@ import type { CommandHandler, CommandRoute } from "../ports/routing.js";
3
3
  export declare class TerminalApprovalsCommand implements CommandHandler {
4
4
  private readonly claw;
5
5
  readonly name = "approvals";
6
- constructor(claw: Pick<ClawRemoteAgentsPort, "approvals" | "setApprovals">);
6
+ constructor(claw: Pick<ClawRemoteAgentsPort, "approvals" | "setApprovals" | "muteTerminal">);
7
7
  run(route: CommandRoute, args: string): Promise<boolean>;
8
+ private mute;
8
9
  }
@@ -1,4 +1,4 @@
1
- import { type Conversation } from "../ports/surface.js";
1
+ import { type Conversation, type FetchedFile } from "../ports/surface.js";
2
2
  import type { StatusBoard } from "./board.js";
3
3
  import type { RemoteContext } from "./context.js";
4
4
  import type { Provider } from "./ended.js";
@@ -22,7 +22,11 @@ export interface Prompt {
22
22
  readonly source: SentFrom;
23
23
  /** The message replies quoting this chat's session card. */
24
24
  readonly quotesWindow: boolean;
25
+ /** Files the machine saves and names in the prompt (its agent `takesFiles`). */
26
+ readonly files?: readonly FetchedFile[];
25
27
  }
28
+ /** `bytes` as base64 (the wire's `prompt.files[].data`). */
29
+ export declare function base64Of(bytes: Uint8Array): string;
26
30
  export declare class Prompts {
27
31
  private readonly ctx;
28
32
  private readonly state;
@@ -49,6 +53,12 @@ export declare class Prompts {
49
53
  * told why) when it did not go.
50
54
  */
51
55
  private send;
56
+ /**
57
+ * A Claw that knows no `files` field took the words and dropped the files unread: the person is told. A repeat of a
58
+ * prompt Claw already has (`duplicate`) says nothing: the first send's answer was where they were told, and a
59
+ * redelivered message is never told twice.
60
+ */
61
+ private filesTaken;
52
62
  private failure;
53
63
  private started;
54
64
  /**
@@ -28,6 +28,7 @@ export declare class RemoteAgents implements RemoteChat {
28
28
  private readonly machine;
29
29
  private readonly permissions;
30
30
  private readonly prompts;
31
+ private readonly ops;
31
32
  private readonly runner;
32
33
  private readonly ctx;
33
34
  constructor(context: RemoteContext);
@@ -54,6 +55,7 @@ export declare class RemoteAgents implements RemoteChat {
54
55
  chatContext(chatKey: string, credential: string): Promise<JsonObject | null>;
55
56
  private call;
56
57
  prompt(request: RemotePrompt): Promise<void>;
58
+ takesFiles(chatKey: string, credential: string): Promise<boolean>;
57
59
  /** `only`: a Stop card's turn; the press stops nothing once that turn is not the one running (see Prompts.stop). */
58
60
  stop(chat: UserRef, credential: string, conversation: Conversation, only?: RemoteTurn): Promise<boolean>;
59
61
  /** The turn this worker is watching for the chat now, if any (what a phone's Stop card is sent for). */
@@ -7,6 +7,7 @@ export { REVIEW_MODE_NAMES, isReviewMode, type ReviewMode } from "./review-turn.
7
7
  export { connectionsText, UNKNOWN, type ConnectionsInput } from "./connect/connections.js";
8
8
  export { GithubReview } from "./service/github-review.js";
9
9
  export { ReviewHandoffAction, type HandoffActionDeps } from "./service/handoff-action.js";
10
+ export { ONBOARDING_SWEEP_MS } from "./service/onboarding.js";
10
11
  export type { ReviewDeps, ReviewHost, StartReviewTurn, Guard, Audit, FollowWire, RestoreRef } from "./service/deps.js";
11
12
  export type { PostWorkCard } from "./service/notices.js";
12
13
  export { reviewTurnStart, routedReviewTurns, type AfterReviewTurn, type StartRouterTurn, } from "./service/routed-turn.js";
@@ -37,8 +37,10 @@ export declare function refusedText(refused: readonly (readonly [PullRef, string
37
37
  */
38
38
  export declare function modelChosenNote(review: ReviewTurn, who: string, asked: string): string;
39
39
  /**
40
- * What the receipt says of how the merges will be made: only what the reviews started say. Every one waits for the
41
- * reviewer's confirmation: that, plainly. Otherwise the reviewer's fully automatic setting is said, a held one among the
42
- * others is named, and a merge Claw makes with the asker's own account is said. '' when there is nothing to say.
40
+ * What the receipt says of how the merges will be made: only what the reviews started say. A review asked of someone else is merged
41
+ * with that reviewer's account once they approve, said plainly, with "they confirm it first" when its merge waits for them; the
42
+ * reviewer's fully automatic setting is said; and when Claw may put the merge to the asker (`mergeByRequester`), that the asker is
43
+ * asked first, only when the reviewer has no permission to merge. Nothing is merged with the asker's account unasked
44
+ * (2026-11-20). One's own review says only whether its merge waits for one's own confirmation. '' when there is nothing to say.
43
45
  */
44
46
  export declare function mergeLine(reviews: readonly ReviewTurn[], who: string, merge: boolean, auto: boolean): string;
@@ -2,6 +2,8 @@ import { type CredentialFailure, type DeviceCode } from "../../ports/github.js";
2
2
  import type { Conversation, OutMessage, UserRef } from "../../ports/surface.js";
3
3
  import { type ReviewMode } from "../review-turn.js";
4
4
  import type { ReviewDeps } from "./deps.js";
5
+ /** What a person changed on their binding, for what waits on it (`GithubAccount.changed`). */
6
+ export type AccountChange = "bound" | "delegation_on" | "delegation_off";
5
7
  /** `(connected, login)` once a device flow has ended, for a question that waited for it. */
6
8
  export type OnBound = (connected: boolean, login: string) => Promise<void>;
7
9
  export declare class GithubAccount {
@@ -10,7 +12,10 @@ export declare class GithubAccount {
10
12
  private readonly binding;
11
13
  /** Teams user -> the confirmation setting chosen while their binding is made. */
12
14
  private readonly modeChosen;
15
+ /** Told after a person connected GitHub or switched their standing authorization (errors are logged, never thrown). */
16
+ changed: ((userId: string, change: AccountChange) => Promise<void>) | undefined;
13
17
  constructor(deps: ReviewDeps);
18
+ private tellChanged;
14
19
  /** Settles when every device flow started so far has ended (for tests and an orderly stop). */
15
20
  idle(): Promise<void>;
16
21
  /** `/github ...` in a 1:1 chat. */
@@ -0,0 +1,12 @@
1
+ /** What the review service reads a request from (the message, or a press of a button that asks it again). */
2
+ import type { Conversation, InboundMessage, UserRef } from "../../ports/surface.js";
3
+ /** Where and by whom a request was made. */
4
+ export interface RequestContext {
5
+ readonly message: InboundMessage;
6
+ readonly sender: UserRef;
7
+ readonly conversation: Conversation;
8
+ readonly scope: string;
9
+ /** What the person wrote (the asker's note to the reviewer). */
10
+ readonly text: string;
11
+ readonly group: boolean;
12
+ }
@@ -26,11 +26,14 @@ export declare class GithubReview {
26
26
  private readonly held;
27
27
  private readonly checks;
28
28
  private readonly launch;
29
+ private readonly onboarding;
29
30
  constructor(deps: ReviewDeps, random: Random, postWorkCard: PostWorkCard);
30
31
  /** Settles when the background work started so far (device flows, follows, hints) has ended. For tests. */
31
32
  idle(): Promise<void>;
32
33
  /** Which channel id is whose, from a message of theirs: a mention in a group can then be read without the member list. */
33
34
  remember(message: InboundMessage): void;
35
+ /** The reviewers a review waits for, read again: each step done is answered with the next (every ONBOARDING_SWEEP_MS). */
36
+ sweepOnboarding(): Promise<void>;
34
37
  private context;
35
38
  /**
36
39
  * A message that may be "请 XX 帮我 review 合入 <PR> [<PR> ...]". True when it was one (answered here, or started), false
@@ -38,6 +38,13 @@ export declare class Notices {
38
38
  reachNote(review: ReviewTurn | undefined, channel: string): Promise<string>;
39
39
  /** Sends what `send` says into the person's own chat, at most once a day for this kind; true when they have it. */
40
40
  onceADay(person: Actor, via: ConversationRef, kind: string, send: (chat: Conversation) => Promise<void>): Promise<boolean>;
41
+ /**
42
+ * As `onceADay`, telling apart sent now ("sent"), held back because a notice of this kind already went to them today
43
+ * ("earlier": what that one said may not be this), and not sent ("failed").
44
+ */
45
+ onceADayOutcome(person: Actor, via: ConversationRef, kind: string, send: (chat: Conversation) => Promise<void>): Promise<"sent" | "earlier" | "failed">;
46
+ /** Sends what `send` says into the person's own chat, with no daily limit; true when it went. */
47
+ toPerson(person: Actor, via: ConversationRef, send: (chat: Conversation) => Promise<void>): Promise<boolean>;
41
48
  /** The asker has no Primus key of their own linked, and a review runs on it: one line where asked, and the steps in their chat. */
42
49
  requesterMustLink(via: ConversationRef, group: boolean, requester: Actor, conversation: Conversation, pulls: readonly PullRef[]): Promise<void>;
43
50
  /** The person named cannot be acted as yet: one line where asked and, once a day, the steps in their own chat. */