@phnx-labs/agents-cli 1.23.13 → 1.23.15
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 +47 -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/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/teams/placement-probe.d.ts +9 -0
- package/dist/lib/teams/placement-probe.js +20 -15
- 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
package/dist/lib/registry.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { createHash } from 'crypto';
|
|
4
|
-
import { DEFAULT_REGISTRIES, SEEDED_REGISTRIES } from './types.js';
|
|
5
|
-
import { readMeta, writeMeta } from './state.js';
|
|
6
|
-
import { discoverSkillsFromRepo } from './plugins/skills.js';
|
|
7
|
-
const UNSAFE_PACKAGE_SPEC_CHARS = /[;&|`$\s\x00-\x1f\x7f]/;
|
|
8
|
-
const NPM_SPEC_PATTERN = /^(@[a-z0-9][a-z0-9-_.]*\/)?[a-z0-9][a-z0-9-_.]*(@[A-Za-z0-9._+-]+)?$/;
|
|
9
|
-
const PYPI_SPEC_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*(\[[A-Za-z0-9,_-]+\])?(==[A-Za-z0-9._-]+)?$/;
|
|
10
|
-
export function validatedNpmSpec(spec) {
|
|
11
|
-
if (spec.length > 214 || UNSAFE_PACKAGE_SPEC_CHARS.test(spec) || !NPM_SPEC_PATTERN.test(spec)) {
|
|
12
|
-
throw new Error(`Invalid npm package spec: ${spec}`);
|
|
13
|
-
}
|
|
14
|
-
return spec;
|
|
15
|
-
}
|
|
16
|
-
export function validatedPyPISpec(spec) {
|
|
17
|
-
if (UNSAFE_PACKAGE_SPEC_CHARS.test(spec) || !PYPI_SPEC_PATTERN.test(spec)) {
|
|
18
|
-
throw new Error(`Invalid PyPI package spec: ${spec}`);
|
|
19
|
-
}
|
|
20
|
-
return spec;
|
|
21
|
-
}
|
|
22
|
-
function offeredSeeds(type, meta) {
|
|
23
|
-
const removed = new Set(meta.seededPresets || []);
|
|
24
|
-
const offered = {};
|
|
25
|
-
for (const [name, config] of Object.entries(SEEDED_REGISTRIES[type] || {})) {
|
|
26
|
-
if (!removed.has(`${type}.${name}`))
|
|
27
|
-
offered[name] = { ...config };
|
|
28
|
-
}
|
|
29
|
-
return offered;
|
|
30
|
-
}
|
|
31
|
-
export function getRegistries(type) {
|
|
32
|
-
const meta = readMeta();
|
|
33
|
-
const defaultRegs = DEFAULT_REGISTRIES[type] || {};
|
|
34
|
-
const userRegs = meta.registries?.[type] || {};
|
|
35
|
-
return { ...defaultRegs, ...offeredSeeds(type, meta), ...userRegs };
|
|
36
|
-
}
|
|
37
|
-
export function getEnabledRegistries(type) {
|
|
38
|
-
const registries = getRegistries(type);
|
|
39
|
-
return Object.entries(registries)
|
|
40
|
-
.filter(([, config]) => config.enabled)
|
|
41
|
-
.map(([name, config]) => ({ name, config }));
|
|
42
|
-
}
|
|
43
|
-
export function setRegistry(type, name, config) {
|
|
44
|
-
const meta = readMeta();
|
|
45
|
-
if (!meta.registries) {
|
|
46
|
-
meta.registries = { mcp: {}, skill: {} };
|
|
47
|
-
}
|
|
48
|
-
if (!meta.registries[type]) {
|
|
49
|
-
meta.registries[type] = {};
|
|
50
|
-
}
|
|
51
|
-
const existing = meta.registries[type][name]
|
|
52
|
-
|| DEFAULT_REGISTRIES[type]?.[name]
|
|
53
|
-
|| SEEDED_REGISTRIES[type]?.[name];
|
|
54
|
-
meta.registries[type][name] = { ...existing, ...config };
|
|
55
|
-
writeMeta(meta);
|
|
56
|
-
}
|
|
57
|
-
export function removeRegistry(type, name) {
|
|
58
|
-
const meta = readMeta();
|
|
59
|
-
const inUserConfig = !!meta.registries?.[type]?.[name];
|
|
60
|
-
const isOfferedSeed = !!offeredSeeds(type, meta)[name];
|
|
61
|
-
if (!inUserConfig && !isOfferedSeed)
|
|
62
|
-
return false;
|
|
63
|
-
if (inUserConfig)
|
|
64
|
-
delete meta.registries[type][name];
|
|
65
|
-
if (SEEDED_REGISTRIES[type]?.[name]) {
|
|
66
|
-
meta.seededPresets = [...new Set([...(meta.seededPresets || []), `${type}.${name}`])];
|
|
67
|
-
}
|
|
68
|
-
writeMeta(meta);
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
const REGISTRY_FETCH_TIMEOUT_MS = 8000;
|
|
72
|
-
async function fetchMcpRegistry(url, query, limit = 20, apiKey) {
|
|
73
|
-
const params = new URLSearchParams();
|
|
74
|
-
if (query)
|
|
75
|
-
params.set('search', query);
|
|
76
|
-
params.set('limit', String(limit));
|
|
77
|
-
const fullUrl = `${url}/servers?${params}`;
|
|
78
|
-
const headers = {
|
|
79
|
-
Accept: 'application/json',
|
|
80
|
-
};
|
|
81
|
-
if (apiKey) {
|
|
82
|
-
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
83
|
-
}
|
|
84
|
-
const response = await fetch(fullUrl, {
|
|
85
|
-
headers,
|
|
86
|
-
signal: AbortSignal.timeout(REGISTRY_FETCH_TIMEOUT_MS),
|
|
87
|
-
});
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
throw new Error(`Registry request failed: ${response.status} ${response.statusText}`);
|
|
90
|
-
}
|
|
91
|
-
return response.json();
|
|
92
|
-
}
|
|
93
|
-
export async function searchMcpRegistries(query, options) {
|
|
94
|
-
const registries = getEnabledRegistries('mcp');
|
|
95
|
-
const results = [];
|
|
96
|
-
const targetRegistries = options?.registry
|
|
97
|
-
? registries.filter((r) => r.name === options.registry)
|
|
98
|
-
: registries;
|
|
99
|
-
if (targetRegistries.length === 0) {
|
|
100
|
-
if (options?.registry) {
|
|
101
|
-
throw new Error(`Registry '${options.registry}' not found or not enabled`);
|
|
102
|
-
}
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
for (const { name, config } of targetRegistries) {
|
|
106
|
-
try {
|
|
107
|
-
const response = await fetchMcpRegistry(config.url, query, options?.limit || 20, config.apiKey);
|
|
108
|
-
for (const { server } of response.servers) {
|
|
109
|
-
results.push({
|
|
110
|
-
name: server.name,
|
|
111
|
-
description: server.description,
|
|
112
|
-
type: 'mcp',
|
|
113
|
-
source: server.repository?.url || server.name,
|
|
114
|
-
registry: name,
|
|
115
|
-
version: server.version_detail?.version,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
console.error(`Failed to search ${name}: ${err.message}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return results;
|
|
124
|
-
}
|
|
125
|
-
export function mcpEntryToInstallSpec(entry) {
|
|
126
|
-
const pkg = entry.packages?.[0];
|
|
127
|
-
if (!pkg)
|
|
128
|
-
return null;
|
|
129
|
-
if (pkg.transport === 'sse' || pkg.transport === 'streamable-http') {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
const reg = pkg.registry_name?.toLowerCase();
|
|
133
|
-
const runtime = pkg.runtime;
|
|
134
|
-
const name = pkg.name;
|
|
135
|
-
if (!name)
|
|
136
|
-
return null;
|
|
137
|
-
if (reg === 'npm' || runtime === 'node') {
|
|
138
|
-
return { command: `npx -y ${name}`, transport: 'stdio' };
|
|
139
|
-
}
|
|
140
|
-
if (reg === 'pypi' || runtime === 'python') {
|
|
141
|
-
return { command: `uvx ${name}`, transport: 'stdio' };
|
|
142
|
-
}
|
|
143
|
-
if (runtime === 'docker') {
|
|
144
|
-
return { command: `docker run --rm -i ${name}`, transport: 'stdio' };
|
|
145
|
-
}
|
|
146
|
-
if (runtime === 'binary') {
|
|
147
|
-
return { command: name, transport: 'stdio' };
|
|
148
|
-
}
|
|
149
|
-
return { command: name, transport: 'stdio' };
|
|
150
|
-
}
|
|
151
|
-
export async function getMcpServerInfo(serverName, registryName) {
|
|
152
|
-
const registries = getEnabledRegistries('mcp');
|
|
153
|
-
const targetRegistries = registryName
|
|
154
|
-
? registries.filter((r) => r.name === registryName)
|
|
155
|
-
: registries;
|
|
156
|
-
for (const { config } of targetRegistries) {
|
|
157
|
-
try {
|
|
158
|
-
const response = await fetchMcpRegistry(config.url, serverName, 10, config.apiKey);
|
|
159
|
-
const match = response.servers.find(({ server }) => server.name === serverName ||
|
|
160
|
-
server.name.endsWith(`/${serverName}`));
|
|
161
|
-
if (match) {
|
|
162
|
-
return match.server;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch {
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
const skillIndexCache = new Map();
|
|
171
|
-
const SKILL_INDEX_TTL_MS = 10 * 60_000;
|
|
172
|
-
async function fetchSkillIndex(url, apiKey) {
|
|
173
|
-
const cached = skillIndexCache.get(url);
|
|
174
|
-
if (cached && Date.now() - cached.fetchedAt < SKILL_INDEX_TTL_MS) {
|
|
175
|
-
return cached.doc;
|
|
176
|
-
}
|
|
177
|
-
const headers = { Accept: 'application/json' };
|
|
178
|
-
if (apiKey)
|
|
179
|
-
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
180
|
-
const response = await fetch(url, {
|
|
181
|
-
headers,
|
|
182
|
-
signal: AbortSignal.timeout(REGISTRY_FETCH_TIMEOUT_MS),
|
|
183
|
-
});
|
|
184
|
-
if (!response.ok) {
|
|
185
|
-
throw new Error(`Registry request failed: ${response.status} ${response.statusText}`);
|
|
186
|
-
}
|
|
187
|
-
const doc = (await response.json());
|
|
188
|
-
skillIndexCache.set(url, { fetchedAt: Date.now(), doc });
|
|
189
|
-
return doc;
|
|
190
|
-
}
|
|
191
|
-
export function normalizeSkillEntry(raw) {
|
|
192
|
-
return {
|
|
193
|
-
name: raw.name,
|
|
194
|
-
description: raw.description,
|
|
195
|
-
source: raw.source || 'unknown',
|
|
196
|
-
identifier: raw.identifier,
|
|
197
|
-
repo: raw.repo || undefined,
|
|
198
|
-
path: raw.path || undefined,
|
|
199
|
-
author: raw.author,
|
|
200
|
-
installs: raw.installs,
|
|
201
|
-
tags: raw.tags,
|
|
202
|
-
trustLevel: raw.trust_level,
|
|
203
|
-
sha256: raw.sha256,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
function skillMatchesQuery(entry, query) {
|
|
207
|
-
if (!query)
|
|
208
|
-
return true;
|
|
209
|
-
const q = query.toLowerCase();
|
|
210
|
-
const haystack = [
|
|
211
|
-
entry.name,
|
|
212
|
-
entry.identifier,
|
|
213
|
-
entry.description,
|
|
214
|
-
entry.source,
|
|
215
|
-
...(entry.tags || []),
|
|
216
|
-
]
|
|
217
|
-
.filter(Boolean)
|
|
218
|
-
.join(' ')
|
|
219
|
-
.toLowerCase();
|
|
220
|
-
return haystack.includes(q);
|
|
221
|
-
}
|
|
222
|
-
export async function searchSkillRegistries(query, options) {
|
|
223
|
-
const registries = getEnabledRegistries('skill');
|
|
224
|
-
if (registries.length === 0)
|
|
225
|
-
return [];
|
|
226
|
-
const targetRegistries = options?.registry
|
|
227
|
-
? registries.filter((r) => r.name === options.registry)
|
|
228
|
-
: registries;
|
|
229
|
-
if (targetRegistries.length === 0) {
|
|
230
|
-
if (options?.registry) {
|
|
231
|
-
throw new Error(`Registry '${options.registry}' not found or not enabled`);
|
|
232
|
-
}
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
|
-
const limit = options?.limit ?? 20;
|
|
236
|
-
const results = [];
|
|
237
|
-
for (const { name, config } of targetRegistries) {
|
|
238
|
-
try {
|
|
239
|
-
const doc = await fetchSkillIndex(config.url, config.apiKey);
|
|
240
|
-
for (const raw of doc.skills || []) {
|
|
241
|
-
const entry = normalizeSkillEntry(raw);
|
|
242
|
-
if (!skillMatchesQuery(entry, query))
|
|
243
|
-
continue;
|
|
244
|
-
results.push({
|
|
245
|
-
name: entry.identifier || entry.name,
|
|
246
|
-
description: entry.description,
|
|
247
|
-
type: 'skill',
|
|
248
|
-
source: entry.source,
|
|
249
|
-
registry: name,
|
|
250
|
-
installs: entry.installs,
|
|
251
|
-
});
|
|
252
|
-
if (results.length >= limit)
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
if (results.length >= limit)
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
catch (err) {
|
|
259
|
-
console.error(`Failed to search ${name}: ${err.message}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return results;
|
|
263
|
-
}
|
|
264
|
-
export async function getSkillEntry(skillIdentifier, registryName) {
|
|
265
|
-
const registries = getEnabledRegistries('skill');
|
|
266
|
-
const targets = registryName
|
|
267
|
-
? registries.filter((r) => r.name === registryName)
|
|
268
|
-
: registries;
|
|
269
|
-
for (const { config } of targets) {
|
|
270
|
-
try {
|
|
271
|
-
const doc = await fetchSkillIndex(config.url, config.apiKey);
|
|
272
|
-
const match = (doc.skills || []).find((s) => s.identifier === skillIdentifier || s.name === skillIdentifier);
|
|
273
|
-
if (match)
|
|
274
|
-
return normalizeSkillEntry(match);
|
|
275
|
-
}
|
|
276
|
-
catch {
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
export function skillEntryToGitSource(entry) {
|
|
282
|
-
if (entry.repo) {
|
|
283
|
-
return `gh:${entry.repo.replace(/\.git$/, '')}`;
|
|
284
|
-
}
|
|
285
|
-
if (entry.source === 'official') {
|
|
286
|
-
return 'gh:NousResearch/hermes-agent';
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
export async function search(query, options) {
|
|
291
|
-
const results = [];
|
|
292
|
-
if (!options?.type || options.type === 'mcp') {
|
|
293
|
-
const mcpResults = await searchMcpRegistries(query, options);
|
|
294
|
-
results.push(...mcpResults);
|
|
295
|
-
}
|
|
296
|
-
if (!options?.type || options.type === 'skill') {
|
|
297
|
-
const skillResults = await searchSkillRegistries(query, options);
|
|
298
|
-
results.push(...skillResults);
|
|
299
|
-
}
|
|
300
|
-
return results;
|
|
301
|
-
}
|
|
302
|
-
export function parsePackageIdentifier(identifier) {
|
|
303
|
-
if (identifier.startsWith('mcp:')) {
|
|
304
|
-
return { type: 'mcp', name: identifier.slice(4) };
|
|
305
|
-
}
|
|
306
|
-
if (identifier.startsWith('skill:')) {
|
|
307
|
-
return { type: 'skill', name: identifier.slice(6) };
|
|
308
|
-
}
|
|
309
|
-
if (identifier.startsWith('plugin:')) {
|
|
310
|
-
return { type: 'plugin', name: identifier.slice('plugin:'.length) };
|
|
311
|
-
}
|
|
312
|
-
if (identifier.startsWith('gh:')) {
|
|
313
|
-
return { type: 'git', name: identifier };
|
|
314
|
-
}
|
|
315
|
-
if (identifier.startsWith('https://') || identifier.startsWith('git@')) {
|
|
316
|
-
return { type: 'git', name: identifier };
|
|
317
|
-
}
|
|
318
|
-
if (identifier.startsWith('/') ||
|
|
319
|
-
identifier.startsWith('./') ||
|
|
320
|
-
identifier.startsWith('../') ||
|
|
321
|
-
fs.existsSync(identifier)) {
|
|
322
|
-
return { type: 'git', name: identifier };
|
|
323
|
-
}
|
|
324
|
-
if (identifier.includes('/') && !identifier.includes(':')) {
|
|
325
|
-
return { type: 'unknown', name: identifier };
|
|
326
|
-
}
|
|
327
|
-
return { type: 'unknown', name: identifier };
|
|
328
|
-
}
|
|
329
|
-
export async function resolvePackage(identifier) {
|
|
330
|
-
const parsed = parsePackageIdentifier(identifier);
|
|
331
|
-
if (parsed.type === 'plugin') {
|
|
332
|
-
const spec = parsed.name.trim();
|
|
333
|
-
if (!spec)
|
|
334
|
-
return null;
|
|
335
|
-
return { type: 'plugin', source: spec, pluginSpec: spec };
|
|
336
|
-
}
|
|
337
|
-
if (parsed.type === 'git') {
|
|
338
|
-
return { type: 'git', source: parsed.name };
|
|
339
|
-
}
|
|
340
|
-
if (parsed.type === 'mcp') {
|
|
341
|
-
const entry = await getMcpServerInfo(parsed.name);
|
|
342
|
-
if (entry) {
|
|
343
|
-
return {
|
|
344
|
-
type: 'mcp',
|
|
345
|
-
source: entry.repository?.url || entry.name,
|
|
346
|
-
mcpEntry: entry,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
if (parsed.type === 'skill') {
|
|
352
|
-
const entry = await getSkillEntry(parsed.name);
|
|
353
|
-
if (entry) {
|
|
354
|
-
const gitSource = skillEntryToGitSource(entry);
|
|
355
|
-
if (gitSource) {
|
|
356
|
-
return {
|
|
357
|
-
type: 'skill',
|
|
358
|
-
source: gitSource,
|
|
359
|
-
skillEntry: entry,
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
const gitSource = parsed.name.startsWith('gh:') ? parsed.name : `gh:${parsed.name}`;
|
|
365
|
-
return { type: 'git', source: gitSource };
|
|
366
|
-
}
|
|
367
|
-
if (parsed.type === 'unknown') {
|
|
368
|
-
const mcpEntry = await getMcpServerInfo(parsed.name);
|
|
369
|
-
if (mcpEntry) {
|
|
370
|
-
return {
|
|
371
|
-
type: 'mcp',
|
|
372
|
-
source: mcpEntry.repository?.url || mcpEntry.name,
|
|
373
|
-
mcpEntry,
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
if (parsed.name.includes('/')) {
|
|
377
|
-
return { type: 'git', source: `gh:${parsed.name}` };
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
export function sha256OfFile(file) {
|
|
383
|
-
return createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
384
|
-
}
|
|
385
|
-
export function parseOwnerRepoFromRemote(remoteUrl) {
|
|
386
|
-
const s = remoteUrl.trim().replace(/\\/g, '/').replace(/\.git$/, '');
|
|
387
|
-
const m = s.match(/github\.com[/:]([^/]+\/[^/]+)$/);
|
|
388
|
-
return m ? m[1] : null;
|
|
389
|
-
}
|
|
390
|
-
export function buildSkillIndex(repoPath, repoSlug, opts) {
|
|
391
|
-
const discovered = discoverSkillsFromRepo(repoPath);
|
|
392
|
-
const skills = discovered.map((s) => ({
|
|
393
|
-
name: s.name,
|
|
394
|
-
description: s.metadata.description || undefined,
|
|
395
|
-
identifier: s.name,
|
|
396
|
-
source: repoSlug,
|
|
397
|
-
repo: repoSlug,
|
|
398
|
-
path: path.relative(repoPath, s.path),
|
|
399
|
-
author: s.metadata.author,
|
|
400
|
-
sha256: sha256OfFile(path.join(s.path, 'SKILL.md')),
|
|
401
|
-
}));
|
|
402
|
-
return {
|
|
403
|
-
version: 1,
|
|
404
|
-
generated_at: opts?.generatedAt,
|
|
405
|
-
skill_count: skills.length,
|
|
406
|
-
skills,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
export function verifySkillIntegrity(repoPath, entry) {
|
|
410
|
-
if (!entry.sha256)
|
|
411
|
-
return { ok: true };
|
|
412
|
-
const rel = entry.path || path.join('skills', entry.name);
|
|
413
|
-
const skillMd = rel.endsWith('SKILL.md')
|
|
414
|
-
? path.join(repoPath, rel)
|
|
415
|
-
: path.join(repoPath, rel, 'SKILL.md');
|
|
416
|
-
if (!fs.existsSync(skillMd)) {
|
|
417
|
-
return {
|
|
418
|
-
ok: false,
|
|
419
|
-
error: `Integrity check failed for skill '${entry.name}': SKILL.md not found at ${rel}.`,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
const actual = sha256OfFile(skillMd);
|
|
423
|
-
const expected = entry.sha256.toLowerCase();
|
|
424
|
-
if (actual !== expected) {
|
|
425
|
-
return {
|
|
426
|
-
ok: false,
|
|
427
|
-
error: `Integrity check failed for skill '${entry.name}': expected sha256 ${expected}, got ${actual}. ` +
|
|
428
|
-
`The published SKILL.md does not match the registry index — refusing to install.`,
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
return { ok: true };
|
|
432
|
-
}
|
package/dist/lib/routers.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface RouterHarnessAllowlist {
|
|
2
|
-
models: string[];
|
|
3
|
-
accounts?: string[];
|
|
4
|
-
}
|
|
5
|
-
export interface Router {
|
|
6
|
-
name: string;
|
|
7
|
-
task?: string;
|
|
8
|
-
harnesses: Record<string, RouterHarnessAllowlist>;
|
|
9
|
-
weights?: {
|
|
10
|
-
cost?: number;
|
|
11
|
-
success?: number;
|
|
12
|
-
headroom?: number;
|
|
13
|
-
};
|
|
14
|
-
hijack?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function routersDir(): string;
|
|
17
|
-
export declare function validateRouterName(name: string): void;
|
|
18
|
-
export declare function routerExists(name: string, cwd?: string): boolean;
|
|
19
|
-
export declare function routerSource(name: string, cwd?: string): string | null;
|
|
20
|
-
export declare function readRouter(name: string, cwd?: string): Router;
|
|
21
|
-
export declare function writeRouter(router: Router): void;
|
|
22
|
-
export declare function deleteRouter(name: string): boolean;
|
|
23
|
-
export declare function renameRouter(oldName: string, newName: string): void;
|
|
24
|
-
export declare function validateRouter(router: Router): void;
|
|
25
|
-
export declare function listRouters(cwd?: string): Router[];
|
package/dist/lib/routers.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as yaml from 'yaml';
|
|
4
|
-
import { getUserAgentsDir } from './state.js';
|
|
5
|
-
import { resolveResource, listResources } from './resources.js';
|
|
6
|
-
import { ALL_AGENT_IDS } from './agents.js';
|
|
7
|
-
import { isTierToken, resolveTierMap, MODEL_TIERS } from './model-tiers.js';
|
|
8
|
-
import { getModelCatalog } from './models.js';
|
|
9
|
-
import { resolveVersion } from './installations/versions.js';
|
|
10
|
-
const ROUTER_NAME_PATTERN = /^[a-z0-9][a-z0-9-_]{0,48}$/i;
|
|
11
|
-
export function routersDir() {
|
|
12
|
-
return path.join(getUserAgentsDir(), 'routers');
|
|
13
|
-
}
|
|
14
|
-
function routerPath(name) {
|
|
15
|
-
return path.join(routersDir(), `${name}.yml`);
|
|
16
|
-
}
|
|
17
|
-
export function validateRouterName(name) {
|
|
18
|
-
if (!ROUTER_NAME_PATTERN.test(name)) {
|
|
19
|
-
throw new Error(`Invalid router name '${name}'. Use letters, digits, dash, underscore (max 48 chars).`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function routerExists(name, cwd) {
|
|
23
|
-
validateRouterName(name);
|
|
24
|
-
return resolveResource('routers', name, cwd) !== null;
|
|
25
|
-
}
|
|
26
|
-
export function routerSource(name, cwd) {
|
|
27
|
-
validateRouterName(name);
|
|
28
|
-
return resolveResource('routers', name, cwd)?.source ?? null;
|
|
29
|
-
}
|
|
30
|
-
function parseRouterFile(file, name) {
|
|
31
|
-
const raw = fs.readFileSync(file, 'utf-8');
|
|
32
|
-
const parsed = yaml.parse(raw);
|
|
33
|
-
if (!parsed || typeof parsed !== 'object') {
|
|
34
|
-
throw new Error(`Router '${name}' is malformed.`);
|
|
35
|
-
}
|
|
36
|
-
if (!parsed.name)
|
|
37
|
-
parsed.name = name;
|
|
38
|
-
if (!parsed.harnesses || typeof parsed.harnesses !== 'object')
|
|
39
|
-
parsed.harnesses = {};
|
|
40
|
-
return parsed;
|
|
41
|
-
}
|
|
42
|
-
export function readRouter(name, cwd) {
|
|
43
|
-
validateRouterName(name);
|
|
44
|
-
const resolved = resolveResource('routers', name, cwd);
|
|
45
|
-
if (!resolved) {
|
|
46
|
-
throw new Error(`Router '${name}' not found.`);
|
|
47
|
-
}
|
|
48
|
-
return parseRouterFile(resolved.path, name);
|
|
49
|
-
}
|
|
50
|
-
export function writeRouter(router) {
|
|
51
|
-
validateRouterName(router.name);
|
|
52
|
-
const dir = routersDir();
|
|
53
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
54
|
-
const body = yaml.stringify(router);
|
|
55
|
-
const file = routerPath(router.name);
|
|
56
|
-
const tmp = `${file}.tmp-${process.pid}`;
|
|
57
|
-
fs.writeFileSync(tmp, body, 'utf-8');
|
|
58
|
-
fs.renameSync(tmp, file);
|
|
59
|
-
}
|
|
60
|
-
export function deleteRouter(name) {
|
|
61
|
-
validateRouterName(name);
|
|
62
|
-
const file = routerPath(name);
|
|
63
|
-
if (!fs.existsSync(file))
|
|
64
|
-
return false;
|
|
65
|
-
fs.unlinkSync(file);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
export function renameRouter(oldName, newName) {
|
|
69
|
-
validateRouterName(newName);
|
|
70
|
-
const source = routerSource(oldName);
|
|
71
|
-
if (source === null) {
|
|
72
|
-
throw new Error(`Router '${oldName}' not found.`);
|
|
73
|
-
}
|
|
74
|
-
if (source !== 'user') {
|
|
75
|
-
throw new Error(`Router '${oldName}' resolves from the '${source}' layer, not 'user' -- ` +
|
|
76
|
-
`agents route rename can only rename a user-layer router. Rename its file directly, ` +
|
|
77
|
-
`or create a user-layer router under a different name.`);
|
|
78
|
-
}
|
|
79
|
-
if (routerExists(newName)) {
|
|
80
|
-
throw new Error(`Router '${newName}' already exists; remove it first.`);
|
|
81
|
-
}
|
|
82
|
-
const router = readRouter(oldName);
|
|
83
|
-
router.name = newName;
|
|
84
|
-
writeRouter(router);
|
|
85
|
-
deleteRouter(oldName);
|
|
86
|
-
}
|
|
87
|
-
export function validateRouter(router) {
|
|
88
|
-
for (const [harness, allowlist] of Object.entries(router.harnesses)) {
|
|
89
|
-
if (!ALL_AGENT_IDS.includes(harness)) {
|
|
90
|
-
throw new Error(`router '${router.name}': unknown harness '${harness}'. Known harnesses: ${ALL_AGENT_IDS.join(', ')}.`);
|
|
91
|
-
}
|
|
92
|
-
const agent = harness;
|
|
93
|
-
for (const token of allowlist.models) {
|
|
94
|
-
if (isTierToken(token))
|
|
95
|
-
continue;
|
|
96
|
-
const version = resolveVersion(agent) ?? '0.0.0';
|
|
97
|
-
const tierMap = resolveTierMap(agent, version);
|
|
98
|
-
const tierRungIds = new Set(MODEL_TIERS.map((t) => tierMap[t].model).filter((m) => m !== null));
|
|
99
|
-
if (tierRungIds.has(token))
|
|
100
|
-
continue;
|
|
101
|
-
const catalog = getModelCatalog(agent, version);
|
|
102
|
-
const inCatalog = catalog
|
|
103
|
-
? catalog.models.some((m) => m.id === token) || Boolean(catalog.aliases[token])
|
|
104
|
-
: false;
|
|
105
|
-
if (inCatalog)
|
|
106
|
-
continue;
|
|
107
|
-
throw new Error(`router '${router.name}': unknown model '${token}' for harness '${harness}'. ` +
|
|
108
|
-
`Use a tier token (${MODEL_TIERS.join('|')}) or a model id '${harness}' actually ships.`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
export function listRouters(cwd) {
|
|
113
|
-
const routers = [];
|
|
114
|
-
for (const resolved of listResources('routers', cwd)) {
|
|
115
|
-
try {
|
|
116
|
-
routers.push(parseRouterFile(resolved.path, resolved.name));
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return routers.sort((a, b) => a.name.localeCompare(b.name));
|
|
122
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { getCliLaunch } from './cli-entry.js';
|
|
3
|
-
import { readSession } from './identity/client.js';
|
|
4
|
-
import { hasSyncedBefore } from './traces/sync.js';
|
|
5
|
-
export function shouldAutoSyncTraces(disabled) {
|
|
6
|
-
if (disabled)
|
|
7
|
-
return false;
|
|
8
|
-
if (process.env.AGENTS_NO_TRACE_SYNC === '1')
|
|
9
|
-
return false;
|
|
10
|
-
if (!readSession())
|
|
11
|
-
return false;
|
|
12
|
-
if (!hasSyncedBefore())
|
|
13
|
-
return false;
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
function spawnDetachedTraceSync() {
|
|
17
|
-
try {
|
|
18
|
-
const { command, args } = getCliLaunch(['traces', 'sync']);
|
|
19
|
-
const child = spawn(command, args, { detached: true, stdio: 'ignore' });
|
|
20
|
-
child.on('error', () => { });
|
|
21
|
-
child.unref();
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export function armRunFinishTraceSync(opts = {}) {
|
|
27
|
-
if (!shouldAutoSyncTraces(!!opts.disabled))
|
|
28
|
-
return;
|
|
29
|
-
process.on('exit', spawnDetachedTraceSync);
|
|
30
|
-
}
|
|
31
|
-
export function fireTraceSyncInBackground(opts = {}) {
|
|
32
|
-
if (!shouldAutoSyncTraces(!!opts.disabled))
|
|
33
|
-
return;
|
|
34
|
-
spawnDetachedTraceSync();
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import { prunePidSessionRegistry, readPidSessionEntry, writePidSessionEntry } from '../pid-registry.js';
|
|
4
|
-
import { getActiveSessions } from '../active.js';
|
|
5
|
-
import { loadLocalActiveSessions, loadFleetActiveSessions, writeActiveSessionsCache, updateImmutableMemos, readActiveSessionsCache } from '../session-cache.js';
|
|
6
|
-
const hostPid = Number(process.argv[2]);
|
|
7
|
-
fs.writeFileSync('/proc/self/comm', 'init');
|
|
8
|
-
assert.equal(readPidSessionEntry(hostPid)?.sessionId, 'host-session');
|
|
9
|
-
assert.throws(() => process.kill(hostPid, 0), { code: 'ESRCH' });
|
|
10
|
-
writePidSessionEntry({ pid: hostPid, agent: 'codex', sessionId: 'namespace-collision', startedAtMs: Date.now() });
|
|
11
|
-
assert.equal(readPidSessionEntry(hostPid)?.sessionId, 'host-session');
|
|
12
|
-
prunePidSessionRegistry(() => false);
|
|
13
|
-
assert.equal(readPidSessionEntry(hostPid)?.sessionId, 'host-session');
|
|
14
|
-
const local = await loadLocalActiveSessions({ forceRefresh: true, gather: async () => { throw new Error('partial gather must never run'); } });
|
|
15
|
-
assert.equal(local.sessions[0].sessionId, 'host-session');
|
|
16
|
-
assert.equal(local.capturedAt, 1);
|
|
17
|
-
assert.equal(local.servedFromCache, true);
|
|
18
|
-
const fleet = await loadFleetActiveSessions({ forceRefresh: true, gather: async () => { throw new Error('partial fleet gather must never run'); } });
|
|
19
|
-
assert.equal(fleet.remoteDeviceCount, 2);
|
|
20
|
-
assert.equal(fleet.capturedAt, 1);
|
|
21
|
-
assert.equal((await getActiveSessions())[0].sessionId, 'host-session');
|
|
22
|
-
assert.throws(() => writeActiveSessionsCache('local', []), /process namespace/);
|
|
23
|
-
assert.throws(() => updateImmutableMemos([]), /process namespace/);
|
|
24
|
-
assert.equal(readActiveSessionsCache('local')?.capturedAt, 1);
|
|
25
|
-
console.log('host pid: ESRCH; overwrite: refused; registry and snapshots: retained');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|