nomoreide 0.1.71 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/agent-profiles/index.d.ts +4 -0
- package/dist/core/agent-profiles/index.js +4 -0
- package/dist/core/agent-profiles/index.js.map +1 -1
- package/dist/core/agent-profiles/registry-auth.d.ts +25 -0
- package/dist/core/agent-profiles/registry-auth.js +78 -0
- package/dist/core/agent-profiles/registry-auth.js.map +1 -0
- package/dist/core/agent-profiles/registry-client.d.ts +65 -0
- package/dist/core/agent-profiles/registry-client.js +97 -0
- package/dist/core/agent-profiles/registry-client.js.map +1 -0
- package/dist/core/agent-profiles/registry-config.d.ts +48 -0
- package/dist/core/agent-profiles/registry-config.js +164 -0
- package/dist/core/agent-profiles/registry-config.js.map +1 -0
- package/dist/core/agent-profiles/registry-transfer.d.ts +42 -0
- package/dist/core/agent-profiles/registry-transfer.js +102 -0
- package/dist/core/agent-profiles/registry-transfer.js.map +1 -0
- package/dist/mcp/tools/agent-registry.d.ts +9 -0
- package/dist/mcp/tools/agent-registry.js +81 -0
- package/dist/mcp/tools/agent-registry.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +1 -1
- package/dist/mcp/tools/index.js +3 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/web/client/assets/{code-editor-B0j6kcLb.js → code-editor-fZ2dpXfw.js} +1 -1
- package/dist/web/client/assets/{index-DAiSqTLR.js → index-CraqLFuO.js} +116 -116
- package/dist/web/client/index.html +1 -1
- package/dist/web/routes/agent-registry-routes.d.ts +2 -0
- package/dist/web/routes/agent-registry-routes.js +295 -0
- package/dist/web/routes/agent-registry-routes.js.map +1 -0
- package/dist/web/routes/index.js +4 -0
- package/dist/web/routes/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,4 +7,8 @@ export { applyProfile, previewProfileApply, type ProfileApplyItem, type ProfileA
|
|
|
7
7
|
export { findUnresolvedCredentialKeys, redactMcpCredentials, resolveMcpCredentials, } from "./credentials.js";
|
|
8
8
|
export { assertValidProfileName, copySkillBetweenProfiles, createProfile, deleteProfile, getProfile, listProfiles, profileDir, profilesRoot, profileSkillsDir, snapshotProfileFromAgent, updateProfile, writeProfile, type ProfileStoreOptions, } from "./store.js";
|
|
9
9
|
export { exportProfile, importProfile, type ExportResult, type ImportResult } from "./transfer.js";
|
|
10
|
+
export { createRegistryConfigService, DEFAULT_REGISTRY_API_BASE_URL, DEFAULT_REGISTRY_FRONTEND_URL, registryConfigPath, resolveRegistryApiBaseUrl, resolveRegistryApiTarget, resolveRegistryApiToken, resolveRegistryFrontendUrl, type RegistryApiTarget, type RegistryConfigOptions, type RegistryConfigService, } from "./registry-config.js";
|
|
11
|
+
export { createRegistryTokenManager, type RegistryTokenManager, type RegistryTokenManagerOptions, } from "./registry-auth.js";
|
|
12
|
+
export { createRegistryClient, type RegisterGithubProfileInput, type RegistryClient, type RegistryInstallDescriptor, type RegistryProfile, } from "./registry-client.js";
|
|
13
|
+
export { installProfileFromRegistry, publishProfileToRegistry, type InstallFromRegistryInput, type InstallFromRegistryResult, type PublishProfileInput, type PublishProfileResult, } from "./registry-transfer.js";
|
|
10
14
|
export { PROFILE_NAME_PATTERN, profileManifestSchema, profileMcpSchema, profileSchema, slugifyProfileName, type CredentialSpec, type Profile, type ProfileManifest, type ProfileMcp, type ProfileSummary, } from "./types.js";
|
|
@@ -7,5 +7,9 @@ export { applyProfile, previewProfileApply, } from "./apply.js";
|
|
|
7
7
|
export { findUnresolvedCredentialKeys, redactMcpCredentials, resolveMcpCredentials, } from "./credentials.js";
|
|
8
8
|
export { assertValidProfileName, copySkillBetweenProfiles, createProfile, deleteProfile, getProfile, listProfiles, profileDir, profilesRoot, profileSkillsDir, snapshotProfileFromAgent, updateProfile, writeProfile, } from "./store.js";
|
|
9
9
|
export { exportProfile, importProfile } from "./transfer.js";
|
|
10
|
+
export { createRegistryConfigService, DEFAULT_REGISTRY_API_BASE_URL, DEFAULT_REGISTRY_FRONTEND_URL, registryConfigPath, resolveRegistryApiBaseUrl, resolveRegistryApiTarget, resolveRegistryApiToken, resolveRegistryFrontendUrl, } from "./registry-config.js";
|
|
11
|
+
export { createRegistryTokenManager, } from "./registry-auth.js";
|
|
12
|
+
export { createRegistryClient, } from "./registry-client.js";
|
|
13
|
+
export { installProfileFromRegistry, publishProfileToRegistry, } from "./registry-transfer.js";
|
|
10
14
|
export { PROFILE_NAME_PATTERN, profileManifestSchema, profileMcpSchema, profileSchema, slugifyProfileName, } from "./types.js";
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/agent-profiles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,YAAY,EACZ,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAwC,MAAM,eAAe,CAAC;AACnG,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,GAMnB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/agent-profiles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,YAAY,EACZ,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAwC,MAAM,eAAe,CAAC;AACnG,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,GAG3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,GAKrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GAKzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,GAMnB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bearer-token manager for the profile registry: reads the stored access
|
|
3
|
+
* token, transparently refreshes it once on a 401, and persists rotated
|
|
4
|
+
* tokens back to the registry config file.
|
|
5
|
+
*/
|
|
6
|
+
import { type RegistryConfigOptions, type RegistryConfigService } from "./registry-config.js";
|
|
7
|
+
export interface RegistryTokenManager {
|
|
8
|
+
/** Current access token, or null when signed out. */
|
|
9
|
+
getAccessToken(): Promise<string | null>;
|
|
10
|
+
/** Authenticated fetch that refreshes once on 401 and retries. */
|
|
11
|
+
authenticatedFetch(pathOrUrl: string, init?: RequestInit): Promise<Response>;
|
|
12
|
+
/** Persist tokens after a fresh sign-in. */
|
|
13
|
+
saveTokens(input: {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
refreshToken?: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
/** Sign out: drop both tokens. */
|
|
18
|
+
clear(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export interface RegistryTokenManagerOptions extends RegistryConfigOptions {
|
|
21
|
+
configService?: RegistryConfigService;
|
|
22
|
+
apiBaseUrl?: string;
|
|
23
|
+
fetch?: typeof fetch;
|
|
24
|
+
}
|
|
25
|
+
export declare function createRegistryTokenManager(options?: RegistryTokenManagerOptions): RegistryTokenManager;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bearer-token manager for the profile registry: reads the stored access
|
|
3
|
+
* token, transparently refreshes it once on a 401, and persists rotated
|
|
4
|
+
* tokens back to the registry config file.
|
|
5
|
+
*/
|
|
6
|
+
import { createRegistryConfigService, resolveRegistryApiBaseUrl, resolveRegistryApiToken, } from "./registry-config.js";
|
|
7
|
+
export function createRegistryTokenManager(options = {}) {
|
|
8
|
+
const config = options.configService ?? createRegistryConfigService(options);
|
|
9
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
10
|
+
let refreshInFlight = null;
|
|
11
|
+
async function apiBase() {
|
|
12
|
+
return (options.apiBaseUrl ??
|
|
13
|
+
(await resolveRegistryApiBaseUrl({ ...options, configService: config }))).replace(/\/$/, "");
|
|
14
|
+
}
|
|
15
|
+
async function readAccessToken() {
|
|
16
|
+
const resolved = await resolveRegistryApiToken({ ...options, configService: config });
|
|
17
|
+
return resolved?.token ?? null;
|
|
18
|
+
}
|
|
19
|
+
async function refresh() {
|
|
20
|
+
if (refreshInFlight)
|
|
21
|
+
return refreshInFlight;
|
|
22
|
+
refreshInFlight = (async () => {
|
|
23
|
+
const refreshToken = (await config.get("apiRefreshToken")) ?? null;
|
|
24
|
+
if (!refreshToken)
|
|
25
|
+
return null;
|
|
26
|
+
const res = await fetchImpl(`${await apiBase()}/auth/refresh`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: { "content-type": "application/json" },
|
|
29
|
+
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
30
|
+
});
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
// Refresh token is dead — drop both so status reports signed-out.
|
|
33
|
+
await config.unset("apiRefreshToken");
|
|
34
|
+
await config.unset("apiToken");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const data = (await res.json());
|
|
38
|
+
await config.set("apiToken", data.access_token);
|
|
39
|
+
if (data.refresh_token)
|
|
40
|
+
await config.set("apiRefreshToken", data.refresh_token);
|
|
41
|
+
return data.access_token;
|
|
42
|
+
})().finally(() => {
|
|
43
|
+
refreshInFlight = null;
|
|
44
|
+
});
|
|
45
|
+
return refreshInFlight;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
getAccessToken: readAccessToken,
|
|
49
|
+
async saveTokens({ accessToken, refreshToken }) {
|
|
50
|
+
await config.set("apiToken", accessToken);
|
|
51
|
+
if (refreshToken)
|
|
52
|
+
await config.set("apiRefreshToken", refreshToken);
|
|
53
|
+
},
|
|
54
|
+
async clear() {
|
|
55
|
+
await config.unset("apiToken");
|
|
56
|
+
await config.unset("apiRefreshToken");
|
|
57
|
+
},
|
|
58
|
+
async authenticatedFetch(pathOrUrl, init = {}) {
|
|
59
|
+
const url = pathOrUrl.startsWith("http")
|
|
60
|
+
? pathOrUrl
|
|
61
|
+
: `${await apiBase()}${pathOrUrl.startsWith("/") ? "" : "/"}${pathOrUrl}`;
|
|
62
|
+
const send = (token) => {
|
|
63
|
+
const headers = new Headers(init.headers);
|
|
64
|
+
if (token)
|
|
65
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
66
|
+
return fetchImpl(url, { ...init, headers });
|
|
67
|
+
};
|
|
68
|
+
const first = await send(await readAccessToken());
|
|
69
|
+
if (first.status !== 401)
|
|
70
|
+
return first;
|
|
71
|
+
const refreshed = await refresh();
|
|
72
|
+
if (!refreshed)
|
|
73
|
+
return first;
|
|
74
|
+
return send(refreshed);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=registry-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-auth.js","sourceRoot":"","sources":["../../../src/core/agent-profiles/registry-auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,GAGxB,MAAM,sBAAsB,CAAC;AAmB9B,MAAM,UAAU,0BAA0B,CACxC,UAAuC,EAAE;IAEzC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACzC,IAAI,eAAe,GAAkC,IAAI,CAAC;IAE1D,KAAK,UAAU,OAAO;QACpB,OAAO,CACL,OAAO,CAAC,UAAU;YAClB,CAAC,MAAM,yBAAyB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CACzE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,UAAU,eAAe;QAC5B,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;QACtF,OAAO,QAAQ,EAAE,KAAK,IAAI,IAAI,CAAC;IACjC,CAAC;IAED,KAAK,UAAU,OAAO;QACpB,IAAI,eAAe;YAAE,OAAO,eAAe,CAAC;QAC5C,eAAe,GAAG,CAAC,KAAK,IAAI,EAAE;YAC5B,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,IAAI,IAAI,CAAC;YACnE,IAAI,CAAC,YAAY;gBAAE,OAAO,IAAI,CAAC;YAC/B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,MAAM,OAAO,EAAE,eAAe,EAAE;gBAC7D,MAAM,EAAE,MAAM;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BAAkB,CAAC,SAAS,EAAE,IAAI,GAAG,EAAE;YAC3C,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;gBACtC,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,GAAG,MAAM,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,SAAS,EAAE,CAAC;YAE5E,MAAM,IAAI,GAAG,CAAC,KAAoB,EAAE,EAAE;gBACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC1C,IAAI,KAAK;oBAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;gBAC3D,OAAO,SAAS,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9C,CAAC,CAAC;YAEF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;YAClD,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG;gBAAE,OAAO,KAAK,CAAC;YAEvC,MAAM,SAAS,GAAG,MAAM,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,SAAS;gBAAE,OAAO,KAAK,CAAC;YAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the hosted profile registry (the brainctl platform).
|
|
3
|
+
* Thin wrapper over its REST API: profile CRUD, version + package upload,
|
|
4
|
+
* publish, install descriptors, and GitHub-repo registration. Auth is the
|
|
5
|
+
* caller's job — pass a token or an already-authenticated `fetch`.
|
|
6
|
+
*/
|
|
7
|
+
export interface RegistryProfile {
|
|
8
|
+
id: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
title: string;
|
|
11
|
+
summary: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RegistryProfileVersion {
|
|
14
|
+
id: string;
|
|
15
|
+
profile_id: string;
|
|
16
|
+
version: string;
|
|
17
|
+
}
|
|
18
|
+
export interface RegistryInstallDescriptor {
|
|
19
|
+
slug: string;
|
|
20
|
+
version: string;
|
|
21
|
+
source_kind: "brainctl" | "github" | string;
|
|
22
|
+
download_url: string;
|
|
23
|
+
checksum_sha256?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface RegisterGithubProfileInput {
|
|
26
|
+
repoUrl: string;
|
|
27
|
+
slug: string;
|
|
28
|
+
title: string;
|
|
29
|
+
summary?: string;
|
|
30
|
+
refName?: string;
|
|
31
|
+
profilePath?: string;
|
|
32
|
+
manifestJson: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface RegistryClient {
|
|
35
|
+
getProfileBySlug(slug: string): Promise<RegistryProfile | null>;
|
|
36
|
+
createProfile(input: {
|
|
37
|
+
slug: string;
|
|
38
|
+
title: string;
|
|
39
|
+
summary?: string;
|
|
40
|
+
visibility?: "public" | "private";
|
|
41
|
+
}): Promise<RegistryProfile>;
|
|
42
|
+
createProfileVersion(input: {
|
|
43
|
+
profileId: string;
|
|
44
|
+
version: string;
|
|
45
|
+
changelog?: string;
|
|
46
|
+
manifestJson: Record<string, unknown>;
|
|
47
|
+
}): Promise<RegistryProfileVersion>;
|
|
48
|
+
uploadPackage(input: {
|
|
49
|
+
profileId: string;
|
|
50
|
+
versionId: string;
|
|
51
|
+
bytes: Uint8Array;
|
|
52
|
+
mimeType?: string;
|
|
53
|
+
}): Promise<unknown>;
|
|
54
|
+
publishProfileVersion(input: {
|
|
55
|
+
profileId: string;
|
|
56
|
+
versionId: string;
|
|
57
|
+
}): Promise<unknown>;
|
|
58
|
+
getInstallDescriptor(slug: string): Promise<RegistryInstallDescriptor>;
|
|
59
|
+
registerGithubProfile(input: RegisterGithubProfileInput): Promise<unknown>;
|
|
60
|
+
}
|
|
61
|
+
export declare function createRegistryClient(options: {
|
|
62
|
+
baseUrl: string;
|
|
63
|
+
token?: string;
|
|
64
|
+
fetch?: typeof fetch;
|
|
65
|
+
}): RegistryClient;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the hosted profile registry (the brainctl platform).
|
|
3
|
+
* Thin wrapper over its REST API: profile CRUD, version + package upload,
|
|
4
|
+
* publish, install descriptors, and GitHub-repo registration. Auth is the
|
|
5
|
+
* caller's job — pass a token or an already-authenticated `fetch`.
|
|
6
|
+
*/
|
|
7
|
+
export function createRegistryClient(options) {
|
|
8
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
9
|
+
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
10
|
+
const authHeaders = options.token
|
|
11
|
+
? { authorization: `Bearer ${options.token}` }
|
|
12
|
+
: {};
|
|
13
|
+
const jsonHeaders = { "content-type": "application/json", ...authHeaders };
|
|
14
|
+
async function failIfNotOk(response, action) {
|
|
15
|
+
if (response.ok)
|
|
16
|
+
return;
|
|
17
|
+
const text = await response.text().catch(() => "");
|
|
18
|
+
throw new Error(`${action} failed: HTTP ${response.status}${text ? ` — ${text}` : ""}`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
async getProfileBySlug(slug) {
|
|
22
|
+
const response = await fetchImpl(`${baseUrl}/profiles/${slug}`, {
|
|
23
|
+
headers: authHeaders,
|
|
24
|
+
});
|
|
25
|
+
if (response.status === 404)
|
|
26
|
+
return null;
|
|
27
|
+
await failIfNotOk(response, "Lookup profile");
|
|
28
|
+
return (await response.json());
|
|
29
|
+
},
|
|
30
|
+
async createProfile(input) {
|
|
31
|
+
const response = await fetchImpl(`${baseUrl}/profiles`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: jsonHeaders,
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
slug: input.slug,
|
|
36
|
+
title: input.title,
|
|
37
|
+
summary: input.summary ?? "",
|
|
38
|
+
visibility: input.visibility ?? "public",
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
await failIfNotOk(response, "Create profile");
|
|
42
|
+
return (await response.json());
|
|
43
|
+
},
|
|
44
|
+
async createProfileVersion(input) {
|
|
45
|
+
const response = await fetchImpl(`${baseUrl}/profiles/${input.profileId}/versions`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: jsonHeaders,
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
version: input.version,
|
|
50
|
+
changelog: input.changelog ?? "",
|
|
51
|
+
manifest_json: input.manifestJson,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
await failIfNotOk(response, "Create profile version");
|
|
55
|
+
return (await response.json());
|
|
56
|
+
},
|
|
57
|
+
async uploadPackage(input) {
|
|
58
|
+
const response = await fetchImpl(`${baseUrl}/profiles/${input.profileId}/versions/${input.versionId}/package`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "content-type": input.mimeType ?? "application/gzip", ...authHeaders },
|
|
61
|
+
body: input.bytes,
|
|
62
|
+
});
|
|
63
|
+
await failIfNotOk(response, "Upload package");
|
|
64
|
+
return response.json();
|
|
65
|
+
},
|
|
66
|
+
async publishProfileVersion(input) {
|
|
67
|
+
const response = await fetchImpl(`${baseUrl}/profiles/${input.profileId}/versions/${input.versionId}/publish`, { method: "POST", headers: authHeaders });
|
|
68
|
+
await failIfNotOk(response, "Publish profile version");
|
|
69
|
+
return response.json();
|
|
70
|
+
},
|
|
71
|
+
async getInstallDescriptor(slug) {
|
|
72
|
+
const response = await fetchImpl(`${baseUrl}/profiles/${slug}/install`, {
|
|
73
|
+
headers: authHeaders,
|
|
74
|
+
});
|
|
75
|
+
await failIfNotOk(response, "Read install descriptor");
|
|
76
|
+
return (await response.json());
|
|
77
|
+
},
|
|
78
|
+
async registerGithubProfile(input) {
|
|
79
|
+
const response = await fetchImpl(`${baseUrl}/profiles/github/register`, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: jsonHeaders,
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
repo_url: input.repoUrl,
|
|
84
|
+
slug: input.slug,
|
|
85
|
+
title: input.title,
|
|
86
|
+
summary: input.summary ?? "",
|
|
87
|
+
ref_name: input.refName ?? "main",
|
|
88
|
+
profile_path: input.profilePath ?? "profile.yaml",
|
|
89
|
+
manifest_json: input.manifestJson,
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
await failIfNotOk(response, "Register GitHub profile");
|
|
93
|
+
return response.json();
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=registry-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-client.js","sourceRoot":"","sources":["../../../src/core/agent-profiles/registry-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0DH,MAAM,UAAU,oBAAoB,CAAC,OAIpC;IACC,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnD,MAAM,WAAW,GAA2B,OAAO,CAAC,KAAK;QACvD,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE,EAAE;QAC9C,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,WAAW,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,WAAW,EAAE,CAAC;IAE3E,KAAK,UAAU,WAAW,CAAC,QAAkB,EAAE,MAAc;QAC3D,IAAI,QAAQ,CAAC,EAAE;YAAE,OAAO;QACxB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,iBAAiB,QAAQ,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YACH,MAAM,WAAW,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;YACvD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA8B,CAAC;QAC9D,CAAC;QAED,KAAK,CAAC,qBAAqB,CAAC,KAAK;YAC/B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,OAAO,2BAA2B,EAAE;gBACtE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,QAAQ,EAAE,KAAK,CAAC,OAAO;oBACvB,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE;oBAC5B,QAAQ,EAAE,KAAK,CAAC,OAAO,IAAI,MAAM;oBACjC,YAAY,EAAE,KAAK,CAAC,WAAW,IAAI,cAAc;oBACjD,aAAa,EAAE,KAAK,CAAC,YAAY;iBAClC,CAAC;aACH,CAAC,CAAC;YACH,MAAM,WAAW,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;YACvD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const DEFAULT_REGISTRY_API_BASE_URL = "https://api.brainctl.net";
|
|
2
|
+
export declare const DEFAULT_REGISTRY_FRONTEND_URL = "https://app.brainctl.net";
|
|
3
|
+
export type RegistryConfigKey = "apiBaseUrl" | "apiToken" | "apiRefreshToken" | "apiFrontendUrl";
|
|
4
|
+
export interface RegistryConfig {
|
|
5
|
+
apiBaseUrl?: string;
|
|
6
|
+
apiToken?: string;
|
|
7
|
+
apiRefreshToken?: string;
|
|
8
|
+
apiFrontendUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export type RegistryApiTargetSource = "env" | "config" | "default";
|
|
11
|
+
export type RegistryApiTargetMode = "local" | "prod" | "custom";
|
|
12
|
+
export interface RegistryApiTarget {
|
|
13
|
+
apiBaseUrl: string;
|
|
14
|
+
source: RegistryApiTargetSource;
|
|
15
|
+
mode: RegistryApiTargetMode;
|
|
16
|
+
}
|
|
17
|
+
export interface RegistryConfigOptions {
|
|
18
|
+
/** Injectable for tmpdir tests. */
|
|
19
|
+
configPath?: string;
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
}
|
|
22
|
+
export interface RegistryConfigService {
|
|
23
|
+
path(): string;
|
|
24
|
+
get(key: RegistryConfigKey): Promise<string | undefined>;
|
|
25
|
+
set(key: RegistryConfigKey, value: string): Promise<void>;
|
|
26
|
+
unset(key: RegistryConfigKey): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare function registryConfigPath(options?: RegistryConfigOptions): string;
|
|
29
|
+
export declare function createRegistryConfigService(options?: RegistryConfigOptions): RegistryConfigService;
|
|
30
|
+
export declare function resolveRegistryApiTarget(options?: RegistryConfigOptions & {
|
|
31
|
+
configService?: RegistryConfigService;
|
|
32
|
+
}): Promise<RegistryApiTarget>;
|
|
33
|
+
export declare function resolveRegistryApiBaseUrl(options?: RegistryConfigOptions & {
|
|
34
|
+
apiBaseUrl?: string;
|
|
35
|
+
configService?: RegistryConfigService;
|
|
36
|
+
}): Promise<string>;
|
|
37
|
+
export type RegistryTokenSource = "env" | "config";
|
|
38
|
+
export declare function resolveRegistryApiToken(options?: RegistryConfigOptions & {
|
|
39
|
+
configService?: RegistryConfigService;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
token: string;
|
|
42
|
+
source: RegistryTokenSource;
|
|
43
|
+
} | null>;
|
|
44
|
+
/** Registry web UI base — where the browser sign-in flow lives. */
|
|
45
|
+
export declare function resolveRegistryFrontendUrl(options?: RegistryConfigOptions & {
|
|
46
|
+
apiBaseUrl?: string;
|
|
47
|
+
configService?: RegistryConfigService;
|
|
48
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile registry configuration (ROR-63). The hosted registry is the
|
|
3
|
+
* brainctl platform (kept as-is per the ROR-63 decision), so credentials and
|
|
4
|
+
* target URLs live in brainctl's config file at `~/.brainctl/config.json` and
|
|
5
|
+
* honor the `BRAINCTL_*` environment variables — existing brainctl sign-ins
|
|
6
|
+
* keep working unchanged.
|
|
7
|
+
*/
|
|
8
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
export const DEFAULT_REGISTRY_API_BASE_URL = "https://api.brainctl.net";
|
|
12
|
+
export const DEFAULT_REGISTRY_FRONTEND_URL = "https://app.brainctl.net";
|
|
13
|
+
export function registryConfigPath(options = {}) {
|
|
14
|
+
const env = options.env ?? process.env;
|
|
15
|
+
return (options.configPath ??
|
|
16
|
+
env.BRAINCTL_CONFIG_PATH ??
|
|
17
|
+
path.join(env.BRAINCTL_HOME ?? homedir(), ".brainctl", "config.json"));
|
|
18
|
+
}
|
|
19
|
+
export function createRegistryConfigService(options = {}) {
|
|
20
|
+
const filePath = registryConfigPath(options);
|
|
21
|
+
async function read() {
|
|
22
|
+
let source;
|
|
23
|
+
try {
|
|
24
|
+
source = await readFile(filePath, "utf8");
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return normalizeConfig(JSON.parse(source));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`Invalid registry config at ${filePath}: ${error.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function write(config) {
|
|
37
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
38
|
+
await writeFile(filePath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
path: () => filePath,
|
|
42
|
+
async get(key) {
|
|
43
|
+
return (await read())[key];
|
|
44
|
+
},
|
|
45
|
+
async set(key, value) {
|
|
46
|
+
const config = await read();
|
|
47
|
+
await write({ ...config, [key]: normalizeConfigValue(key, value) });
|
|
48
|
+
},
|
|
49
|
+
async unset(key) {
|
|
50
|
+
const config = await read();
|
|
51
|
+
delete config[key];
|
|
52
|
+
await write(config);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export async function resolveRegistryApiTarget(options = {}) {
|
|
57
|
+
const env = options.env ?? process.env;
|
|
58
|
+
const envValue = env.BRAINCTL_API_BASE_URL ?? env.BRAINCTL_API_URL;
|
|
59
|
+
if (envValue)
|
|
60
|
+
return toApiTarget(normalizeBaseUrl(envValue), "env");
|
|
61
|
+
const configService = options.configService ?? createRegistryConfigService(options);
|
|
62
|
+
const configured = await configService.get("apiBaseUrl");
|
|
63
|
+
if (configured)
|
|
64
|
+
return toApiTarget(normalizeBaseUrl(configured), "config");
|
|
65
|
+
return toApiTarget(DEFAULT_REGISTRY_API_BASE_URL, "default");
|
|
66
|
+
}
|
|
67
|
+
export async function resolveRegistryApiBaseUrl(options = {}) {
|
|
68
|
+
if (options.apiBaseUrl)
|
|
69
|
+
return normalizeBaseUrl(options.apiBaseUrl);
|
|
70
|
+
return (await resolveRegistryApiTarget(options)).apiBaseUrl;
|
|
71
|
+
}
|
|
72
|
+
export async function resolveRegistryApiToken(options = {}) {
|
|
73
|
+
const env = options.env ?? process.env;
|
|
74
|
+
if (env.BRAINCTL_API_TOKEN?.trim()) {
|
|
75
|
+
return { token: env.BRAINCTL_API_TOKEN.trim(), source: "env" };
|
|
76
|
+
}
|
|
77
|
+
const configService = options.configService ?? createRegistryConfigService(options);
|
|
78
|
+
const stored = await configService.get("apiToken");
|
|
79
|
+
if (stored?.trim())
|
|
80
|
+
return { token: stored.trim(), source: "config" };
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** Registry web UI base — where the browser sign-in flow lives. */
|
|
84
|
+
export async function resolveRegistryFrontendUrl(options = {}) {
|
|
85
|
+
const env = options.env ?? process.env;
|
|
86
|
+
if (env.BRAINCTL_FRONTEND_URL?.trim()) {
|
|
87
|
+
return normalizeBaseUrl(env.BRAINCTL_FRONTEND_URL);
|
|
88
|
+
}
|
|
89
|
+
const configService = options.configService ?? createRegistryConfigService(options);
|
|
90
|
+
const stored = await configService.get("apiFrontendUrl");
|
|
91
|
+
if (stored)
|
|
92
|
+
return normalizeBaseUrl(stored);
|
|
93
|
+
if (options.apiBaseUrl) {
|
|
94
|
+
try {
|
|
95
|
+
const url = new URL(options.apiBaseUrl);
|
|
96
|
+
if (url.hostname === "localhost" || url.hostname === "127.0.0.1") {
|
|
97
|
+
return `${url.protocol}//${url.hostname}:5173`;
|
|
98
|
+
}
|
|
99
|
+
if (url.hostname.startsWith("api.")) {
|
|
100
|
+
return `${url.protocol}//app.${url.hostname.slice("api.".length)}`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// fall through to default
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return DEFAULT_REGISTRY_FRONTEND_URL;
|
|
108
|
+
}
|
|
109
|
+
function normalizeConfig(value) {
|
|
110
|
+
if (!value || typeof value !== "object")
|
|
111
|
+
return {};
|
|
112
|
+
const config = {};
|
|
113
|
+
if (typeof value.apiBaseUrl === "string" && value.apiBaseUrl.trim()) {
|
|
114
|
+
config.apiBaseUrl = normalizeBaseUrl(value.apiBaseUrl);
|
|
115
|
+
}
|
|
116
|
+
if (typeof value.apiFrontendUrl === "string" && value.apiFrontendUrl.trim()) {
|
|
117
|
+
config.apiFrontendUrl = normalizeBaseUrl(value.apiFrontendUrl);
|
|
118
|
+
}
|
|
119
|
+
if (typeof value.apiToken === "string" && value.apiToken.trim()) {
|
|
120
|
+
config.apiToken = value.apiToken.trim();
|
|
121
|
+
}
|
|
122
|
+
if (typeof value.apiRefreshToken === "string" && value.apiRefreshToken.trim()) {
|
|
123
|
+
config.apiRefreshToken = value.apiRefreshToken.trim();
|
|
124
|
+
}
|
|
125
|
+
return config;
|
|
126
|
+
}
|
|
127
|
+
function normalizeConfigValue(key, value) {
|
|
128
|
+
if (key === "apiBaseUrl" || key === "apiFrontendUrl")
|
|
129
|
+
return normalizeBaseUrl(value);
|
|
130
|
+
const trimmed = value.trim();
|
|
131
|
+
if (!trimmed)
|
|
132
|
+
throw new Error(`${key} cannot be empty.`);
|
|
133
|
+
return trimmed;
|
|
134
|
+
}
|
|
135
|
+
function normalizeBaseUrl(value) {
|
|
136
|
+
const trimmed = value.trim().replace(/\/+$/, "");
|
|
137
|
+
if (!trimmed)
|
|
138
|
+
throw new Error("Registry URL cannot be empty.");
|
|
139
|
+
let parsed;
|
|
140
|
+
try {
|
|
141
|
+
parsed = new URL(trimmed);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
throw new Error(`Invalid registry URL "${value}". Use an http:// or https:// URL.`);
|
|
145
|
+
}
|
|
146
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
147
|
+
throw new Error(`Invalid registry URL "${value}". Use an http:// or https:// URL.`);
|
|
148
|
+
}
|
|
149
|
+
return trimmed;
|
|
150
|
+
}
|
|
151
|
+
function toApiTarget(apiBaseUrl, source) {
|
|
152
|
+
let mode = "custom";
|
|
153
|
+
if (apiBaseUrl === DEFAULT_REGISTRY_API_BASE_URL) {
|
|
154
|
+
mode = "prod";
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const { hostname } = new URL(apiBaseUrl);
|
|
158
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") {
|
|
159
|
+
mode = "local";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return { apiBaseUrl, source, mode };
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=registry-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-config.js","sourceRoot":"","sources":["../../../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AAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,oCAAoC,CAAC,CAAC;IACtF,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,oCAAoC,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,UAAkB,EAAE,MAA+B;IACtE,IAAI,IAAI,GAA0B,QAAQ,CAAC;IAC3C,IAAI,UAAU,KAAK,6BAA6B,EAAE,CAAC;QACjD,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC/E,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type RegistryClient } from "./registry-client.js";
|
|
2
|
+
import { type ProfileStoreOptions } from "./store.js";
|
|
3
|
+
import { type ImportResult } from "./transfer.js";
|
|
4
|
+
export interface PublishProfileInput {
|
|
5
|
+
name: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
title: string;
|
|
8
|
+
summary?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
changelog?: string;
|
|
11
|
+
visibility?: "public" | "private";
|
|
12
|
+
cwd: string;
|
|
13
|
+
/** Registry API base; the caller resolves it (config/env/default). */
|
|
14
|
+
apiBaseUrl: string;
|
|
15
|
+
/** Pass an authenticated fetch (token manager) or a raw token. */
|
|
16
|
+
token?: string;
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}
|
|
19
|
+
export interface PublishProfileResult {
|
|
20
|
+
slug: string;
|
|
21
|
+
profileId: string;
|
|
22
|
+
versionId: string;
|
|
23
|
+
version: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function publishProfileToRegistry(input: PublishProfileInput, options?: ProfileStoreOptions): Promise<PublishProfileResult>;
|
|
26
|
+
export interface InstallFromRegistryInput {
|
|
27
|
+
slug: string;
|
|
28
|
+
apiBaseUrl: string;
|
|
29
|
+
token?: string;
|
|
30
|
+
force?: boolean;
|
|
31
|
+
/** Import under a different local profile name. */
|
|
32
|
+
as?: string;
|
|
33
|
+
credentials?: Record<string, string>;
|
|
34
|
+
fetch?: typeof fetch;
|
|
35
|
+
/** Injectable for tests. */
|
|
36
|
+
client?: RegistryClient;
|
|
37
|
+
}
|
|
38
|
+
export interface InstallFromRegistryResult extends ImportResult {
|
|
39
|
+
version: string;
|
|
40
|
+
sourceKind: string;
|
|
41
|
+
}
|
|
42
|
+
export declare function installProfileFromRegistry(input: InstallFromRegistryInput, options?: ProfileStoreOptions): Promise<InstallFromRegistryResult>;
|