@primusclaw/personal-agent 0.11.0 → 0.13.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 +2783 -2004
- package/dist/types/assistant/actions.d.ts +8 -1
- package/dist/types/assistant/confirm-outcome.d.ts +5 -2
- package/dist/types/assistant/events.d.ts +34 -4
- package/dist/types/assistant/say.d.ts +5 -2
- package/dist/types/assistant/seat-dispatch-outcome.d.ts +8 -0
- package/dist/types/assistant/seat-outcome.d.ts +4 -0
- package/dist/types/assistant/views.d.ts +21 -0
- package/dist/types/claw/model.d.ts +10 -0
- package/dist/types/claw/work-item.d.ts +17 -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/language/chosen.d.ts +2 -1
- package/dist/types/locales/assistant-cards.d.ts +9 -0
- package/dist/types/locales/assistant-seats.d.ts +46 -0
- package/dist/types/locales/assistant-work-clicks.d.ts +5 -0
- package/dist/types/locales/index.d.ts +1 -0
- package/dist/types/locales/remote-agents.d.ts +1 -0
- package/dist/types/locales/remote.d.ts +7 -0
- package/dist/types/locales/terminal-approvals.d.ts +14 -0
- package/dist/types/ports/claw/assistant.d.ts +5 -2
- 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/assistant.d.ts +13 -2
- package/dist/types/ports/store/remote.d.ts +5 -0
- package/dist/types/ports/surface.d.ts +22 -0
- package/dist/types/proactive/deliver.d.ts +5 -0
- package/dist/types/proactive/deps.d.ts +4 -0
- package/dist/types/proactive/quiet.d.ts +4 -1
- package/dist/types/protocol/claw-api/assistant-events.d.ts +44 -4
- package/dist/types/protocol/remote-agents.d.ts +90 -0
- package/dist/types/remote/agents.d.ts +2 -0
- package/dist/types/remote/approvals-command.d.ts +2 -1
- package/dist/types/remote/chat-key.d.ts +2 -0
- package/dist/types/remote/context.d.ts +4 -1
- package/dist/types/remote/prompt.d.ts +11 -1
- package/dist/types/remote/remote-agents.d.ts +2 -0
- package/dist/types/remote/state.d.ts +4 -1
- package/dist/types/remote-view/permission-view.d.ts +4 -0
- package/dist/types/routing/chat.d.ts +4 -3
- 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/question-reply.d.ts +6 -1
- package/dist/types/routing/session-files.d.ts +57 -0
- package/dist/types/routing/turn-runner.d.ts +3 -2
- package/dist/types/routing/turn-start.d.ts +8 -13
- package/package.json +1 -1
|
@@ -76,10 +76,34 @@ export interface AssistantConfirmWrite {
|
|
|
76
76
|
* started for the person's own account holds for them (`claw_github_confirmations`, `assistant/review-items.ts`); the same decision
|
|
77
77
|
* route answers it, and it is made exactly as `POST /v1/github-review/confirmations/{confirmation_id}/decision` makes it.
|
|
78
78
|
*/
|
|
79
|
-
kind: "trigger_create" | "trigger_cancel" | "github_comment" | "devenv_send" | "devenv_hide" | "skill_save" | "github_merge" | "github_review";
|
|
79
|
+
kind: "trigger_create" | "trigger_cancel" | "github_comment" | "devenv_send" | "devenv_hide" | "skill_save" | "seat_role" | "seat_set" | "seat_dispatch" | "github_merge" | "github_review";
|
|
80
80
|
/** What the button that lets it through says, in the language of the text. */
|
|
81
81
|
allow_label: string;
|
|
82
82
|
expires_at: string;
|
|
83
|
+
/**
|
|
84
|
+
* Only on `seat_dispatch` when the router named several places a task could go (2 to 5): a choice card. A channel draws one button per
|
|
85
|
+
* option and one that cancels (`deny`); the button carries only the card, and the channel reads which option it was from its own record
|
|
86
|
+
* of the card, then posts `{decision: "allow", choice: option.id}`. Claw checks the choice is one it offered. A channel that cannot draw
|
|
87
|
+
* buttons shows the text; the person names the place in the chat.
|
|
88
|
+
*/
|
|
89
|
+
options?: AssistantConfirmOption[];
|
|
90
|
+
}
|
|
91
|
+
/** One place a `seat_dispatch` choice card offers. */
|
|
92
|
+
export interface AssistantConfirmOption {
|
|
93
|
+
/** Opaque, at most 64 characters (a seat's id, or `sandbox`). */
|
|
94
|
+
id: string;
|
|
95
|
+
/** The name the person confirmed for the seat, else `<machine>/<agent>`: one plain line of at most 40 code points. */
|
|
96
|
+
label: string;
|
|
97
|
+
/** The folder, as the machine reported it: shown as text only. */
|
|
98
|
+
detail?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The body of `POST /v1/assistant/confirmations/{confirmation_id}/decision`. `choice` only on a card with `options`, and required there
|
|
102
|
+
* for `allow`: the `id` of the option picked.
|
|
103
|
+
*/
|
|
104
|
+
export interface AssistantConfirmationDecision {
|
|
105
|
+
decision: "allow" | "deny";
|
|
106
|
+
choice?: string;
|
|
83
107
|
}
|
|
84
108
|
/**
|
|
85
109
|
* A personal skill as a message shows it (`assistant/skill-writes.ts`): what was just saved, changed, turned off or deleted at the
|
|
@@ -147,9 +171,10 @@ export interface AssistantRemoteNotice {
|
|
|
147
171
|
/**
|
|
148
172
|
* `resolved` (only for a terminal's request, `ask.origin` "terminal"): a request this channel was sent as a card was answered, or stopped
|
|
149
173
|
* waiting, somewhere else (`resolved`), so a channel that still shows that card marks it so in place; the text says the same in one line
|
|
150
|
-
* for a channel that does not.
|
|
174
|
+
* for a channel that does not. `progress` (only for a task the assistant handed to a seat): the hourly line of a task that has run
|
|
175
|
+
* more than an hour, naming its latest step.
|
|
151
176
|
*/
|
|
152
|
-
kind: "done" | "needs_you" | "error" | "resolved";
|
|
177
|
+
kind: "done" | "needs_you" | "error" | "resolved" | "progress";
|
|
153
178
|
session_id: string;
|
|
154
179
|
machine: string;
|
|
155
180
|
agent: string;
|
|
@@ -159,11 +184,21 @@ export interface AssistantRemoteNotice {
|
|
|
159
184
|
*/
|
|
160
185
|
tool?: "claude" | "codex" | "cursor";
|
|
161
186
|
ask?: AssistantRemoteAsk;
|
|
162
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* With `kind: "resolved"`: which request, and who ended it (`terminal`, or `timeout`, `park_expired`, `session_end`, `connector_restart`
|
|
189
|
+
* when nobody did).
|
|
190
|
+
*/
|
|
163
191
|
resolved?: {
|
|
164
192
|
action_id: string;
|
|
165
193
|
by: string;
|
|
166
194
|
};
|
|
195
|
+
/** A task the assistant handed to a seat: its item number (`#N`). Absent for a session's own message. */
|
|
196
|
+
item_seq?: number;
|
|
197
|
+
/** A task the assistant handed to a seat: which seat; `alias` is the name the person confirmed for it, null when none. */
|
|
198
|
+
seat?: {
|
|
199
|
+
seat_id: string;
|
|
200
|
+
alias: string | null;
|
|
201
|
+
};
|
|
167
202
|
}
|
|
168
203
|
/** A permission request a development environment's agent waits on (`permissionRequest`), as its connector posted it. */
|
|
169
204
|
export interface AssistantRemoteAsk {
|
|
@@ -203,6 +238,11 @@ export interface AssistantRemoteAsk {
|
|
|
203
238
|
* which withdraws the card (Codex).
|
|
204
239
|
*/
|
|
205
240
|
terminal_asks?: TerminalAsks;
|
|
241
|
+
/**
|
|
242
|
+
* The request outlived its first wait and the connector keeps waiting (a task the assistant handed to a seat): `expires_at` is then
|
|
243
|
+
* when that longer wait ends. The one reminder Claw sends for it carries this.
|
|
244
|
+
*/
|
|
245
|
+
parked?: true;
|
|
206
246
|
}
|
|
207
247
|
/** When a terminal asks a request that is also on a card, besides alongside it: see {@link AssistantRemoteAsk.terminal_asks}. */
|
|
208
248
|
export type TerminalAsks = "after_card" | "on_input";
|
|
@@ -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,28 @@ 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 permission request of a turn sent with `park_permissions` outlived the connector's own wait (`permissionTtlMs`): instead of refusing
|
|
75
|
+
* it, the connector keeps it open until `parked_until` (at most {@link PERMISSION_PARK_MAX_MS} after it was asked), still answerable and
|
|
76
|
+
* cancellable as before. Data: `{actionId, cmd_seq, parked_until}` (`cmd_seq`: the prompt of the turn that asked, null when not known).
|
|
77
|
+
* When the park ends unanswered the connector refuses it and posts `permission_resolved` with `by: "park_expired"`.
|
|
78
|
+
*/
|
|
79
|
+
export declare const REMOTE_EVENT_PERMISSION_PARKED = "permission_parked";
|
|
80
|
+
/** The longest a connector keeps a parked permission request open (see {@link REMOTE_EVENT_PERMISSION_PARKED}). */
|
|
81
|
+
export declare const PERMISSION_PARK_MAX_MS: number;
|
|
82
|
+
/**
|
|
83
|
+
* `permissionRequest` and `permission_parked` carry `cmd_seq`: the prompt of the turn that asked (absent from connector 0.3.1 and
|
|
84
|
+
* older). `permission_resolved.by` is `park_expired` when a parked request's park ended unanswered.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* A turn of a conversation open in a terminal ended while nobody was at that terminal, posted on the conversation's terminal-hook
|
|
88
|
+
* session (`origin` "terminal_hook") by its connector: `{ref, outcome: "done" | "error", error?, message, agent, cwd, ended_at,
|
|
89
|
+
* away_ms}`. `message` is the end of what the agent last said (untrusted text); `error` names why a turn that failed did
|
|
90
|
+
* (Claude Code's `StopFailure` reason, such as `rate_limit`). The connector posts it only once the terminal has had no input for a
|
|
91
|
+
* minute after the turn ended, and never while a chat follows the conversation; Claw tells the owner, unless they turned the
|
|
92
|
+
* terminal pushes off or muted that conversation.
|
|
93
|
+
*/
|
|
94
|
+
export declare const REMOTE_EVENT_TERMINAL_TURN_END = "terminal_turn_end";
|
|
69
95
|
/**
|
|
70
96
|
* What the person sent a session (a `prompt` command), written by Claw itself when it queues the prompt: `{text, cmd_id, cmd_seq,
|
|
71
97
|
* client, by: "claw"}` with a negative `seq`. An agent's events carry only its own side, so without it a window opened on the
|
|
@@ -101,7 +127,51 @@ export interface RemoteHeartbeat {
|
|
|
101
127
|
cmdCursor: number | null;
|
|
102
128
|
/** What the connector holds that Claw has not acknowledged yet (`outbox` on the wire); absent from an older connector. */
|
|
103
129
|
outbox?: RemoteOutboxReport | null;
|
|
130
|
+
/**
|
|
131
|
+
* The git repository of each folder its sessions work in (`workspaces` on the wire, {@link parseWorkspacesReport}); absent (null)
|
|
132
|
+
* from a connector that does not report it, which is every connector before the agent capability `git_info`.
|
|
133
|
+
*/
|
|
134
|
+
workspaces?: RemoteWorkspace[] | null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* How much of the folders' git facts one heartbeat carries. A folder named by anyone, a remote and a branch named by whoever made the
|
|
138
|
+
* repository: each is cut to a shape that cannot carry more than a name, and the whole report is bounded.
|
|
139
|
+
*/
|
|
140
|
+
export declare const REMOTE_WORKSPACE_LIMITS: {
|
|
141
|
+
/** Folders one heartbeat reports, at most. */
|
|
142
|
+
readonly maxEntries: 32;
|
|
143
|
+
readonly maxCwdChars: 1024;
|
|
144
|
+
/** A remote as {@link normalizeGitRemote} writes it: `host/owner/repo`. */
|
|
145
|
+
readonly maxRemoteChars: 200;
|
|
146
|
+
readonly maxBranchChars: 100;
|
|
147
|
+
};
|
|
148
|
+
/** One folder's git facts: the remote its `origin` names and the branch checked out, each null when there is none or it is unreadable. */
|
|
149
|
+
export interface RemoteWorkspace {
|
|
150
|
+
cwd: string;
|
|
151
|
+
git_remote: string | null;
|
|
152
|
+
git_branch: string | null;
|
|
104
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* A git remote as `host/owner/repo` (lower-case host, no scheme, no `.git`), or null when it is not a remote that can be written that
|
|
156
|
+
* way. Whatever names a person or carries a secret goes: the user (`git@`, `user:token@`), a query and a fragment; and a remote with a
|
|
157
|
+
* path segment shaped like a credential (`ghp_...`, a long opaque run) is no remote at all, never one with the secret cut out. A local
|
|
158
|
+
* path (`/srv/repo.git`, `file://`) is null: it names a folder on that machine, not a repository anyone else knows.
|
|
159
|
+
*/
|
|
160
|
+
export declare function normalizeGitRemote(raw: unknown): string | null;
|
|
161
|
+
/**
|
|
162
|
+
* A remote as a connector reports it: already `host/owner/repo` ({@link normalizeGitRemote} on the machine), checked to be exactly
|
|
163
|
+
* that shape again; else null. A URL (a connector that sent one raw) is normalized here the same way.
|
|
164
|
+
*/
|
|
165
|
+
export declare function normalizedRemote(raw: unknown): string | null;
|
|
166
|
+
/** A branch name as git allows it (and no more), or null: no `..`, no leading `-` or `/`, no control or space, at most 100 characters. */
|
|
167
|
+
export declare function normalizeGitBranch(raw: unknown): string | null;
|
|
168
|
+
/**
|
|
169
|
+
* The heartbeat's `workspaces`, or null when it is absent or not a list. Lenient, as the outbox report is: an entry that does not fit
|
|
170
|
+
* is left out, never a reason to refuse the heartbeat; a remote or a branch that does not normalize is null; at most
|
|
171
|
+
* {@link REMOTE_WORKSPACE_LIMITS.maxEntries} folders, each once. Normalized again here whatever the connector did: Claw never stores
|
|
172
|
+
* what it did not shape itself.
|
|
173
|
+
*/
|
|
174
|
+
export declare function parseWorkspacesReport(raw: unknown): RemoteWorkspace[] | null;
|
|
105
175
|
/** Sessions an outbox report names at most, the longest waiting first. */
|
|
106
176
|
export declare const REMOTE_OUTBOX_REPORT_MAX_SESSIONS = 20;
|
|
107
177
|
/** One session's part of an outbox report. */
|
|
@@ -225,6 +295,11 @@ export declare function parseTerminalSessionOpen(body: unknown): Parsed<RemoteTe
|
|
|
225
295
|
export declare function parseApprovalsSetting(body: unknown): Parsed<{
|
|
226
296
|
enabled: boolean;
|
|
227
297
|
}>;
|
|
298
|
+
/** `PUT /v1/remote-agents/approvals/mutes`: mute (or unmute) the conversation behind work item `#item`, one open in a terminal. */
|
|
299
|
+
export declare function parseTerminalMute(body: unknown): Parsed<{
|
|
300
|
+
item: number;
|
|
301
|
+
muted: boolean;
|
|
302
|
+
}>;
|
|
228
303
|
/**
|
|
229
304
|
* Hiding conversations of a machine from its owner's lists (`POST /v1/remote-agents/connectors/:cid/hidden`), and the
|
|
230
305
|
* listing that leaves them out (`GET /v1/remote-agents/connectors`, `?hidden=include` to list them too). Nothing on the
|
|
@@ -292,6 +367,21 @@ export interface RemoteCommandSpec {
|
|
|
292
367
|
/** What the audit trail keeps. Never the text a user typed. */
|
|
293
368
|
audit(payload: Record<string, unknown>): Record<string, unknown>;
|
|
294
369
|
}
|
|
370
|
+
/** A file a prompt carries, as the connector receives it. */
|
|
371
|
+
export interface RemotePromptFile {
|
|
372
|
+
/** One safe path component: letters, digits, `._ -`, no leading dot, at most 100 characters. */
|
|
373
|
+
name: string;
|
|
374
|
+
media_type: string;
|
|
375
|
+
/** The bytes, base64. */
|
|
376
|
+
data: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The files a prompt carries (`files`, optional): at most {@link REMOTE_AGENT_LIMITS.maxPromptFiles}, each a safe name, a
|
|
380
|
+
* media type and its bytes in base64, all together at most {@link REMOTE_AGENT_LIMITS.maxPromptFileBytes} decoded, no two
|
|
381
|
+
* with one name (compared without case). A connector that says it can (the agent capability `prompt_files`) saves them on its machine and names
|
|
382
|
+
* where in the prompt; Claw keeps them only while the command waits to be delivered, never in the session's events.
|
|
383
|
+
*/
|
|
384
|
+
export declare function parsePromptFiles(raw: unknown): Parsed<RemotePromptFile[]>;
|
|
295
385
|
export declare const REMOTE_COMMANDS: Record<RemoteCommandType, RemoteCommandSpec>;
|
|
296
386
|
export declare function isRemoteCommandType(v: unknown): v is RemoteCommandType;
|
|
297
387
|
/** 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
|
}
|
|
@@ -10,4 +10,6 @@ export declare const GROUP_KEY_SEP = "#";
|
|
|
10
10
|
export declare function groupChatKey(userId: string, conversationId: string): string;
|
|
11
11
|
/** The person a chat key belongs to: the key itself for a 1:1 chat, the binder for a group's. */
|
|
12
12
|
export declare function personOf(chatKey: string): string;
|
|
13
|
+
/** The group conversation a chat key binds ("" for a 1:1 chat's). */
|
|
14
|
+
export declare function groupConversationOf(chatKey: string): string;
|
|
13
15
|
export declare function isGroupKey(chatKey: string): boolean;
|
|
@@ -7,6 +7,7 @@ import type { PublicErrors } from "../public-error/public-errors.js";
|
|
|
7
7
|
import type { Clock } from "../ports/clock.js";
|
|
8
8
|
import type { Logger } from "../ports/logger.js";
|
|
9
9
|
import type { Random } from "../ports/random.js";
|
|
10
|
+
import type { GroupLanguageRepository } from "../ports/store/group-language.js";
|
|
10
11
|
import type { ConversationRefRepository, PrefsRepository } from "../ports/store/people.js";
|
|
11
12
|
import type { RemotePermissionRepository, RemoteSessionNameRepository, RemoteStateRepository } from "../ports/store/remote.js";
|
|
12
13
|
import type { Conversation } from "../ports/surface.js";
|
|
@@ -69,6 +70,8 @@ export interface RemoteContext {
|
|
|
69
70
|
readonly sessionNames: RemoteSessionNameRepository;
|
|
70
71
|
readonly permissions: RemotePermissionRepository;
|
|
71
72
|
readonly prefs: PrefsRepository;
|
|
73
|
+
/** The language each group chat's members set (none given: a group binding's texts are English). */
|
|
74
|
+
readonly groupLanguage?: GroupLanguageRepository;
|
|
72
75
|
readonly references: ConversationRefRepository;
|
|
73
76
|
/** The conversation a stored reference posts to. */
|
|
74
77
|
conversationFor(reference: JsonObject): Conversation;
|
|
@@ -89,7 +92,7 @@ export interface RemoteContext {
|
|
|
89
92
|
readonly logger: Logger;
|
|
90
93
|
/** The hex digest of `text` (UTF-8): an idempotency key, a correlation id. */
|
|
91
94
|
digestHex(algorithm: "sha1" | "sha256", text: string): string;
|
|
92
|
-
/** The language a person is answered in. */
|
|
95
|
+
/** The language a person is answered in (their 1:1 chat's; a group binding's is the group's, `ChatState.lang`). */
|
|
93
96
|
langOf(person: string): Lang;
|
|
94
97
|
/** PA_DIRECT_CHAT: whose 1:1 chat is the agent's window itself. */
|
|
95
98
|
readonly directChat: DirectChat;
|
|
@@ -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). */
|
|
@@ -12,7 +12,10 @@ export declare class ChatState {
|
|
|
12
12
|
private readonly views;
|
|
13
13
|
constructor(ctx: RemoteContext, chats: ChatRegistry);
|
|
14
14
|
attached(chatKey: string): RemoteState | null;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The language the chat is answered in ("en" when it cannot be read): a 1:1 chat's is its person's; a group binding's is the
|
|
17
|
+
* group's, the one its members set (`/lang zh|en`, `groupLangOf`), else English, never the binder's own.
|
|
18
|
+
*/
|
|
16
19
|
lang(chatKey: string): Lang;
|
|
17
20
|
/** PA_DIRECT_CHAT is on for this 1:1 chat's person (a group binding keeps its session card). */
|
|
18
21
|
directOn(chatKey: string): boolean;
|
|
@@ -41,6 +41,10 @@ export interface RemoteAsk {
|
|
|
41
41
|
readonly agent: string;
|
|
42
42
|
/** Which errand: `#seq title`. */
|
|
43
43
|
readonly about: string;
|
|
44
|
+
/** The name the person gave the seat the errand went to (absent: none): the card's title names it. */
|
|
45
|
+
readonly seat?: string | undefined;
|
|
46
|
+
/** The one reminder of a request the agent keeps waiting on: the card says it still waits, until when. */
|
|
47
|
+
readonly parked?: boolean | undefined;
|
|
44
48
|
readonly expiresAt: number;
|
|
45
49
|
readonly zone: string;
|
|
46
50
|
}
|
|
@@ -22,10 +22,11 @@ export declare function helpLang(store: Pick<RouterStore, "prefs">, userId: stri
|
|
|
22
22
|
/**
|
|
23
23
|
* The language a group chat is answered in, its fixed texts and its answers alike: the one its members set (`/lang zh|en` there,
|
|
24
24
|
* or a pick on its language card); else (none set, or "follow the asker") the language of the message being answered (`written`).
|
|
25
|
-
* A
|
|
26
|
-
* language
|
|
25
|
+
* A message that says no language of its own ("help", "/new", a link) is answered in English: a group's members share no other
|
|
26
|
+
* language, so neither the sender's own (`/lang` in their 1:1 chat, or the one their messages were last written in) nor their
|
|
27
|
+
* client's locale is read here.
|
|
27
28
|
*/
|
|
28
|
-
export declare function groupLangOf(store:
|
|
29
|
+
export declare function groupLangOf(store: Partial<Pick<RouterStore, "groupLanguage">>, conversationId: string, written: string): Lang;
|
|
29
30
|
/** The language a group chat's members set, when it is one (`/lang zh|en`); undefined for none, and for "follow the asker". */
|
|
30
31
|
export declare function groupChosenLang(store: Partial<Pick<RouterStore, "groupLanguage">>, conversationId: string): Lang | undefined;
|
|
31
32
|
/** One chat as the router answers in it: who wrote, where to answer, and in which language. */
|
|
@@ -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. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Chat } from "./chat.js";
|
|
2
2
|
import type { RouterContext } from "./context.js";
|
|
3
3
|
/**
|
|
4
4
|
* A question with less than this left of its wait is not answered from a typed message: Brain may already have stopped
|
|
@@ -10,6 +10,11 @@ export declare const TYPED_ANSWER_MARGIN_SECONDS = 15;
|
|
|
10
10
|
export interface TypedReply {
|
|
11
11
|
readonly chat: Chat;
|
|
12
12
|
readonly text: string;
|
|
13
|
+
/**
|
|
14
|
+
* What the message forwards, as text for the model ("" none), read once there is a question to answer: it goes to Claw with
|
|
15
|
+
* the answer, since no other message carries it (the card shows only the words).
|
|
16
|
+
*/
|
|
17
|
+
readonly forward?: () => string;
|
|
13
18
|
/** The Claw credential of the person, read when there is a question to answer. */
|
|
14
19
|
readonly credential: () => Promise<string>;
|
|
15
20
|
}
|
|
@@ -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 {};
|
|
@@ -45,8 +45,9 @@ export interface TurnRun {
|
|
|
45
45
|
readonly lang: Lang;
|
|
46
46
|
/**
|
|
47
47
|
* The language the turn is to be answered in, told to Claw after the message: in a 1:1 chat the one the person chose (`/lang
|
|
48
|
-
* zh|en`, `chosenLang`), in a group the group's (`groupChosenLang`), or with none the
|
|
49
|
-
*
|
|
48
|
+
* zh|en`, `chosenLang`), in a group the group's (`groupChosenLang`), or with none the language of the message's own words
|
|
49
|
+
* (`writtenLang`), else English; undefined (a 1:1 chat with none chosen): the answer is in the language of what they wrote.
|
|
50
|
+
* A chat turn's only: a review's follows its request.
|
|
50
51
|
*/
|
|
51
52
|
readonly replyLang?: Lang;
|
|
52
53
|
/** The answer gets thumbs of the worker's own (a phone, whose own thumbs never reach the worker). */
|
|
@@ -51,6 +51,11 @@ export interface StartTurn {
|
|
|
51
51
|
readonly messageId: string;
|
|
52
52
|
readonly clientPlatform: string;
|
|
53
53
|
readonly quote?: string;
|
|
54
|
+
/**
|
|
55
|
+
* What it forwards, alone, as text for the model ("": nothing): part of `quote` (beside what it quotes and, in a group, the
|
|
56
|
+
* chat's recent messages), and what goes with the words when they answer a waiting question. Read only then.
|
|
57
|
+
*/
|
|
58
|
+
readonly forward?: () => string;
|
|
54
59
|
readonly sent?: string;
|
|
55
60
|
readonly files?: readonly InboundFile[];
|
|
56
61
|
readonly review?: ReviewTurnStart;
|
|
@@ -69,7 +74,6 @@ export interface StartTurn {
|
|
|
69
74
|
export declare class TurnStarter {
|
|
70
75
|
private readonly ctx;
|
|
71
76
|
private readonly running;
|
|
72
|
-
private readonly askers;
|
|
73
77
|
constructor(ctx: RouterContext);
|
|
74
78
|
/** The turns that run now (a test waits for them). */
|
|
75
79
|
settled(): Promise<void>;
|
|
@@ -102,9 +106,9 @@ export declare class TurnStarter {
|
|
|
102
106
|
/**
|
|
103
107
|
* The language a chat turn is to be answered in (a review's answer follows its request's language). In a 1:1 chat the one the
|
|
104
108
|
* person chose, if any. In a group the group's (`groupChosenLang`; the sender's own choice is not read there); with none set, or
|
|
105
|
-
* "follow the asker", the language of the @-message's own words (`writtenLang`), else
|
|
106
|
-
*
|
|
107
|
-
* the model answers in the language of that history, not the asker's.
|
|
109
|
+
* "follow the asker", the language of the @-message's own words (`writtenLang`), else English, as the group's fixed texts are
|
|
110
|
+
* (`groupLangOf`): a message with no words of its own (`help`, `ok #3`, a link) is answered in English. A group's shared
|
|
111
|
+
* session holds every member's turns, and without the line the model answers in the language of that history, not the asker's.
|
|
108
112
|
*/
|
|
109
113
|
private replyLang;
|
|
110
114
|
private hooks;
|
|
@@ -116,12 +120,3 @@ export declare class TurnStarter {
|
|
|
116
120
|
*/
|
|
117
121
|
private recordSession;
|
|
118
122
|
}
|
|
119
|
-
/**
|
|
120
|
-
* The language each member of a group last asked in there, for a message with no words of its own (`ok`, `#3`, a link): kept in
|
|
121
|
-
* memory, per group and member, the newest `ASKERS_MAX`. After a restart such a message gets no language until its sender writes one.
|
|
122
|
-
*/
|
|
123
|
-
export declare class AskerLanguages {
|
|
124
|
-
private readonly last;
|
|
125
|
-
/** The language of `text` when it has words (and it is remembered), else the one remembered for `userId` in `scope`. */
|
|
126
|
-
answer(scope: string, userId: string, text: string): Lang | undefined;
|
|
127
|
-
}
|