@fractary/codex-mcp 0.9.0 → 0.9.1

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/cli.cjs CHANGED
@@ -12687,8 +12687,40 @@ var ArchiveProjectConfigSchema = external_exports.object({
12687
12687
  var ArchiveConfigSchema = external_exports.object({
12688
12688
  projects: external_exports.record(ArchiveProjectConfigSchema)
12689
12689
  });
12690
+ var GitHubAuthConfigSchema = external_exports.object({
12691
+ /** Default token environment variable name (default: GITHUB_TOKEN) */
12692
+ default_token_env: external_exports.string().optional(),
12693
+ /** Fallback to public access if authentication fails */
12694
+ fallback_to_public: external_exports.boolean().optional()
12695
+ });
12696
+ var AuthConfigSchema = external_exports.object({
12697
+ /** GitHub authentication configuration */
12698
+ github: GitHubAuthConfigSchema.optional()
12699
+ });
12700
+ var SourceConfigSchema = external_exports.object({
12701
+ /** Source type */
12702
+ type: external_exports.enum(["github", "s3", "http", "local"]),
12703
+ /** Environment variable containing the authentication token */
12704
+ token_env: external_exports.string().optional(),
12705
+ /** Direct token value (not recommended, use token_env instead) */
12706
+ token: external_exports.string().optional(),
12707
+ /** Branch to fetch from (for GitHub sources) */
12708
+ branch: external_exports.string().optional(),
12709
+ /** Base URL (for HTTP sources) */
12710
+ base_url: external_exports.string().optional(),
12711
+ /** Bucket name (for S3 sources) */
12712
+ bucket: external_exports.string().optional(),
12713
+ /** Prefix/path within bucket (for S3 sources) */
12714
+ prefix: external_exports.string().optional()
12715
+ });
12716
+ var DependencyConfigSchema = external_exports.object({
12717
+ /** Sources within this dependency */
12718
+ sources: external_exports.record(SourceConfigSchema)
12719
+ });
12690
12720
  var CodexConfigSchema = external_exports.object({
12691
12721
  organizationSlug: external_exports.string(),
12722
+ /** Project name (optional) */
12723
+ project: external_exports.string().optional(),
12692
12724
  directories: external_exports.object({
12693
12725
  source: external_exports.string().optional(),
12694
12726
  target: external_exports.string().optional(),
@@ -12698,7 +12730,11 @@ var CodexConfigSchema = external_exports.object({
12698
12730
  // Directional sync configuration
12699
12731
  sync: DirectionalSyncSchema.optional(),
12700
12732
  // Archive configuration
12701
- archive: ArchiveConfigSchema.optional()
12733
+ archive: ArchiveConfigSchema.optional(),
12734
+ // Authentication configuration
12735
+ auth: AuthConfigSchema.optional(),
12736
+ // Dependencies configuration (external projects)
12737
+ dependencies: external_exports.record(DependencyConfigSchema).optional()
12702
12738
  }).strict();
12703
12739
  var FileSourceSchema = external_exports.object({
12704
12740
  type: external_exports.enum(["s3", "r2", "gcs", "local"]),
@@ -13692,7 +13728,9 @@ var S3ArchiveStorage = class {
13692
13728
  var StorageManager = class {
13693
13729
  providers = /* @__PURE__ */ new Map();
13694
13730
  priority;
13731
+ codexConfig;
13695
13732
  constructor(config = {}) {
13733
+ this.codexConfig = config.codexConfig;
13696
13734
  this.providers.set("local", new LocalStorage(config.local));
13697
13735
  this.providers.set("github", new GitHubStorage(config.github));
13698
13736
  this.providers.set("http", new HttpStorage(config.http));
@@ -13704,6 +13742,48 @@ var StorageManager = class {
13704
13742
  }
13705
13743
  this.priority = config.priority || (config.filePlugin && config.s3Archive ? ["file-plugin", "local", "s3-archive", "github", "http"] : config.filePlugin ? ["file-plugin", "local", "github", "http"] : config.s3Archive ? ["local", "s3-archive", "github", "http"] : ["local", "github", "http"]);
13706
13744
  }
13745
+ /**
13746
+ * Resolve authentication token for a reference
13747
+ *
13748
+ * Looks up dependency-specific authentication or falls back to default
13749
+ */
13750
+ resolveToken(reference) {
13751
+ if (!this.codexConfig) {
13752
+ return void 0;
13753
+ }
13754
+ const dependencyKey = `${reference.org}/${reference.project}`;
13755
+ if (this.codexConfig.dependencies?.[dependencyKey]) {
13756
+ const dependency = this.codexConfig.dependencies[dependencyKey];
13757
+ for (const [, sourceConfig] of Object.entries(dependency.sources)) {
13758
+ if (sourceConfig.type === "github") {
13759
+ if (sourceConfig.token_env) {
13760
+ const token = process.env[sourceConfig.token_env];
13761
+ if (token) {
13762
+ return token;
13763
+ }
13764
+ }
13765
+ if (sourceConfig.token) {
13766
+ return sourceConfig.token;
13767
+ }
13768
+ }
13769
+ }
13770
+ }
13771
+ const defaultTokenEnv = this.codexConfig.auth?.github?.default_token_env || "GITHUB_TOKEN";
13772
+ return process.env[defaultTokenEnv];
13773
+ }
13774
+ /**
13775
+ * Resolve fetch options with authentication
13776
+ *
13777
+ * Merges reference-specific authentication with provided options
13778
+ */
13779
+ resolveFetchOptions(reference, options) {
13780
+ const token = this.resolveToken(reference);
13781
+ return {
13782
+ ...options,
13783
+ token: options?.token || token
13784
+ // Explicit option overrides resolved token
13785
+ };
13786
+ }
13707
13787
  /**
13708
13788
  * Register a custom storage provider
13709
13789
  */
@@ -13744,8 +13824,10 @@ var StorageManager = class {
13744
13824
  * Fetch content for a reference
13745
13825
  *
13746
13826
  * Tries providers in priority order until one succeeds.
13827
+ * Automatically resolves authentication based on dependency configuration.
13747
13828
  */
13748
13829
  async fetch(reference, options) {
13830
+ const resolvedOptions = this.resolveFetchOptions(reference, options);
13749
13831
  const errors = [];
13750
13832
  for (const type2 of this.priority) {
13751
13833
  const provider = this.providers.get(type2);
@@ -13753,7 +13835,7 @@ var StorageManager = class {
13753
13835
  continue;
13754
13836
  }
13755
13837
  try {
13756
- return await provider.fetch(reference, options);
13838
+ return await provider.fetch(reference, resolvedOptions);
13757
13839
  } catch (error) {
13758
13840
  errors.push(error instanceof Error ? error : new Error(String(error)));
13759
13841
  }
@@ -13774,15 +13856,17 @@ var StorageManager = class {
13774
13856
  * Check if content exists for a reference
13775
13857
  *
13776
13858
  * Returns true if any provider reports the content exists.
13859
+ * Automatically resolves authentication based on dependency configuration.
13777
13860
  */
13778
13861
  async exists(reference, options) {
13862
+ const resolvedOptions = this.resolveFetchOptions(reference, options);
13779
13863
  for (const type2 of this.priority) {
13780
13864
  const provider = this.providers.get(type2);
13781
13865
  if (!provider || !provider.canHandle(reference)) {
13782
13866
  continue;
13783
13867
  }
13784
13868
  try {
13785
- if (await provider.exists(reference, options)) {
13869
+ if (await provider.exists(reference, resolvedOptions)) {
13786
13870
  return true;
13787
13871
  }
13788
13872
  } catch {
@@ -13802,6 +13886,8 @@ var StorageManager = class {
13802
13886
  }
13803
13887
  /**
13804
13888
  * Fetch multiple references in parallel
13889
+ *
13890
+ * Automatically resolves authentication for each reference based on dependency configuration.
13805
13891
  */
13806
13892
  async fetchMany(references, options) {
13807
13893
  const results = /* @__PURE__ */ new Map();