@phren/cli 0.3.11 → 0.3.13
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/bridge/account-usage.d.ts +124 -0
- package/dist/bridge/account-usage.js +258 -0
- package/dist/bridge/agent-hook-stores.d.ts +3 -0
- package/dist/bridge/agent-hook-stores.js +5 -0
- package/dist/bridge/agent-hooks.d.ts +162 -5
- package/dist/bridge/agent-hooks.js +682 -49
- package/dist/bridge/approval-summary.d.ts +16 -0
- package/dist/bridge/approval-summary.js +133 -0
- package/dist/bridge/authority-command.d.ts +20 -0
- package/dist/bridge/authority-command.js +120 -0
- package/dist/bridge/authority.d.ts +223 -0
- package/dist/bridge/authority.js +231 -0
- package/dist/bridge/claude-account-setup.d.ts +14 -0
- package/dist/bridge/claude-account-setup.js +69 -0
- package/dist/bridge/claude-accounts.d.ts +49 -0
- package/dist/bridge/claude-accounts.js +195 -0
- package/dist/bridge/code-routes.js +2 -2
- package/dist/bridge/codex-app-server.d.ts +144 -0
- package/dist/bridge/codex-app-server.js +319 -0
- package/dist/bridge/codex-auth-refresh.d.ts +33 -0
- package/dist/bridge/codex-auth-refresh.js +71 -0
- package/dist/bridge/codex-hook-trust.d.ts +27 -0
- package/dist/bridge/codex-hook-trust.js +237 -0
- package/dist/bridge/codex-question-reply.d.ts +16 -0
- package/dist/bridge/codex-question-reply.js +57 -0
- package/dist/bridge/codex-review-mode.d.ts +10 -0
- package/dist/bridge/codex-review-mode.js +74 -0
- package/dist/bridge/codex-servers.d.ts +217 -0
- package/dist/bridge/codex-servers.js +636 -0
- package/dist/bridge/command.js +97 -4
- package/dist/bridge/computer-identity.d.ts +75 -0
- package/dist/bridge/computer-identity.js +166 -0
- package/dist/bridge/conductor-group.d.ts +91 -8
- package/dist/bridge/conductor-group.js +105 -9
- package/dist/bridge/conductor-role.d.ts +94 -0
- package/dist/bridge/conductor-role.js +176 -0
- package/dist/bridge/conductor-sets.d.ts +20 -0
- package/dist/bridge/conductor-sets.js +59 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +82 -12
- package/dist/bridge/dispatch-returns.d.ts +128 -19
- package/dist/bridge/dispatch-returns.js +371 -54
- package/dist/bridge/dispatch.d.ts +128 -3
- package/dist/bridge/dispatch.js +303 -42
- package/dist/bridge/fanouts.d.ts +7 -1
- package/dist/bridge/fanouts.js +39 -4
- package/dist/bridge/folder-trust.d.ts +56 -0
- package/dist/bridge/folder-trust.js +195 -0
- package/dist/bridge/grants.d.ts +22 -1
- package/dist/bridge/grants.js +57 -9
- package/dist/bridge/hand-off-queue.d.ts +74 -0
- package/dist/bridge/hand-off-queue.js +235 -0
- package/dist/bridge/hand-off.d.ts +30 -10
- package/dist/bridge/hand-off.js +79 -46
- package/dist/bridge/harness-status.d.ts +11 -0
- package/dist/bridge/harness-status.js +32 -0
- package/dist/bridge/harnesses.d.ts +39 -0
- package/dist/bridge/harnesses.js +65 -0
- package/dist/bridge/health.d.ts +2 -0
- package/dist/bridge/health.js +1 -1
- package/dist/bridge/herdr.d.ts +11 -2
- package/dist/bridge/herdr.js +98 -23
- package/dist/bridge/hook-fast.d.ts +4 -0
- package/dist/bridge/hook-fast.js +68 -0
- package/dist/bridge/install.d.ts +16 -1
- package/dist/bridge/install.js +102 -21
- package/dist/bridge/launch-brief.d.ts +96 -0
- package/dist/bridge/launch-brief.js +164 -0
- package/dist/bridge/model-switch.d.ts +3 -0
- package/dist/bridge/model-switch.js +17 -1
- package/dist/bridge/models.d.ts +8 -4
- package/dist/bridge/models.js +24 -8
- package/dist/bridge/mux-wire.d.ts +9 -0
- package/dist/bridge/mux-wire.js +19 -0
- package/dist/bridge/opencode-pane-server.d.ts +113 -0
- package/dist/bridge/opencode-pane-server.js +332 -0
- package/dist/bridge/opencode-panes.d.ts +111 -0
- package/dist/bridge/opencode-panes.js +295 -0
- package/dist/bridge/pane-accounts.d.ts +8 -0
- package/dist/bridge/pane-accounts.js +46 -0
- package/dist/bridge/pane-status.d.ts +12 -0
- package/dist/bridge/pane-status.js +50 -1
- package/dist/bridge/prompt-startup.d.ts +5 -0
- package/dist/bridge/prompt-startup.js +24 -0
- package/dist/bridge/protocol.d.ts +5 -0
- package/dist/bridge/protocol.js +4 -0
- package/dist/bridge/push.d.ts +11 -4
- package/dist/bridge/push.js +27 -4
- package/dist/bridge/questions.d.ts +37 -2
- package/dist/bridge/questions.js +158 -15
- package/dist/bridge/resources.d.ts +9 -3
- package/dist/bridge/resources.js +24 -8
- package/dist/bridge/schedule-format.d.ts +2 -0
- package/dist/bridge/schedule-format.js +3 -0
- package/dist/bridge/schedule-launch.d.ts +2 -1
- package/dist/bridge/schedule-launch.js +27 -53
- package/dist/bridge/schedule-watch.d.ts +24 -1
- package/dist/bridge/schedule-watch.js +89 -2
- package/dist/bridge/server-launch.d.ts +22 -5
- package/dist/bridge/server-launch.js +238 -32
- package/dist/bridge/server-overview.d.ts +10 -3
- package/dist/bridge/server-overview.js +32 -15
- package/dist/bridge/server-pane-routes.d.ts +3 -0
- package/dist/bridge/server-pane-routes.js +150 -18
- package/dist/bridge/server-routes.d.ts +11 -0
- package/dist/bridge/server-routes.js +214 -36
- package/dist/bridge/server-stream.d.ts +2 -0
- package/dist/bridge/server-stream.js +22 -8
- package/dist/bridge/server.d.ts +6 -1
- package/dist/bridge/server.js +58 -13
- package/dist/bridge/session-activity.d.ts +93 -0
- package/dist/bridge/session-activity.js +139 -0
- package/dist/bridge/session-rename.d.ts +48 -0
- package/dist/bridge/session-rename.js +190 -0
- package/dist/bridge/session-servers.js +2 -2
- package/dist/bridge/settings-switch.d.ts +60 -0
- package/dist/bridge/settings-switch.js +287 -0
- package/dist/bridge/speech-voice.d.ts +55 -0
- package/dist/bridge/speech-voice.js +132 -0
- package/dist/bridge/speech.d.ts +70 -11
- package/dist/bridge/speech.js +169 -41
- package/dist/bridge/stalls.d.ts +22 -0
- package/dist/bridge/stalls.js +57 -0
- package/dist/bridge/sudo.d.ts +209 -0
- package/dist/bridge/sudo.js +501 -0
- package/dist/bridge/terminal-herdr.js +9 -3
- package/dist/bridge/terminal-tmux.d.ts +15 -3
- package/dist/bridge/terminal-tmux.js +103 -13
- package/dist/bridge/terminal.d.ts +27 -4
- package/dist/bridge/terminal.js +8 -1
- package/dist/bridge/transcript-claude.d.ts +4 -0
- package/dist/bridge/transcript-claude.js +186 -16
- package/dist/bridge/transcript-codex.d.ts +0 -2
- package/dist/bridge/transcript-codex.js +29 -4
- package/dist/bridge/transcript-preview.d.ts +1 -0
- package/dist/bridge/transcript-preview.js +24 -4
- package/dist/bridge/transcripts.d.ts +15 -2
- package/dist/bridge/transcripts.js +47 -16
- package/dist/bridge/turn-records.d.ts +85 -0
- package/dist/bridge/turn-records.js +143 -0
- package/dist/bridge/uploads.d.ts +3 -0
- package/dist/bridge/uploads.js +14 -0
- package/dist/bridge/usage.d.ts +56 -10
- package/dist/bridge/usage.js +190 -45
- package/dist/bridge-hook.mjs +27975 -20636
- package/dist/cli/claude-unmanaged.d.ts +12 -0
- package/dist/cli/claude-unmanaged.js +105 -0
- package/dist/cli/schedules.js +2 -1
- package/dist/cli/session-start.js +10 -1
- package/dist/cli/session-stop.js +9 -1
- package/dist/cli-registry.js +31 -6
- package/dist/data/task-receipts.d.ts +19 -0
- package/dist/data/task-receipts.js +68 -0
- package/dist/data/tasks.js +4 -1
- package/dist/generated/memory-ui-graph.browser.js +63 -63
- package/dist/graph-core/model.js +24 -3
- package/dist/graph-core/types.d.ts +4 -1
- package/dist/graph-core/types.js +1 -0
- package/dist/init/init-preset.js +7 -3
- package/dist/init/init-uninstall.js +2 -11
- package/dist/init/teardown.d.ts +3 -0
- package/dist/init/teardown.js +47 -0
- package/dist/link/context.js +21 -9
- package/dist/mcp/plugin-mode.js +1 -1
- package/dist/memory-ui-graph.runtime.js +63 -63
- package/dist/modules/code-package.d.ts +1 -0
- package/dist/modules/code-package.js +36 -7
- package/dist/modules/registry.js +17 -16
- package/dist/profile-store.d.ts +6 -0
- package/dist/profile-store.js +25 -1
- package/dist/shell/graph/glyphs.js +4 -0
- package/dist/shell/graph/graph-view.js +2 -0
- package/dist/status.js +7 -1
- package/dist/sync/task-claim.js +3 -2
- package/dist/task/lifecycle.js +25 -4
- package/dist/test-global-setup.js +5 -0
- package/dist/tools/dispatch.js +52 -4
- package/dist/tools/tasks.js +10 -1
- package/package.json +1 -1
- package/plugins/opencode/phren-transcript.js +87 -4
- package/starter/global/AGENTS.md +4 -0
- package/starter/global/skills/conductor/SKILL.md +51 -4
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from "node:http";
|
|
2
|
+
import { type Json } from "./protocol.js";
|
|
3
|
+
/**
|
|
4
|
+
* sudo with no terminal, answered from the phone.
|
|
5
|
+
*
|
|
6
|
+
* `sudo -A` runs `SUDO_ASKPASS` (`<bridge>/askpass`, a two-line script the
|
|
7
|
+
* Hook installs) with its prompt as the argument and reads the password from
|
|
8
|
+
* its stdout. The script runs the bundle's `askpass`, which asks the Hook over
|
|
9
|
+
* agent.sock and holds the connection. The password must reach sudo and no
|
|
10
|
+
* one else, so before asking the phone the Hook checks the whole chain
|
|
11
|
+
* (`verifyAsker`): the asker is this Hook's node running its bundle with no
|
|
12
|
+
* flags, its parent is the installed script, that script's parent is a sudo
|
|
13
|
+
* running as root (euid 0, which no process of the owner's can fake), and the
|
|
14
|
+
* asker's stdout is a pipe no other process of the owner's reads. The
|
|
15
|
+
* connection is bound to that process too: on macOS its other end must be
|
|
16
|
+
* held by the asker alone; on Linux the Hook writes the password straight into
|
|
17
|
+
* the asker's stdout (`/proc/<pid>/fd/1`), so a connection that names another
|
|
18
|
+
* process's pid gets nothing. It reads
|
|
19
|
+
* that sudo's command line itself and pushes the request to the phone; `GET /v1/sudo` and the overview socket's `sudo` frame
|
|
20
|
+
* list it. `POST /v1/sudo/answer` writes the password into the held
|
|
21
|
+
* connection and forgets the request: the password is never logged, stored,
|
|
22
|
+
* or kept past that write. Deny, a timeout, no reachable phone, or the asker
|
|
23
|
+
* going away ends the request, and askpass exits non-zero, so sudo fails.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SUDO_HOLD_MS: number;
|
|
26
|
+
/** Held askpass requests at once; more are refused. */
|
|
27
|
+
export declare const MAX_SUDO_PENDING = 8;
|
|
28
|
+
/** How long after a password is handed over the Hook waits to see whether
|
|
29
|
+
* sudo asks again, before calling it accepted. */
|
|
30
|
+
export declare const SUDO_OUTCOME_MS: number;
|
|
31
|
+
export type SudoOutcome = "accepted" | "rejected" | "unknown";
|
|
32
|
+
export declare const ASKPASS_FILE = "askpass";
|
|
33
|
+
export declare const askpassPath: () => string;
|
|
34
|
+
export declare const askpassInstalled: () => boolean;
|
|
35
|
+
/** SUDO_ASKPASS for a launch, when this computer's Hook installed its helper. */
|
|
36
|
+
export declare const askpassEnv: () => Record<string, string>;
|
|
37
|
+
/** sudo runs SUDO_ASKPASS with no arguments of its own, so the helper is a
|
|
38
|
+
* script: the node that installed the Hook, the current bundle, `askpass`.
|
|
39
|
+
* It stays node's parent (no exec) so the Hook can see it in the chain, and
|
|
40
|
+
* drops what would load other code into node. */
|
|
41
|
+
export declare function askpassScript(node: string, bundle: string): string;
|
|
42
|
+
export declare function installAskpass(node: string, bundle: string): Promise<void>;
|
|
43
|
+
export declare function removeAskpass(): Promise<void>;
|
|
44
|
+
export interface SudoSession {
|
|
45
|
+
source?: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
server?: string;
|
|
48
|
+
workspace?: string;
|
|
49
|
+
tab?: string;
|
|
50
|
+
pane?: string;
|
|
51
|
+
}
|
|
52
|
+
/** What the phone sees. Never carries a password. */
|
|
53
|
+
export interface SudoRequestView {
|
|
54
|
+
/** `account` is whose password sudo asks for (the invoking user); `user` is who the command runs as. */
|
|
55
|
+
id: string;
|
|
56
|
+
computer: string;
|
|
57
|
+
command: string;
|
|
58
|
+
account?: string;
|
|
59
|
+
user?: string;
|
|
60
|
+
cwd?: string;
|
|
61
|
+
session?: SudoSession;
|
|
62
|
+
askedAt: string;
|
|
63
|
+
expiresAt: string;
|
|
64
|
+
}
|
|
65
|
+
/** What askpass gets: the password to print, word that the Hook wrote it into
|
|
66
|
+
* askpass's stdout itself (Linux), or why not. */
|
|
67
|
+
export type SudoReply = {
|
|
68
|
+
password: string;
|
|
69
|
+
} | {
|
|
70
|
+
delivered: true;
|
|
71
|
+
} | {
|
|
72
|
+
error: string;
|
|
73
|
+
status: number;
|
|
74
|
+
};
|
|
75
|
+
/** The command a sudo process will run, without sudo's own options, and the
|
|
76
|
+
* user it runs as. Falls back to the whole line when there is no command
|
|
77
|
+
* (`sudo -v`, `sudo -s`). */
|
|
78
|
+
export declare function sudoCommand(argv: string[]): {
|
|
79
|
+
command: string;
|
|
80
|
+
user?: string;
|
|
81
|
+
};
|
|
82
|
+
export interface ProcessRecord {
|
|
83
|
+
ppid: number;
|
|
84
|
+
/** Effective user id. */
|
|
85
|
+
euid: number;
|
|
86
|
+
/** Executable name (`comm`). */
|
|
87
|
+
name: string;
|
|
88
|
+
/** Arguments, split on NULs on Linux and on spaces on macOS. */
|
|
89
|
+
argv: string[];
|
|
90
|
+
/** The whole command line as ps prints it. */
|
|
91
|
+
line: string;
|
|
92
|
+
/** Environment names, where the platform shows them (Linux). */
|
|
93
|
+
env?: string[];
|
|
94
|
+
/** When it started (`ps -o lstart`), to tell it from a later process with its pid. */
|
|
95
|
+
started?: string;
|
|
96
|
+
}
|
|
97
|
+
/** One process's parent, effective uid, name and arguments. */
|
|
98
|
+
export declare function readProcess(pid: number): Promise<ProcessRecord | undefined>;
|
|
99
|
+
/** Whether `pid`'s stdout is a pipe that no process of the owner's other than
|
|
100
|
+
* `allowed` holds. sudo, running as root, is never visible here. */
|
|
101
|
+
export declare function stdoutReaders(pid: number, allowed: number[]): Promise<"sudo" | "other" | "unknown">;
|
|
102
|
+
/** macOS: whether the other end of the Hook's connection `hookFd` is held by
|
|
103
|
+
* `pid` and no other process of the owner's. */
|
|
104
|
+
export declare function connectionHolders(pid: number, hookFd: number | undefined): Promise<"asker" | "other" | "unknown">;
|
|
105
|
+
/** Linux: a process's start time, to tell it from a later one with its pid. */
|
|
106
|
+
export declare function processStart(pid: number): Promise<string | undefined>;
|
|
107
|
+
export interface AskerCheck {
|
|
108
|
+
processes: (pid: number) => Promise<ProcessRecord | undefined>;
|
|
109
|
+
stdout: (pid: number, allowed: number[]) => Promise<"sudo" | "other" | "unknown">;
|
|
110
|
+
/** Whether the connection that asked belongs to the asker alone. */
|
|
111
|
+
connection: (pid: number) => Promise<"asker" | "other" | "unknown">;
|
|
112
|
+
/** This Hook's node and the bundle paths askpass may run from. */
|
|
113
|
+
node: string;
|
|
114
|
+
bundles: string[];
|
|
115
|
+
script: string;
|
|
116
|
+
unprivilegedSudo?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** The chain from askpass up to sudo, or why it is refused. */
|
|
119
|
+
export declare function verifyAsker(pid: number, check: AskerCheck): Promise<{
|
|
120
|
+
sudo: ProcessRecord;
|
|
121
|
+
sudoPid: number;
|
|
122
|
+
} | {
|
|
123
|
+
refused: string;
|
|
124
|
+
}>;
|
|
125
|
+
export interface SudoBrokerOptions {
|
|
126
|
+
computer: () => string;
|
|
127
|
+
push?: {
|
|
128
|
+
readonly available: boolean;
|
|
129
|
+
notifySudo(value: SudoRequestView): Promise<boolean>;
|
|
130
|
+
};
|
|
131
|
+
/** Label and agent for the pane that asked, when the Hook can place it. */
|
|
132
|
+
describe?: (place: {
|
|
133
|
+
server: string;
|
|
134
|
+
workspace: string;
|
|
135
|
+
tab: string;
|
|
136
|
+
pane: string;
|
|
137
|
+
}) => Promise<Pick<SudoSession, "source" | "label"> | undefined>;
|
|
138
|
+
label?: (dispatchId: string) => Promise<string | undefined>;
|
|
139
|
+
/** Reads a process, to see whether sudo is still running; tests replace it. */
|
|
140
|
+
processes?: (pid: number) => Promise<ProcessRecord | undefined>;
|
|
141
|
+
/** The askpass chain check and how the password then reaches it; tests replace it. */
|
|
142
|
+
verify?: (pid: number, hookFd: number | undefined) => Promise<Verified | {
|
|
143
|
+
refused: string;
|
|
144
|
+
}>;
|
|
145
|
+
holdMs?: number;
|
|
146
|
+
outcomeMs?: number;
|
|
147
|
+
/** Whose password sudo asks for; this Hook's user. */
|
|
148
|
+
account?: string;
|
|
149
|
+
now?: () => number;
|
|
150
|
+
}
|
|
151
|
+
export interface Verified {
|
|
152
|
+
sudo: ProcessRecord;
|
|
153
|
+
sudoPid: number;
|
|
154
|
+
deliver: (password: string) => Promise<SudoReply>;
|
|
155
|
+
}
|
|
156
|
+
export declare class SudoBroker {
|
|
157
|
+
private options;
|
|
158
|
+
private pending;
|
|
159
|
+
private events;
|
|
160
|
+
private watchers;
|
|
161
|
+
private tries;
|
|
162
|
+
constructor(options: SudoBrokerOptions);
|
|
163
|
+
private get now();
|
|
164
|
+
list(): SudoRequestView[];
|
|
165
|
+
/** Overview sockets that asked for sudo frames. Each counts as a phone
|
|
166
|
+
* that can answer while it is open. */
|
|
167
|
+
subscribe(listener: (requests: SudoRequestView[]) => void): () => void;
|
|
168
|
+
private changed;
|
|
169
|
+
/** An askpass call: checks the caller, builds the request, holds it until
|
|
170
|
+
* an answer, a timeout, or `cancel` (the caller went away). */
|
|
171
|
+
ask(body: Json, respond: (reply: SudoReply) => void, hookFd?: number): Promise<{
|
|
172
|
+
cancel: () => void;
|
|
173
|
+
}>;
|
|
174
|
+
/** The phone's answer. Single use: the request is gone once answered.
|
|
175
|
+
* `outcome` resolves to whether sudo took the password: rejected when the
|
|
176
|
+
* same sudo asks again, accepted when it has not within `outcomeMs` (or
|
|
177
|
+
* is still running then), unknown when it gave up or the Hook cannot tell. */
|
|
178
|
+
answer(id: string, answer: {
|
|
179
|
+
password: string;
|
|
180
|
+
} | {
|
|
181
|
+
deny: true;
|
|
182
|
+
}): false | {
|
|
183
|
+
outcome: Promise<SudoOutcome | undefined>;
|
|
184
|
+
};
|
|
185
|
+
private watchOutcome;
|
|
186
|
+
close(): void;
|
|
187
|
+
/** The agent.sock `/sudo` route. */
|
|
188
|
+
handle(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
/** A password as sudo reads it from askpass: one line, nothing it would cut. */
|
|
191
|
+
export declare function sudoAnswer(data: Json): {
|
|
192
|
+
id: string;
|
|
193
|
+
answer: {
|
|
194
|
+
password: string;
|
|
195
|
+
} | {
|
|
196
|
+
deny: true;
|
|
197
|
+
};
|
|
198
|
+
outcome: boolean;
|
|
199
|
+
};
|
|
200
|
+
export declare class SudoAnswerError extends Error {
|
|
201
|
+
constructor();
|
|
202
|
+
}
|
|
203
|
+
/** The bundle's `askpass` command, run by sudo through `<bridge>/askpass`.
|
|
204
|
+
* Prints the password and exits 0, or explains on stderr and exits 1. */
|
|
205
|
+
export declare function askpass(prompt: string | undefined, env?: NodeJS.ProcessEnv): Promise<number>;
|
|
206
|
+
/** `phren sudo <command...>`: `sudo -A` with this Hook's askpass, so the
|
|
207
|
+
* password comes from the phone even with no terminal (a `!` command, an
|
|
208
|
+
* agent's shell). Exits with sudo's status. */
|
|
209
|
+
export declare function runSudo(args: string[]): Promise<number>;
|