@phnx-labs/agents-cli 1.22.121 → 1.22.123
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/CHANGELOG.md +316 -0
- package/README.md +53 -53
- package/dist/bootstrap.js +22 -17
- package/dist/cli/command-registry.d.ts +0 -1
- package/dist/cli/command-registry.js +2 -12
- package/dist/commands/auth.js +13 -4
- package/dist/commands/browser.js +3 -4
- package/dist/commands/cloud-transcripts.d.ts +7 -0
- package/dist/commands/cloud-transcripts.js +100 -0
- package/dist/commands/cloud.js +5 -0
- package/dist/commands/computer.d.ts +0 -12
- package/dist/commands/computer.js +14 -124
- package/dist/commands/config.js +5 -4
- package/dist/commands/daemon-index.d.ts +2 -0
- package/dist/commands/daemon-index.js +44 -0
- package/dist/commands/daemon.js +13 -8
- package/dist/commands/doctor.js +3 -4
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.js +35 -7
- package/dist/commands/feed-watch.js +12 -0
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +7 -4
- package/dist/commands/insights.js +3 -1
- package/dist/commands/inspect.js +1 -1
- package/dist/commands/logs.js +2 -1
- package/dist/commands/mailboxes.js +1 -1
- package/dist/commands/models.js +1 -1
- package/dist/commands/projects.js +3 -3
- package/dist/commands/prune.js +6 -28
- package/dist/commands/ps-roster.d.ts +0 -1
- package/dist/commands/ps-roster.js +2 -21
- package/dist/commands/ps.js +13 -1
- package/dist/commands/recordings.d.ts +2 -0
- package/dist/commands/recordings.js +117 -0
- package/dist/commands/routines.js +1 -1
- package/dist/commands/secrets-passthrough.js +3 -3
- package/dist/commands/send.js +33 -20
- package/dist/commands/sessions-backfill.d.ts +1 -0
- package/dist/commands/sessions-backfill.js +48 -13
- package/dist/commands/sessions-migrate.d.ts +1 -1
- package/dist/commands/sessions-migrate.js +11 -10
- package/dist/commands/sessions-optimize.d.ts +1 -0
- package/dist/commands/sessions-optimize.js +7 -4
- package/dist/commands/sessions-resume.js +8 -1
- package/dist/commands/sessions-stats.d.ts +2 -0
- package/dist/commands/sessions-stats.js +24 -7
- package/dist/commands/sessions.d.ts +5 -11
- package/dist/commands/sessions.js +8 -236
- package/dist/commands/setup-computer.js +1 -2
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/sync.js +101 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/testdata/feed-hub.js +11 -0
- package/dist/commands/trash.d.ts +0 -1
- package/dist/commands/trash.js +74 -10
- package/dist/lib/accounting/usage-sync.js +7 -0
- package/dist/lib/agent-modes.d.ts +1 -1
- package/dist/lib/agent-modes.js +11 -5
- package/dist/lib/auth-mint.d.ts +4 -0
- package/dist/lib/auth-mint.js +6 -4
- package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
- package/dist/lib/browser/native-history.test-fixture.js +43 -0
- package/dist/lib/browser/paths.d.ts +5 -0
- package/dist/lib/browser/paths.js +7 -1
- package/dist/lib/browser/sessions-list.d.ts +28 -1
- package/dist/lib/browser/sessions-list.js +137 -25
- package/dist/lib/channels/providers/rush.d.ts +2 -1
- package/dist/lib/channels/providers/rush.js +2 -2
- package/dist/lib/channels/providers/session.d.ts +1 -0
- package/dist/lib/channels/providers/session.js +23 -12
- package/dist/lib/channels/registry.d.ts +9 -2
- package/dist/lib/channels/send.d.ts +5 -10
- package/dist/lib/channels/send.js +88 -50
- package/dist/lib/cloud/rush.d.ts +6 -0
- package/dist/lib/cloud/rush.js +18 -3
- package/dist/lib/computer-client.d.ts +19 -0
- package/dist/lib/computer-client.js +104 -0
- package/dist/lib/config-keys.d.ts +5 -1
- package/dist/lib/config-keys.js +14 -11
- package/dist/lib/daemon/auth-sync-service.js +13 -0
- package/dist/lib/daemon/daemon.js +20 -23
- package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
- package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
- package/dist/lib/daemon-services.d.ts +2 -1
- package/dist/lib/daemon-services.js +17 -10
- package/dist/lib/daemon-webhooks.d.ts +1 -1
- package/dist/lib/daemon-webhooks.js +1 -1
- package/dist/lib/device-config.d.ts +4 -1
- package/dist/lib/device-config.js +58 -8
- package/dist/lib/devices/doctor-findings.d.ts +2 -3
- package/dist/lib/devices/doctor-findings.js +10 -19
- package/dist/lib/event-provenance.d.ts +1 -0
- package/dist/lib/event-provenance.js +2 -0
- package/dist/lib/exec.d.ts +1 -0
- package/dist/lib/exec.js +20 -15
- package/dist/lib/feed/pr-status.d.ts +5 -1
- package/dist/lib/feed/pr-status.js +44 -3
- package/dist/lib/feed/tool-activity.js +9 -6
- package/dist/lib/feed/tools.d.ts +4 -1
- package/dist/lib/feed/tools.js +8 -11
- package/dist/lib/feed-broadcast.d.ts +5 -3
- package/dist/lib/feed-broadcast.js +47 -36
- package/dist/lib/fleet-shared-state.d.ts +5 -0
- package/dist/lib/fleet-shared-state.js +8 -0
- package/dist/lib/github/project-prs.d.ts +4 -1
- package/dist/lib/github/project-prs.js +20 -7
- package/dist/lib/help.d.ts +1 -0
- package/dist/lib/help.js +8 -0
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/passthrough.js +5 -9
- package/dist/lib/hosts/remote-cmd.d.ts +2 -7
- package/dist/lib/hosts/remote-cmd.js +14 -22
- package/dist/lib/hosts/routing-flag.d.ts +22 -0
- package/dist/lib/hosts/routing-flag.js +127 -14
- package/dist/lib/identity/index.d.ts +22 -0
- package/dist/lib/identity/index.js +3 -0
- package/dist/lib/installations/migrate.d.ts +7 -0
- package/dist/lib/installations/migrate.js +99 -88
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/launch-identity.d.ts +6 -1
- package/dist/lib/launch-identity.js +12 -2
- package/dist/lib/menubar/install-menubar.d.ts +1 -0
- package/dist/lib/menubar/install-menubar.js +8 -5
- package/dist/lib/menubar/snapshot.js +2 -3
- package/dist/lib/notify.d.ts +7 -14
- package/dist/lib/notify.js +29 -75
- package/dist/lib/owner-message.d.ts +4 -6
- package/dist/lib/owner-message.js +12 -11
- package/dist/lib/owner-notify-tokens.d.ts +49 -0
- package/dist/lib/owner-notify-tokens.js +214 -0
- package/dist/lib/owner-notify.d.ts +75 -0
- package/dist/lib/owner-notify.js +144 -0
- package/dist/lib/plugins/plugins.d.ts +7 -1
- package/dist/lib/plugins/plugins.js +26 -5
- package/dist/lib/pr-land-detach.js +2 -2
- package/dist/lib/recordings/config.d.ts +11 -0
- package/dist/lib/recordings/config.js +54 -0
- package/dist/lib/recordings/identity.d.ts +12 -0
- package/dist/lib/recordings/identity.js +57 -0
- package/dist/lib/recordings/ledger.d.ts +16 -0
- package/dist/lib/recordings/ledger.js +141 -0
- package/dist/lib/recordings/model.d.ts +29 -0
- package/dist/lib/recordings/model.js +28 -0
- package/dist/lib/recordings/pipeline.d.ts +44 -0
- package/dist/lib/recordings/pipeline.js +272 -0
- package/dist/lib/recordings/process.d.ts +17 -0
- package/dist/lib/recordings/process.js +94 -0
- package/dist/lib/recordings/service.d.ts +15 -0
- package/dist/lib/recordings/service.js +45 -0
- package/dist/lib/recordings/settle.d.ts +21 -0
- package/dist/lib/recordings/settle.js +92 -0
- package/dist/lib/recordings/transcode.d.ts +13 -0
- package/dist/lib/recordings/transcode.js +44 -0
- package/dist/lib/refresh.js +4 -1
- package/dist/lib/reminders.d.ts +0 -1
- package/dist/lib/reminders.js +1 -1
- package/dist/lib/reserved-stores.d.ts +3 -0
- package/dist/lib/reserved-stores.js +13 -0
- package/dist/lib/routine-notify-owner.d.ts +3 -23
- package/dist/lib/routine-notify-owner.js +26 -107
- package/dist/lib/rush-api.d.ts +1 -0
- package/dist/lib/rush-api.js +1 -0
- package/dist/lib/scheduling/routines.d.ts +1 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/session/active.d.ts +18 -2
- package/dist/lib/session/active.js +47 -37
- package/dist/lib/session/cloud.js +18 -45
- package/dist/lib/session/db.d.ts +3 -1
- package/dist/lib/session/db.js +64 -32
- package/dist/lib/session/glance-files.d.ts +4 -3
- package/dist/lib/session/glance-files.js +31 -0
- package/dist/lib/session/inject-target.js +12 -2
- package/dist/lib/session/pid-registry.d.ts +2 -0
- package/dist/lib/session/pid-registry.js +6 -2
- package/dist/lib/session/presentation.d.ts +21 -0
- package/dist/lib/session/presentation.js +198 -0
- package/dist/lib/session/projection.js +9 -2
- package/dist/lib/sqlite.d.ts +3 -1
- package/dist/lib/sqlite.js +7 -3
- package/dist/lib/staleness/index.js +12 -0
- package/dist/lib/staleness/types.d.ts +5 -0
- package/dist/lib/standalone-tools.js +1 -1
- package/dist/lib/startup/command-registry.js +10 -5
- package/dist/lib/state.d.ts +2 -5
- package/dist/lib/state.js +3 -11
- package/dist/lib/sync-delete.d.ts +21 -0
- package/dist/lib/sync-delete.js +113 -0
- package/dist/lib/terminal/inject.js +1 -1
- package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
- package/dist/lib/testdata/owner-notify-api.js +102 -0
- package/dist/lib/trash.d.ts +14 -0
- package/dist/lib/trash.js +75 -0
- package/dist/lib/types.d.ts +0 -34
- package/package.json +1 -3
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -68
- package/dist/commands/humans.d.ts +0 -2
- package/dist/commands/humans.js +0 -83
- package/dist/commands/modes.d.ts +0 -2
- package/dist/commands/modes.js +0 -134
- package/dist/commands/monitors.d.ts +0 -2
- package/dist/commands/monitors.js +0 -1070
- package/dist/commands/reminders.d.ts +0 -2
- package/dist/commands/reminders.js +0 -49
- package/dist/lib/channels/owner-forward.d.ts +0 -25
- package/dist/lib/channels/owner-forward.js +0 -78
- package/dist/lib/channels/owner-sink.d.ts +0 -10
- package/dist/lib/channels/owner-sink.js +0 -26
- package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
- package/dist/lib/daemon/monitor-engine-service.js +0 -25
- package/dist/lib/humans.d.ts +0 -12
- package/dist/lib/humans.js +0 -64
- package/dist/lib/monitors/config.d.ts +0 -77
- package/dist/lib/monitors/config.js +0 -405
- package/dist/lib/monitors/dispatch.d.ts +0 -10
- package/dist/lib/monitors/dispatch.js +0 -72
- package/dist/lib/monitors/engine.d.ts +0 -45
- package/dist/lib/monitors/engine.js +0 -243
- package/dist/lib/monitors/fingerprint.d.ts +0 -3
- package/dist/lib/monitors/fingerprint.js +0 -43
- package/dist/lib/monitors/pid-watch.d.ts +0 -4
- package/dist/lib/monitors/pid-watch.js +0 -14
- package/dist/lib/monitors/remote.d.ts +0 -31
- package/dist/lib/monitors/remote.js +0 -63
- package/dist/lib/monitors/sources/command.d.ts +0 -4
- package/dist/lib/monitors/sources/command.js +0 -20
- package/dist/lib/monitors/sources/device.d.ts +0 -3
- package/dist/lib/monitors/sources/device.js +0 -31
- package/dist/lib/monitors/sources/failure.d.ts +0 -5
- package/dist/lib/monitors/sources/failure.js +0 -25
- package/dist/lib/monitors/sources/file.d.ts +0 -4
- package/dist/lib/monitors/sources/file.js +0 -46
- package/dist/lib/monitors/sources/http.d.ts +0 -3
- package/dist/lib/monitors/sources/http.js +0 -25
- package/dist/lib/monitors/sources/index.d.ts +0 -5
- package/dist/lib/monitors/sources/index.js +0 -22
- package/dist/lib/monitors/sources/poll.d.ts +0 -1
- package/dist/lib/monitors/sources/poll.js +0 -1
- package/dist/lib/monitors/sources/types.d.ts +0 -9
- package/dist/lib/monitors/sources/webhook.d.ts +0 -3
- package/dist/lib/monitors/sources/webhook.js +0 -3
- package/dist/lib/monitors/sources/ws.d.ts +0 -4
- package/dist/lib/monitors/sources/ws.js +0 -35
- package/dist/lib/monitors/state.d.ts +0 -51
- package/dist/lib/monitors/state.js +0 -221
- /package/dist/{lib/monitors/sources/types.js → commands/testdata/feed-hub.d.ts} +0 -0
package/dist/commands/trash.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
+
import { confirm } from '@inquirer/prompts';
|
|
4
5
|
import { resolveAgentName, agentLabel } from '../lib/agents.js';
|
|
5
|
-
import { getTrashVersionsDir } from '../lib/state.js';
|
|
6
|
+
import { getTrashDir, getTrashVersionsDir } from '../lib/state.js';
|
|
6
7
|
import { getVersionDir } from '../lib/installations/versions.js';
|
|
8
|
+
import { parseDuration } from '../lib/hooks/cache.js';
|
|
9
|
+
import { emptyTrash, listTrashItems } from '../lib/trash.js';
|
|
10
|
+
import { setHelpSections } from '../lib/help.js';
|
|
11
|
+
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
7
12
|
function listTrashEntries(filterAgent) {
|
|
8
13
|
const root = getTrashVersionsDir();
|
|
9
14
|
if (!fs.existsSync(root))
|
|
@@ -127,7 +132,7 @@ export function restoreVersion(target) {
|
|
|
127
132
|
const dest = getVersionDir(agent, version);
|
|
128
133
|
if (fs.existsSync(dest)) {
|
|
129
134
|
console.error(chalk.red(`Cannot restore: ${dest} already exists.`));
|
|
130
|
-
console.error(chalk.gray('Move or remove the existing dir first, then re-run restore.'));
|
|
135
|
+
console.error(chalk.gray('Move or remove the existing dir first, then re-run agents trash restore.'));
|
|
131
136
|
process.exit(1);
|
|
132
137
|
}
|
|
133
138
|
try {
|
|
@@ -149,16 +154,10 @@ export function restoreVersion(target) {
|
|
|
149
154
|
catch { }
|
|
150
155
|
console.log(chalk.green(`Restored ${agentLabel(agent)}@${version} to ${dest}`));
|
|
151
156
|
}
|
|
152
|
-
export function registerRestoreCommand(program) {
|
|
153
|
-
program
|
|
154
|
-
.command('restore <target>')
|
|
155
|
-
.description('Restore a soft-deleted agent version (e.g. "codex@0.141.0") removed via prune/remove')
|
|
156
|
-
.action((target) => restoreVersion(target));
|
|
157
|
-
}
|
|
158
157
|
export function registerTrashCommands(program) {
|
|
159
158
|
const trash = program
|
|
160
159
|
.command('trash')
|
|
161
|
-
.description('Inspect and
|
|
160
|
+
.description('Inspect, restore, and empty soft-deleted agent versions and resources');
|
|
162
161
|
trash
|
|
163
162
|
.command('list [agent]')
|
|
164
163
|
.description('List soft-deleted version directories (optionally filtered to one agent)')
|
|
@@ -184,6 +183,71 @@ export function registerTrashCommands(program) {
|
|
|
184
183
|
chalk.gray(`${e.stamp} ${size} ${e.trashPath}`));
|
|
185
184
|
}
|
|
186
185
|
console.log();
|
|
187
|
-
console.log(chalk.gray('Restore with: agents restore <agent>@<version>'));
|
|
186
|
+
console.log(chalk.gray('Restore with: agents trash restore <agent>@<version>'));
|
|
187
|
+
});
|
|
188
|
+
trash
|
|
189
|
+
.command('restore <target>')
|
|
190
|
+
.description('Restore the newest soft-deleted copy of an agent version (e.g. "codex@0.141.0")')
|
|
191
|
+
.action((target) => restoreVersion(target));
|
|
192
|
+
const empty = trash
|
|
193
|
+
.command('empty')
|
|
194
|
+
.description('Permanently delete trashed items, optionally only those trashed before a cutoff')
|
|
195
|
+
.option('--older-than <duration>', 'only items trashed at least this long ago (e.g. 30d, 12h)')
|
|
196
|
+
.option('-y, --yes', 'skip the confirmation prompt')
|
|
197
|
+
.action(async (opts) => runTrashEmpty(opts));
|
|
198
|
+
setHelpSections(empty, {
|
|
199
|
+
examples: `
|
|
200
|
+
agents trash list
|
|
201
|
+
agents trash empty --older-than 30d
|
|
202
|
+
agents trash empty --yes
|
|
203
|
+
`,
|
|
204
|
+
notes: `
|
|
205
|
+
Removes items from ~/.agents/.history/trash for good; they cannot be
|
|
206
|
+
restored afterwards. An item's age is the time it was moved to trash.
|
|
207
|
+
Without --yes, a terminal asks first and a non-interactive shell refuses.
|
|
208
|
+
`,
|
|
188
209
|
});
|
|
189
210
|
}
|
|
211
|
+
async function runTrashEmpty(opts) {
|
|
212
|
+
let olderThanMs;
|
|
213
|
+
if (opts.olderThan !== undefined) {
|
|
214
|
+
const seconds = parseDuration(opts.olderThan);
|
|
215
|
+
if (seconds === null) {
|
|
216
|
+
console.error(chalk.red(`Invalid --older-than '${opts.olderThan}'. Use a number with s, m, h or d (e.g. 30d).`));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
olderThanMs = seconds * 1000;
|
|
220
|
+
}
|
|
221
|
+
const now = Date.now();
|
|
222
|
+
const due = listTrashItems().filter((item) => olderThanMs === undefined || now - item.trashedAtMs >= olderThanMs);
|
|
223
|
+
if (due.length === 0) {
|
|
224
|
+
console.log(chalk.gray(opts.olderThan ? `Nothing in trash is older than ${opts.olderThan}.` : 'Trash is empty.'));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const bytes = due.reduce((sum, item) => sum + dirSizeBytes(item.path), 0);
|
|
228
|
+
if (!opts.yes) {
|
|
229
|
+
if (!isInteractiveTerminal()) {
|
|
230
|
+
console.error(chalk.yellow(`Would permanently delete ${due.length} trashed item(s) (${humanSize(bytes)}). Pass --yes to confirm.`));
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
let ok = false;
|
|
234
|
+
try {
|
|
235
|
+
ok = await confirm({ message: `Permanently delete ${due.length} trashed item(s) (${humanSize(bytes)})?`, default: false });
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
if (isPromptCancelled(err)) {
|
|
239
|
+
console.log(chalk.gray('Cancelled'));
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
throw err;
|
|
243
|
+
}
|
|
244
|
+
if (!ok) {
|
|
245
|
+
console.log(chalk.gray('Cancelled'));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const { removed, kept } = emptyTrash({ olderThanMs, now });
|
|
250
|
+
console.log(chalk.green(`Deleted ${removed.length} trashed item(s) (${humanSize(bytes)}) from ${getTrashDir()}.`));
|
|
251
|
+
if (kept > 0)
|
|
252
|
+
console.log(chalk.gray(`${kept} newer item(s) kept.`));
|
|
253
|
+
}
|
|
@@ -118,6 +118,13 @@ export async function publishOwnFleetState(options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
if (auth.error)
|
|
120
120
|
errors.push(`auth: ${auth.error}`);
|
|
121
|
+
try {
|
|
122
|
+
const { publishOwnerNotifyState } = await import('../owner-notify-tokens.js');
|
|
123
|
+
await publishOwnerNotifyState({ userAgentsDir: options.userAgentsDir, device: options.device });
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
errors.push(`owner-notify: ${err.message}`);
|
|
127
|
+
}
|
|
121
128
|
return { usage, mirror, auth, errors };
|
|
122
129
|
}
|
|
123
130
|
// Workers never initiate or poll OAuth usage; only headed peers publish the usage rows they own.
|
|
@@ -17,4 +17,4 @@ export interface AgentModesCatalog {
|
|
|
17
17
|
notes: string[];
|
|
18
18
|
}
|
|
19
19
|
export declare function getAgentModesCatalog(agent: AgentId, version?: string | null, cwd?: string): AgentModesCatalog;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function formatModeSupportTable(): string;
|
package/dist/lib/agent-modes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ALL_MODES } from './types.js';
|
|
2
|
-
import { AGENTS } from './agents.js';
|
|
2
|
+
import { AGENTS, ALL_AGENT_IDS } from './agents.js';
|
|
3
3
|
import { AGENT_COMMANDS, defaultModeFor } from './exec.js';
|
|
4
4
|
import { resolveRunDefaults } from './run-defaults.js';
|
|
5
5
|
export const MODE_DESCRIPTIONS = {
|
|
@@ -60,8 +60,14 @@ export function getAgentModesCatalog(agent, version, cwd = process.cwd()) {
|
|
|
60
60
|
notes,
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
63
|
+
export function formatModeSupportTable() {
|
|
64
|
+
const agents = ALL_AGENT_IDS.filter((id) => !AGENTS[id].deprecated?.hard);
|
|
65
|
+
const width = Math.max(...agents.map((id) => id.length));
|
|
66
|
+
return agents
|
|
67
|
+
.map((agent) => {
|
|
68
|
+
const defaultMode = defaultModeFor(agent);
|
|
69
|
+
const modes = AGENTS[agent].capabilities.modes.map((mode) => (mode === defaultMode ? `${mode}*` : mode));
|
|
70
|
+
return `${agent.padEnd(width)} ${modes.join(' ')}`;
|
|
71
|
+
})
|
|
72
|
+
.join('\n');
|
|
67
73
|
}
|
package/dist/lib/auth-mint.d.ts
CHANGED
|
@@ -55,6 +55,10 @@ export declare function seedReservedStoreKey(harness: AgentId, kind: StorableCre
|
|
|
55
55
|
bundle: string;
|
|
56
56
|
key: string;
|
|
57
57
|
};
|
|
58
|
+
export declare function writeReservedStoreItem(name: string, key: string, value: string, description: string): {
|
|
59
|
+
bundle: string;
|
|
60
|
+
key: string;
|
|
61
|
+
};
|
|
58
62
|
export interface AdoptLegacyReservedItemsResult {
|
|
59
63
|
adopted: Array<{
|
|
60
64
|
bundle: string;
|
package/dist/lib/auth-mint.js
CHANGED
|
@@ -204,10 +204,12 @@ export function workerCredentialStoreKey(harness, accountId) {
|
|
|
204
204
|
export function seedReservedStoreKey(harness, kind, key, value) {
|
|
205
205
|
// Reserved worker bundles are real file-backed policy-never stores, never rotating OAuth/session credentials.
|
|
206
206
|
assertStorableCredentialKind(kind, harness);
|
|
207
|
-
|
|
207
|
+
return writeReservedStoreItem(reservedStoreName(harness), key, value, `Reserved ${harness} worker credentials (${kind}), one key per account; pushed to worker devices by the daemon. Never a native OAuth session.`);
|
|
208
|
+
}
|
|
209
|
+
export function writeReservedStoreItem(name, key, value, description) {
|
|
208
210
|
const cleaned = value.trim();
|
|
209
211
|
if (!cleaned)
|
|
210
|
-
throw new Error(`Empty
|
|
212
|
+
throw new Error(`Empty value for reserved store '${name}' key ${key}.`);
|
|
211
213
|
const item = secretsKeychainItem(name, key);
|
|
212
214
|
try {
|
|
213
215
|
if (bundleExistsSync(name)) {
|
|
@@ -231,7 +233,7 @@ export function seedReservedStoreKey(harness, kind, key, value) {
|
|
|
231
233
|
name,
|
|
232
234
|
backend: 'file',
|
|
233
235
|
policy: 'never',
|
|
234
|
-
description
|
|
236
|
+
description,
|
|
235
237
|
vars: { [key]: keychainRef(key) },
|
|
236
238
|
meta: { [key]: { type: 'token' } },
|
|
237
239
|
};
|
|
@@ -240,7 +242,7 @@ export function seedReservedStoreKey(harness, kind, key, value) {
|
|
|
240
242
|
}
|
|
241
243
|
catch (err) {
|
|
242
244
|
if (isSecretsClientError(err, 'OPERATION_FAILED')) {
|
|
243
|
-
throw new Error(`Could not write the reserved store '${name}' as a bundle: ${err.message}. agents-cli needs @phnx-labs/secrets-cli 0.1.1 or newer, which accepts the __<
|
|
245
|
+
throw new Error(`Could not write the reserved store '${name}' as a bundle: ${err.message}. agents-cli needs @phnx-labs/secrets-cli 0.1.1 or newer, which accepts the __<name>__ bundle name: npm i -g @phnx-labs/secrets-cli@latest`);
|
|
244
246
|
}
|
|
245
247
|
throw err;
|
|
246
248
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BrowserTaskSummary } from './sessions-list.js';
|
|
2
|
+
export declare class NativeHistoryWriter {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(file: string);
|
|
6
|
+
put(record: Omit<BrowserTaskSummary, 'counts'> & {
|
|
7
|
+
counts?: BrowserTaskSummary['counts'];
|
|
8
|
+
}): void;
|
|
9
|
+
putMany(records: Parameters<NativeHistoryWriter['put']>[0][]): void;
|
|
10
|
+
rawRecord(profile: string, task: string, record: string, lastActivity: number): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import Database from '../sqlite.js';
|
|
4
|
+
export class NativeHistoryWriter {
|
|
5
|
+
file;
|
|
6
|
+
db;
|
|
7
|
+
constructor(file) {
|
|
8
|
+
this.file = file;
|
|
9
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
10
|
+
this.db = new Database(file);
|
|
11
|
+
this.db.exec(`PRAGMA busy_timeout=5000;
|
|
12
|
+
PRAGMA journal_mode=WAL;
|
|
13
|
+
PRAGMA wal_autocheckpoint=0;
|
|
14
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
15
|
+
profile TEXT NOT NULL, task TEXT NOT NULL, last_activity INTEGER NOT NULL,
|
|
16
|
+
record TEXT NOT NULL, native INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(profile, task));
|
|
17
|
+
CREATE INDEX IF NOT EXISTS tasks_activity ON tasks(last_activity DESC);
|
|
18
|
+
CREATE TABLE IF NOT EXISTS migrations (name TEXT PRIMARY KEY);`);
|
|
19
|
+
this.db.exec('PRAGMA user_version=1');
|
|
20
|
+
}
|
|
21
|
+
put(record) {
|
|
22
|
+
this.db.prepare(`INSERT INTO tasks(profile,task,last_activity,record,native) VALUES(?,?,?,?,1)
|
|
23
|
+
ON CONFLICT(profile,task) DO UPDATE SET
|
|
24
|
+
last_activity=MAX(tasks.last_activity,excluded.last_activity), native=excluded.native,
|
|
25
|
+
record=json_set(
|
|
26
|
+
CASE WHEN excluded.last_activity >= tasks.last_activity
|
|
27
|
+
THEN json_patch(tasks.record,excluded.record)
|
|
28
|
+
ELSE json_patch(excluded.record,tasks.record) END,
|
|
29
|
+
'$.lastActivity', MAX(tasks.last_activity,excluded.last_activity),
|
|
30
|
+
'$.startedAt', MIN(json_extract(tasks.record,'$.startedAt'),json_extract(excluded.record,'$.startedAt')))`).run(record.profile, record.task, record.lastActivity, JSON.stringify(record));
|
|
31
|
+
}
|
|
32
|
+
putMany(records) {
|
|
33
|
+
this.db.transaction(() => { for (const record of records)
|
|
34
|
+
this.put(record); })();
|
|
35
|
+
}
|
|
36
|
+
rawRecord(profile, task, record, lastActivity) {
|
|
37
|
+
this.db.prepare('INSERT OR REPLACE INTO tasks(profile,task,last_activity,record,native) VALUES(?,?,?,?,1)')
|
|
38
|
+
.run(profile, task, lastActivity, record);
|
|
39
|
+
}
|
|
40
|
+
close() {
|
|
41
|
+
this.db.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export { getBrowserDurableDir } from '../state.js';
|
|
2
2
|
export declare function getBrowserRuntimeDir(): string;
|
|
3
3
|
export declare function getProfileRuntimeDir(name: string): string;
|
|
4
|
+
export declare function profileOfCacheKey(key: string): string;
|
|
5
|
+
export declare function profileScopeSql(column: string, profile: string): {
|
|
6
|
+
sql: string;
|
|
7
|
+
params: string[];
|
|
8
|
+
};
|
|
4
9
|
export declare function listProfileCacheDirs(profileName: string): string[];
|
|
@@ -8,10 +8,16 @@ export function getBrowserRuntimeDir() {
|
|
|
8
8
|
export function getProfileRuntimeDir(name) {
|
|
9
9
|
return path.join(getBrowserRuntimeDir(), name);
|
|
10
10
|
}
|
|
11
|
-
function profileOfCacheKey(key) {
|
|
11
|
+
export function profileOfCacheKey(key) {
|
|
12
12
|
const at = key.lastIndexOf('@');
|
|
13
13
|
return at === -1 ? key : key.slice(0, at);
|
|
14
14
|
}
|
|
15
|
+
export function profileScopeSql(column, profile) {
|
|
16
|
+
return {
|
|
17
|
+
sql: `(${column} = ? OR (substr(${column}, 1, length(?) + 1) = ? || '@' AND instr(substr(${column}, length(?) + 2), '@') = 0))`,
|
|
18
|
+
params: [profile, profile, profile, profile],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
15
21
|
export function listProfileCacheDirs(profileName) {
|
|
16
22
|
const root = getBrowserRuntimeDir();
|
|
17
23
|
if (!fs.existsSync(root))
|
|
@@ -20,7 +20,29 @@ export interface TaskIdentity {
|
|
|
20
20
|
owner?: string;
|
|
21
21
|
launchId?: string;
|
|
22
22
|
sessionId?: string;
|
|
23
|
+
startedAt?: number;
|
|
24
|
+
lastActivity?: number;
|
|
25
|
+
machine?: string;
|
|
26
|
+
captureDir?: string;
|
|
27
|
+
capturesRemote?: string;
|
|
28
|
+
counts?: Partial<Record<ArtifactKind, number>>;
|
|
23
29
|
}
|
|
30
|
+
export interface BrowserTaskSummary extends Omit<TaskIdentity, 'owner'> {
|
|
31
|
+
profile: string;
|
|
32
|
+
task: string;
|
|
33
|
+
actor?: string;
|
|
34
|
+
startedAt: number;
|
|
35
|
+
lastActivity: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const BROWSER_HISTORY_LIMIT = 2000;
|
|
38
|
+
export declare function nativeBrowserHistoryPath(): string;
|
|
39
|
+
export interface BrowserHistoryQuery {
|
|
40
|
+
key?: string;
|
|
41
|
+
profile?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function readNativeBrowserHistory(query?: BrowserHistoryQuery, file?: string): BrowserTaskSummary[];
|
|
45
|
+
export declare function readBrowserTaskHistory(query?: BrowserHistoryQuery): BrowserTaskSummary[];
|
|
24
46
|
export declare function loadTaskIdentities(profile: string): Map<string, TaskIdentity>;
|
|
25
47
|
export declare function loadDurableTaskIdentities(profile: string): Map<string, TaskIdentity>;
|
|
26
48
|
export interface LaunchSessionIndex {
|
|
@@ -41,8 +63,13 @@ export interface BrowserSessionRow {
|
|
|
41
63
|
artifacts: BrowserArtifact[];
|
|
42
64
|
counts: Record<ArtifactKind, number>;
|
|
43
65
|
latestMtimeMs: number;
|
|
66
|
+
startedAt?: number;
|
|
67
|
+
machine?: string;
|
|
68
|
+
captureDir?: string;
|
|
69
|
+
capturesRemote?: string;
|
|
44
70
|
}
|
|
45
|
-
export declare function groupIntoRows(groups: ProfileArtifacts[], taskIdentities: Map<string, Map<string, TaskIdentity>>, resolveLaunch?: (launchId: string) => SessionMeta | null, resolveSession?: (sessionId: string) => SessionMeta | null): BrowserSessionRow[];
|
|
71
|
+
export declare function groupIntoRows(groups: ProfileArtifacts[], taskIdentities: Map<string, Map<string, TaskIdentity>>, resolveLaunch?: (launchId: string) => SessionMeta | null, resolveSession?: (sessionId: string) => SessionMeta | null, listed?: Map<string, Set<string>>): BrowserSessionRow[];
|
|
72
|
+
export declare function readBrowserSessionRows(profile?: string): BrowserSessionRow[];
|
|
46
73
|
export declare function buildBrowserSessionRows(profile?: string): BrowserSessionRow[];
|
|
47
74
|
export declare function matchesBrowserSessionRow(row: BrowserSessionRow, query: string): boolean;
|
|
48
75
|
export declare function runBrowserSessions(opts: {
|
|
@@ -3,9 +3,11 @@ import * as fs from 'fs';
|
|
|
3
3
|
import { formatBytes } from '../format.js';
|
|
4
4
|
export { formatBytes };
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { getBrowserRuntimeDir, getProfileRuntimeDir, listProfileCacheDirs } from './paths.js';
|
|
6
|
+
import { getBrowserRuntimeDir, getProfileRuntimeDir, listProfileCacheDirs, profileScopeSql } from './paths.js';
|
|
7
7
|
import { formatRelativeTime } from '../session/relative-time.js';
|
|
8
8
|
import { getSessionById, listBrowserSessionRecords, pruneToolSessions } from '../session/db.js';
|
|
9
|
+
import Database from '../sqlite.js';
|
|
10
|
+
import { getHistoryDir } from '../state.js';
|
|
9
11
|
import { listPidSessionEntries } from '../session/pid-registry.js';
|
|
10
12
|
import { loadHookSessionIndex } from '../session/hook-sessions.js';
|
|
11
13
|
import { readRecentActivity } from '../feed/activity.js';
|
|
@@ -43,6 +45,19 @@ function walkFiles(dir) {
|
|
|
43
45
|
}
|
|
44
46
|
return out;
|
|
45
47
|
}
|
|
48
|
+
function listTaskArtifacts(dir, task) {
|
|
49
|
+
const artifacts = [];
|
|
50
|
+
for (const file of walkFiles(dir)) {
|
|
51
|
+
const kind = EXT_KIND[path.extname(file).toLowerCase()];
|
|
52
|
+
if (!kind)
|
|
53
|
+
continue;
|
|
54
|
+
const st = statSafe(file);
|
|
55
|
+
if (!st)
|
|
56
|
+
continue;
|
|
57
|
+
artifacts.push({ kind, task, name: path.basename(file), path: file, bytes: st.size, mtimeMs: st.mtimeMs });
|
|
58
|
+
}
|
|
59
|
+
return artifacts;
|
|
60
|
+
}
|
|
46
61
|
function listProfileArtifacts(profile) {
|
|
47
62
|
const root = getProfileRuntimeDir(profile);
|
|
48
63
|
const artifacts = [];
|
|
@@ -53,17 +68,8 @@ function listProfileArtifacts(profile) {
|
|
|
53
68
|
}
|
|
54
69
|
catch { }
|
|
55
70
|
for (const t of taskDirs) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
for (const file of walkFiles(path.join(sessionsRoot, t.name))) {
|
|
59
|
-
const kind = EXT_KIND[path.extname(file).toLowerCase()];
|
|
60
|
-
if (!kind)
|
|
61
|
-
continue;
|
|
62
|
-
const st = statSafe(file);
|
|
63
|
-
if (!st)
|
|
64
|
-
continue;
|
|
65
|
-
artifacts.push({ kind, task: t.name, name: path.basename(file), path: file, bytes: st.size, mtimeMs: st.mtimeMs });
|
|
66
|
-
}
|
|
71
|
+
if (t.isDirectory())
|
|
72
|
+
artifacts.push(...listTaskArtifacts(path.join(sessionsRoot, t.name), t.name));
|
|
67
73
|
}
|
|
68
74
|
for (const file of walkFiles(path.join(root, 'downloads'))) {
|
|
69
75
|
const st = statSafe(file);
|
|
@@ -130,6 +136,74 @@ export function resolveArtifact(groups, selector) {
|
|
|
130
136
|
const hit = all.find((a) => a.name === selector) ?? all.find((a) => a.name.includes(selector));
|
|
131
137
|
return hit ? hit.path : null;
|
|
132
138
|
}
|
|
139
|
+
export const BROWSER_HISTORY_LIMIT = 2000;
|
|
140
|
+
export function nativeBrowserHistoryPath() {
|
|
141
|
+
return path.join(getHistoryDir(), 'browser', 'history.db');
|
|
142
|
+
}
|
|
143
|
+
const SUMMARY_TEXT_FIELDS = ['actor', 'sessionId', 'launchId', 'machine', 'captureDir', 'capturesRemote'];
|
|
144
|
+
const COUNT_KINDS = ['screenshot', 'pdf', 'recording', 'download'];
|
|
145
|
+
function parseSummary(file, raw) {
|
|
146
|
+
let value;
|
|
147
|
+
try {
|
|
148
|
+
value = JSON.parse(raw);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throw new Error(`unreadable browser history record in ${file}: ${error.message}`);
|
|
152
|
+
}
|
|
153
|
+
const r = value;
|
|
154
|
+
if (!r || typeof r !== 'object' || typeof r.profile !== 'string' || typeof r.task !== 'string'
|
|
155
|
+
|| !Number.isFinite(r.startedAt) || !Number.isFinite(r.lastActivity)) {
|
|
156
|
+
throw new Error(`unexpected browser history record in ${file}: needs profile, task and finite timestamps`);
|
|
157
|
+
}
|
|
158
|
+
const summary = {
|
|
159
|
+
profile: r.profile, task: r.task, startedAt: r.startedAt, lastActivity: r.lastActivity,
|
|
160
|
+
};
|
|
161
|
+
for (const key of SUMMARY_TEXT_FIELDS) {
|
|
162
|
+
if (typeof r[key] === 'string')
|
|
163
|
+
summary[key] = r[key];
|
|
164
|
+
}
|
|
165
|
+
if (r.counts && typeof r.counts === 'object') {
|
|
166
|
+
const counts = {};
|
|
167
|
+
for (const kind of COUNT_KINDS) {
|
|
168
|
+
const n = r.counts[kind];
|
|
169
|
+
if (Number.isFinite(n))
|
|
170
|
+
counts[kind] = n;
|
|
171
|
+
}
|
|
172
|
+
summary.counts = counts;
|
|
173
|
+
}
|
|
174
|
+
return summary;
|
|
175
|
+
}
|
|
176
|
+
export function readNativeBrowserHistory(query = {}, file = nativeBrowserHistoryPath()) {
|
|
177
|
+
if (!fs.existsSync(file))
|
|
178
|
+
return [];
|
|
179
|
+
const where = query.key ? { sql: 'profile = ?', params: [query.key] }
|
|
180
|
+
: query.profile ? profileScopeSql('profile', query.profile) : undefined;
|
|
181
|
+
const db = new Database(file, { readOnly: true });
|
|
182
|
+
try {
|
|
183
|
+
const rows = db.prepare(`SELECT record FROM tasks${where ? ` WHERE ${where.sql}` : ''} ORDER BY last_activity DESC${query.limit === undefined ? '' : ' LIMIT ?'}`).all(...(where?.params ?? []), ...(query.limit === undefined ? [] : [query.limit]));
|
|
184
|
+
return rows.map((row) => parseSummary(file, row.record));
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
db.close();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export function readBrowserTaskHistory(query = {}) {
|
|
191
|
+
const merged = new Map();
|
|
192
|
+
const id = (s) => `${s.profile}\0${s.task}`;
|
|
193
|
+
const legacyRows = query.key
|
|
194
|
+
? listBrowserSessionRecords(query.key, { limit: query.limit })
|
|
195
|
+
: listBrowserSessionRecords(query.profile, { deviceKeys: true, limit: query.limit });
|
|
196
|
+
for (const legacy of legacyRows) {
|
|
197
|
+
if (legacy.startedAt === undefined)
|
|
198
|
+
continue;
|
|
199
|
+
merged.set(id(legacy), { ...legacy, startedAt: legacy.startedAt, lastActivity: legacy.lastActivity ?? legacy.startedAt });
|
|
200
|
+
}
|
|
201
|
+
for (const native of readNativeBrowserHistory(query)) {
|
|
202
|
+
const legacy = merged.get(id(native));
|
|
203
|
+
merged.set(id(native), legacy ? { ...legacy, ...native } : native);
|
|
204
|
+
}
|
|
205
|
+
return [...merged.values()];
|
|
206
|
+
}
|
|
133
207
|
export function loadTaskIdentities(profile) {
|
|
134
208
|
const out = new Map();
|
|
135
209
|
let raw;
|
|
@@ -162,16 +236,14 @@ export function loadTaskIdentities(profile) {
|
|
|
162
236
|
}
|
|
163
237
|
export function loadDurableTaskIdentities(profile) {
|
|
164
238
|
const merged = new Map();
|
|
165
|
-
for (const record of
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
launchId: record.launchId,
|
|
169
|
-
sessionId: record.sessionId,
|
|
170
|
-
});
|
|
239
|
+
for (const record of readBrowserTaskHistory({ key: profile })) {
|
|
240
|
+
const { actor, profile: _profile, task: _task, ...rest } = record;
|
|
241
|
+
merged.set(record.task, { ...rest, owner: actor });
|
|
171
242
|
}
|
|
172
243
|
for (const [task, live] of loadTaskIdentities(profile)) {
|
|
173
244
|
const durable = merged.get(task);
|
|
174
245
|
merged.set(task, {
|
|
246
|
+
...durable,
|
|
175
247
|
owner: live.owner ?? durable?.owner,
|
|
176
248
|
launchId: live.launchId ?? durable?.launchId,
|
|
177
249
|
sessionId: live.sessionId ?? durable?.sessionId,
|
|
@@ -199,7 +271,13 @@ export function resolveLaunchSession(index, launchId) {
|
|
|
199
271
|
const sessionId = index.byLaunchId.get(launchId);
|
|
200
272
|
return sessionId ? getSessionById(sessionId) : null;
|
|
201
273
|
}
|
|
202
|
-
|
|
274
|
+
function mergeCounts(found, recorded) {
|
|
275
|
+
const out = { ...found };
|
|
276
|
+
for (const kind of COUNT_KINDS)
|
|
277
|
+
out[kind] = Math.max(found[kind], recorded?.[kind] ?? 0);
|
|
278
|
+
return out;
|
|
279
|
+
}
|
|
280
|
+
export function groupIntoRows(groups, taskIdentities, resolveLaunch, resolveSession, listed) {
|
|
203
281
|
const rows = [];
|
|
204
282
|
for (const g of groups) {
|
|
205
283
|
const identities = taskIdentities.get(g.profile) ?? new Map();
|
|
@@ -214,6 +292,10 @@ export function groupIntoRows(groups, taskIdentities, resolveLaunch, resolveSess
|
|
|
214
292
|
list.push(a);
|
|
215
293
|
byTask.set(a.task, list);
|
|
216
294
|
}
|
|
295
|
+
for (const task of listed?.get(g.profile) ?? []) {
|
|
296
|
+
if (!byTask.has(task))
|
|
297
|
+
byTask.set(task, []);
|
|
298
|
+
}
|
|
217
299
|
for (const [task, artifacts] of byTask) {
|
|
218
300
|
artifacts.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
219
301
|
const identity = identities.get(task);
|
|
@@ -234,8 +316,12 @@ export function groupIntoRows(groups, taskIdentities, resolveLaunch, resolveSess
|
|
|
234
316
|
linkStatus: linkedSession ? 'linked' : hasIdentityKey ? 'unresolved' : 'unlinked',
|
|
235
317
|
linkedSession: linkedSession ?? undefined,
|
|
236
318
|
artifacts,
|
|
237
|
-
counts: countByKind(artifacts),
|
|
238
|
-
latestMtimeMs: artifacts[0]?.mtimeMs ?? 0,
|
|
319
|
+
counts: mergeCounts(countByKind(artifacts), identity?.counts),
|
|
320
|
+
latestMtimeMs: Math.max(artifacts[0]?.mtimeMs ?? 0, identity?.lastActivity ?? 0),
|
|
321
|
+
...(identity?.startedAt !== undefined ? { startedAt: identity.startedAt } : {}),
|
|
322
|
+
...(identity?.machine ? { machine: identity.machine } : {}),
|
|
323
|
+
...(identity?.captureDir ? { captureDir: identity.captureDir } : {}),
|
|
324
|
+
...(identity?.capturesRemote ? { capturesRemote: identity.capturesRemote } : {}),
|
|
239
325
|
});
|
|
240
326
|
}
|
|
241
327
|
if (downloads.length > 0) {
|
|
@@ -253,15 +339,41 @@ export function groupIntoRows(groups, taskIdentities, resolveLaunch, resolveSess
|
|
|
253
339
|
rows.sort((a, b) => b.latestMtimeMs - a.latestMtimeMs);
|
|
254
340
|
return rows;
|
|
255
341
|
}
|
|
342
|
+
export function readBrowserSessionRows(profile) {
|
|
343
|
+
const groups = listBrowserSessions(profile);
|
|
344
|
+
const byProfile = new Map(groups.map((g) => [g.profile, g]));
|
|
345
|
+
const listed = new Map();
|
|
346
|
+
for (const record of readBrowserTaskHistory({ profile, limit: BROWSER_HISTORY_LIMIT })) {
|
|
347
|
+
if (!byProfile.has(record.profile)) {
|
|
348
|
+
const group = { profile: record.profile, artifacts: listProfileArtifacts(record.profile) };
|
|
349
|
+
byProfile.set(record.profile, group);
|
|
350
|
+
groups.push(group);
|
|
351
|
+
}
|
|
352
|
+
const tasks = listed.get(record.profile) ?? new Set();
|
|
353
|
+
tasks.add(record.task);
|
|
354
|
+
listed.set(record.profile, tasks);
|
|
355
|
+
}
|
|
356
|
+
const taskIdentities = new Map(groups.map((g) => [g.profile, loadDurableTaskIdentities(g.profile)]));
|
|
357
|
+
for (const group of groups) {
|
|
358
|
+
const identities = taskIdentities.get(group.profile);
|
|
359
|
+
const known = new Set(group.artifacts.map((a) => a.path));
|
|
360
|
+
const tasks = new Set([...(listed.get(group.profile) ?? []), ...group.artifacts.flatMap((a) => a.task ? [a.task] : [])]);
|
|
361
|
+
for (const task of tasks) {
|
|
362
|
+
const identity = identities.get(task);
|
|
363
|
+
if (!identity?.captureDir || identity.capturesRemote)
|
|
364
|
+
continue;
|
|
365
|
+
group.artifacts.push(...listTaskArtifacts(identity.captureDir, task).filter((a) => !known.has(a.path)));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const index = buildLaunchSessionIndex();
|
|
369
|
+
return groupIntoRows(groups, taskIdentities, (launchId) => resolveLaunchSession(index, launchId), (sessionId) => getSessionById(sessionId), listed);
|
|
370
|
+
}
|
|
256
371
|
export function buildBrowserSessionRows(profile) {
|
|
257
372
|
try {
|
|
258
373
|
pruneToolSessions();
|
|
259
374
|
}
|
|
260
375
|
catch { }
|
|
261
|
-
|
|
262
|
-
const taskIdentities = new Map(groups.map((g) => [g.profile, loadDurableTaskIdentities(g.profile)]));
|
|
263
|
-
const index = buildLaunchSessionIndex();
|
|
264
|
-
return groupIntoRows(groups, taskIdentities, (launchId) => resolveLaunchSession(index, launchId), (sessionId) => getSessionById(sessionId));
|
|
376
|
+
return readBrowserSessionRows(profile);
|
|
265
377
|
}
|
|
266
378
|
export function matchesBrowserSessionRow(row, query) {
|
|
267
379
|
const q = query.trim().toLowerCase();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ChannelProvider } from '../registry.js';
|
|
1
|
+
import type { ChannelProvider, SendOptions, SendResult } from '../registry.js';
|
|
2
2
|
export type RushChannel = 'telegram' | 'imessage' | 'slack' | 'discord';
|
|
3
3
|
export declare const RUSH_CHANNELS: RushChannel[];
|
|
4
4
|
export declare function buildImessageOsascriptArgs(text: string, phone: string): string[];
|
|
5
|
+
export declare function sendImessage(text: string, opts: SendOptions): Promise<SendResult>;
|
|
5
6
|
export declare function resolveSlackToken(): string | undefined;
|
|
6
7
|
export declare function buildSlackPayload(channel: string, text: string, thread?: string): Record<string, string>;
|
|
7
8
|
export declare const rushProviders: ChannelProvider[];
|
|
@@ -17,12 +17,12 @@ export function buildImessageOsascriptArgs(text, phone) {
|
|
|
17
17
|
].join('\n');
|
|
18
18
|
return ['-e', script];
|
|
19
19
|
}
|
|
20
|
-
async function sendImessage(text, opts) {
|
|
20
|
+
export async function sendImessage(text, opts) {
|
|
21
21
|
const channel = 'imessage';
|
|
22
22
|
if (opts.dryRun)
|
|
23
23
|
return { ok: true, channel, id: opts.target };
|
|
24
24
|
if (platform() !== 'darwin') {
|
|
25
|
-
return { ok: false, channel, id: opts.target, error: 'iMessage requires macOS
|
|
25
|
+
return { ok: false, channel, id: opts.target, error: 'iMessage requires macOS' };
|
|
26
26
|
}
|
|
27
27
|
if ((opts.attachments?.length ?? 0) > 0) {
|
|
28
28
|
return { ok: false, channel, id: opts.target, error: 'iMessage attachments not supported via osascript' };
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
import { injectIntoTerminal } from '../../terminal/index.js';
|
|
2
2
|
import { resolveLiveInjectTarget } from '../../session/inject-target.js';
|
|
3
|
-
const
|
|
3
|
+
export const SESSION_CHANNEL = 'session';
|
|
4
4
|
export const sessionProvider = {
|
|
5
|
-
name:
|
|
5
|
+
name: SESSION_CHANNEL,
|
|
6
6
|
async send(text, opts) {
|
|
7
7
|
const id = opts.target;
|
|
8
|
-
const fail = (error) => ({ ok: false, channel:
|
|
9
|
-
if (!text.trim())
|
|
10
|
-
return fail('refusing to type an empty message into a session');
|
|
8
|
+
const fail = (error) => ({ ok: false, channel: SESSION_CHANNEL, id, error });
|
|
11
9
|
if (opts.attachments?.length)
|
|
12
10
|
return fail('the session channel types text only; --attach is not supported');
|
|
13
11
|
if (opts.thread)
|
|
14
12
|
return fail('the session channel has no threads; drop --thread');
|
|
15
13
|
if (opts.from)
|
|
16
14
|
return fail('the session channel types the text verbatim; drop --from');
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const terminal = opts.terminal ?? {};
|
|
16
|
+
let target;
|
|
17
|
+
if (terminal.pane) {
|
|
18
|
+
target = { backend: 'tmux', pane: terminal.pane, socket: terminal.socket };
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
else {
|
|
21
|
+
const resolved = await resolveLiveInjectTarget(id);
|
|
22
|
+
if (!resolved.target) {
|
|
23
|
+
return fail(resolved.hint ? `${resolved.reason}\n${resolved.hint}` : resolved.reason ?? 'session not addressable');
|
|
24
|
+
}
|
|
25
|
+
target = resolved.target;
|
|
26
|
+
}
|
|
27
|
+
const res = await injectIntoTerminal(target, text, {
|
|
28
|
+
enter: terminal.enter !== false,
|
|
29
|
+
combined: terminal.combined,
|
|
30
|
+
dryRun: opts.dryRun,
|
|
31
|
+
});
|
|
32
|
+
const delivery = { backend: res.backend, writes: res.writes, confirmed: res.confirmed };
|
|
33
|
+
return res.ok
|
|
34
|
+
? { ok: true, channel: SESSION_CHANNEL, id, ...delivery }
|
|
35
|
+
: { ...fail(res.error ?? 'injection failed'), ...delivery };
|
|
25
36
|
},
|
|
26
37
|
};
|