@phnx-labs/agents-cli 1.22.122 → 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 +261 -0
- package/README.md +49 -10
- package/dist/bootstrap.js +22 -17
- package/dist/cli/command-registry.d.ts +0 -1
- package/dist/cli/command-registry.js +2 -10
- 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 +6 -0
- 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/models.js +1 -1
- 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.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/testdata/feed-hub.d.ts +1 -0
- 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 -8
- 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 -5
- package/dist/lib/device-config.d.ts +4 -1
- package/dist/lib/device-config.js +57 -7
- 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 +18 -5
- 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 -8
- 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/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/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/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 +2 -0
- package/dist/lib/session/db.js +13 -4
- 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/standalone-tools.js +1 -1
- package/dist/lib/startup/command-registry.js +9 -4
- package/dist/lib/state.d.ts +2 -2
- package/dist/lib/state.js +3 -5
- 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 -1
- 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/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/humans.d.ts +0 -12
- package/dist/lib/humans.js +0 -64
package/dist/lib/cloud/rush.js
CHANGED
|
@@ -9,7 +9,7 @@ import { parseSSE } from './stream.js';
|
|
|
9
9
|
import { listInstalledVersions, getVersionHomePath } from '../installations/versions.js';
|
|
10
10
|
import { getAccountInfo } from '../agents.js';
|
|
11
11
|
import { selectBalancedVersion } from '../accounting/rotate.js';
|
|
12
|
-
|
|
12
|
+
import { RUSH_API_BASE } from '../rush-api.js';
|
|
13
13
|
const USER_YAML = path.join(os.homedir(), '.rush', 'user.yaml');
|
|
14
14
|
export function isRushSessionValid(yamlPath = USER_YAML) {
|
|
15
15
|
try {
|
|
@@ -44,6 +44,21 @@ export function readToken(yamlPath = USER_YAML) {
|
|
|
44
44
|
}
|
|
45
45
|
return token;
|
|
46
46
|
}
|
|
47
|
+
export async function rushOrgHandle(token, yamlPath = USER_YAML) {
|
|
48
|
+
const saved = yaml.parse(fs.readFileSync(yamlPath, 'utf-8'))?.org?.trim();
|
|
49
|
+
if (saved)
|
|
50
|
+
return saved;
|
|
51
|
+
const res = await api('GET', '/me', token);
|
|
52
|
+
if (!res.ok)
|
|
53
|
+
throw new Error(`Could not read your Rush organizations (${res.status}). Run \`rush login\` again.`);
|
|
54
|
+
const handle = personalOrgHandle((await res.json()).orgs ?? []);
|
|
55
|
+
if (!handle)
|
|
56
|
+
throw new Error('No Rush organization found for your account. Run `rush login` again.');
|
|
57
|
+
return handle;
|
|
58
|
+
}
|
|
59
|
+
export function personalOrgHandle(orgs) {
|
|
60
|
+
return (orgs.find((o) => o.kind === 'personal' && o.slug) ?? orgs.find((o) => o.slug))?.slug;
|
|
61
|
+
}
|
|
47
62
|
function readEmail() {
|
|
48
63
|
try {
|
|
49
64
|
const raw = fs.readFileSync(USER_YAML, 'utf-8');
|
|
@@ -55,7 +70,7 @@ function readEmail() {
|
|
|
55
70
|
}
|
|
56
71
|
}
|
|
57
72
|
async function api(method, endpoint, token, body) {
|
|
58
|
-
const url = endpoint.startsWith('http') ? endpoint : `${
|
|
73
|
+
const url = endpoint.startsWith('http') ? endpoint : `${RUSH_API_BASE}${endpoint}`;
|
|
59
74
|
const headers = {
|
|
60
75
|
'Authorization': `Bearer ${token}`,
|
|
61
76
|
'Content-Type': 'application/json',
|
|
@@ -318,7 +333,7 @@ export class RushCloudProvider {
|
|
|
318
333
|
}
|
|
319
334
|
async *stream(taskId) {
|
|
320
335
|
const token = readToken();
|
|
321
|
-
const res = await fetch(`${
|
|
336
|
+
const res = await fetch(`${RUSH_API_BASE}/api/v1/cloud-runs/${encodeURIComponent(taskId)}/stream`, {
|
|
322
337
|
headers: { 'Authorization': `Bearer ${token}` },
|
|
323
338
|
});
|
|
324
339
|
if (!res.ok) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComputerTargetContext } from './computer/context.js';
|
|
1
2
|
export declare const COMPUTER_CONTEXT_FD = 3;
|
|
2
3
|
export declare const COMPUTER_EVENTS_FD = 4;
|
|
3
4
|
export declare class ComputerClientError extends Error {
|
|
@@ -40,5 +41,23 @@ interface RunComputerResult {
|
|
|
40
41
|
stdout: string;
|
|
41
42
|
}
|
|
42
43
|
export declare function runComputer(opts: RunComputerOptions): Promise<RunComputerResult>;
|
|
44
|
+
export declare function withHostFlag(argv: string[], host?: string): string[];
|
|
45
|
+
export declare function resolveDeviceHost(device: string): Promise<{
|
|
46
|
+
host: string;
|
|
47
|
+
target: ComputerTargetContext;
|
|
48
|
+
}>;
|
|
49
|
+
export interface ForwardToComputerOptions {
|
|
50
|
+
argv: string[];
|
|
51
|
+
device?: string;
|
|
52
|
+
record?: boolean;
|
|
53
|
+
capture?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare function forwardToComputer(opts: ForwardToComputerOptions): Promise<RunComputerResult>;
|
|
56
|
+
export declare function installComputerHelperMacLocal(): Promise<void>;
|
|
57
|
+
export declare function activateComputerHelperMacLocal(): Promise<{
|
|
58
|
+
trusted: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
export declare function parseTrustFromStatusJson(stdout: string): boolean;
|
|
61
|
+
export declare function probeComputerTrust(): Promise<boolean>;
|
|
43
62
|
export declare function _resetComputerClientForTest(): void;
|
|
44
63
|
export {};
|
|
@@ -6,6 +6,11 @@ import { spawn } from 'node:child_process';
|
|
|
6
6
|
import { realpathSync, existsSync } from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import { findInPath } from './agent-spec/agents.js';
|
|
9
|
+
import { buildComputerContext } from './computer/context.js';
|
|
10
|
+
import { recordComputerAction } from './computer/record.js';
|
|
11
|
+
import { resolveRemoteDevice } from './ssh-tunnel.js';
|
|
12
|
+
import { getConfigValue } from './device-config.js';
|
|
13
|
+
import { parseAddress, sshTarget } from './address.js';
|
|
9
14
|
const INSTALL_HINT = 'npm i -g @phnx-labs/computer-cli';
|
|
10
15
|
export const COMPUTER_CONTEXT_FD = 3;
|
|
11
16
|
export const COMPUTER_EVENTS_FD = 4;
|
|
@@ -135,6 +140,105 @@ function osSignalNumber(signal) {
|
|
|
135
140
|
};
|
|
136
141
|
return table[signal];
|
|
137
142
|
}
|
|
143
|
+
export function withHostFlag(argv, host) {
|
|
144
|
+
if (!host)
|
|
145
|
+
return argv;
|
|
146
|
+
if (argv.some((arg) => arg === '--host' || arg.startsWith('--host=')))
|
|
147
|
+
return argv;
|
|
148
|
+
const [verb, ...rest] = argv;
|
|
149
|
+
return [verb, '--host', host, ...rest];
|
|
150
|
+
}
|
|
151
|
+
export async function resolveDeviceHost(device) {
|
|
152
|
+
const configured = getConfigValue('computer.host', { device }).value;
|
|
153
|
+
if (configured) {
|
|
154
|
+
const addr = parseAddress(configured);
|
|
155
|
+
if (addr.scheme === 'vnc' || addr.scheme === 'tcp') {
|
|
156
|
+
return { host: configured, target: { alias: device, host: addr.host, user: addr.user ?? '', hostname: addr.host, platform: addr.scheme, sshArgs: [] } };
|
|
157
|
+
}
|
|
158
|
+
const resolved = await resolveRemoteDevice(device, {});
|
|
159
|
+
const target = sshTarget(addr);
|
|
160
|
+
return {
|
|
161
|
+
host: configured,
|
|
162
|
+
target: { alias: device, host: target, user: addr.user ?? resolved.user, hostname: addr.host, platform: resolved.device.platform, sshArgs: resolved.identityArgs },
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const resolved = await resolveRemoteDevice(device, {
|
|
166
|
+
expectPlatform: 'windows',
|
|
167
|
+
forWhat: '`agents computer --device` drives the Windows computer-helper daemon, so it',
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
host: `ssh://${resolved.target}`,
|
|
171
|
+
target: { alias: device, host: resolved.target, user: resolved.user, hostname: resolved.host, platform: resolved.device.platform, sshArgs: resolved.identityArgs },
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export async function forwardToComputer(opts) {
|
|
175
|
+
let bin;
|
|
176
|
+
try {
|
|
177
|
+
bin = resolveComputerBin();
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
if (isComputerClientError(err)) {
|
|
181
|
+
console.error(err.message);
|
|
182
|
+
return { exitCode: 1, stdout: '' };
|
|
183
|
+
}
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
const hostFlag = opts.argv.findIndex(arg => arg === '--host' || arg.startsWith('--host='));
|
|
187
|
+
let host = hostFlag < 0 ? undefined : (opts.argv[hostFlag].includes('=') ? opts.argv[hostFlag].slice(7) : opts.argv[hostFlag + 1]);
|
|
188
|
+
let target;
|
|
189
|
+
if (!host && opts.device) {
|
|
190
|
+
const resolved = await resolveDeviceHost(opts.device);
|
|
191
|
+
host = resolved.host;
|
|
192
|
+
target = resolved.target;
|
|
193
|
+
}
|
|
194
|
+
const context = await buildComputerContext({ device: opts.device, host, target, computerBin: bin });
|
|
195
|
+
return runComputer({
|
|
196
|
+
argv: withHostFlag(opts.argv, host),
|
|
197
|
+
context,
|
|
198
|
+
capture: opts.capture,
|
|
199
|
+
onEvent: opts.record === false
|
|
200
|
+
? undefined
|
|
201
|
+
: (event) => recordComputerAction(event, { device: opts.device }),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export async function installComputerHelperMacLocal() {
|
|
205
|
+
const { exitCode } = await forwardToComputer({ argv: ['setup'], record: false });
|
|
206
|
+
if (exitCode !== 0)
|
|
207
|
+
throw new Error(`\`computer setup\` failed (exit ${exitCode})`);
|
|
208
|
+
}
|
|
209
|
+
export async function activateComputerHelperMacLocal() {
|
|
210
|
+
const { exitCode } = await forwardToComputer({ argv: ['start'], record: false });
|
|
211
|
+
if (exitCode !== 0)
|
|
212
|
+
throw new Error(`\`computer start\` failed (exit ${exitCode})`);
|
|
213
|
+
return { trusted: await probeComputerTrust() };
|
|
214
|
+
}
|
|
215
|
+
export function parseTrustFromStatusJson(stdout) {
|
|
216
|
+
const start = stdout.indexOf('{');
|
|
217
|
+
if (start < 0)
|
|
218
|
+
return false;
|
|
219
|
+
try {
|
|
220
|
+
const parsed = JSON.parse(stdout.slice(start));
|
|
221
|
+
return parsed.trusted === true;
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
export async function probeComputerTrust() {
|
|
228
|
+
try {
|
|
229
|
+
const { exitCode, stdout } = await forwardToComputer({
|
|
230
|
+
argv: ['status', '--json'],
|
|
231
|
+
record: false,
|
|
232
|
+
capture: true,
|
|
233
|
+
});
|
|
234
|
+
if (exitCode !== 0)
|
|
235
|
+
return false;
|
|
236
|
+
return parseTrustFromStatusJson(stdout);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
138
242
|
export function _resetComputerClientForTest() {
|
|
139
243
|
cachedBin = undefined;
|
|
140
244
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { AgentId } from './types.js';
|
|
2
2
|
import { type ModelTier } from './model-tiers.js';
|
|
3
3
|
export type ConfigScope = 'run' | 'interactive' | 'auto' | 'browser' | 'project' | 'device' | 'summarizer' | 'updates' | 'menubar';
|
|
4
|
-
export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "prGroupOpen", "prGroupMerged"];
|
|
4
|
+
export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "prGroupOpen", "prGroupMerged", "homeGoals"];
|
|
5
|
+
export declare const MENUBAR_STATUSBAR_PROPERTIES: readonly ["goalCountdown"];
|
|
6
|
+
export type MenubarSection = 'menu' | 'statusbar';
|
|
7
|
+
export declare const MENUBAR_CONFIG_KEYS: readonly string[];
|
|
5
8
|
export interface ParsedRunConfigKey {
|
|
6
9
|
scope: 'run';
|
|
7
10
|
agent: AgentId;
|
|
@@ -42,6 +45,7 @@ export interface ParsedUpdatesConfigKey {
|
|
|
42
45
|
}
|
|
43
46
|
export interface ParsedMenubarConfigKey {
|
|
44
47
|
scope: 'menubar';
|
|
48
|
+
section: MenubarSection;
|
|
45
49
|
property: string;
|
|
46
50
|
}
|
|
47
51
|
export type ParsedConfigKey = ParsedRunConfigKey | ParsedInteractiveConfigKey | ParsedAutoConfigKey | ParsedBrowserConfigKey | ParsedProjectConfigKey | ParsedDeviceConfigKey | ParsedSummarizerConfigKey | ParsedUpdatesConfigKey | ParsedMenubarConfigKey;
|
package/dist/lib/config-keys.js
CHANGED
|
@@ -26,6 +26,12 @@ export const MENUBAR_MENU_PROPERTIES = [
|
|
|
26
26
|
'groupTicketsByMilestone',
|
|
27
27
|
'prGroupOpen',
|
|
28
28
|
'prGroupMerged',
|
|
29
|
+
'homeGoals',
|
|
30
|
+
];
|
|
31
|
+
export const MENUBAR_STATUSBAR_PROPERTIES = ['goalCountdown'];
|
|
32
|
+
export const MENUBAR_CONFIG_KEYS = [
|
|
33
|
+
...MENUBAR_MENU_PROPERTIES.map((p) => `menubar.menu.${p}`),
|
|
34
|
+
...MENUBAR_STATUSBAR_PROPERTIES.map((p) => `menubar.statusbar.${p}`),
|
|
29
35
|
];
|
|
30
36
|
const DEVICE_CONFIG_PROPERTIES = [
|
|
31
37
|
'browser.viewer',
|
|
@@ -93,13 +99,12 @@ export function parseConfigKey(key) {
|
|
|
93
99
|
if (summarizerMatch) {
|
|
94
100
|
return { scope: 'summarizer', property: summarizerMatch[1] };
|
|
95
101
|
}
|
|
96
|
-
const menubarMatch = raw.match(/^menubar\.menu\.(.+)$/);
|
|
102
|
+
const menubarMatch = raw.match(/^menubar\.(menu|statusbar)\.(.+)$/);
|
|
97
103
|
if (menubarMatch) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
throw new Error(`Unknown AGI Menu preference '${key}'. Known keys: ${MENUBAR_MENU_PROPERTIES.map((p) => `menubar.menu.${p}`).join(', ')}.`);
|
|
104
|
+
if (!MENUBAR_CONFIG_KEYS.includes(raw)) {
|
|
105
|
+
throw new Error(`Unknown AGI Menu preference '${key}'. Known keys: ${MENUBAR_CONFIG_KEYS.join(', ')}.`);
|
|
101
106
|
}
|
|
102
|
-
return { scope: 'menubar', property };
|
|
107
|
+
return { scope: 'menubar', section: menubarMatch[1], property: menubarMatch[2] };
|
|
103
108
|
}
|
|
104
109
|
if (raw === 'updates.auto') {
|
|
105
110
|
return { scope: 'updates', property: 'auto' };
|
|
@@ -142,7 +147,7 @@ export function parseConfigKey(key) {
|
|
|
142
147
|
throw new Error(`Invalid updates config key '${key}'. Use updates.auto or updates.<agent>.auto.`);
|
|
143
148
|
}
|
|
144
149
|
if (raw.startsWith('menubar.')) {
|
|
145
|
-
throw new Error(`Invalid AGI Menu config key '${key}'. Use ${
|
|
150
|
+
throw new Error(`Invalid AGI Menu config key '${key}'. Use ${MENUBAR_CONFIG_KEYS.join(', ')}.`);
|
|
146
151
|
}
|
|
147
152
|
if (raw.startsWith('devices.')) {
|
|
148
153
|
throw new Error(`Invalid device config key '${key}'. Expected devices.<name>.<${DEVICE_CONFIG_PROPERTIES.join('|')}>.`);
|
|
@@ -173,7 +178,7 @@ export function formatConfigKey(parsed) {
|
|
|
173
178
|
case 'updates':
|
|
174
179
|
return parsed.agent ? `updates.${parsed.agent}.auto` : 'updates.auto';
|
|
175
180
|
case 'menubar':
|
|
176
|
-
return `menubar.
|
|
181
|
+
return `menubar.${parsed.section}.${parsed.property}`;
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
export function listKnownConfigKeys() {
|
|
@@ -183,9 +188,7 @@ export function listKnownConfigKeys() {
|
|
|
183
188
|
keys.push(`run.<agent@version>.tier.${tier}`);
|
|
184
189
|
}
|
|
185
190
|
keys.push('interactive.host', 'auto.pool', 'browser.profile', 'browser.viewer', 'browser.device', 'project.root', 'summarizer.enabled', 'summarizer.baseUrl', 'summarizer.model', 'updates.auto', 'updates.<agent>.auto');
|
|
186
|
-
|
|
187
|
-
keys.push(`menubar.menu.${prop}`);
|
|
188
|
-
}
|
|
191
|
+
keys.push(...MENUBAR_CONFIG_KEYS);
|
|
189
192
|
for (const prop of DEVICE_CONFIG_PROPERTIES) {
|
|
190
193
|
keys.push(`devices.<name>.${prop}`);
|
|
191
194
|
}
|
|
@@ -256,6 +259,6 @@ export function configKeyStorageHint(parsed) {
|
|
|
256
259
|
? `config.updatesAgentAuto.${parsed.agent} (central agents.yaml; syncs fleet-wide)`
|
|
257
260
|
: 'config.updatesAuto (central agents.yaml; syncs fleet-wide)';
|
|
258
261
|
case 'menubar':
|
|
259
|
-
return `config.
|
|
262
|
+
return `config.menubar${parsed.section === 'menu' ? 'Menu' : 'Statusbar'}${parsed.property.charAt(0).toUpperCase()}${parsed.property.slice(1)} (central agents.yaml; syncs fleet-wide)`;
|
|
260
263
|
}
|
|
261
264
|
}
|
|
@@ -51,5 +51,18 @@ export class AuthSyncService extends BasePeriodicService {
|
|
|
51
51
|
catch (err) {
|
|
52
52
|
ctx.log('WARN', `auth-sync: reserved-store sync: ${err.message}`);
|
|
53
53
|
}
|
|
54
|
+
try {
|
|
55
|
+
const { syncOwnerNotifyTokens } = await import('../owner-notify-tokens.js');
|
|
56
|
+
const notify = await syncOwnerNotifyTokens();
|
|
57
|
+
if (notify.minted.length > 0)
|
|
58
|
+
ctx.log('INFO', `auth-sync: minted owner-notify device token(s) for ${notify.minted.join(', ')}`);
|
|
59
|
+
if (notify.pushed.length > 0)
|
|
60
|
+
ctx.log('INFO', `auth-sync: pushed owner-notify device token(s) to ${notify.pushed.join(', ')}`);
|
|
61
|
+
for (const err of notify.errors)
|
|
62
|
+
ctx.log('WARN', `auth-sync: owner-notify ${err.device}: ${err.message}`);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
ctx.log('WARN', `auth-sync: owner-notify token sync: ${err.message}`);
|
|
66
|
+
}
|
|
54
67
|
}
|
|
55
68
|
}
|
|
@@ -14,6 +14,7 @@ import { detectOverdueJobs, notifyOverdue } from '../overdue.js';
|
|
|
14
14
|
import { runCatchup } from '../catchup.js';
|
|
15
15
|
import { notifyRoutineStart, notifyRoutineFinish, notifyRoutineStartFailed } from '../routine-notify.js';
|
|
16
16
|
import { notifyOwnerRoutineFinish, notifyOwnerRoutineStartFailed } from '../routine-notify-owner.js';
|
|
17
|
+
import { describeOwnerResult } from '../owner-notify.js';
|
|
17
18
|
import { redactSecrets } from '../redact.js';
|
|
18
19
|
import { getAgentsBinPath, getCliLaunch, BUN_VIRTUAL_ROOT } from '../cli-entry.js';
|
|
19
20
|
import { localBinDir } from '../platform/posixpath.js';
|
|
@@ -503,7 +504,7 @@ export function assertTestDaemonHome(daemonDir = getDaemonDir(), testHome = proc
|
|
|
503
504
|
}
|
|
504
505
|
export async function runDaemon() {
|
|
505
506
|
assertTestDaemonHome();
|
|
506
|
-
const [{ SessionIndexService }, { SessionSummarizerService }, { SessionTitleService }, { AccountUsageService, AccountAuthService }, { CatchupService }, { WatchdogService }, { DeviceProbeService }, { SelfHealService }, { SelfUpdateService }, { HarnessUpdateService }, { AuthSyncService }, { UsageSyncService }, { StateDirCheckService }, { SessionStateService }, { FeedStreamService }, { AttentionNotifyService }, { WebhookReceiverService }, { HeartbeatService }, { TmuxReapService },] = await Promise.all([
|
|
507
|
+
const [{ SessionIndexService }, { SessionSummarizerService }, { SessionTitleService }, { AccountUsageService, AccountAuthService }, { CatchupService }, { WatchdogService }, { DeviceProbeService }, { SelfHealService }, { SelfUpdateService }, { HarnessUpdateService }, { AuthSyncService }, { UsageSyncService }, { StateDirCheckService }, { SessionStateService }, { FeedStreamService }, { AttentionNotifyService }, { OwnerDeviceDeliveryService }, { RecordingsService }, { WebhookReceiverService }, { HeartbeatService }, { TmuxReapService },] = await Promise.all([
|
|
507
508
|
import('./session-index-service.js'),
|
|
508
509
|
import('./session-summarizer-service.js'),
|
|
509
510
|
import('./session-title-service.js'),
|
|
@@ -520,6 +521,8 @@ export async function runDaemon() {
|
|
|
520
521
|
import('./session-state-service.js'),
|
|
521
522
|
import('./feed-stream-service.js'),
|
|
522
523
|
import('./attention-notify-service.js'),
|
|
524
|
+
import('./owner-device-delivery-service.js'),
|
|
525
|
+
import('../recordings/service.js'),
|
|
523
526
|
import('./webhook-receiver-service.js'),
|
|
524
527
|
import('./heartbeat-service.js'),
|
|
525
528
|
import('./tmux-reap-service.js'),
|
|
@@ -596,6 +599,9 @@ export async function runDaemon() {
|
|
|
596
599
|
supervisor.register(new FeedStreamService(), { enabled: isEnabled('feed-stream') });
|
|
597
600
|
if (!isEnabled('feed-stream'))
|
|
598
601
|
log('INFO', 'Shared feed stream service disabled');
|
|
602
|
+
supervisor.register(new RecordingsService(), { enabled: isEnabled('recordings') });
|
|
603
|
+
if (!isEnabled('recordings'))
|
|
604
|
+
log('INFO', 'CleanShot recordings service disabled');
|
|
599
605
|
if (isEnabled('account-state'))
|
|
600
606
|
supervisor.register(new AccountUsageService());
|
|
601
607
|
else
|
|
@@ -626,6 +632,12 @@ export async function runDaemon() {
|
|
|
626
632
|
supervisor.register(new AttentionNotifyService());
|
|
627
633
|
else
|
|
628
634
|
log('INFO', 'Attention-notify service disabled');
|
|
635
|
+
if (process.platform === 'darwin') {
|
|
636
|
+
if (isEnabled('owner-device-delivery'))
|
|
637
|
+
supervisor.register(new OwnerDeviceDeliveryService());
|
|
638
|
+
else
|
|
639
|
+
log('INFO', 'Owner device-delivery service disabled');
|
|
640
|
+
}
|
|
629
641
|
if (isEnabled('session-title'))
|
|
630
642
|
supervisor.register(new SessionTitleService());
|
|
631
643
|
else
|
|
@@ -711,10 +723,10 @@ export async function runDaemon() {
|
|
|
711
723
|
catch { }
|
|
712
724
|
void notifyOwnerRoutineFinish(final)
|
|
713
725
|
.then((r) => {
|
|
714
|
-
if (r.
|
|
715
|
-
log('WARN', `Owner failure-notify for '${config.name}' reached no channel
|
|
726
|
+
if (r && r.suppressed === null && r.delivered.length + r.queued.length === 0)
|
|
727
|
+
log('WARN', `Owner failure-notify for '${config.name}' reached no channel: ${describeOwnerResult(r)}`);
|
|
716
728
|
})
|
|
717
|
-
.catch(() => { });
|
|
729
|
+
.catch((err) => log('WARN', `Owner failure-notify for '${config.name}' failed: ${err.message}`));
|
|
718
730
|
},
|
|
719
731
|
}, { kind: 'schedule', scheduledFor: ctx?.scheduledFor });
|
|
720
732
|
log('INFO', `Job '${config.name}' spawned (run: ${meta.runId}, PID: ${meta.pid})`);
|
|
@@ -731,12 +743,12 @@ export async function runDaemon() {
|
|
|
731
743
|
notifyRoutineStartFailed(config, message);
|
|
732
744
|
}
|
|
733
745
|
catch { }
|
|
734
|
-
void notifyOwnerRoutineStartFailed(config, message)
|
|
746
|
+
void notifyOwnerRoutineStartFailed(config, message, ctx?.scheduledFor)
|
|
735
747
|
.then((r) => {
|
|
736
|
-
if (r.
|
|
737
|
-
log('WARN', `Owner start-failure notify for '${config.name}' reached no channel
|
|
748
|
+
if (r.suppressed === null && r.delivered.length + r.queued.length === 0)
|
|
749
|
+
log('WARN', `Owner start-failure notify for '${config.name}' reached no channel: ${describeOwnerResult(r)}`);
|
|
738
750
|
})
|
|
739
|
-
.catch(() => { });
|
|
751
|
+
.catch((err) => log('WARN', `Owner start-failure notify for '${config.name}' failed: ${err.message}`));
|
|
740
752
|
}
|
|
741
753
|
};
|
|
742
754
|
function bootScheduler() {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DaemonServiceId } from '../daemon-services.js';
|
|
2
|
+
import { BasePeriodicService, type DaemonContext } from './service.js';
|
|
3
|
+
export declare class OwnerDeviceDeliveryService extends BasePeriodicService {
|
|
4
|
+
readonly id: DaemonServiceId;
|
|
5
|
+
readonly intervalMs = 15000;
|
|
6
|
+
readonly deadlineMs = 60000;
|
|
7
|
+
protected onStart(_ctx: DaemonContext): Promise<void>;
|
|
8
|
+
protected onStop(): Promise<void>;
|
|
9
|
+
protected onTick(ctx: DaemonContext): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { sendImessage } from '../channels/providers/rush.js';
|
|
2
|
+
import { claimDeviceDeliveries, reportDeviceDelivery, resolveOwnerCredential, selfDeviceName, } from '../owner-notify.js';
|
|
3
|
+
import { BasePeriodicService } from './service.js';
|
|
4
|
+
const OWNER_DEVICE_DELIVERY_TICK_MS = 15_000;
|
|
5
|
+
const OWNER_DEVICE_DELIVERY_DEADLINE_MS = 60_000;
|
|
6
|
+
export class OwnerDeviceDeliveryService extends BasePeriodicService {
|
|
7
|
+
id = 'owner-device-delivery';
|
|
8
|
+
intervalMs = OWNER_DEVICE_DELIVERY_TICK_MS;
|
|
9
|
+
deadlineMs = OWNER_DEVICE_DELIVERY_DEADLINE_MS;
|
|
10
|
+
async onStart(_ctx) { }
|
|
11
|
+
async onStop() { }
|
|
12
|
+
async onTick(ctx) {
|
|
13
|
+
if (!resolveOwnerCredential())
|
|
14
|
+
return;
|
|
15
|
+
const deliveries = await claimDeviceDeliveries(selfDeviceName());
|
|
16
|
+
for (const delivery of deliveries) {
|
|
17
|
+
const sent = await sendImessage(delivery.body, { target: delivery.address });
|
|
18
|
+
if (!sent.ok)
|
|
19
|
+
ctx.log('WARN', `owner-device-delivery: ${delivery.id} to ${delivery.address}: ${sent.error}`);
|
|
20
|
+
try {
|
|
21
|
+
await reportDeviceDelivery(delivery.id, sent.ok ? { ok: true } : { ok: false, error: sent.error ?? 'iMessage send failed' });
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
ctx.log('WARN', `owner-device-delivery: ${delivery.id} ${sent.ok ? 'sent' : 'failed'} but the result was not recorded: ${err.message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export type DaemonServiceId = 'scheduler' | 'catchup' | 'webhook-receiver' | 'self-heal' | 'self-update' | 'account-state' | 'account-auth' | 'watchdog' | 'device-probe' | 'state-dir-check' | 'session-index' | 'session-title' | 'auth-sync' | 'usage-sync' | 'daemon-heartbeat' | 'tmux-reap' | 'session-state' | 'feed-stream' | 'session-summarizer' | 'attention-notify' | 'harness-update';
|
|
1
|
+
export type DaemonServiceId = 'scheduler' | 'catchup' | 'webhook-receiver' | 'self-heal' | 'self-update' | 'account-state' | 'account-auth' | 'watchdog' | 'device-probe' | 'state-dir-check' | 'session-index' | 'session-title' | 'auth-sync' | 'usage-sync' | 'daemon-heartbeat' | 'tmux-reap' | 'session-state' | 'feed-stream' | 'session-summarizer' | 'attention-notify' | 'owner-device-delivery' | 'recordings' | 'harness-update';
|
|
2
2
|
interface DaemonServiceDef {
|
|
3
3
|
id: DaemonServiceId;
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
|
+
defaultEnabled?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const DAEMON_SERVICES: DaemonServiceDef[];
|
|
8
9
|
export declare const DAEMON_SERVICE_IDS: DaemonServiceId[];
|
|
@@ -89,6 +89,17 @@ export const DAEMON_SERVICES = [
|
|
|
89
89
|
title: 'Attention desktop banners',
|
|
90
90
|
description: 'Posts one actionable desktop banner per new attention item (question / permission / plan review / stall) so the macOS helper can answer it through agents feed answer (PHNX-4004).',
|
|
91
91
|
},
|
|
92
|
+
{
|
|
93
|
+
id: 'owner-device-delivery',
|
|
94
|
+
title: 'Owner iMessage delivery',
|
|
95
|
+
description: 'macOS only: every 15 s, claims the iMessage notifications your account queued for a device and sends them through Messages, then reports each result. Idle without a Phoenix session or device token (PHNX-4267).',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'recordings',
|
|
99
|
+
title: 'CleanShot recording publisher',
|
|
100
|
+
description: 'Publishes settled CleanShot videos as organization-only artifacts. Off until enabled by `agents recordings watch`.',
|
|
101
|
+
defaultEnabled: false,
|
|
102
|
+
},
|
|
92
103
|
{
|
|
93
104
|
id: 'session-title',
|
|
94
105
|
title: 'Session titles',
|
|
@@ -113,8 +124,8 @@ export const DAEMON_SERVICES = [
|
|
|
113
124
|
export const DAEMON_SERVICE_IDS = DAEMON_SERVICES.map((s) => s.id);
|
|
114
125
|
function defaultServicesConfig() {
|
|
115
126
|
const services = {};
|
|
116
|
-
for (const
|
|
117
|
-
services[id] =
|
|
127
|
+
for (const service of DAEMON_SERVICES)
|
|
128
|
+
services[service.id] = service.defaultEnabled !== false;
|
|
118
129
|
return { services };
|
|
119
130
|
}
|
|
120
131
|
export function getDaemonServicesConfigPath() {
|
|
@@ -151,8 +162,9 @@ export function writeDaemonServicesConfig(cfg) {
|
|
|
151
162
|
catch {
|
|
152
163
|
}
|
|
153
164
|
const services = {};
|
|
154
|
-
for (const
|
|
155
|
-
services[id] = cfg.services[id] ??
|
|
165
|
+
for (const service of DAEMON_SERVICES) {
|
|
166
|
+
services[service.id] = cfg.services[service.id] ?? service.defaultEnabled !== false;
|
|
167
|
+
}
|
|
156
168
|
const out = yaml.stringify({ ...preserved, services }, { sortMapEntries: false });
|
|
157
169
|
atomicWriteFileSync(filePath, out, 'utf-8');
|
|
158
170
|
}
|
|
@@ -167,7 +179,7 @@ export function setDaemonServiceEnabled(id, enabled) {
|
|
|
167
179
|
}
|
|
168
180
|
export function listDaemonServiceStates() {
|
|
169
181
|
const cfg = readDaemonServicesConfig();
|
|
170
|
-
return DAEMON_SERVICES.map((s) => ({ ...s, enabled: cfg.services[s.id]
|
|
182
|
+
return DAEMON_SERVICES.map((s) => ({ ...s, enabled: cfg.services[s.id] }));
|
|
171
183
|
}
|
|
172
184
|
function getDaemonServiceActionsPath() {
|
|
173
185
|
return path.join(getDaemonConfigDir(), 'service-actions.json');
|
|
@@ -8,6 +8,7 @@ interface ConfigKeySpecBase {
|
|
|
8
8
|
description: string;
|
|
9
9
|
defaultValue?: unknown;
|
|
10
10
|
validate?: (value: unknown) => string | null;
|
|
11
|
+
normalize?: (value: unknown) => unknown;
|
|
11
12
|
}
|
|
12
13
|
export type ConfigKeySpec = (ConfigKeySpecBase & {
|
|
13
14
|
scope: 'user';
|
|
@@ -28,7 +29,9 @@ interface ConfigTarget {
|
|
|
28
29
|
}
|
|
29
30
|
declare const DEVICE_ROLES: readonly ["worker", "personal", "desktop"];
|
|
30
31
|
declare const AUTO_POOL_MODES: readonly ["workers", "all"];
|
|
31
|
-
export declare const MENUBAR_TABS: readonly ["home", "
|
|
32
|
+
export declare const MENUBAR_TABS: readonly ["home", "goals", "projects", "sessions", "inbox"];
|
|
33
|
+
export declare const MENUBAR_HOME_GOALS: readonly ["company", "week", "myWeek", "myDay"];
|
|
34
|
+
export declare function resolveMenubarTabOrder(stored: readonly string[]): string[];
|
|
32
35
|
export declare const CONFIG_KEYS: readonly ConfigKeySpec[];
|
|
33
36
|
export declare function configKeySpec(name: string): ConfigKeySpec;
|
|
34
37
|
export declare function assertValidValue(spec: ConfigKeySpec, value: unknown): void;
|
|
@@ -14,7 +14,18 @@ const SSH_AUTH_METHODS = ['key', 'password'];
|
|
|
14
14
|
const DEVICE_ROLES = ['worker', 'personal', 'desktop'];
|
|
15
15
|
const AUTO_POOL_MODES = ['workers', 'all'];
|
|
16
16
|
const DEVICE_FORM_FACTORS = ['laptop', 'desktop', 'server', 'unknown'];
|
|
17
|
-
export const MENUBAR_TABS = ['home', '
|
|
17
|
+
export const MENUBAR_TABS = ['home', 'goals', 'projects', 'sessions', 'inbox'];
|
|
18
|
+
const MENUBAR_TABS_ADDED_LATER = ['goals'];
|
|
19
|
+
export const MENUBAR_HOME_GOALS = ['company', 'week', 'myWeek', 'myDay'];
|
|
20
|
+
export function resolveMenubarTabOrder(stored) {
|
|
21
|
+
const known = MENUBAR_TABS;
|
|
22
|
+
const tabs = [];
|
|
23
|
+
for (const id of stored) {
|
|
24
|
+
if (known.includes(id) && !tabs.includes(id))
|
|
25
|
+
tabs.push(id);
|
|
26
|
+
}
|
|
27
|
+
return [...tabs, ...known.filter((t) => !tabs.includes(t))];
|
|
28
|
+
}
|
|
18
29
|
function oneOf(name, allowed) {
|
|
19
30
|
return (v) => (allowed.includes(v) ? null : `${name} must be one of ${allowed.join(' | ')}.`);
|
|
20
31
|
}
|
|
@@ -91,7 +102,7 @@ export const CONFIG_KEYS = [
|
|
|
91
102
|
scope: 'device',
|
|
92
103
|
visibility: 'machine',
|
|
93
104
|
type: 'string',
|
|
94
|
-
description: "Which browser THIS machine shows YOU a page in (an .html artifact,
|
|
105
|
+
description: "Which browser THIS machine shows YOU a page in (an .html artifact, a login " +
|
|
95
106
|
"dashboard): a profile name, or `os` for the OS default handler. Unset follows browser.profile. " +
|
|
96
107
|
"Distinct from browser.profile, which is the profile agents DRIVE — see RUSH-2709 for why " +
|
|
97
108
|
"collapsing the two was a mistake. Set it to `os` to keep the OS default handler.",
|
|
@@ -539,12 +550,20 @@ export const CONFIG_KEYS = [
|
|
|
539
550
|
type: 'string-list',
|
|
540
551
|
defaultValue: [...MENUBAR_TABS],
|
|
541
552
|
description: `AGI Menu: the order of the tab bar — every one of ${MENUBAR_TABS.join(', ')} exactly once. ` +
|
|
542
|
-
'Settings is always last and is not listed.
|
|
553
|
+
'Settings is always last and is not listed. An order saved before Goals existed may omit goals; ' +
|
|
554
|
+
'it reads back with goals appended. Hiding a tab is menubar.menu.hiddenTabs, not this key.',
|
|
543
555
|
validate: (v) => {
|
|
544
556
|
const tabs = v;
|
|
545
|
-
const
|
|
546
|
-
|
|
557
|
+
const required = MENUBAR_TABS.filter((t) => !MENUBAR_TABS_ADDED_LATER.includes(t));
|
|
558
|
+
const ok = new Set(tabs).size === tabs.length
|
|
559
|
+
&& tabs.every((t) => MENUBAR_TABS.includes(t))
|
|
560
|
+
&& required.every((t) => tabs.includes(t));
|
|
561
|
+
return ok
|
|
562
|
+
? null
|
|
563
|
+
: `menubar.menu.tabOrder must list each of ${MENUBAR_TABS.join(', ')} exactly once ` +
|
|
564
|
+
`(${MENUBAR_TABS_ADDED_LATER.join(', ')} may be left out and is appended).`;
|
|
547
565
|
},
|
|
566
|
+
normalize: (v) => (Array.isArray(v) ? resolveMenubarTabOrder(v.map(String)) : v),
|
|
548
567
|
},
|
|
549
568
|
{
|
|
550
569
|
name: 'menubar.menu.hiddenTabs',
|
|
@@ -594,6 +613,31 @@ export const CONFIG_KEYS = [
|
|
|
594
613
|
'conventional-commit type in the title), or day (Today, Yesterday, Earlier this week).',
|
|
595
614
|
validate: oneOf('menubar.menu.prGroupMerged', ['none', 'type', 'day']),
|
|
596
615
|
},
|
|
616
|
+
{
|
|
617
|
+
name: 'menubar.menu.homeGoals',
|
|
618
|
+
yamlKey: 'menubarMenuHomeGoals',
|
|
619
|
+
scope: 'user',
|
|
620
|
+
type: 'string-list',
|
|
621
|
+
defaultValue: ['company'],
|
|
622
|
+
description: `AGI Menu: the goal levels shown on Home, in order — any of ${MENUBAR_HOME_GOALS.join(', ')} ` +
|
|
623
|
+
'(company quarter goal, company week goal, your week goal, your day goal). Empty shows none.',
|
|
624
|
+
validate: (v) => {
|
|
625
|
+
const levels = v;
|
|
626
|
+
const bad = levels.find((l) => !MENUBAR_HOME_GOALS.includes(l));
|
|
627
|
+
if (bad !== undefined)
|
|
628
|
+
return `menubar.menu.homeGoals: "${bad}" is not one of ${MENUBAR_HOME_GOALS.join(', ')}.`;
|
|
629
|
+
const dup = levels.find((l, i) => levels.indexOf(l) !== i);
|
|
630
|
+
return dup === undefined ? null : `menubar.menu.homeGoals lists "${dup}" twice.`;
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: 'menubar.statusbar.goalCountdown',
|
|
635
|
+
yamlKey: 'menubarStatusbarGoalCountdown',
|
|
636
|
+
scope: 'user',
|
|
637
|
+
type: 'bool',
|
|
638
|
+
defaultValue: false,
|
|
639
|
+
description: 'AGI Menu: show the countdown to the next goal deadline beside the menu-bar icon.',
|
|
640
|
+
},
|
|
597
641
|
];
|
|
598
642
|
function dynamicAgentAutoUpdateSpec(name) {
|
|
599
643
|
const match = name.match(/^updates\.(.+)\.auto$/);
|
|
@@ -745,7 +789,9 @@ export function getConfigValue(name, opts) {
|
|
|
745
789
|
const spec = configKeySpec(name);
|
|
746
790
|
if (spec.scope === 'user') {
|
|
747
791
|
const value = readMeta({ migrate: false }).config?.[spec.yamlKey];
|
|
748
|
-
|
|
792
|
+
if (value === undefined)
|
|
793
|
+
return { spec, value, source: 'default' };
|
|
794
|
+
return { spec, value: spec.normalize ? spec.normalize(value) : value, source: 'user' };
|
|
749
795
|
}
|
|
750
796
|
ensureDeviceConfigMigrated();
|
|
751
797
|
if (opts?.fleet) {
|
|
@@ -766,7 +812,9 @@ export async function getConfigValueAsync(name, opts) {
|
|
|
766
812
|
const spec = configKeySpec(name);
|
|
767
813
|
if (spec.scope === 'user') {
|
|
768
814
|
const value = readMeta({ migrate: false }).config?.[spec.yamlKey];
|
|
769
|
-
|
|
815
|
+
if (value === undefined)
|
|
816
|
+
return { spec, value, source: 'default' };
|
|
817
|
+
return { spec, value: spec.normalize ? spec.normalize(value) : value, source: 'user' };
|
|
770
818
|
}
|
|
771
819
|
ensureDeviceConfigMigrated();
|
|
772
820
|
if (opts?.fleet) {
|
|
@@ -855,6 +903,8 @@ export function setConfigValue(name, value, opts) {
|
|
|
855
903
|
ensureDeviceConfigMigrated();
|
|
856
904
|
const spec = configKeySpec(name);
|
|
857
905
|
assertValidValue(spec, value);
|
|
906
|
+
if (spec.normalize)
|
|
907
|
+
value = spec.normalize(value);
|
|
858
908
|
if (spec.scope === 'user') {
|
|
859
909
|
if (opts?.fleet) {
|
|
860
910
|
throw new Error(`Config key '${spec.name}' is user-scope (already fleet-wide) — --fleet does not apply.`);
|