@phnx-labs/agents-cli 1.23.12 → 1.23.14
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 +42 -0
- package/README.md +30 -59
- package/dist/cli/command-registry.js +0 -24
- package/dist/commands/accounts.js +3 -3
- package/dist/commands/daemon.js +5 -147
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/events-logs.d.ts +2 -0
- package/dist/commands/{logs.js → events-logs.js} +28 -127
- package/dist/commands/events.js +3 -1
- package/dist/commands/exec.d.ts +0 -1
- package/dist/commands/exec.js +3 -11
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +4 -7
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/menubar.js +12 -226
- package/dist/commands/projects.js +1 -2
- package/dist/commands/{trash.d.ts → prune-trash.d.ts} +1 -1
- package/dist/commands/{trash.js → prune-trash.js} +8 -8
- package/dist/commands/prune.js +3 -1
- package/dist/commands/send.js +2 -5
- package/dist/commands/sessions.js +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/ssh.js +2 -2
- package/dist/commands/utils.d.ts +1 -5
- package/dist/commands/utils.js +1 -7
- package/dist/lib/agent-spec/agents.d.ts +0 -2
- package/dist/lib/agent-spec/agents.js +0 -12
- package/dist/lib/agent-spec/index.d.ts +0 -4
- package/dist/lib/agent-spec/index.js +0 -4
- package/dist/lib/commands.d.ts +1 -5
- package/dist/lib/commands.js +2 -69
- package/dist/lib/comms-render.d.ts +0 -7
- package/dist/lib/comms-render.js +0 -41
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +8 -0
- package/dist/lib/daemon/daemon.js +1 -6
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +0 -5
- package/dist/lib/device-config.d.ts +2 -0
- package/dist/lib/device-config.js +81 -8
- package/dist/lib/devices/doctor-findings.d.ts +6 -1
- package/dist/lib/devices/doctor-findings.js +34 -1
- package/dist/lib/git.d.ts +1 -0
- package/dist/lib/git.js +5 -0
- package/dist/lib/hooks/install.d.ts +0 -7
- package/dist/lib/hooks/install.js +0 -55
- package/dist/lib/hosts/passthrough.js +2 -4
- package/dist/lib/hosts/progress.js +2 -2
- package/dist/lib/hosts/remote-cmd.js +0 -1
- package/dist/lib/installations/migrate.d.ts +1 -0
- package/dist/lib/installations/migrate.js +18 -1
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/loop.js +1 -1
- package/dist/lib/mailbox-target.d.ts +0 -31
- package/dist/lib/mailbox-target.js +0 -37
- package/dist/lib/mcp-lookup.d.ts +7 -0
- package/dist/lib/mcp-lookup.js +71 -0
- package/dist/lib/mcp.d.ts +0 -8
- package/dist/lib/mcp.js +0 -47
- package/dist/lib/menubar/install-menubar.d.ts +0 -15
- package/dist/lib/menubar/install-menubar.js +24 -118
- package/dist/lib/menubar/resolve-version.d.ts +9 -10
- package/dist/lib/menubar/resolve-version.js +70 -30
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -18
- package/dist/lib/plugins/skills.d.ts +0 -10
- package/dist/lib/plugins/skills.js +2 -165
- package/dist/lib/project-pull.js +1 -2
- package/dist/lib/resources.d.ts +1 -1
- package/dist/lib/routines-project.js +1 -1
- package/dist/lib/session/local-tmux-attach.js +2 -2
- package/dist/lib/startup/command-registry.js +20 -7
- package/dist/lib/teams/agents.js +1 -1
- package/dist/lib/triggers/webhook.d.ts +2 -59
- package/dist/lib/triggers/webhook.js +2 -422
- package/package.json +2 -1
- package/dist/commands/funnel.d.ts +0 -2
- package/dist/commands/funnel.js +0 -77
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/mailboxes.d.ts +0 -2
- package/dist/commands/mailboxes.js +0 -400
- package/dist/commands/message.d.ts +0 -2
- package/dist/commands/message.js +0 -259
- package/dist/commands/packages-materialize.d.ts +0 -6
- package/dist/commands/packages-materialize.js +0 -90
- package/dist/commands/packages.d.ts +0 -5
- package/dist/commands/packages.js +0 -763
- package/dist/commands/route.d.ts +0 -2
- package/dist/commands/route.js +0 -259
- package/dist/commands/testdata/feed-hub.d.ts +0 -1
- package/dist/commands/testdata/feed-hub.js +0 -11
- package/dist/commands/tmux.d.ts +0 -7
- package/dist/commands/tmux.js +0 -529
- package/dist/commands/traces.d.ts +0 -2
- package/dist/commands/traces.js +0 -204
- package/dist/commands/webhook.d.ts +0 -5
- package/dist/commands/webhook.js +0 -105
- package/dist/lib/agent-spec/materialize.d.ts +0 -3
- package/dist/lib/agent-spec/materialize.js +0 -277
- package/dist/lib/agent-spec/package-resolve.d.ts +0 -4
- package/dist/lib/agent-spec/package-resolve.js +0 -231
- package/dist/lib/agent-spec/package-schema.d.ts +0 -3
- package/dist/lib/agent-spec/package-schema.js +0 -136
- package/dist/lib/agent-spec/package-types.d.ts +0 -94
- package/dist/lib/agent-spec/package-types.js +0 -10
- package/dist/lib/daemon/testdata/process-view-daemon.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-daemon.js +0 -12
- package/dist/lib/daemon/testdata/process-view-start.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-start.js +0 -41
- package/dist/lib/daemon/webhook-receiver-service.d.ts +0 -8
- package/dist/lib/daemon/webhook-receiver-service.js +0 -16
- package/dist/lib/daemon-webhooks.d.ts +0 -48
- package/dist/lib/daemon-webhooks.js +0 -177
- package/dist/lib/funnel.d.ts +0 -6
- package/dist/lib/funnel.js +0 -31
- package/dist/lib/net-close.d.ts +0 -2
- package/dist/lib/net-close.js +0 -20
- package/dist/lib/packages/output-home.d.ts +0 -9
- package/dist/lib/packages/output-home.js +0 -89
- package/dist/lib/registry.d.ts +0 -65
- package/dist/lib/registry.js +0 -432
- package/dist/lib/routers.d.ts +0 -25
- package/dist/lib/routers.js +0 -122
- package/dist/lib/run-trace-sync.d.ts +0 -7
- package/dist/lib/run-trace-sync.js +0 -35
- package/dist/lib/session/testdata/pid-registry-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/pid-registry-namespace.js +0 -25
- package/dist/lib/session/testdata/process-view-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-namespace.js +0 -56
- package/dist/lib/session/testdata/process-view-private.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-private.js +0 -11
- package/dist/lib/testdata/daemon-health-writer.d.ts +0 -1
- package/dist/lib/testdata/daemon-health-writer.js +0 -8
- package/dist/lib/testdata/owner-notify-api.d.ts +0 -23
- package/dist/lib/testdata/owner-notify-api.js +0 -82
- package/dist/lib/testdata/refresh-coordinator-worker.d.ts +0 -1
- package/dist/lib/testdata/refresh-coordinator-worker.js +0 -23
- package/dist/lib/traces/backend.d.ts +0 -8
- package/dist/lib/traces/backend.js +0 -33
- package/dist/lib/traces/classify.d.ts +0 -40
- package/dist/lib/traces/classify.js +0 -70
- package/dist/lib/traces/config.d.ts +0 -2
- package/dist/lib/traces/config.js +0 -2
- package/dist/lib/traces/insights.d.ts +0 -30
- package/dist/lib/traces/insights.js +0 -198
- package/dist/lib/traces/phenotype.d.ts +0 -18
- package/dist/lib/traces/phenotype.js +0 -335
- package/dist/lib/traces/provision.d.ts +0 -16
- package/dist/lib/traces/provision.js +0 -25
- package/dist/lib/traces/schema2-build.d.ts +0 -28
- package/dist/lib/traces/schema2-build.js +0 -496
- package/dist/lib/traces/schema2-danger.d.ts +0 -7
- package/dist/lib/traces/schema2-danger.js +0 -123
- package/dist/lib/traces/schema2.d.ts +0 -139
- package/dist/lib/traces/schema2.js +0 -20
- package/dist/lib/traces/segments.d.ts +0 -73
- package/dist/lib/traces/segments.js +0 -236
- package/dist/lib/traces/sync.d.ts +0 -197
- package/dist/lib/traces/sync.js +0 -654
- package/dist/lib/traces/worker-template.d.ts +0 -1
- package/dist/lib/traces/worker-template.js +0 -292
- package/dist/lib/triggers/handlers.d.ts +0 -66
- package/dist/lib/triggers/handlers.js +0 -383
|
@@ -17,6 +17,8 @@ const DEVICE_FORM_FACTORS = ['laptop', 'desktop', 'server', 'unknown'];
|
|
|
17
17
|
export const MENUBAR_TABS = ['home', 'goals', 'secrets', 'projects', 'linear', 'github', 'sessions', 'inbox'];
|
|
18
18
|
const MENUBAR_TABS_ADDED_LATER = ['goals', 'secrets', 'linear', 'github'];
|
|
19
19
|
export const MENUBAR_HOME_GOALS = ['company', 'week', 'myWeek', 'myDay'];
|
|
20
|
+
export const MENUBAR_HOME_SECTIONS = ['company', 'cycle', 'today', 'needs', 'prs', 'issues', 'sessions', 'artifacts', 'todos'];
|
|
21
|
+
export const MENUBAR_ARTIFACT_KINDS = ['image', 'html', 'markdown'];
|
|
20
22
|
export function resolveMenubarTabOrder(stored) {
|
|
21
23
|
const known = MENUBAR_TABS;
|
|
22
24
|
const tabs = [];
|
|
@@ -183,7 +185,7 @@ export const CONFIG_KEYS = [
|
|
|
183
185
|
defaultValue: true,
|
|
184
186
|
description: 'Whether the daemon may run on this device at all (browser IPC, watchdog, and the ' +
|
|
185
187
|
'routines scheduler). Disabling is the top-level kill switch: nothing auto-starts the daemon while it ' +
|
|
186
|
-
'is set, including `routines add`/`routines start`/`routines catchup
|
|
188
|
+
'is set, including `routines add`/`routines start`/`routines catchup`/`routines webhook`. ' +
|
|
187
189
|
'`agents daemon start` still starts it explicitly.',
|
|
188
190
|
},
|
|
189
191
|
{
|
|
@@ -205,7 +207,7 @@ export const CONFIG_KEYS = [
|
|
|
205
207
|
description: 'Whether an interactive `agents run` on this device is wrapped in the shared-socket tmux session — local runs and ' +
|
|
206
208
|
'followed `--device` runs alike (PHNX-3316). Off, the default, spawns the agent directly; a remote run left bare ' +
|
|
207
209
|
'is protected by reconnect-and-resume, not a pane. Turn it on to give every agent an addressable pane for ' +
|
|
208
|
-
'`agents
|
|
210
|
+
'`agents send --channel session`, injection, and `agents focus` once the tmux mouse, clipboard, and scrollback behavior suits this device.',
|
|
209
211
|
},
|
|
210
212
|
{
|
|
211
213
|
name: 'browser.remote-control',
|
|
@@ -453,9 +455,10 @@ export const CONFIG_KEYS = [
|
|
|
453
455
|
yamlKey: 'menubarMenuTicketSort',
|
|
454
456
|
scope: 'user',
|
|
455
457
|
type: 'string',
|
|
456
|
-
defaultValue: '
|
|
457
|
-
description: 'AGI Menu: how tickets within a project are ordered —
|
|
458
|
-
|
|
458
|
+
defaultValue: 'due',
|
|
459
|
+
description: 'AGI Menu: how tickets within a project are ordered — due (overdue first, then the soonest due, ' +
|
|
460
|
+
'undated by priority), priority, updated, newest, oldest, or title.',
|
|
461
|
+
validate: oneOf('menubar.menu.ticketSort', ['due', 'priority', 'updated', 'newest', 'oldest', 'title']),
|
|
459
462
|
},
|
|
460
463
|
{
|
|
461
464
|
name: 'menubar.menu.showPullRequests',
|
|
@@ -583,6 +586,16 @@ export const CONFIG_KEYS = [
|
|
|
583
586
|
},
|
|
584
587
|
normalize: (v) => (Array.isArray(v) ? resolveMenubarTabOrder(v.map(String)) : v),
|
|
585
588
|
},
|
|
589
|
+
{
|
|
590
|
+
name: 'menubar.enabled',
|
|
591
|
+
yamlKey: 'menubarEnabled',
|
|
592
|
+
scope: 'device',
|
|
593
|
+
visibility: 'machine',
|
|
594
|
+
type: 'bool',
|
|
595
|
+
defaultValue: true,
|
|
596
|
+
description: 'Whether AGI Menu runs on this Mac. Set false and the next agents command removes its login item; ' +
|
|
597
|
+
'set true and the next agents command installs it again.',
|
|
598
|
+
},
|
|
586
599
|
{
|
|
587
600
|
name: 'menubar.autoUpdate',
|
|
588
601
|
yamlKey: 'menubarAutoUpdate',
|
|
@@ -658,9 +671,10 @@ export const CONFIG_KEYS = [
|
|
|
658
671
|
scope: 'user',
|
|
659
672
|
type: 'string',
|
|
660
673
|
defaultValue: 'none',
|
|
661
|
-
description: 'AGI Menu: how the
|
|
662
|
-
'
|
|
663
|
-
|
|
674
|
+
description: 'AGI Menu: how the Home and Linear tabs group each project\'s tickets — none, status, due (Overdue, ' +
|
|
675
|
+
'Due today, Due this week, Due later, No due date), assignee, delegate, milestone, or priority. ' +
|
|
676
|
+
'Replaces groupTicketsByMilestone for menus that know it.',
|
|
677
|
+
validate: oneOf('menubar.menu.ticketGroup', ['none', 'status', 'due', 'assignee', 'delegate', 'milestone', 'priority']),
|
|
664
678
|
},
|
|
665
679
|
{
|
|
666
680
|
name: 'menubar.menu.prGroupOpen',
|
|
@@ -699,6 +713,65 @@ export const CONFIG_KEYS = [
|
|
|
699
713
|
return dup === undefined ? null : `menubar.menu.homeGoals lists "${dup}" twice.`;
|
|
700
714
|
},
|
|
701
715
|
},
|
|
716
|
+
{
|
|
717
|
+
name: 'menubar.menu.homeSections',
|
|
718
|
+
yamlKey: 'menubarMenuHomeSections',
|
|
719
|
+
scope: 'user',
|
|
720
|
+
type: 'string-list',
|
|
721
|
+
defaultValue: [...MENUBAR_HOME_SECTIONS],
|
|
722
|
+
description: `AGI Menu: Home's sections in order — each of ${MENUBAR_HOME_SECTIONS.join(', ')} at most once, ` +
|
|
723
|
+
'a leading "-" hiding one (-today). A section the list leaves out keeps its default place.',
|
|
724
|
+
validate: (v) => {
|
|
725
|
+
const ids = v.map((s) => (s.startsWith('-') ? s.slice(1) : s));
|
|
726
|
+
const bad = ids.find((id) => !MENUBAR_HOME_SECTIONS.includes(id));
|
|
727
|
+
if (bad !== undefined)
|
|
728
|
+
return `menubar.menu.homeSections: "${bad}" is not one of ${MENUBAR_HOME_SECTIONS.join(', ')}.`;
|
|
729
|
+
const dup = ids.find((id, i) => ids.indexOf(id) !== i);
|
|
730
|
+
return dup === undefined ? null : `menubar.menu.homeSections lists "${dup}" twice.`;
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: 'menubar.menu.sessionFilter',
|
|
735
|
+
yamlKey: 'menubarMenuSessionFilter',
|
|
736
|
+
scope: 'user',
|
|
737
|
+
type: 'string',
|
|
738
|
+
defaultValue: 'show=working,needs,idle;which=tab;sort=updated;group=status',
|
|
739
|
+
description: 'AGI Menu: the one filter Home\'s Open sessions and the Sessions tab share — ' +
|
|
740
|
+
'`show=<statuses>;which=<kinds>;sort=<updated|newest|idle|idletime|longest>;group=<status|app|project|device|none>`.',
|
|
741
|
+
validate: (v) => {
|
|
742
|
+
const allowed = {
|
|
743
|
+
show: null, which: null,
|
|
744
|
+
sort: ['updated', 'newest', 'idle', 'idletime', 'longest'],
|
|
745
|
+
group: ['status', 'app', 'project', 'device', 'none'],
|
|
746
|
+
};
|
|
747
|
+
for (const part of String(v).split(';').filter((p) => p.trim())) {
|
|
748
|
+
const [name, value = ''] = part.split('=').map((s) => s.trim());
|
|
749
|
+
if (!(name in allowed))
|
|
750
|
+
return `menubar.menu.sessionFilter: "${name}" is not one of show, which, sort, group.`;
|
|
751
|
+
const values = allowed[name];
|
|
752
|
+
if (values && !values.includes(value))
|
|
753
|
+
return `menubar.menu.sessionFilter: ${name}="${value}" is not one of ${values.join(', ')}.`;
|
|
754
|
+
}
|
|
755
|
+
return null;
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
name: 'menubar.menu.artifactApps',
|
|
760
|
+
yamlKey: 'menubarMenuArtifactApps',
|
|
761
|
+
scope: 'user',
|
|
762
|
+
type: 'string-list',
|
|
763
|
+
defaultValue: [],
|
|
764
|
+
description: `AGI Menu: the app each artifact kind opens with, as <kind>=<bundle id> (${MENUBAR_ARTIFACT_KINDS.join(', ')}); ` +
|
|
765
|
+
'a kind not listed opens with the Mac\'s default app.',
|
|
766
|
+
validate: (v) => {
|
|
767
|
+
const entries = v;
|
|
768
|
+
const bad = entries.find((e) => {
|
|
769
|
+
const [kind, id] = e.split('=');
|
|
770
|
+
return !MENUBAR_ARTIFACT_KINDS.includes(kind) || !id;
|
|
771
|
+
});
|
|
772
|
+
return bad === undefined ? null : `menubar.menu.artifactApps: "${bad}" is not <kind>=<bundle id> for ${MENUBAR_ARTIFACT_KINDS.join(', ')}.`;
|
|
773
|
+
},
|
|
774
|
+
},
|
|
702
775
|
{
|
|
703
776
|
name: 'menubar.statusbar.goalCountdown',
|
|
704
777
|
yamlKey: 'menubarStatusbarGoalCountdown',
|
|
@@ -2,6 +2,7 @@ import type { AgentId } from '../types.js';
|
|
|
2
2
|
import type { DuplicateVersionHook } from '../hooks/install.js';
|
|
3
3
|
import type { AgentsBinaryShadow } from '../binary-shadow.js';
|
|
4
4
|
import type { LeakedDaemon } from '../daemon/leaked-daemons.js';
|
|
5
|
+
import type { MenubarDoctorReport, MenubarStatus } from '../menubar/install-menubar.js';
|
|
5
6
|
import type { RcSecretFinding } from '../secrets-types.js';
|
|
6
7
|
import { type WindowsSshEnrollmentAudit } from './windows-ssh-enrollment.js';
|
|
7
8
|
import type { SyncStatusRow, OrphanRow } from '../drift.js';
|
|
@@ -9,7 +10,7 @@ import type { FetchStatusMarker } from '../auto-pull.js';
|
|
|
9
10
|
import { type VersionResourceReport } from '../doctor-diff.js';
|
|
10
11
|
import type { FleetDivergence, FleetHookRuntimeState, FleetVersionSignIn } from './fleet-divergence.js';
|
|
11
12
|
export type FindingSeverity = 'critical' | 'warning';
|
|
12
|
-
export declare const ALL_FINDING_KINDS: readonly ["logged-out", "logout-unprovable", "missing-hook", "missing-plugin", "unwired-hook", "hook-runtime-broken", "hook-runtime-visibility-unavailable", "cli-missing", "missing-resource", "content-drift", "never-synced", "stale", "repo-behind", "repo-drift", "fleet-resource-gap", "host-cli-missing", "host-cli-invalid", "version-skew", "orphan", "duplicate-hook", "duplicate-hook-drift", "rc-secret-export", "env-secret-export", "auth-bundle-wrong-backend", "exec-policy", "ssh-key-enrollment", "stale-cli", "binary-shadow", "owner-not-signed-in", "leaked-daemon"];
|
|
13
|
+
export declare const ALL_FINDING_KINDS: readonly ["logged-out", "logout-unprovable", "missing-hook", "missing-plugin", "unwired-hook", "hook-runtime-broken", "hook-runtime-visibility-unavailable", "cli-missing", "missing-resource", "content-drift", "never-synced", "stale", "repo-behind", "repo-drift", "fleet-resource-gap", "host-cli-missing", "host-cli-invalid", "version-skew", "orphan", "duplicate-hook", "duplicate-hook-drift", "rc-secret-export", "env-secret-export", "auth-bundle-wrong-backend", "exec-policy", "ssh-key-enrollment", "stale-cli", "binary-shadow", "owner-not-signed-in", "leaked-daemon", "menubar"];
|
|
13
14
|
export declare const FINDING_SEVERITY: Record<FindingKind, FindingSeverity>;
|
|
14
15
|
export type FindingKind = typeof ALL_FINDING_KINDS[number];
|
|
15
16
|
export interface DoctorFinding {
|
|
@@ -55,6 +56,10 @@ export interface LocalFindingInputs {
|
|
|
55
56
|
ownerSignedIn?: boolean;
|
|
56
57
|
binaryShadows?: AgentsBinaryShadow[];
|
|
57
58
|
leakedDaemons?: LeakedDaemon[];
|
|
59
|
+
menubar?: {
|
|
60
|
+
status: Pick<MenubarStatus, 'disabledByUser' | 'stale' | 'installedVersion' | 'currentVersion' | 'instances' | 'foreignInstances'>;
|
|
61
|
+
report: Pick<MenubarDoctorReport, 'signingIdentity' | 'staleRunningProcess' | 'accessibilityHintNeeded'>;
|
|
62
|
+
};
|
|
58
63
|
}
|
|
59
64
|
export declare function buildLocalFindings(input: LocalFindingInputs): DoctorFinding[];
|
|
60
65
|
/**
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* fleet-resource-gap · hook-runtime-visibility-unavailable · orphan · duplicate-hook ·
|
|
28
28
|
* duplicate-hook-drift · host-cli-missing · host-cli-invalid ·
|
|
29
29
|
* rc-secret-export · env-secret-export · auth-bundle-wrong-backend · exec-policy · stale-cli ·
|
|
30
|
-
* binary-shadow · leaked-daemon.
|
|
30
|
+
* binary-shadow · leaked-daemon · menubar.
|
|
31
31
|
* (RUSH-2162 moved never-synced and duplicate-hook-drift to WARNING: both are
|
|
32
32
|
* stale-sync states one `agents sync` resolves, not "needs you now".)
|
|
33
33
|
*
|
|
@@ -99,6 +99,7 @@ export const ALL_FINDING_KINDS = [
|
|
|
99
99
|
'binary-shadow',
|
|
100
100
|
'owner-not-signed-in',
|
|
101
101
|
'leaked-daemon',
|
|
102
|
+
'menubar',
|
|
102
103
|
];
|
|
103
104
|
export const FINDING_SEVERITY = {
|
|
104
105
|
'logged-out': 'critical',
|
|
@@ -131,6 +132,7 @@ export const FINDING_SEVERITY = {
|
|
|
131
132
|
'stale-cli': 'warning',
|
|
132
133
|
'binary-shadow': 'warning',
|
|
133
134
|
'leaked-daemon': 'warning',
|
|
135
|
+
'menubar': 'warning',
|
|
134
136
|
};
|
|
135
137
|
function agentName(agent) {
|
|
136
138
|
return AGENT_NAMES[agent] || agent;
|
|
@@ -216,6 +218,8 @@ export function remediationFor(finding) {
|
|
|
216
218
|
return 'remove or repoint the shadowing agents install(s)';
|
|
217
219
|
case 'leaked-daemon':
|
|
218
220
|
return 'kill <pid>';
|
|
221
|
+
case 'menubar':
|
|
222
|
+
return 'agents menubar restart';
|
|
219
223
|
case 'owner-not-signed-in':
|
|
220
224
|
return 'agents auth login';
|
|
221
225
|
}
|
|
@@ -419,8 +423,37 @@ export function buildLocalFindings(input) {
|
|
|
419
423
|
remediation: `kill ${d.pid}`,
|
|
420
424
|
});
|
|
421
425
|
}
|
|
426
|
+
if (input.menubar)
|
|
427
|
+
out.push(...menubarFindings(device, input.menubar));
|
|
422
428
|
return collapseAcrossVersions(out, new Set(input.isolatedVersions ?? []));
|
|
423
429
|
}
|
|
430
|
+
function menubarFindings(device, { status, report }) {
|
|
431
|
+
if (status.disabledByUser)
|
|
432
|
+
return [];
|
|
433
|
+
const out = [];
|
|
434
|
+
const add = (message, remediation) => out.push({ severity: FINDING_SEVERITY.menubar, kind: 'menubar', device, message, remediation });
|
|
435
|
+
const pids = (ps) => ps.map((p) => p.pid).join(' ');
|
|
436
|
+
if (status.instances.length > 1) {
|
|
437
|
+
add(`${status.instances.length} copies of AGI Menu are running (duplicate menu-bar icon)`, `kill ${pids(status.instances.slice(1))}`);
|
|
438
|
+
}
|
|
439
|
+
if (status.foreignInstances.length > 0) {
|
|
440
|
+
add(`AGI Menu process outside the install may hold Cmd-Shift-V/O (pid ${pids(status.foreignInstances)})`, `kill ${pids(status.foreignInstances)}`);
|
|
441
|
+
}
|
|
442
|
+
if (status.stale) {
|
|
443
|
+
add(`AGI Menu ${status.installedVersion ?? 'unknown'} is older than ${status.currentVersion}`, 'agents menubar update');
|
|
444
|
+
}
|
|
445
|
+
if (report.signingIdentity === 'ad-hoc') {
|
|
446
|
+
add('AGI Menu is ad-hoc signed; its Accessibility grant breaks on every update', 'agents menubar update');
|
|
447
|
+
}
|
|
448
|
+
const replaced = report.staleRunningProcess.filter((p) => p.stale);
|
|
449
|
+
if (replaced.length > 0) {
|
|
450
|
+
add(`AGI Menu pid ${pids(replaced)} still runs the binary an update replaced`, 'agents menubar restart');
|
|
451
|
+
}
|
|
452
|
+
if (report.accessibilityHintNeeded) {
|
|
453
|
+
add('AGI Menu Accessibility grant may not be trusted for the current binary', 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"');
|
|
454
|
+
}
|
|
455
|
+
return out;
|
|
456
|
+
}
|
|
424
457
|
function orphanFinding(device, rows) {
|
|
425
458
|
const affected = rows.filter((r) => r.commands + r.skills + r.hooks > 0);
|
|
426
459
|
if (affected.length === 0)
|
package/dist/lib/git.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare function resolveSnapshotSha(repoRoot: string): string | undefined
|
|
|
24
24
|
export declare function _resetSnapshotShaCacheForTest(): void;
|
|
25
25
|
export declare function getRemoteUrl(repoPath: string): Promise<string | null>;
|
|
26
26
|
export declare function canonicalGitRemote(url: string): string;
|
|
27
|
+
export declare function parseOwnerRepoFromRemote(remoteUrl: string): string | null;
|
|
27
28
|
export declare function isSystemRepoRemote(remote: string | null | undefined): boolean;
|
|
28
29
|
export declare function isExpectedSystemRepoRemote(remote: string | null | undefined): boolean;
|
|
29
30
|
export declare function sameGitRemote(a: string | null | undefined, b: string | null | undefined): boolean;
|
package/dist/lib/git.js
CHANGED
|
@@ -288,6 +288,11 @@ export function canonicalGitRemote(url) {
|
|
|
288
288
|
const RENAMED_REMOTE_ALIASES = {
|
|
289
289
|
'github.com/phnx-labs/.agents': 'github.com/phnx-labs/.agents-system',
|
|
290
290
|
};
|
|
291
|
+
export function parseOwnerRepoFromRemote(remoteUrl) {
|
|
292
|
+
const s = remoteUrl.trim().replace(/\\/g, '/').replace(/\.git$/, '');
|
|
293
|
+
const m = s.match(/github\.com[/:]([^/]+\/[^/]+)$/);
|
|
294
|
+
return m ? m[1] : null;
|
|
295
|
+
}
|
|
291
296
|
export function isSystemRepoRemote(remote) {
|
|
292
297
|
if (!remote)
|
|
293
298
|
return false;
|
|
@@ -27,12 +27,6 @@ export declare function getHooksDirInHome(agentId: AgentId, home: string): strin
|
|
|
27
27
|
export declare function listInstalledHooksWithScope(agentId: AgentId, cwd?: string, options?: {
|
|
28
28
|
home?: string;
|
|
29
29
|
}): InstalledHook[];
|
|
30
|
-
export declare function installHooks(source: string, agents: AgentId[], options?: {
|
|
31
|
-
scope?: 'user' | 'project';
|
|
32
|
-
}): Promise<{
|
|
33
|
-
installed: string[];
|
|
34
|
-
errors: string[];
|
|
35
|
-
}>;
|
|
36
30
|
export declare function getVersionHooksDir(agent: AgentId, version: string): string;
|
|
37
31
|
export declare function listHooksInVersionHome(agent: AgentId, version: string): HookEntry[];
|
|
38
32
|
export interface HookWiringIssue {
|
|
@@ -147,7 +141,6 @@ export declare function registerHooksToSettings(agentId: AgentId, versionHome: s
|
|
|
147
141
|
registered: string[];
|
|
148
142
|
errors: string[];
|
|
149
143
|
};
|
|
150
|
-
export declare function hookRegistrationTargets(agentId: AgentId, home: string): string[];
|
|
151
144
|
export declare function pruneVersionHomeHookEntriesFromSettings(settingsPath: string, agent: AgentId, removedVersion: string): number;
|
|
152
145
|
interface InstallSessionTrackerHookResult {
|
|
153
146
|
installed: boolean;
|
|
@@ -473,33 +473,6 @@ export function listInstalledHooksWithScope(agentId, cwd = process.cwd(), option
|
|
|
473
473
|
}
|
|
474
474
|
return results;
|
|
475
475
|
}
|
|
476
|
-
export async function installHooks(source, agents, options = {}) {
|
|
477
|
-
const installed = [];
|
|
478
|
-
const errors = [];
|
|
479
|
-
const scope = options.scope || 'user';
|
|
480
|
-
const cwd = process.cwd();
|
|
481
|
-
const hooksDir = path.join(source, 'hooks');
|
|
482
|
-
const hooks = listHookEntriesFromDir(hooksDir);
|
|
483
|
-
const uniqueAgents = Array.from(new Set(agents));
|
|
484
|
-
for (const agentId of uniqueAgents) {
|
|
485
|
-
const agent = AGENTS[agentId];
|
|
486
|
-
if (!agent || !agent.supportsHooks) {
|
|
487
|
-
errors.push(`${agentId}:Agent does not support hooks`);
|
|
488
|
-
continue;
|
|
489
|
-
}
|
|
490
|
-
const targetDir = scope === 'project' ? getProjectHooksDirs(agentId, cwd)[0] : getHooksDir(agentId);
|
|
491
|
-
for (const entry of hooks) {
|
|
492
|
-
try {
|
|
493
|
-
copyHook(entry, targetDir);
|
|
494
|
-
installed.push(`${entry.name}:${agentId}`);
|
|
495
|
-
}
|
|
496
|
-
catch (err) {
|
|
497
|
-
errors.push(`${entry.name}:${agentId}:${err.message}`);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return { installed, errors };
|
|
502
|
-
}
|
|
503
476
|
export function getVersionHooksDir(agent, version) {
|
|
504
477
|
return getHooksDirInHome(agent, getVersionHomePath(agent, version));
|
|
505
478
|
}
|
|
@@ -1295,34 +1268,6 @@ export function registerHooksToSettings(agentId, versionHome, hookManifest, agen
|
|
|
1295
1268
|
}
|
|
1296
1269
|
return { registered: [], errors: [] };
|
|
1297
1270
|
}
|
|
1298
|
-
export function hookRegistrationTargets(agentId, home) {
|
|
1299
|
-
switch (agentId) {
|
|
1300
|
-
case 'claude':
|
|
1301
|
-
case 'droid':
|
|
1302
|
-
case 'muse':
|
|
1303
|
-
return [path.join(home, agentConfigDirName(agentId), 'settings.json')];
|
|
1304
|
-
case 'codex':
|
|
1305
|
-
return [path.join(home, '.codex', 'hooks.json'), path.join(home, '.codex', 'config.toml')];
|
|
1306
|
-
case 'antigravity':
|
|
1307
|
-
return [path.join(home, '.gemini', 'antigravity-cli', 'settings.json')];
|
|
1308
|
-
case 'grok':
|
|
1309
|
-
return [path.join(home, '.grok', 'hooks', 'hooks.json')];
|
|
1310
|
-
case 'kimi':
|
|
1311
|
-
return [path.join(home, '.kimi-code', 'config.toml')];
|
|
1312
|
-
case 'copilot':
|
|
1313
|
-
return [path.join(home, '.copilot', 'hooks', COPILOT_MANAGED_HOOKS_FILE)];
|
|
1314
|
-
case 'goose':
|
|
1315
|
-
return [path.join(home, '.agents', 'plugins', GOOSE_MANAGED_PLUGIN_NAME, 'hooks', 'hooks.json')];
|
|
1316
|
-
case 'cursor':
|
|
1317
|
-
return [path.join(home, '.cursor', 'hooks.json')];
|
|
1318
|
-
case 'hermes':
|
|
1319
|
-
return [path.join(home, '.hermes', 'config.yaml')];
|
|
1320
|
-
case 'opencode':
|
|
1321
|
-
return [path.join(home, '.config', 'opencode', 'plugins', 'agents-cli-hooks.ts')];
|
|
1322
|
-
default:
|
|
1323
|
-
return [];
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
1271
|
const OPENCODE_DIRECT_EVENT_MAP = {
|
|
1327
1272
|
PreToolUse: 'tool.execute.before',
|
|
1328
1273
|
PostToolUse: 'tool.execute.after',
|
|
@@ -51,18 +51,15 @@ export const REMOTE_PASSTHROUGH = {
|
|
|
51
51
|
defaults: {},
|
|
52
52
|
update: {},
|
|
53
53
|
teams: {},
|
|
54
|
-
message: {},
|
|
55
54
|
send: {},
|
|
56
55
|
routines: {},
|
|
57
56
|
jobs: {},
|
|
58
57
|
cron: {},
|
|
59
58
|
prune: {},
|
|
60
|
-
trash: {},
|
|
61
59
|
restore: {},
|
|
62
60
|
worktree: {},
|
|
63
61
|
events: {},
|
|
64
62
|
feedback: {},
|
|
65
|
-
tmux: {},
|
|
66
63
|
watchdog: {},
|
|
67
64
|
factory: {},
|
|
68
65
|
};
|
|
@@ -78,7 +75,6 @@ export const OWN_HOST_COMMANDS = new Set([
|
|
|
78
75
|
'browser',
|
|
79
76
|
'secrets',
|
|
80
77
|
'accounts',
|
|
81
|
-
'logs',
|
|
82
78
|
'hosts',
|
|
83
79
|
'ssh',
|
|
84
80
|
'devices',
|
|
@@ -345,6 +341,8 @@ export async function maybeRunOnHost(command, allArgs, opts) {
|
|
|
345
341
|
return false;
|
|
346
342
|
if (command === 'daemon' && firstSubcommand(allArgs, 'daemon') === 'index')
|
|
347
343
|
return false;
|
|
344
|
+
if (command === 'events' && firstSubcommand(allArgs, 'events') === 'logs')
|
|
345
|
+
return false;
|
|
348
346
|
if (command === 'teams') {
|
|
349
347
|
const teamsIdx = allArgs.indexOf('teams');
|
|
350
348
|
const sub = teamsIdx >= 0 ? allArgs.slice(teamsIdx + 1).find((a) => !a.startsWith('-')) : undefined;
|
|
@@ -138,7 +138,7 @@ export async function followHostTask(target, opts) {
|
|
|
138
138
|
for (;;) {
|
|
139
139
|
const remaining = deadline - Date.now();
|
|
140
140
|
if (remaining <= 0) {
|
|
141
|
-
process.stderr.write('\n[hosts] follow timed out; the run continues on the host. Reattach with: agents logs ' + opts.taskId + ' -f\n');
|
|
141
|
+
process.stderr.write('\n[hosts] follow timed out; the run continues on the host. Reattach with: agents events logs ' + opts.taskId + ' -f\n');
|
|
142
142
|
return -1;
|
|
143
143
|
}
|
|
144
144
|
const abort = new AbortController();
|
|
@@ -163,7 +163,7 @@ export async function followHostTask(target, opts) {
|
|
|
163
163
|
return Number.isFinite(code) ? code : 0;
|
|
164
164
|
}
|
|
165
165
|
if (Date.now() > deadline) {
|
|
166
|
-
process.stderr.write('\n[hosts] follow timed out; the run continues on the host. Reattach with: agents logs ' + opts.taskId + ' -f\n');
|
|
166
|
+
process.stderr.write('\n[hosts] follow timed out; the run continues on the host. Reattach with: agents events logs ' + opts.taskId + ' -f\n');
|
|
167
167
|
return -1;
|
|
168
168
|
}
|
|
169
169
|
waitMs = gotOutput ? fastMs : Math.min(maxMs, Math.round(waitMs * 1.5));
|
|
@@ -9,6 +9,7 @@ export declare function migrateExtrasExtrasToAgentsExtras(historyDir?: string):
|
|
|
9
9
|
export declare function migrateRoutineDeviceToDevices(routinesDir?: string): void;
|
|
10
10
|
export declare function migrateRoutineRemoteCwdToCwd(routinesDir?: string): void;
|
|
11
11
|
export declare function migrateWatchdogSentinelToConfig(sentinelPath?: string, enable?: (value: boolean) => void): void;
|
|
12
|
+
export declare function migrateMenubarSentinelToConfig(sentinelPath?: string, disable?: () => void): void;
|
|
12
13
|
export declare function migrateCliDirToClis(agentsDirs: string[]): void;
|
|
13
14
|
export declare const LEGACY_HUMANS_FILE = "humans.yaml";
|
|
14
15
|
export declare function humansToPreferencesPatch(doc: unknown): {
|
|
@@ -1178,7 +1178,7 @@ function containsOnlyDsStore(dir) {
|
|
|
1178
1178
|
}
|
|
1179
1179
|
function warnSystemOrphans() {
|
|
1180
1180
|
const SHIPPED_ALLOWLIST = new Set([
|
|
1181
|
-
'commands', 'hooks', 'skills', 'rules', 'mcp', 'clis', 'permissions', 'subagents', 'profiles', 'agents', 'routines',
|
|
1181
|
+
'commands', 'hooks', 'skills', 'rules', 'mcp', 'clis', 'permissions', 'subagents', 'profiles', 'agents', 'routines',
|
|
1182
1182
|
'agents.yaml', 'hooks.yaml', 'README.md', 'CHANGELOG.md',
|
|
1183
1183
|
'.git', '.githooks', '.gitignore', '.assets', '.environment', '.plans',
|
|
1184
1184
|
'.DS_Store', '.claude',
|
|
@@ -1594,6 +1594,22 @@ export function migrateWatchdogSentinelToConfig(sentinelPath = path.join(CACHE_D
|
|
|
1594
1594
|
catch { }
|
|
1595
1595
|
console.error('Migrated watchdog: legacy enable sentinel → watchdog.enabled config (kept enabled)');
|
|
1596
1596
|
}
|
|
1597
|
+
export function migrateMenubarSentinelToConfig(sentinelPath = path.join(CACHE_DIR, 'state', 'menubar.disabled'), disable = () => setConfigValue('menubar.enabled', false)) {
|
|
1598
|
+
if (!fs.existsSync(sentinelPath))
|
|
1599
|
+
return;
|
|
1600
|
+
try {
|
|
1601
|
+
disable();
|
|
1602
|
+
}
|
|
1603
|
+
catch (err) {
|
|
1604
|
+
console.error(`menubar sentinel migration: could not set menubar.enabled (${err.message}); leaving the sentinel for a later retry`);
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
try {
|
|
1608
|
+
fs.rmSync(sentinelPath);
|
|
1609
|
+
}
|
|
1610
|
+
catch { }
|
|
1611
|
+
console.error('Migrated AGI Menu: legacy disabled sentinel → menubar.enabled=false');
|
|
1612
|
+
}
|
|
1597
1613
|
export function migrateCliDirToClis(agentsDirs) {
|
|
1598
1614
|
for (const agentsDir of agentsDirs) {
|
|
1599
1615
|
const src = path.join(agentsDir, 'cli');
|
|
@@ -1906,6 +1922,7 @@ export async function runMigration() {
|
|
|
1906
1922
|
migrateRoutineRemoteCwdToCwd();
|
|
1907
1923
|
migrateLegacyRoutineActivation();
|
|
1908
1924
|
migrateWatchdogSentinelToConfig();
|
|
1925
|
+
migrateMenubarSentinelToConfig();
|
|
1909
1926
|
removeHomeCompiledProjectRules();
|
|
1910
1927
|
pauseUnreadyEnabledRoutines();
|
|
1911
1928
|
repairAgentConfigSymlinks();
|
|
@@ -1302,10 +1302,10 @@ export function printTrashFooter(moved) {
|
|
|
1302
1302
|
console.log(chalk.gray('Sessions remain accessible via `agents sessions`.'));
|
|
1303
1303
|
if (moved.length === 1) {
|
|
1304
1304
|
const { agent, version } = moved[0];
|
|
1305
|
-
console.log(chalk.gray(`Restore with: agents trash restore ${agent}@${version}`));
|
|
1305
|
+
console.log(chalk.gray(`Restore with: agents prune trash restore ${agent}@${version}`));
|
|
1306
1306
|
}
|
|
1307
1307
|
else {
|
|
1308
|
-
console.log(chalk.gray('Restore with: agents trash restore <agent>@<version> (run `agents trash list` to see)'));
|
|
1308
|
+
console.log(chalk.gray('Restore with: agents prune trash restore <agent>@<version> (run `agents prune trash list` to see)'));
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
1311
|
export function removeAllVersions(agent) {
|
package/dist/lib/loop.js
CHANGED
|
@@ -111,7 +111,7 @@ export async function runLoop(execOptions, loop, ctx, deps) {
|
|
|
111
111
|
process.stderr.write(`[loop] WARNING: cross-iteration conversation continuity applies to claude only. ` +
|
|
112
112
|
`Each ${ctx.agent} iteration runs as an independent fresh conversation (no /continue handoff).\n`);
|
|
113
113
|
}
|
|
114
|
-
process.stderr.write(`[loop] mailbox: agents
|
|
114
|
+
process.stderr.write(`[loop] mailbox: agents send --channel mailbox --to ${ctx.runId} --text "<text>"\n`);
|
|
115
115
|
let tokens = ctx.startTokens ?? 0;
|
|
116
116
|
let lastSignal;
|
|
117
117
|
let stopSignal = false;
|
|
@@ -1,33 +1,2 @@
|
|
|
1
1
|
import type { ActiveSession } from './session/active.js';
|
|
2
|
-
import type { HostTask } from './hosts/tasks.js';
|
|
3
|
-
type MessageResolution = {
|
|
4
|
-
kind: 'cloud';
|
|
5
|
-
id: string;
|
|
6
|
-
} | {
|
|
7
|
-
kind: 'local';
|
|
8
|
-
id: string;
|
|
9
|
-
} | {
|
|
10
|
-
kind: 'none';
|
|
11
|
-
} | {
|
|
12
|
-
kind: 'ambiguous';
|
|
13
|
-
candidates: Array<{
|
|
14
|
-
id: string;
|
|
15
|
-
label: string;
|
|
16
|
-
}>;
|
|
17
|
-
};
|
|
18
2
|
export declare function mailboxIdForActiveSession(s: ActiveSession): string | undefined;
|
|
19
|
-
export declare function resolveMessageTarget(target: string, sessions: ActiveSession[], isCloudTask: (id: string) => boolean): MessageResolution;
|
|
20
|
-
export type HostTaskRoute = {
|
|
21
|
-
kind: 'reroute';
|
|
22
|
-
remoteRef: string;
|
|
23
|
-
host: string;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'finished';
|
|
26
|
-
host: string;
|
|
27
|
-
status: string;
|
|
28
|
-
exitCode?: number;
|
|
29
|
-
} | {
|
|
30
|
-
kind: 'not-found';
|
|
31
|
-
};
|
|
32
|
-
export declare function decideHostTaskRoute(task: HostTask | null, target: string): HostTaskRoute;
|
|
33
|
-
export {};
|
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
import { sessionHeadline } from './session/title.js';
|
|
2
1
|
export function mailboxIdForActiveSession(s) {
|
|
3
2
|
return s.agentId ?? s.sessionId;
|
|
4
3
|
}
|
|
5
|
-
function labelFor(s) {
|
|
6
|
-
return sessionHeadline(s) ?? s.teamName ?? s.host ?? s.context;
|
|
7
|
-
}
|
|
8
|
-
export function resolveMessageTarget(target, sessions, isCloudTask) {
|
|
9
|
-
if (isCloudTask(target))
|
|
10
|
-
return { kind: 'cloud', id: target };
|
|
11
|
-
if (target.length === 0)
|
|
12
|
-
return { kind: 'none' };
|
|
13
|
-
const exact = sessions.filter((s) => s.sessionId === target || s.agentId === target);
|
|
14
|
-
const chosen = exact.length > 0
|
|
15
|
-
? exact
|
|
16
|
-
: sessions.filter((s) => Boolean(s.sessionId?.startsWith(target)) || Boolean(s.agentId?.startsWith(target)));
|
|
17
|
-
const byId = new Map();
|
|
18
|
-
for (const s of chosen) {
|
|
19
|
-
const id = mailboxIdForActiveSession(s);
|
|
20
|
-
if (id && !byId.has(id))
|
|
21
|
-
byId.set(id, s);
|
|
22
|
-
}
|
|
23
|
-
const ids = [...byId.keys()];
|
|
24
|
-
if (ids.length === 0)
|
|
25
|
-
return { kind: 'none' };
|
|
26
|
-
if (ids.length === 1)
|
|
27
|
-
return { kind: 'local', id: ids[0] };
|
|
28
|
-
return {
|
|
29
|
-
kind: 'ambiguous',
|
|
30
|
-
candidates: [...byId.entries()].map(([id, s]) => ({ id, label: labelFor(s) })),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function decideHostTaskRoute(task, target) {
|
|
34
|
-
if (!task)
|
|
35
|
-
return { kind: 'not-found' };
|
|
36
|
-
if (task.status === 'running') {
|
|
37
|
-
return { kind: 'reroute', remoteRef: task.sessionId ?? task.name ?? target, host: task.host };
|
|
38
|
-
}
|
|
39
|
-
return { kind: 'finished', host: task.host, status: task.status, exitCode: task.exitCode };
|
|
40
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpServerEntry } from './types.js';
|
|
2
|
+
export declare function mcpEntryToInstallSpec(entry: McpServerEntry): {
|
|
3
|
+
command?: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
transport: 'stdio' | 'http';
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function getMcpServerInfo(serverName: string): Promise<McpServerEntry | null>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DEFAULT_REGISTRIES } from './types.js';
|
|
2
|
+
import { readMeta } from './state.js';
|
|
3
|
+
function enabledMcpRegistries() {
|
|
4
|
+
const registries = { ...DEFAULT_REGISTRIES.mcp, ...readMeta().registries?.mcp };
|
|
5
|
+
return Object.entries(registries)
|
|
6
|
+
.filter(([, config]) => config.enabled)
|
|
7
|
+
.map(([name, config]) => ({ name, config }));
|
|
8
|
+
}
|
|
9
|
+
const REGISTRY_FETCH_TIMEOUT_MS = 8000;
|
|
10
|
+
async function fetchMcpRegistry(url, query, limit = 20, apiKey) {
|
|
11
|
+
const params = new URLSearchParams();
|
|
12
|
+
if (query)
|
|
13
|
+
params.set('search', query);
|
|
14
|
+
params.set('limit', String(limit));
|
|
15
|
+
const fullUrl = `${url}/servers?${params}`;
|
|
16
|
+
const headers = {
|
|
17
|
+
Accept: 'application/json',
|
|
18
|
+
};
|
|
19
|
+
if (apiKey) {
|
|
20
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(fullUrl, {
|
|
23
|
+
headers,
|
|
24
|
+
signal: AbortSignal.timeout(REGISTRY_FETCH_TIMEOUT_MS),
|
|
25
|
+
});
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`Registry request failed: ${response.status} ${response.statusText}`);
|
|
28
|
+
}
|
|
29
|
+
return response.json();
|
|
30
|
+
}
|
|
31
|
+
export function mcpEntryToInstallSpec(entry) {
|
|
32
|
+
const pkg = entry.packages?.[0];
|
|
33
|
+
if (!pkg)
|
|
34
|
+
return null;
|
|
35
|
+
if (pkg.transport === 'sse' || pkg.transport === 'streamable-http') {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const reg = pkg.registry_name?.toLowerCase();
|
|
39
|
+
const runtime = pkg.runtime;
|
|
40
|
+
const name = pkg.name;
|
|
41
|
+
if (!name)
|
|
42
|
+
return null;
|
|
43
|
+
if (reg === 'npm' || runtime === 'node') {
|
|
44
|
+
return { command: `npx -y ${name}`, transport: 'stdio' };
|
|
45
|
+
}
|
|
46
|
+
if (reg === 'pypi' || runtime === 'python') {
|
|
47
|
+
return { command: `uvx ${name}`, transport: 'stdio' };
|
|
48
|
+
}
|
|
49
|
+
if (runtime === 'docker') {
|
|
50
|
+
return { command: `docker run --rm -i ${name}`, transport: 'stdio' };
|
|
51
|
+
}
|
|
52
|
+
if (runtime === 'binary') {
|
|
53
|
+
return { command: name, transport: 'stdio' };
|
|
54
|
+
}
|
|
55
|
+
return { command: name, transport: 'stdio' };
|
|
56
|
+
}
|
|
57
|
+
export async function getMcpServerInfo(serverName) {
|
|
58
|
+
for (const { config } of enabledMcpRegistries()) {
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetchMcpRegistry(config.url, serverName, 10, config.apiKey);
|
|
61
|
+
const match = response.servers.find(({ server }) => server.name === serverName ||
|
|
62
|
+
server.name.endsWith(`/${serverName}`));
|
|
63
|
+
if (match) {
|
|
64
|
+
return match.server;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|