@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.
- package/dist/index.js +1471 -509
- package/dist/types/assistant/views.d.ts +2 -0
- package/dist/types/claw/model.d.ts +1 -1
- package/dist/types/inbound-text/forward-block.d.ts +24 -0
- package/dist/types/inbound-text/index.d.ts +1 -0
- package/dist/types/locales/assistant-cards.d.ts +1 -0
- package/dist/types/locales/remote-agents.d.ts +1 -0
- package/dist/types/locales/review-onboarding.d.ts +48 -0
- package/dist/types/locales/review-start.d.ts +0 -2
- package/dist/types/locales/terminal-approvals.d.ts +14 -0
- package/dist/types/ports/claw/remote-agents.d.ts +12 -0
- package/dist/types/ports/metrics.d.ts +8 -0
- package/dist/types/ports/store/github.d.ts +58 -2
- package/dist/types/ports/store/policy.d.ts +2 -0
- package/dist/types/ports/surface.d.ts +22 -0
- package/dist/types/protocol/claw-api/reviews.d.ts +5 -1
- package/dist/types/protocol/remote-agents.d.ts +69 -0
- package/dist/types/remote/agents.d.ts +2 -0
- package/dist/types/remote/approvals-command.d.ts +2 -1
- package/dist/types/remote/prompt.d.ts +11 -1
- package/dist/types/remote/remote-agents.d.ts +2 -0
- package/dist/types/review/index.d.ts +1 -0
- package/dist/types/review/refusals.d.ts +5 -3
- package/dist/types/review/service/account.d.ts +5 -0
- package/dist/types/review/service/context.d.ts +12 -0
- package/dist/types/review/service/github-review.d.ts +3 -0
- package/dist/types/review/service/notices.d.ts +7 -0
- package/dist/types/review/service/onboarding.d.ts +85 -0
- package/dist/types/review/service/start.d.ts +9 -13
- package/dist/types/routing/features.d.ts +8 -1
- package/dist/types/routing/group-remote.d.ts +1 -1
- package/dist/types/routing/personal-text.d.ts +11 -1
- package/dist/types/routing/session-files.d.ts +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type OnboardingStep } from "../../locales/review-onboarding.js";
|
|
2
|
+
import type { ClickRoute } from "../../ports/routing.js";
|
|
3
|
+
import type { Conversation, UserRef } from "../../ports/surface.js";
|
|
4
|
+
import type { Random } from "../../ports/random.js";
|
|
5
|
+
import type { PullRef } from "../../claw/model.js";
|
|
6
|
+
import { type ReviewAsk } from "../request-parse.js";
|
|
7
|
+
import type { ReviewDeps } from "./deps.js";
|
|
8
|
+
import type { Notices } from "./notices.js";
|
|
9
|
+
import type { Actor } from "./reviewer.js";
|
|
10
|
+
import type { RequestContext } from "./context.js";
|
|
11
|
+
/** How often the reviewers something waits for are read again (a confirmation at the identity service sends nothing). */
|
|
12
|
+
export declare const ONBOARDING_SWEEP_MS = 60000;
|
|
13
|
+
/** The click kind of the buttons this sends. */
|
|
14
|
+
export declare const ONBOARDING_CLICK = "review_onboarding";
|
|
15
|
+
/** Where a reviewer is: the step to do now, every one done, or undefined when it could not be read just now. */
|
|
16
|
+
export type ReviewerProgress = OnboardingStep | "ready";
|
|
17
|
+
export declare class ReviewerOnboarding {
|
|
18
|
+
private readonly deps;
|
|
19
|
+
private readonly notices;
|
|
20
|
+
private readonly random;
|
|
21
|
+
/** Starts a request again, as the asker's press of the retry button (the review service's checks). */
|
|
22
|
+
private readonly retry;
|
|
23
|
+
/** `/github <args>` as the person typed it in their 1:1 chat (the steps' buttons). */
|
|
24
|
+
private readonly github;
|
|
25
|
+
private readonly running;
|
|
26
|
+
constructor(deps: ReviewDeps, notices: Notices, random: Random,
|
|
27
|
+
/** Starts a request again, as the asker's press of the retry button (the review service's checks). */
|
|
28
|
+
retry: (ctx: RequestContext, ask: ReviewAsk, actor: Actor) => Promise<void>,
|
|
29
|
+
/** `/github <args>` as the person typed it in their 1:1 chat (the steps' buttons). */
|
|
30
|
+
github: (sender: UserRef, args: string, conversation: Conversation) => Promise<void>);
|
|
31
|
+
/** Settles when the reads started by messages have ended. For tests. */
|
|
32
|
+
idle(): Promise<void>;
|
|
33
|
+
/** The step this person is to do now for a review asked of them, or undefined when it cannot be read just now. */
|
|
34
|
+
progress(userId: string): Promise<ReviewerProgress | undefined>;
|
|
35
|
+
private linked;
|
|
36
|
+
/**
|
|
37
|
+
* A review for someone else did not start because `step` is theirs to do: kept, the steps sent to them (once a day, the
|
|
38
|
+
* identity card too while the identity service does not know them), and one line where it was asked naming the step.
|
|
39
|
+
*/
|
|
40
|
+
refused(ctx: RequestContext, ask: ReviewAsk, actor: Actor, pulls: readonly PullRef[], step: OnboardingStep): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* What goes with a step, after its text went: a card that could not be sent is not worth saying the step again for
|
|
43
|
+
* (the text names what to type), so it is only logged and the step counts as said.
|
|
44
|
+
*/
|
|
45
|
+
private cardAfterText;
|
|
46
|
+
/** What goes with a step: the identity card, or a button that does the step. */
|
|
47
|
+
private stepCard;
|
|
48
|
+
/**
|
|
49
|
+
* A reviewer who undid a step they had done (`/github unbind`, or an identity service that no longer knows them) is
|
|
50
|
+
* behind what they were told: each open ask told further than `rank` is put just below it, so the step they are at
|
|
51
|
+
* now is said again (once, by whoever raises it first). True when any was.
|
|
52
|
+
*/
|
|
53
|
+
private behind;
|
|
54
|
+
/** A message of this person's: when something waits for them, their state is read again (in the background). */
|
|
55
|
+
activity(userId: string): void;
|
|
56
|
+
/** Every reviewer something waits for, read again; every asker still owed a reviewer's no, told. */
|
|
57
|
+
sweep(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* This person's state, read again: a step further than they were told is answered with the next one (once, whoever
|
|
60
|
+
* reads it first), and so is a step they undid; all done, each asker is told where they asked. A step that could not
|
|
61
|
+
* be said is claimed back, so the next read (their next message, or the sweep) says it.
|
|
62
|
+
*/
|
|
63
|
+
advance(userId: string): Promise<void>;
|
|
64
|
+
/** The step `now` said in the reviewer's own chat; false when that chat could not be reached. */
|
|
65
|
+
private tell;
|
|
66
|
+
private via;
|
|
67
|
+
/**
|
|
68
|
+
* Every step is done: each asker, where they asked, hears it with the button that asks again, and only then is the
|
|
69
|
+
* request marked told; one that could not be told is claimed back (from `rank`) and told on the next read. The
|
|
70
|
+
* reviewer hears it too.
|
|
71
|
+
*/
|
|
72
|
+
private ready;
|
|
73
|
+
/**
|
|
74
|
+
* The reviewer turned their standing authorization off, or said not now: each asker waiting on them is told, once. Each
|
|
75
|
+
* is marked declined first (nothing waits for the reviewer any more), and stays owed to its asker until the telling
|
|
76
|
+
* went, so a send that fails is tried again by the sweep.
|
|
77
|
+
*/
|
|
78
|
+
declined(userId: string): Promise<void>;
|
|
79
|
+
/** Each asker owed a reviewer's no is told it where they asked (once, whoever takes it first); then it is dropped. */
|
|
80
|
+
private tellDeclined;
|
|
81
|
+
/** A press of one of the buttons this sent. */
|
|
82
|
+
click(click: ClickRoute): Promise<void>;
|
|
83
|
+
/** The asker's press of "ask again": the same request, started again through every check, once. */
|
|
84
|
+
private retryClick;
|
|
85
|
+
}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { type GithubState } from "../../ports/github.js";
|
|
2
|
-
import type { Conversation, InboundMessage, UserRef } from "../../ports/surface.js";
|
|
3
2
|
import type { PullRef } from "../../claw/model.js";
|
|
4
3
|
import type { ReviewAsk } from "../request-parse.js";
|
|
5
4
|
import { type ReviewTurn } from "../review-turn.js";
|
|
6
5
|
import type { ReviewDeps, ReviewTaskSlots } from "./deps.js";
|
|
7
6
|
import type { ReviewItems } from "./items.js";
|
|
8
7
|
import type { Notices } from "./notices.js";
|
|
8
|
+
import type { ReviewerOnboarding } from "./onboarding.js";
|
|
9
9
|
import type { Actor, ReviewerReader } from "./reviewer.js";
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
readonly message: InboundMessage;
|
|
13
|
-
readonly sender: UserRef;
|
|
14
|
-
readonly conversation: Conversation;
|
|
15
|
-
readonly scope: string;
|
|
16
|
-
/** What the person wrote (the asker's note to the reviewer). */
|
|
17
|
-
readonly text: string;
|
|
18
|
-
readonly group: boolean;
|
|
19
|
-
}
|
|
10
|
+
import type { RequestContext } from "./context.js";
|
|
11
|
+
export type { RequestContext } from "./context.js";
|
|
20
12
|
/** What `take` settled, for the start: who asks and for whom, with what. */
|
|
21
13
|
export interface Settled {
|
|
22
14
|
readonly ctx: RequestContext;
|
|
@@ -42,8 +34,9 @@ export declare class ReviewChecks {
|
|
|
42
34
|
private readonly reviewers;
|
|
43
35
|
private readonly items;
|
|
44
36
|
private readonly notices;
|
|
37
|
+
private readonly onboarding;
|
|
45
38
|
private readonly launch;
|
|
46
|
-
constructor(deps: ReviewDeps, reviewers: ReviewerReader, items: ReviewItems, notices: Notices, launch: Launch);
|
|
39
|
+
constructor(deps: ReviewDeps, reviewers: ReviewerReader, items: ReviewItems, notices: Notices, onboarding: ReviewerOnboarding, launch: Launch);
|
|
47
40
|
private say;
|
|
48
41
|
/** The pull requests' checks, then `take`. `named`: the reviewer, already known (a handoff); undefined: read from the message. */
|
|
49
42
|
request(ctx: RequestContext, ask: ReviewAsk, named?: Actor): Promise<void>;
|
|
@@ -51,7 +44,10 @@ export declare class ReviewChecks {
|
|
|
51
44
|
private askerToken;
|
|
52
45
|
/** Who reviews: the asker (a 1:1 chat that names nobody), the reviewer a handoff named, or the one the message names. */
|
|
53
46
|
private whoReviews;
|
|
54
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The reviewer's GitHub binding, usable and authorized, or undefined when the asker was told why not. A review asked of
|
|
49
|
+
* someone else who has a step left is kept until they have done it (`ReviewerOnboarding`), and the asker is told which.
|
|
50
|
+
*/
|
|
55
51
|
private reviewerState;
|
|
56
52
|
/** A review asked of someone else runs on their own token and key: both, or undefined when the asker was told. */
|
|
57
53
|
private actingCredentials;
|
|
@@ -3,7 +3,7 @@ import type { JsonObject } from "../json.js";
|
|
|
3
3
|
import type { KeyOwner } from "../plugins/identity-lookup.js";
|
|
4
4
|
import type { Lang } from "../locales/lang.js";
|
|
5
5
|
import type { GroupContextKept } from "../locales/transparency.js";
|
|
6
|
-
import type { Conversation, InboundFile, InboundMessage, OutMessage, UserRef } from "../ports/surface.js";
|
|
6
|
+
import type { Conversation, FetchedFile, InboundFile, InboundMessage, OutMessage, UserRef } from "../ports/surface.js";
|
|
7
7
|
/**
|
|
8
8
|
* What the router asks of the features it hands messages to. Each is implemented by the feature's own module (the
|
|
9
9
|
* assistant, remote agents, the turn engine, the review service, observing, notifications) and given to the router by
|
|
@@ -89,6 +89,8 @@ export interface RemotePrompt {
|
|
|
89
89
|
readonly prompt: string;
|
|
90
90
|
readonly conversation: Conversation;
|
|
91
91
|
readonly provider: CredentialProvider;
|
|
92
|
+
/** Files the session's machine saves and names in the prompt (only where it `takesFiles`). */
|
|
93
|
+
readonly files?: readonly FetchedFile[];
|
|
92
94
|
}
|
|
93
95
|
export interface RemoteAgentCommand {
|
|
94
96
|
readonly chat: UserRef;
|
|
@@ -104,6 +106,11 @@ export interface RemoteAgentCommand {
|
|
|
104
106
|
export interface RemoteChat {
|
|
105
107
|
readonly enabled: boolean;
|
|
106
108
|
attached(chatKey: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The machine of the chat's session saves the files a prompt carries and names them in it (its agent says `prompt_files`);
|
|
111
|
+
* absent or false: a session gets text only.
|
|
112
|
+
*/
|
|
113
|
+
takesFiles?(chatKey: string, credential: string): Promise<boolean>;
|
|
107
114
|
/** The chat is the agent's window itself (direct chat). */
|
|
108
115
|
direct(chatKey: string): boolean;
|
|
109
116
|
windowMode(chatKey: string): "card" | "chat";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InboundMessage } from "../ports/surface.js";
|
|
2
2
|
import type { Chat } from "./chat.js";
|
|
3
3
|
import type { RouterContext } from "./context.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type PersonalText } from "./personal-text.js";
|
|
5
5
|
export interface GroupWords {
|
|
6
6
|
readonly text: string;
|
|
7
7
|
readonly quote: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { InboundFile, InboundMessage } from "../ports/surface.js";
|
|
1
|
+
import type { FetchedFile, InboundFile, InboundMessage } from "../ports/surface.js";
|
|
2
2
|
import type { Chat } from "./chat.js";
|
|
3
3
|
import type { CommandTable } from "./command-table.js";
|
|
4
4
|
import type { RouterContext } from "./context.js";
|
|
5
5
|
import { type TurnStarter } from "./turn-start.js";
|
|
6
|
+
/** What a session is sent for files that came with no words (a prompt is never empty). */
|
|
7
|
+
export declare const FILES_ONLY = "The person sent the files below with no words.";
|
|
6
8
|
/**
|
|
7
9
|
* A 1:1 message that is not one of the chat's commands, as it goes on (the Python `Agent._text_of`, `_on_text`,
|
|
8
10
|
* `_sent_on`, `_talks_to_agent`, `_session_control`, `_understand`, `_understood`, `_offer_github`, `_attachments`):
|
|
@@ -28,6 +30,14 @@ export declare class PersonalText {
|
|
|
28
30
|
talksToAgent(message: InboundMessage): boolean;
|
|
29
31
|
/** The files that go to Claw with a message; the person is told about the ones that do not, and they are counted. */
|
|
30
32
|
attachments(message: InboundMessage, chat: Chat, elsewhere?: boolean): Promise<readonly InboundFile[]>;
|
|
33
|
+
/**
|
|
34
|
+
* The files of a message to the session `chatKey` is attached to (the 1:1 chat's, or a bound group's): text files inline
|
|
35
|
+
* after the person's words, in `room` bytes; other files to its machine where it takes them; the person told about the rest.
|
|
36
|
+
*/
|
|
37
|
+
toSession(message: InboundMessage, chat: Chat, chatKey: string, key: string, room: number): Promise<{
|
|
38
|
+
section: string;
|
|
39
|
+
files: readonly FetchedFile[];
|
|
40
|
+
}>;
|
|
31
41
|
/** What the chat is attached to, for the assistant (only where remote agents are on). */
|
|
32
42
|
private attached;
|
|
33
43
|
/** A 1:1 message that is no command, as it goes on to the attached agent, the assistant or Claw. */
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The files of a message to a session the chat is attached to (a coding agent on the person's own machine). A text file
|
|
3
|
+
* (a log, code, data, a document in plain text) is passed inline, after the person's words, whole while the budget lasts
|
|
4
|
+
* and cut after that. Any other file (an image, a PDF) goes as a file where the session's machine takes files (the
|
|
5
|
+
* connector saves it there and names its path in the prompt); where it does not, the person is told which ones did not
|
|
6
|
+
* reach the session, and why.
|
|
7
|
+
*/
|
|
8
|
+
import type { FetchedFile, FileRefused, InboundFile } from "../ports/surface.js";
|
|
9
|
+
import type { Result } from "../result.js";
|
|
10
|
+
/** The most bytes of files passed inline with one prompt (a session takes a prompt of at most 64 KiB, words included). */
|
|
11
|
+
export declare const INLINE_FILE_BYTES: number;
|
|
12
|
+
/** The most bytes of one prompt to a session: Claw takes at most 64 KiB; the rest is room for what frames it. */
|
|
13
|
+
export declare const SESSION_PROMPT_BYTES: number;
|
|
14
|
+
/** What is said where forwarded or quoted text was cut to fit one prompt. */
|
|
15
|
+
export declare const QUOTE_CUT = "\n\u2026 [cut: the rest of the forwarded and quoted messages did not fit in one message to the session]";
|
|
16
|
+
/** What is said in place of forwarded or quoted text when none of it fits beside the person's words. */
|
|
17
|
+
export declare const QUOTE_DROPPED = "[cut: the forwarded and quoted messages did not fit in one message to the session]";
|
|
18
|
+
/**
|
|
19
|
+
* The forwarded and quoted messages (`quote`) cut so that they and the person's words (`sent`) fit one prompt to a
|
|
20
|
+
* session: the words are the person's and go whole; what others wrote is cut at its end, and says so. When the words
|
|
21
|
+
* leave no room for any of it, the notice alone stands for it (a few bytes past the budget, inside Claw's own limit).
|
|
22
|
+
*/
|
|
23
|
+
export declare function fitQuote(quote: string, sent: string): string;
|
|
24
|
+
/** The bytes of files that may follow `words` in one prompt to a session (at most `INLINE_FILE_BYTES`). */
|
|
25
|
+
export declare function roomAfter(words: string): number;
|
|
26
|
+
/** The type a file is judged by: the one the channel gave, else the extension of its name ("" none). */
|
|
27
|
+
export declare function typeOf(file: Pick<InboundFile, "name" | "type">): string;
|
|
28
|
+
/** Whether a file is one passed inline: a text type (an image never is). */
|
|
29
|
+
export declare function passesInline(file: Pick<InboundFile, "name" | "type">): boolean;
|
|
30
|
+
/** The most files, and bytes of them in all, one prompt carries to a machine (the wire contract's limits). */
|
|
31
|
+
export declare const SESSION_FILES = 10;
|
|
32
|
+
export declare const SESSION_FILE_BYTES: number;
|
|
33
|
+
/** What became of a message's files on their way to a session. */
|
|
34
|
+
export interface InlineFiles {
|
|
35
|
+
/** The text that goes after the person's words ("" none). */
|
|
36
|
+
readonly section: string;
|
|
37
|
+
/** How many files it carries inline. */
|
|
38
|
+
readonly passed: number;
|
|
39
|
+
/** The files that go as files (the machine saves them and names them in the prompt): only where it `takesFiles`. */
|
|
40
|
+
readonly files: FetchedFile[];
|
|
41
|
+
/** [name the person knows it by, why it did not reach the session]. */
|
|
42
|
+
readonly notPassed: [name: string, why: string][];
|
|
43
|
+
}
|
|
44
|
+
export interface InlineOptions {
|
|
45
|
+
/** The most bytes of text passed inline. */
|
|
46
|
+
readonly budget?: number;
|
|
47
|
+
/** The session's machine takes files: a file that is not text goes as a file (fetched), not named back. */
|
|
48
|
+
readonly asFiles?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type Fetch = (file: InboundFile) => Promise<Result<FetchedFile, FileRefused>>;
|
|
51
|
+
/**
|
|
52
|
+
* The files, fetched through `fetch` (an image or another file that is not text only when the machine takes files), as
|
|
53
|
+
* the text that follows the person's words to the session and the files that go with it. `shown(file, i)` is the name
|
|
54
|
+
* the person knows file i (1-based) by.
|
|
55
|
+
*/
|
|
56
|
+
export declare function inlineFiles(files: readonly InboundFile[], fetch: Fetch, shown: (file: InboundFile, index: number) => string, options?: InlineOptions): Promise<InlineFiles>;
|
|
57
|
+
export {};
|